Remove SIGIO support for input [v5]
This removes all of the SIGIO handling support used for input throughout the X server, preparing the way for using threads for input handling instead. Places calling OsBlockSIGIO and OsReleaseSIGIO are marked with calls to stub functions input_lock/input_unlock so that we don't lose this information. xfree86 SIGIO support is reworked to use internal versions of OsBlockSIGIO and OsReleaseSIGIO. v2: Don't change locking order (Peter Hutterer) v3: Comment weird && FALSE in xf86Helper.c Leave errno save/restore in xf86ReadInput Squash with stub adding patch (Peter Hutterer) v4: Leave UseSIGIO config parameter so that existing config files don't break (Peter Hutterer) v5: Split a couple of independent patch bits out of kinput.c (Peter Hutterer) Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
8cf832c288
commit
6a5a4e6037
|
@ -661,7 +661,7 @@ void
|
||||||
DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
|
DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
|
||||||
DeviceChangedEvent *dce)
|
DeviceChangedEvent *dce)
|
||||||
{
|
{
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
|
|
||||||
/* generic feedback classes, not tied to pointer and/or keyboard */
|
/* generic feedback classes, not tied to pointer and/or keyboard */
|
||||||
DeepCopyFeedbackClasses(from, to);
|
DeepCopyFeedbackClasses(from, to);
|
||||||
|
@ -671,7 +671,7 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
|
||||||
if ((dce->flags & DEVCHANGE_POINTER_EVENT))
|
if ((dce->flags & DEVCHANGE_POINTER_EVENT))
|
||||||
DeepCopyPointerClasses(from, to);
|
DeepCopyPointerClasses(from, to);
|
||||||
|
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -86,10 +86,10 @@ remove_device(const char *backend, DeviceIntPtr dev)
|
||||||
|
|
||||||
/* Call PIE here so we don't try to dereference a device that's
|
/* Call PIE here so we don't try to dereference a device that's
|
||||||
* already been removed. */
|
* already been removed. */
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
ProcessInputEvents();
|
ProcessInputEvents();
|
||||||
DeleteInputDeviceRequest(dev);
|
DeleteInputDeviceRequest(dev);
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
14
configure.ac
14
configure.ac
|
@ -381,7 +381,6 @@ AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes])
|
||||||
AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])
|
AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])
|
||||||
|
|
||||||
DRI=no
|
DRI=no
|
||||||
USE_SIGIO_BY_DEFAULT="yes"
|
|
||||||
dnl it would be nice to autodetect these *CONS_SUPPORTs
|
dnl it would be nice to autodetect these *CONS_SUPPORTs
|
||||||
case $host_os in
|
case $host_os in
|
||||||
*freebsd* | *dragonfly*)
|
*freebsd* | *dragonfly*)
|
||||||
|
@ -411,9 +410,6 @@ case $host_os in
|
||||||
;;
|
;;
|
||||||
*solaris*)
|
*solaris*)
|
||||||
PKG_CHECK_EXISTS(libdrm, DRI=yes, DRI=no)
|
PKG_CHECK_EXISTS(libdrm, DRI=yes, DRI=no)
|
||||||
# Disable use of SIGIO by default until some system bugs are
|
|
||||||
# fixed - see Sun/OpenSolaris bug id 6879897
|
|
||||||
USE_SIGIO_BY_DEFAULT="no"
|
|
||||||
;;
|
;;
|
||||||
darwin*)
|
darwin*)
|
||||||
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
|
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
|
||||||
|
@ -446,9 +442,6 @@ AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],
|
||||||
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
|
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
|
||||||
[Enable debugging (default: disabled)]),
|
[Enable debugging (default: disabled)]),
|
||||||
[DEBUGGING=$enableval], [DEBUGGING=no])
|
[DEBUGGING=$enableval], [DEBUGGING=no])
|
||||||
AC_ARG_ENABLE(use-sigio-by-default, AS_HELP_STRING([--enable-use-sigio-by-default]
|
|
||||||
[Enable SIGIO input handlers by default (default: $USE_SIGIO_BY_DEFAULT)]),
|
|
||||||
[USE_SIGIO_BY_DEFAULT=$enableval], [])
|
|
||||||
AC_ARG_WITH(int10, AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: vm86, x86emu or stub]),
|
AC_ARG_WITH(int10, AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: vm86, x86emu or stub]),
|
||||||
[INT10="$withval"],
|
[INT10="$withval"],
|
||||||
[INT10="$DEFAULT_INT10"])
|
[INT10="$DEFAULT_INT10"])
|
||||||
|
@ -967,13 +960,6 @@ if test "x$CONFIG_WSCONS" = xyes; then
|
||||||
AC_DEFINE(CONFIG_WSCONS, 1, [Use wscons for input auto configuration])
|
AC_DEFINE(CONFIG_WSCONS, 1, [Use wscons for input auto configuration])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$USE_SIGIO_BY_DEFAULT" = xyes; then
|
|
||||||
USE_SIGIO_BY_DEFAULT_VALUE=TRUE
|
|
||||||
else
|
|
||||||
USE_SIGIO_BY_DEFAULT_VALUE=FALSE
|
|
||||||
fi
|
|
||||||
AC_DEFINE_UNQUOTED([USE_SIGIO_BY_DEFAULT], [$USE_SIGIO_BY_DEFAULT_VALUE],
|
|
||||||
[Use SIGIO handlers for input device events by default])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for glibc...])
|
AC_MSG_CHECKING([for glibc...])
|
||||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([
|
AC_PREPROC_IFELSE([AC_LANG_SOURCE([
|
||||||
|
|
|
@ -493,14 +493,14 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
|
||||||
|
|
||||||
FreeSprite(dev);
|
FreeSprite(dev);
|
||||||
|
|
||||||
/* now that the device is disabled, we can reset the signal handler's
|
/* now that the device is disabled, we can reset the event reader's
|
||||||
* last.slave */
|
* last.slave */
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
for (other = inputInfo.devices; other; other = other->next) {
|
for (other = inputInfo.devices; other; other = other->next) {
|
||||||
if (other->last.slave == dev)
|
if (other->last.slave == dev)
|
||||||
other->last.slave = NULL;
|
other->last.slave = NULL;
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
|
|
||||||
LeaveWindow(dev);
|
LeaveWindow(dev);
|
||||||
SetFocusOut(dev);
|
SetFocusOut(dev);
|
||||||
|
@ -1033,7 +1033,7 @@ CloseDownDevices(void)
|
||||||
{
|
{
|
||||||
DeviceIntPtr dev;
|
DeviceIntPtr dev;
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
|
|
||||||
/* Float all SDs before closing them. Note that at this point resources
|
/* Float all SDs before closing them. Note that at this point resources
|
||||||
* (e.g. cursors) have been freed already, so we can't just call
|
* (e.g. cursors) have been freed already, so we can't just call
|
||||||
|
@ -1060,7 +1060,7 @@ CloseDownDevices(void)
|
||||||
XkbDeleteRulesDflts();
|
XkbDeleteRulesDflts();
|
||||||
XkbDeleteRulesUsed();
|
XkbDeleteRulesUsed();
|
||||||
|
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -165,7 +165,7 @@ AccelerationDefaultCleanup(DeviceIntPtr dev)
|
||||||
* AccelSchemeProc(), but that seems impossible. Schemes don't get
|
* AccelSchemeProc(), but that seems impossible. Schemes don't get
|
||||||
* switched often anyway.
|
* switched often anyway.
|
||||||
*/
|
*/
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
dev->valuator->accelScheme.AccelSchemeProc = NULL;
|
dev->valuator->accelScheme.AccelSchemeProc = NULL;
|
||||||
FreeVelocityData(vel);
|
FreeVelocityData(vel);
|
||||||
free(vel);
|
free(vel);
|
||||||
|
@ -175,7 +175,7 @@ AccelerationDefaultCleanup(DeviceIntPtr dev)
|
||||||
accelData);
|
accelData);
|
||||||
free(dev->valuator->accelScheme.accelData);
|
free(dev->valuator->accelScheme.accelData);
|
||||||
dev->valuator->accelScheme.accelData = NULL;
|
dev->valuator->accelScheme.accelData = NULL;
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ TouchResizeQueue(ClientPtr client, void *closure)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
|
|
||||||
/* first two ids are reserved */
|
/* first two ids are reserved */
|
||||||
for (i = 2; i < MAXDEVICES; i++) {
|
for (i = 2; i < MAXDEVICES; i++) {
|
||||||
|
@ -112,7 +112,7 @@ TouchResizeQueue(ClientPtr client, void *closure)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1077,7 +1077,7 @@ TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
|
||||||
InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
|
InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
mieqProcessInputEvents();
|
mieqProcessInputEvents();
|
||||||
for (i = 0; i < dev->last.num_touches; i++) {
|
for (i = 0; i < dev->last.num_touches; i++) {
|
||||||
DDXTouchPointInfoPtr ddxti = dev->last.touches + i;
|
DDXTouchPointInfoPtr ddxti = dev->last.touches + i;
|
||||||
|
@ -1091,7 +1091,7 @@ TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
|
||||||
mieqProcessDeviceEvent(dev, eventlist + j, NULL);
|
mieqProcessDeviceEvent(dev, eventlist + j, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
|
|
||||||
FreeEventList(eventlist, GetMaximumEventsNum());
|
FreeEventList(eventlist, GetMaximumEventsNum());
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,25 +227,25 @@ dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
|
||||||
&& pScreen->myNum == dmxScreen->index) {
|
&& pScreen->myNum == dmxScreen->index) {
|
||||||
/* Screen is old screen */
|
/* Screen is old screen */
|
||||||
if (block)
|
if (block)
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
if (pDev)
|
if (pDev)
|
||||||
enqueueMotion(pDev, localX, localY);
|
enqueueMotion(pDev, localX, localY);
|
||||||
if (block)
|
if (block)
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Screen is new */
|
/* Screen is new */
|
||||||
DMXDBG4(" New screen: old=%d new=%d localX=%d localY=%d\n",
|
DMXDBG4(" New screen: old=%d new=%d localX=%d localY=%d\n",
|
||||||
pScreen->myNum, dmxScreen->index, localX, localY);
|
pScreen->myNum, dmxScreen->index, localX, localY);
|
||||||
if (block)
|
if (block)
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
mieqProcessInputEvents();
|
mieqProcessInputEvents();
|
||||||
miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
|
miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
|
||||||
localX, localY);
|
localX, localY);
|
||||||
if (pDev)
|
if (pDev)
|
||||||
enqueueMotion(pDev, localX, localY);
|
enqueueMotion(pDev, localX, localY);
|
||||||
if (block)
|
if (block)
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
#if 00
|
#if 00
|
||||||
miPointerGetPosition(inputInfo.pointer, &localX, &localY);
|
miPointerGetPosition(inputInfo.pointer, &localX, &localY);
|
||||||
|
@ -387,12 +387,12 @@ dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (block)
|
if (block)
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
valuator_mask_set_range(&mask, firstAxis, axesCount, v);
|
valuator_mask_set_range(&mask, firstAxis, axesCount, v);
|
||||||
QueuePointerEvents(pDevice, MotionNotify, 0, POINTER_ABSOLUTE, &mask);
|
QueuePointerEvents(pDevice, MotionNotify, 0, POINTER_ABSOLUTE, &mask);
|
||||||
|
|
||||||
if (block)
|
if (block)
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -489,10 +489,10 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
|
||||||
case XI_DeviceKeyPress:
|
case XI_DeviceKeyPress:
|
||||||
case XI_DeviceKeyRelease:
|
case XI_DeviceKeyRelease:
|
||||||
if (block)
|
if (block)
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
QueueKeyboardEvents(pDevice, event, ke->keycode);
|
QueueKeyboardEvents(pDevice, event, ke->keycode);
|
||||||
if (block)
|
if (block)
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
break;
|
break;
|
||||||
case XI_DeviceButtonPress:
|
case XI_DeviceButtonPress:
|
||||||
case XI_DeviceButtonRelease:
|
case XI_DeviceButtonRelease:
|
||||||
|
@ -500,11 +500,11 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
|
||||||
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
|
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
|
||||||
valuators);
|
valuators);
|
||||||
if (block)
|
if (block)
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
QueuePointerEvents(pDevice, event, ke->keycode,
|
QueuePointerEvents(pDevice, event, ke->keycode,
|
||||||
POINTER_ABSOLUTE, &mask);
|
POINTER_ABSOLUTE, &mask);
|
||||||
if (block)
|
if (block)
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
break;
|
break;
|
||||||
case XI_ProximityIn:
|
case XI_ProximityIn:
|
||||||
case XI_ProximityOut:
|
case XI_ProximityOut:
|
||||||
|
@ -512,10 +512,10 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
|
||||||
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
|
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
|
||||||
valuators);
|
valuators);
|
||||||
if (block)
|
if (block)
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
QueueProximityEvents(pDevice, event, &mask);
|
QueueProximityEvents(pDevice, event, &mask);
|
||||||
if (block)
|
if (block)
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -818,11 +818,11 @@ ScreenPtr ephyrCursorScreen; /* screen containing the cursor */
|
||||||
static void
|
static void
|
||||||
ephyrWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
ephyrWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
||||||
{
|
{
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
ephyrCursorScreen = pScreen;
|
ephyrCursorScreen = pScreen;
|
||||||
miPointerWarpCursor(inputInfo.pointer, pScreen, x, y);
|
miPointerWarpCursor(inputInfo.pointer, pScreen, x, y);
|
||||||
|
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
miPointerScreenFuncRec ephyrPointerScreenFuncs = {
|
miPointerScreenFuncRec ephyrPointerScreenFuncs = {
|
||||||
|
|
|
@ -108,38 +108,6 @@ extern const char *kdGlobalXkbLayout;
|
||||||
extern const char *kdGlobalXkbVariant;
|
extern const char *kdGlobalXkbVariant;
|
||||||
extern const char *kdGlobalXkbOptions;
|
extern const char *kdGlobalXkbOptions;
|
||||||
|
|
||||||
static void
|
|
||||||
KdSigio(int sig)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < kdNumInputFds; i++)
|
|
||||||
(*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_SIGIO
|
|
||||||
|
|
||||||
void
|
|
||||||
KdAssertSigioBlocked(char *where)
|
|
||||||
{
|
|
||||||
sigset_t set, old;
|
|
||||||
|
|
||||||
sigemptyset(&set);
|
|
||||||
sigprocmask(SIG_BLOCK, &set, &old);
|
|
||||||
if (!sigismember(&old, SIGIO)) {
|
|
||||||
ErrorF("SIGIO not blocked at %s\n", where);
|
|
||||||
KdBacktrace(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define KdAssertSigioBlocked(s)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int kdnFds;
|
|
||||||
|
|
||||||
#ifdef FNONBLOCK
|
#ifdef FNONBLOCK
|
||||||
#define NOBLOCK FNONBLOCK
|
#define NOBLOCK FNONBLOCK
|
||||||
#else
|
#else
|
||||||
|
@ -171,49 +139,27 @@ static void
|
||||||
KdNotifyFd(int fd, int ready, void *data)
|
KdNotifyFd(int fd, int ready, void *data)
|
||||||
{
|
{
|
||||||
int i = (int) (intptr_t) data;
|
int i = (int) (intptr_t) data;
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
(*kdInputFds[i].read)(fd, kdInputFds[i].closure);
|
(*kdInputFds[i].read)(fd, kdInputFds[i].closure);
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
KdAddFd(int fd, int i)
|
KdAddFd(int fd, int i)
|
||||||
{
|
{
|
||||||
struct sigaction act;
|
|
||||||
sigset_t set;
|
|
||||||
|
|
||||||
kdnFds++;
|
|
||||||
fcntl(fd, F_SETOWN, getpid());
|
|
||||||
KdNonBlockFd(fd);
|
KdNonBlockFd(fd);
|
||||||
SetNotifyFd(fd, KdNotifyFd, X_NOTIFY_READ, (void *) (intptr_t) i);
|
SetNotifyFd(fd, KdNotifyFd, X_NOTIFY_READ, (void *) (intptr_t) i);
|
||||||
memset(&act, '\0', sizeof act);
|
|
||||||
act.sa_handler = KdSigio;
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
sigaddset(&act.sa_mask, SIGIO);
|
|
||||||
sigaddset(&act.sa_mask, SIGALRM);
|
|
||||||
sigaddset(&act.sa_mask, SIGVTALRM);
|
|
||||||
sigaction(SIGIO, &act, 0);
|
|
||||||
sigemptyset(&set);
|
|
||||||
sigprocmask(SIG_SETMASK, &set, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
KdRemoveFd(int fd)
|
KdRemoveFd(int fd)
|
||||||
{
|
{
|
||||||
struct sigaction act;
|
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
kdnFds--;
|
|
||||||
RemoveNotifyFd(fd);
|
RemoveNotifyFd(fd);
|
||||||
flags = fcntl(fd, F_GETFL);
|
flags = fcntl(fd, F_GETFL);
|
||||||
flags &= ~(FASYNC | NOBLOCK);
|
flags &= ~(FASYNC | NOBLOCK);
|
||||||
fcntl(fd, F_SETFL, flags);
|
fcntl(fd, F_SETFL, flags);
|
||||||
if (kdnFds == 0) {
|
|
||||||
memset(&act, '\0', sizeof act);
|
|
||||||
act.sa_handler = SIG_IGN;
|
|
||||||
sigemptyset(&act.sa_mask);
|
|
||||||
sigaction(SIGIO, &act, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
@ -265,7 +211,7 @@ KdDisableInput(void)
|
||||||
KdPointerInfo *pi;
|
KdPointerInfo *pi;
|
||||||
int found = 0, i = 0;
|
int found = 0, i = 0;
|
||||||
|
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
|
|
||||||
for (ki = kdKeyboards; ki; ki = ki->next) {
|
for (ki = kdKeyboards; ki; ki = ki->next) {
|
||||||
if (ki->driver && ki->driver->Disable)
|
if (ki->driver && ki->driver->Disable)
|
||||||
|
@ -348,7 +294,7 @@ KdEnableInput(void)
|
||||||
NoticeEventTime (&ev, pi->dixdev);
|
NoticeEventTime (&ev, pi->dixdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static KdKeyboardDriver *
|
static KdKeyboardDriver *
|
||||||
|
@ -1850,7 +1796,7 @@ KdReleaseAllKeys(void)
|
||||||
int key;
|
int key;
|
||||||
KdKeyboardInfo *ki;
|
KdKeyboardInfo *ki;
|
||||||
|
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
|
|
||||||
for (ki = kdKeyboards; ki; ki = ki->next) {
|
for (ki = kdKeyboards; ki; ki = ki->next) {
|
||||||
for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) {
|
for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) {
|
||||||
|
@ -1861,7 +1807,7 @@ KdReleaseAllKeys(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2049,9 +1995,9 @@ KdWakeupHandler(ScreenPtr pScreen, unsigned long lresult, void *readmask)
|
||||||
if (pi->timeoutPending) {
|
if (pi->timeoutPending) {
|
||||||
if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) {
|
if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) {
|
||||||
pi->timeoutPending = FALSE;
|
pi->timeoutPending = FALSE;
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
KdReceiveTimeout(pi);
|
KdReceiveTimeout(pi);
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2148,10 +2094,10 @@ int KdCurScreen; /* current event screen */
|
||||||
static void
|
static void
|
||||||
KdWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
KdWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
||||||
{
|
{
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
KdCurScreen = pScreen->myNum;
|
KdCurScreen = pScreen->myNum;
|
||||||
miPointerWarpCursor(pDev, pScreen, x, y);
|
miPointerWarpCursor(pDev, pScreen, x, y);
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
miPointerScreenFuncRec kdPointerScreenFuncs = {
|
miPointerScreenFuncRec kdPointerScreenFuncs = {
|
||||||
|
|
|
@ -807,27 +807,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
|
||||||
xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
|
xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xf86SIGIOSupported()) {
|
|
||||||
xf86Info.useSIGIO =
|
|
||||||
xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO,
|
|
||||||
USE_SIGIO_BY_DEFAULT);
|
|
||||||
if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
|
|
||||||
from = X_CONFIG;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
from = X_DEFAULT;
|
|
||||||
}
|
|
||||||
if (!xf86Info.useSIGIO) {
|
|
||||||
xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
|
|
||||||
}
|
|
||||||
else if (from == X_CONFIG) {
|
|
||||||
xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xf86Info.useSIGIO = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
|
if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
|
||||||
xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
|
xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
|
||||||
&xf86Info.autoAddDevices);
|
&xf86Info.autoAddDevices);
|
||||||
|
|
|
@ -221,7 +221,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
|
||||||
if (pScreen == pCursorScreen)
|
if (pScreen == pCursorScreen)
|
||||||
miPointerGetPosition(dev, &px, &py);
|
miPointerGetPosition(dev, &px, &py);
|
||||||
|
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
Switched = (*pScr->SwitchMode) (pScr, mode);
|
Switched = (*pScr->SwitchMode) (pScr, mode);
|
||||||
if (Switched) {
|
if (Switched) {
|
||||||
pScr->currentMode = mode;
|
pScr->currentMode = mode;
|
||||||
|
@ -260,7 +260,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
|
||||||
pScr->frameY1 = pScr->virtualY - 1;
|
pScr->frameY1 = pScr->virtualY - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
|
|
||||||
if (pScr->AdjustFrame)
|
if (pScr->AdjustFrame)
|
||||||
(*pScr->AdjustFrame) (pScr, pScr->frameX0, pScr->frameY0);
|
(*pScr->AdjustFrame) (pScr, pScr->frameX0, pScr->frameY0);
|
||||||
|
@ -452,11 +452,11 @@ xf86CrossScreen(ScreenPtr pScreen, Bool entering)
|
||||||
static void
|
static void
|
||||||
xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
||||||
{
|
{
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
miPointerWarpCursor(pDev, pScreen, x, y);
|
miPointerWarpCursor(pDev, pScreen, x, y);
|
||||||
|
|
||||||
xf86Info.currentScreen = pScreen;
|
xf86Info.currentScreen = pScreen;
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
|
|
@ -259,7 +259,7 @@ xf86Wakeup(void *blockData, int err, void *pReadmask)
|
||||||
while (pInfo) {
|
while (pInfo) {
|
||||||
if (pInfo->read_input && pInfo->fd >= 0 &&
|
if (pInfo->read_input && pInfo->fd >= 0 &&
|
||||||
(FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
|
(FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove the descriptior from the set because more than one
|
* Remove the descriptior from the set because more than one
|
||||||
|
@ -268,7 +268,7 @@ xf86Wakeup(void *blockData, int err, void *pReadmask)
|
||||||
FD_CLR(pInfo->fd, &devicesWithInput);
|
FD_CLR(pInfo->fd, &devicesWithInput);
|
||||||
|
|
||||||
pInfo->read_input(pInfo);
|
pInfo->read_input(pInfo);
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
pInfo = pInfo->next;
|
pInfo = pInfo->next;
|
||||||
}
|
}
|
||||||
|
@ -291,11 +291,12 @@ xf86Wakeup(void *blockData, int err, void *pReadmask)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* xf86SigioReadInput --
|
* xf86ReadInput --
|
||||||
* signal handler for the SIGIO signal.
|
* input thread handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xf86SigioReadInput(int fd, void *closure)
|
xf86ReadInput(int fd, int ready, void *closure)
|
||||||
{
|
{
|
||||||
int errno_save = errno;
|
int errno_save = errno;
|
||||||
InputInfoPtr pInfo = closure;
|
InputInfoPtr pInfo = closure;
|
||||||
|
@ -312,9 +313,7 @@ xf86SigioReadInput(int fd, void *closure)
|
||||||
void
|
void
|
||||||
xf86AddEnabledDevice(InputInfoPtr pInfo)
|
xf86AddEnabledDevice(InputInfoPtr pInfo)
|
||||||
{
|
{
|
||||||
if (!xf86InstallSIGIOHandler(pInfo->fd, xf86SigioReadInput, pInfo)) {
|
SetNotifyFd(pInfo->fd, xf86ReadInput, X_NOTIFY_READ, pInfo);
|
||||||
AddEnabledDevice(pInfo->fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -324,9 +323,7 @@ xf86AddEnabledDevice(InputInfoPtr pInfo)
|
||||||
void
|
void
|
||||||
xf86RemoveEnabledDevice(InputInfoPtr pInfo)
|
xf86RemoveEnabledDevice(InputInfoPtr pInfo)
|
||||||
{
|
{
|
||||||
if (!xf86RemoveSIGIOHandler(pInfo->fd)) {
|
RemoveNotifyFd(pInfo->fd);
|
||||||
RemoveEnabledDevice(pInfo->fd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int *xf86SignalIntercept = NULL;
|
static int *xf86SignalIntercept = NULL;
|
||||||
|
@ -402,9 +399,9 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
|
||||||
for (i = keyc->xkbInfo->desc->min_key_code;
|
for (i = keyc->xkbInfo->desc->min_key_code;
|
||||||
i < keyc->xkbInfo->desc->max_key_code; i++) {
|
i < keyc->xkbInfo->desc->max_key_code; i++) {
|
||||||
if (key_is_down(pDev, i, KEY_POSTED)) {
|
if (key_is_down(pDev, i, KEY_POSTED)) {
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
QueueKeyboardEvents(pDev, KeyRelease, i);
|
QueueKeyboardEvents(pDev, KeyRelease, i);
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,7 +484,7 @@ xf86VTLeave(void)
|
||||||
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
|
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
|
||||||
xf86DisableInputDeviceForVTSwitch(pInfo);
|
xf86DisableInputDeviceForVTSwitch(pInfo);
|
||||||
|
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
for (i = 0; i < xf86NumScreens; i++)
|
for (i = 0; i < xf86NumScreens; i++)
|
||||||
xf86Screens[i]->LeaveVT(xf86Screens[i]);
|
xf86Screens[i]->LeaveVT(xf86Screens[i]);
|
||||||
for (i = 0; i < xf86NumGPUScreens; i++)
|
for (i = 0; i < xf86NumGPUScreens; i++)
|
||||||
|
@ -545,7 +542,7 @@ switch_failed:
|
||||||
else
|
else
|
||||||
xf86EnableGeneralHandler(ih);
|
xf86EnableGeneralHandler(ih);
|
||||||
}
|
}
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -603,7 +600,7 @@ xf86VTEnter(void)
|
||||||
|
|
||||||
xf86UpdateHasVTProperty(TRUE);
|
xf86UpdateHasVTProperty(TRUE);
|
||||||
|
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1723,7 +1723,11 @@ xf86SetSilkenMouse(ScreenPtr pScreen)
|
||||||
* yet. Should handle this differently so that alternate async methods
|
* yet. Should handle this differently so that alternate async methods
|
||||||
* work correctly with this too.
|
* work correctly with this too.
|
||||||
*/
|
*/
|
||||||
pScrn->silkenMouse = useSM && xf86Info.useSIGIO && xf86SIGIOSupported();
|
/* Disable this completely when removing SIGIO support. It
|
||||||
|
* will get re-enabled correctly when we add threaded input
|
||||||
|
* support
|
||||||
|
*/
|
||||||
|
pScrn->silkenMouse = useSM && FALSE;
|
||||||
if (serverGeneration == 1)
|
if (serverGeneration == 1)
|
||||||
xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
|
xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
|
||||||
pScrn->silkenMouse ? "enabled" : "disabled");
|
pScrn->silkenMouse ? "enabled" : "disabled");
|
||||||
|
|
|
@ -762,7 +762,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
|
||||||
ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
|
ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
|
||||||
#endif
|
#endif
|
||||||
xf86AccessEnter();
|
xf86AccessEnter();
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
sigio_blocked = TRUE;
|
sigio_blocked = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -864,7 +864,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
|
||||||
|
|
||||||
xf86VGAarbiterWrapFunctions();
|
xf86VGAarbiterWrapFunctions();
|
||||||
if (sigio_blocked)
|
if (sigio_blocked)
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
|
|
||||||
xf86InitOrigins();
|
xf86InitOrigins();
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ AbortDDX(enum ExitCode error)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* try to restore the original video state
|
* try to restore the original video state
|
||||||
|
|
|
@ -107,7 +107,7 @@ suspend(pmEvent event, Bool undo)
|
||||||
DisableDevice(pInfo->dev, TRUE);
|
DisableDevice(pInfo->dev, TRUE);
|
||||||
pInfo = pInfo->next;
|
pInfo = pInfo->next;
|
||||||
}
|
}
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
for (i = 0; i < xf86NumScreens; i++) {
|
for (i = 0; i < xf86NumScreens; i++) {
|
||||||
if (xf86Screens[i]->PMEvent)
|
if (xf86Screens[i]->PMEvent)
|
||||||
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
|
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
|
||||||
|
@ -135,7 +135,7 @@ resume(pmEvent event, Bool undo)
|
||||||
xf86Screens[i]->EnterVT(xf86Screens[i]);
|
xf86Screens[i]->EnterVT(xf86Screens[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
for (i = 0; i < xf86NumScreens; i++) {
|
for (i = 0; i < xf86NumScreens; i++) {
|
||||||
if (xf86Screens[i]->EnableDisableFBAccess)
|
if (xf86Screens[i]->EnableDisableFBAccess)
|
||||||
(*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE);
|
(*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE);
|
||||||
|
@ -182,13 +182,13 @@ DoApmEvent(pmEvent event, Bool undo)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
OsBlockSIGIO();
|
input_lock();
|
||||||
for (i = 0; i < xf86NumScreens; i++) {
|
for (i = 0; i < xf86NumScreens; i++) {
|
||||||
if (xf86Screens[i]->PMEvent) {
|
if (xf86Screens[i]->PMEvent) {
|
||||||
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
|
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -931,7 +931,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
|
||||||
|
|
||||||
/* Enable it if it's properly initialised and we're currently in the VT */
|
/* Enable it if it's properly initialised and we're currently in the VT */
|
||||||
if (enable && dev->inited && dev->startup && xf86VTOwner()) {
|
if (enable && dev->inited && dev->startup && xf86VTOwner()) {
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
EnableDevice(dev, TRUE);
|
EnableDevice(dev, TRUE);
|
||||||
if (!dev->enabled) {
|
if (!dev->enabled) {
|
||||||
OsReleaseSignals();
|
OsReleaseSignals();
|
||||||
|
@ -942,7 +942,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
|
||||||
}
|
}
|
||||||
/* send enter/leave event, update sprite window */
|
/* send enter/leave event, update sprite window */
|
||||||
CheckMotion(NULL, dev);
|
CheckMotion(NULL, dev);
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
*pdev = dev;
|
*pdev = dev;
|
||||||
|
@ -1075,7 +1075,7 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
|
||||||
if (pInfo) /* need to get these before RemoveDevice */
|
if (pInfo) /* need to get these before RemoveDevice */
|
||||||
drv = pInfo->drv;
|
drv = pInfo->drv;
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
RemoveDevice(pDev, TRUE);
|
RemoveDevice(pDev, TRUE);
|
||||||
|
|
||||||
if (!isMaster && pInfo != NULL) {
|
if (!isMaster && pInfo != NULL) {
|
||||||
|
@ -1084,7 +1084,7 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
|
||||||
else
|
else
|
||||||
xf86DeleteInput(pInfo, 0);
|
xf86DeleteInput(pInfo, 0);
|
||||||
}
|
}
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -130,6 +130,26 @@ xf86IsPipe(int fd)
|
||||||
return S_ISFIFO(buf.st_mode);
|
return S_ISFIFO(buf.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xf86BlockSIGIO(void)
|
||||||
|
{
|
||||||
|
sigset_t set;
|
||||||
|
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigaddset(&set, SIGIO);
|
||||||
|
sigprocmask(SIG_BLOCK, &set, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xf86ReleaseSIGIO(void)
|
||||||
|
{
|
||||||
|
sigset_t set;
|
||||||
|
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigaddset(&set, SIGIO);
|
||||||
|
sigprocmask(SIG_UNBLOCK, &set, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
|
xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +165,7 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
|
||||||
if (!xf86SigIOFuncs[i].f) {
|
if (!xf86SigIOFuncs[i].f) {
|
||||||
if (xf86IsPipe(fd))
|
if (xf86IsPipe(fd))
|
||||||
return 0;
|
return 0;
|
||||||
OsBlockSIGIO();
|
xf86BlockSIGIO();
|
||||||
#ifdef O_ASYNC
|
#ifdef O_ASYNC
|
||||||
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
|
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
|
||||||
xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
|
xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
|
||||||
|
@ -173,7 +193,7 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!installed) {
|
if (!installed) {
|
||||||
OsReleaseSIGIO();
|
xf86ReleaseSIGIO();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
|
@ -189,7 +209,7 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
|
||||||
if (fd >= xf86SigIOMaxFd)
|
if (fd >= xf86SigIOMaxFd)
|
||||||
xf86SigIOMaxFd = fd + 1;
|
xf86SigIOMaxFd = fd + 1;
|
||||||
FD_SET(fd, &xf86SigIOMask);
|
FD_SET(fd, &xf86SigIOMask);
|
||||||
OsReleaseSIGIO();
|
xf86ReleaseSIGIO();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* Allow overwriting of the closure and callback */
|
/* Allow overwriting of the closure and callback */
|
||||||
|
@ -258,34 +278,3 @@ xf86RemoveSIGIOHandler(int fd)
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
xf86BlockSIGIO(void)
|
|
||||||
{
|
|
||||||
return OsBlockSIGIO();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xf86UnblockSIGIO(int wasset)
|
|
||||||
{
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xf86AssertBlockedSIGIO(char *where)
|
|
||||||
{
|
|
||||||
sigset_t set, old;
|
|
||||||
|
|
||||||
sigemptyset(&set);
|
|
||||||
sigprocmask(SIG_BLOCK, &set, &old);
|
|
||||||
if (!sigismember(&old, SIGIO))
|
|
||||||
xf86Msg(X_ERROR, "SIGIO not blocked at %s\n", where);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
|
|
||||||
|
|
||||||
int
|
|
||||||
xf86SIGIOSupported(void)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
|
@ -45,26 +45,3 @@ xf86RemoveSIGIOHandler(int fd)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
xf86BlockSIGIO(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xf86UnblockSIGIO(int wasset)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xf86AssertBlockedSIGIO(char *where)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */
|
|
||||||
Bool
|
|
||||||
xf86SIGIOSupported()
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
|
@ -169,10 +169,6 @@ extern _X_EXPORT Bool xf86GARTCloseScreen(int screenNum);
|
||||||
extern _X_EXPORT int xf86InstallSIGIOHandler(int fd, void (*f) (int, void *),
|
extern _X_EXPORT int xf86InstallSIGIOHandler(int fd, void (*f) (int, void *),
|
||||||
void *);
|
void *);
|
||||||
extern _X_EXPORT int xf86RemoveSIGIOHandler(int fd);
|
extern _X_EXPORT int xf86RemoveSIGIOHandler(int fd);
|
||||||
extern _X_EXPORT int xf86BlockSIGIO(void);
|
|
||||||
extern _X_EXPORT void xf86UnblockSIGIO(int);
|
|
||||||
extern _X_EXPORT void xf86AssertBlockedSIGIO(char *);
|
|
||||||
extern _X_EXPORT Bool xf86SIGIOSupported(void);
|
|
||||||
|
|
||||||
#ifdef XF86_OS_PRIVS
|
#ifdef XF86_OS_PRIVS
|
||||||
typedef void (*PMClose) (void);
|
typedef void (*PMClose) (void);
|
||||||
|
|
|
@ -714,4 +714,13 @@ extern _X_HIDDEN void input_constrain_cursor(DeviceIntPtr pDev, ScreenPtr screen
|
||||||
int *out_x, int *out_y,
|
int *out_x, int *out_y,
|
||||||
int *nevents, InternalEvent* events);
|
int *nevents, InternalEvent* events);
|
||||||
|
|
||||||
|
static inline void input_lock(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void input_unlock(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void input_force_unlock(void) {
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* INPUT_H */
|
#endif /* INPUT_H */
|
||||||
|
|
|
@ -336,12 +336,6 @@ OsBlockSignals(void);
|
||||||
extern _X_EXPORT void
|
extern _X_EXPORT void
|
||||||
OsReleaseSignals(void);
|
OsReleaseSignals(void);
|
||||||
|
|
||||||
extern _X_EXPORT int
|
|
||||||
OsBlockSIGIO(void);
|
|
||||||
|
|
||||||
extern _X_EXPORT void
|
|
||||||
OsReleaseSIGIO(void);
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
OsResetSignals(void);
|
OsResetSignals(void);
|
||||||
|
|
||||||
|
|
|
@ -127,9 +127,6 @@
|
||||||
/* Path to text files containing PCI IDs */
|
/* Path to text files containing PCI IDs */
|
||||||
#undef PCI_TXT_IDS_PATH
|
#undef PCI_TXT_IDS_PATH
|
||||||
|
|
||||||
/* Use SIGIO handlers for input device events by default */
|
|
||||||
#undef USE_SIGIO_BY_DEFAULT
|
|
||||||
|
|
||||||
/* Build with libdrm support */
|
/* Build with libdrm support */
|
||||||
#undef WITH_LIBDRM
|
#undef WITH_LIBDRM
|
||||||
|
|
||||||
|
|
|
@ -145,10 +145,10 @@ mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents)
|
||||||
|
|
||||||
n_enqueued = mieqNumEnqueued(eventQueue);
|
n_enqueued = mieqNumEnqueued(eventQueue);
|
||||||
|
|
||||||
/* We block signals, so an mieqEnqueue triggered by SIGIO does not
|
/* We lock input, so an mieqEnqueue does not
|
||||||
* write to our queue as we are modifying it.
|
* write to our queue as we are modifying it.
|
||||||
*/
|
*/
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
|
|
||||||
/* First copy the existing events */
|
/* First copy the existing events */
|
||||||
first_hunk = eventQueue->nevents - eventQueue->head;
|
first_hunk = eventQueue->nevents - eventQueue->head;
|
||||||
|
@ -181,7 +181,7 @@ mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents)
|
||||||
free(eventQueue->events);
|
free(eventQueue->events);
|
||||||
eventQueue->events = new_events;
|
eventQueue->events = new_events;
|
||||||
|
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -750,7 +750,7 @@ miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
||||||
POINTER_SCREEN | POINTER_ABSOLUTE |
|
POINTER_SCREEN | POINTER_ABSOLUTE |
|
||||||
POINTER_NORAW, &mask);
|
POINTER_NORAW, &mask);
|
||||||
|
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
#ifdef XQUARTZ
|
#ifdef XQUARTZ
|
||||||
darwinEvents_lock();
|
darwinEvents_lock();
|
||||||
#endif
|
#endif
|
||||||
|
@ -759,5 +759,5 @@ miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
|
||||||
#ifdef XQUARTZ
|
#ifdef XQUARTZ
|
||||||
darwinEvents_unlock();
|
darwinEvents_unlock();
|
||||||
#endif
|
#endif
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
}
|
}
|
||||||
|
|
55
os/utils.c
55
os/utils.c
|
@ -1304,9 +1304,7 @@ OsBlockSignals(void)
|
||||||
if (BlockedSignalCount++ == 0) {
|
if (BlockedSignalCount++ == 0) {
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
|
|
||||||
#ifdef SIGIO
|
input_lock();
|
||||||
OsBlockSIGIO();
|
|
||||||
#endif
|
|
||||||
sigemptyset(&set);
|
sigemptyset(&set);
|
||||||
sigaddset(&set, SIGALRM);
|
sigaddset(&set, SIGALRM);
|
||||||
sigaddset(&set, SIGVTALRM);
|
sigaddset(&set, SIGVTALRM);
|
||||||
|
@ -1322,57 +1320,13 @@ OsBlockSignals(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SIG_BLOCK
|
|
||||||
static sig_atomic_t sigio_blocked;
|
|
||||||
static sigset_t PreviousSigIOMask;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns zero if this call caused SIGIO to be blocked now, non-zero if it
|
|
||||||
* was already blocked by a previous call to this function.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
OsBlockSIGIO(void)
|
|
||||||
{
|
|
||||||
#ifdef SIGIO
|
|
||||||
#ifdef SIG_BLOCK
|
|
||||||
if (sigio_blocked++ == 0) {
|
|
||||||
sigset_t set;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
sigemptyset(&set);
|
|
||||||
sigaddset(&set, SIGIO);
|
|
||||||
sigprocmask(SIG_BLOCK, &set, &PreviousSigIOMask);
|
|
||||||
ret = sigismember(&PreviousSigIOMask, SIGIO);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
OsReleaseSIGIO(void)
|
|
||||||
{
|
|
||||||
#ifdef SIGIO
|
|
||||||
#ifdef SIG_BLOCK
|
|
||||||
if (--sigio_blocked == 0) {
|
|
||||||
sigprocmask(SIG_SETMASK, &PreviousSigIOMask, 0);
|
|
||||||
} else if (sigio_blocked < 0) {
|
|
||||||
BUG_WARN(sigio_blocked < 0);
|
|
||||||
sigio_blocked = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OsReleaseSignals(void)
|
OsReleaseSignals(void)
|
||||||
{
|
{
|
||||||
#ifdef SIG_BLOCK
|
#ifdef SIG_BLOCK
|
||||||
if (--BlockedSignalCount == 0) {
|
if (--BlockedSignalCount == 0) {
|
||||||
sigprocmask(SIG_SETMASK, &PreviousSignalMask, 0);
|
sigprocmask(SIG_SETMASK, &PreviousSignalMask, 0);
|
||||||
OsReleaseSIGIO();
|
input_unlock();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1383,10 +1337,7 @@ OsResetSignals(void)
|
||||||
#ifdef SIG_BLOCK
|
#ifdef SIG_BLOCK
|
||||||
while (BlockedSignalCount > 0)
|
while (BlockedSignalCount > 0)
|
||||||
OsReleaseSignals();
|
OsReleaseSignals();
|
||||||
#ifdef SIGIO
|
input_force_unlock();
|
||||||
while (sigio_blocked > 0)
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ if XORG
|
||||||
# Tests that require at least some DDX functions in order to fully link
|
# Tests that require at least some DDX functions in order to fully link
|
||||||
# For now, requires xf86 ddx, could be adjusted to use another
|
# For now, requires xf86 ddx, could be adjusted to use another
|
||||||
SUBDIRS += xi1 xi2
|
SUBDIRS += xi1 xi2
|
||||||
noinst_PROGRAMS += xkb input xtest misc fixes xfree86 os signal-logging touch
|
noinst_PROGRAMS += xkb input xtest misc fixes xfree86 signal-logging touch
|
||||||
if RES
|
if RES
|
||||||
noinst_PROGRAMS += hashtabletest
|
noinst_PROGRAMS += hashtabletest
|
||||||
endif
|
endif
|
||||||
|
|
166
test/os.c
166
test/os.c
|
@ -1,166 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright © 2012 Red Hat, Inc.
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice (including the next
|
|
||||||
* paragraph) shall be included in all copies or substantial portions of the
|
|
||||||
* Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
||||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_DIX_CONFIG_H
|
|
||||||
#include <dix-config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <signal.h>
|
|
||||||
#include "os.h"
|
|
||||||
|
|
||||||
static int last_signal = 0;
|
|
||||||
static int expect_signal = 0;
|
|
||||||
|
|
||||||
static void sighandler(int signal)
|
|
||||||
{
|
|
||||||
assert(expect_signal);
|
|
||||||
expect_signal = 0;
|
|
||||||
if (!last_signal)
|
|
||||||
raise(signal);
|
|
||||||
OsBlockSignals();
|
|
||||||
OsReleaseSignals();
|
|
||||||
last_signal = 1;
|
|
||||||
expect_signal = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
sig_is_blocked(int sig)
|
|
||||||
{
|
|
||||||
sigset_t current;
|
|
||||||
|
|
||||||
sigemptyset(¤t);
|
|
||||||
assert(sigprocmask(SIG_BLOCK, NULL, ¤t) == 0);
|
|
||||||
return sigismember(¤t, sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void block_sigio_test(void)
|
|
||||||
{
|
|
||||||
#ifdef SIG_BLOCK
|
|
||||||
sigset_t current;
|
|
||||||
|
|
||||||
sigemptyset(¤t);
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* block once */
|
|
||||||
OsBlockSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* block twice, nested */
|
|
||||||
OsBlockSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsBlockSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* block all */
|
|
||||||
OsBlockSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSignals();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* block all nested */
|
|
||||||
OsBlockSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsBlockSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSignals();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* mix the two */
|
|
||||||
/* ABBA */
|
|
||||||
OsBlockSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsBlockSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSignals();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* ABAB */
|
|
||||||
OsBlockSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsBlockSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* BAAB */
|
|
||||||
OsBlockSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsBlockSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
|
|
||||||
/* BABA */
|
|
||||||
OsBlockSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsBlockSignals();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSIGIO();
|
|
||||||
assert(sig_is_blocked(SIGIO));
|
|
||||||
OsReleaseSignals();
|
|
||||||
assert(!sig_is_blocked(SIGIO));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void block_sigio_test_nested(void)
|
|
||||||
{
|
|
||||||
#ifdef SIG_BLOCK
|
|
||||||
/* Check for bug releasing SIGIO during SIGIO signal handling.
|
|
||||||
test case:
|
|
||||||
raise signal
|
|
||||||
→ in signal handler:
|
|
||||||
raise signal
|
|
||||||
OsBlockSignals()
|
|
||||||
OsReleaseSignals()
|
|
||||||
tail guard
|
|
||||||
tail guard must be hit.
|
|
||||||
*/
|
|
||||||
void (*old_handler)(int);
|
|
||||||
old_handler = OsSignal(SIGIO, sighandler);
|
|
||||||
expect_signal = 1;
|
|
||||||
assert(raise(SIGIO) == 0);
|
|
||||||
assert(OsSignal(SIGIO, old_handler) == sighandler);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
block_sigio_test();
|
|
||||||
block_sigio_test_nested();
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1526,7 +1526,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
events = InitEventList(GetMaximumEventsNum() + 1);
|
events = InitEventList(GetMaximumEventsNum() + 1);
|
||||||
OsBlockSignals();
|
input_lock();
|
||||||
pScreen = miPointerGetScreen(ptr);
|
pScreen = miPointerGetScreen(ptr);
|
||||||
saveWait = miPointerSetWaitForUpdate(pScreen, FALSE);
|
saveWait = miPointerSetWaitForUpdate(pScreen, FALSE);
|
||||||
nevents = GetPointerEvents(events, ptr, type, button, flags, mask);
|
nevents = GetPointerEvents(events, ptr, type, button, flags, mask);
|
||||||
|
@ -1534,7 +1534,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags,
|
||||||
UpdateFromMaster(&events[nevents], lastSlave, DEVCHANGE_POINTER_EVENT,
|
UpdateFromMaster(&events[nevents], lastSlave, DEVCHANGE_POINTER_EVENT,
|
||||||
&nevents);
|
&nevents);
|
||||||
miPointerSetWaitForUpdate(pScreen, saveWait);
|
miPointerSetWaitForUpdate(pScreen, saveWait);
|
||||||
OsReleaseSignals();
|
input_unlock();
|
||||||
|
|
||||||
for (i = 0; i < nevents; i++)
|
for (i = 0; i < nevents; i++)
|
||||||
mieqProcessDeviceEvent(ptr, &events[i], NULL);
|
mieqProcessDeviceEvent(ptr, &events[i], NULL);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user