[PATCH xserver 2/6] Remove SIGIO support.
Keith Packard
keithp at keithp.com
Tue Dec 8 15:44:50 PST 2015
This removes all of the SIGIO handling support 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.
Signed-off-by: Keith Packard <keithp at keithp.com>
---
Xi/exevents.c | 4 +-
config/config.c | 4 +-
dix/devices.c | 10 +-
dix/ptrveloc.c | 4 +-
dix/touch.c | 8 +-
hw/dmx/input/dmxevents.c | 24 +--
hw/kdrive/ephyr/ephyr.c | 4 +-
hw/kdrive/src/kinput.c | 74 +-------
hw/xfree86/common/xf86Config.c | 24 ---
hw/xfree86/common/xf86Cursor.c | 8 +-
hw/xfree86/common/xf86Events.c | 33 ++--
hw/xfree86/common/xf86Helper.c | 2 +-
hw/xfree86/common/xf86Init.c | 6 +-
hw/xfree86/common/xf86PM.c | 8 +-
hw/xfree86/common/xf86Xinput.c | 8 +-
hw/xfree86/dri/dri.c | 54 +-----
hw/xfree86/os-support/bsd/Makefile.am | 1 -
hw/xfree86/os-support/hurd/Makefile.am | 1 -
hw/xfree86/os-support/linux/Makefile.am | 1 -
hw/xfree86/os-support/shared/sigio.c | 291 ------------------------------
hw/xfree86/os-support/shared/sigiostubs.c | 70 -------
hw/xfree86/os-support/solaris/Makefile.am | 1 -
hw/xfree86/os-support/stub/Makefile.am | 1 -
hw/xfree86/os-support/xf86_OSproc.h | 12 --
include/os.h | 6 -
mi/mieq.c | 6 +-
mi/mipointer.c | 4 +-
os/utils.c | 54 +-----
test/Makefile.am | 2 +-
test/os.c | 166 -----------------
xkb/xkbActions.c | 4 +-
31 files changed, 77 insertions(+), 818 deletions(-)
delete mode 100644 hw/xfree86/os-support/shared/sigio.c
delete mode 100644 hw/xfree86/os-support/shared/sigiostubs.c
delete mode 100644 test/os.c
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 74e49ed..696e244 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -661,7 +661,7 @@ void
DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
DeviceChangedEvent *dce)
{
- OsBlockSIGIO();
+ input_lock();
/* generic feedback classes, not tied to pointer and/or keyboard */
DeepCopyFeedbackClasses(from, to);
@@ -671,7 +671,7 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to,
if ((dce->flags & DEVCHANGE_POINTER_EVENT))
DeepCopyPointerClasses(from, to);
- OsReleaseSIGIO();
+ input_unlock();
}
/**
diff --git a/config/config.c b/config/config.c
index de45cc3..263982e 100644
--- a/config/config.c
+++ b/config/config.c
@@ -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
* already been removed. */
- OsBlockSignals();
ProcessInputEvents();
+ input_lock();
DeleteInputDeviceRequest(dev);
- OsReleaseSignals();
+ input_unlock();
}
void
diff --git a/dix/devices.c b/dix/devices.c
index 9b0c7d2..7ba6b94 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -491,14 +491,14 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
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 */
- OsBlockSignals();
+ input_lock();
for (other = inputInfo.devices; other; other = other->next) {
if (other->last.slave == dev)
other->last.slave = NULL;
}
- OsReleaseSignals();
+ input_unlock();
LeaveWindow(dev);
SetFocusOut(dev);
@@ -1031,7 +1031,7 @@ CloseDownDevices(void)
{
DeviceIntPtr dev;
- OsBlockSignals();
+ input_lock();
/* 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
@@ -1058,7 +1058,7 @@ CloseDownDevices(void)
XkbDeleteRulesDflts();
XkbDeleteRulesUsed();
- OsReleaseSignals();
+ input_unlock();
}
/**
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index e75300a..1b63c51 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -159,7 +159,7 @@ AccelerationDefaultCleanup(DeviceIntPtr dev)
* AccelSchemeProc(), but that seems impossible. Schemes don't get
* switched often anyway.
*/
- OsBlockSignals();
+ input_lock();
dev->valuator->accelScheme.AccelSchemeProc = NULL;
FreeVelocityData(vel);
free(vel);
@@ -169,7 +169,7 @@ AccelerationDefaultCleanup(DeviceIntPtr dev)
accelData);
free(dev->valuator->accelScheme.accelData);
dev->valuator->accelScheme.accelData = NULL;
- OsReleaseSignals();
+ input_unlock();
}
}
diff --git a/dix/touch.c b/dix/touch.c
index 54da132..eee110d 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -79,7 +79,7 @@ TouchResizeQueue(ClientPtr client, void *closure)
{
int i;
- OsBlockSignals();
+ input_lock();
/* first two ids are reserved */
for (i = 2; i < MAXDEVICES; i++) {
@@ -112,7 +112,7 @@ TouchResizeQueue(ClientPtr client, void *closure)
}
}
- OsReleaseSignals();
+ input_unlock();
return TRUE;
}
@@ -1077,8 +1077,8 @@ TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
int i;
- OsBlockSignals();
mieqProcessInputEvents();
+ input_lock();
for (i = 0; i < dev->last.num_touches; i++) {
DDXTouchPointInfoPtr ddxti = dev->last.touches + i;
@@ -1091,7 +1091,7 @@ TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
mieqProcessDeviceEvent(dev, eventlist + j, NULL);
}
}
- OsReleaseSignals();
+ input_unlock();
FreeEventList(eventlist, GetMaximumEventsNum());
}
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 2b579ee..3789602 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -227,25 +227,25 @@ dmxCoreMotion(DevicePtr pDev, int x, int y, int delta, DMXBlockType block)
&& pScreen->myNum == dmxScreen->index) {
/* Screen is old screen */
if (block)
- OsBlockSIGIO();
+ input_lock();
if (pDev)
enqueueMotion(pDev, localX, localY);
if (block)
- OsReleaseSIGIO();
+ input_unlock();
}
else {
/* Screen is new */
DMXDBG4(" New screen: old=%d new=%d localX=%d localY=%d\n",
pScreen->myNum, dmxScreen->index, localX, localY);
if (block)
- OsBlockSIGIO();
+ input_lock();
mieqProcessInputEvents();
miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
localX, localY);
if (pDev)
enqueueMotion(pDev, localX, localY);
if (block)
- OsReleaseSIGIO();
+ input_unlock();
}
#if 00
miPointerGetPosition(inputInfo.pointer, &localX, &localY);
@@ -387,12 +387,12 @@ dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
}
if (block)
- OsBlockSIGIO();
+ input_lock();
valuator_mask_set_range(&mask, firstAxis, axesCount, v);
QueuePointerEvents(pDevice, MotionNotify, 0, POINTER_ABSOLUTE, &mask);
if (block)
- OsReleaseSIGIO();
+ input_unlock();
}
static int
@@ -489,10 +489,10 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
case XI_DeviceKeyPress:
case XI_DeviceKeyRelease:
if (block)
- OsBlockSIGIO();
+ input_lock();
QueueKeyboardEvents(pDevice, event, ke->keycode);
if (block)
- OsReleaseSIGIO();
+ input_unlock();
break;
case XI_DeviceButtonPress:
case XI_DeviceButtonRelease:
@@ -500,11 +500,11 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
valuators);
if (block)
- OsBlockSIGIO();
+ input_lock();
QueuePointerEvents(pDevice, event, ke->keycode,
POINTER_ABSOLUTE, &mask);
if (block)
- OsReleaseSIGIO();
+ input_unlock();
break;
case XI_ProximityIn:
case XI_ProximityOut:
@@ -512,10 +512,10 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
valuators);
if (block)
- OsBlockSIGIO();
+ input_lock();
QueueProximityEvents(pDevice, event, &mask);
if (block)
- OsReleaseSIGIO();
+ input_unlock();
break;
break;
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 896bac5..e98cd12 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -836,11 +836,11 @@ ScreenPtr ephyrCursorScreen; /* screen containing the cursor */
static void
ephyrWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- OsBlockSIGIO();
+ input_lock();
ephyrCursorScreen = pScreen;
miPointerWarpCursor(inputInfo.pointer, pScreen, x, y);
- OsReleaseSIGIO();
+ input_unlock();
}
miPointerScreenFuncRec ephyrPointerScreenFuncs = {
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 1fdaa52..a3e352c 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -93,38 +93,6 @@ static int kdNumInputFds;
extern Bool kdRawPointerCoordinates;
-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
#define NOBLOCK FNONBLOCK
#else
@@ -156,51 +124,25 @@ static void
KdNotifyFd(int fd, int ready, void *data)
{
int i = (int) (intptr_t) data;
- OsBlockSIGIO();
(*kdInputFds[i].read)(fd, kdInputFds[i].closure);
- OsReleaseSIGIO();
}
static void
KdAddFd(int fd, int i)
{
- struct sigaction act;
- sigset_t set;
-
- kdnFds++;
- fcntl(fd, F_SETOWN, getpid());
KdNonBlockFd(fd);
- AddEnabledDevice(fd);
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
KdRemoveFd(int fd)
{
- struct sigaction act;
int flags;
- kdnFds--;
- RemoveEnabledDevice(fd);
RemoveNotifyFd(fd);
flags = fcntl(fd, F_GETFL);
flags &= ~(FASYNC | NOBLOCK);
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
@@ -252,7 +194,7 @@ KdDisableInput(void)
KdPointerInfo *pi;
int found = 0, i = 0;
- OsBlockSIGIO();
+ input_lock();
for (ki = kdKeyboards; ki; ki = ki->next) {
if (ki->driver && ki->driver->Disable)
@@ -334,8 +276,6 @@ KdEnableInput(void)
/* reset screen saver */
NoticeEventTime (&ev, pi->dixdev);
}
-
- OsReleaseSIGIO();
}
static KdKeyboardDriver *
@@ -1751,7 +1691,7 @@ KdReleaseAllKeys(void)
int key;
KdKeyboardInfo *ki;
- OsBlockSIGIO();
+ input_lock();
for (ki = kdKeyboards; ki; ki = ki->next) {
for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) {
@@ -1762,7 +1702,7 @@ KdReleaseAllKeys(void)
}
}
- OsReleaseSIGIO();
+ input_unlock();
#endif
}
@@ -1950,9 +1890,9 @@ KdWakeupHandler(ScreenPtr pScreen, unsigned long lresult, void *readmask)
if (pi->timeoutPending) {
if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) {
pi->timeoutPending = FALSE;
- OsBlockSIGIO();
+ input_lock();
KdReceiveTimeout(pi);
- OsReleaseSIGIO();
+ input_unlock();
}
}
}
@@ -2049,10 +1989,10 @@ int KdCurScreen; /* current event screen */
static void
KdWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- OsBlockSIGIO();
+ input_lock();
KdCurScreen = pScreen->myNum;
miPointerWarpCursor(pDev, pScreen, x, y);
- OsReleaseSIGIO();
+ input_unlock();
}
miPointerScreenFuncRec kdPointerScreenFuncs = {
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index d2c3225..07afd42 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -701,7 +701,6 @@ typedef enum {
FLAG_AUTO_ENABLE_DEVICES,
FLAG_GLX_VISUALS,
FLAG_DRI2,
- FLAG_USE_SIGIO,
FLAG_AUTO_ADD_GPU,
FLAG_MAX_CLIENTS,
} FlagValues;
@@ -759,8 +758,6 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE},
{FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
{0}, FALSE},
- {FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
- {0}, FALSE},
{FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN,
{0}, FALSE},
{FLAG_MAX_CLIENTS, "MaxClients", OPTV_INTEGER,
@@ -808,27 +805,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
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)) {
xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
&xf86Info.autoAddDevices);
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 92c08af..de054fb 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -221,7 +221,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
if (pScreen == pCursorScreen)
miPointerGetPosition(dev, &px, &py);
- OsBlockSIGIO();
+ input_lock();
Switched = (*pScr->SwitchMode) (pScr, mode);
if (Switched) {
pScr->currentMode = mode;
@@ -260,7 +260,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
pScr->frameY1 = pScr->virtualY - 1;
}
}
- OsReleaseSIGIO();
+ input_unlock();
if (pScr->AdjustFrame)
(*pScr->AdjustFrame) (pScr, pScr->frameX0, pScr->frameY0);
@@ -452,11 +452,11 @@ xf86CrossScreen(ScreenPtr pScreen, Bool entering)
static void
xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
- OsBlockSIGIO();
+ input_lock();
miPointerWarpCursor(pDev, pScreen, x, y);
xf86Info.currentScreen = pScreen;
- OsReleaseSIGIO();
+ input_unlock();
}
void *
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 709afd6..3d16f24 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -259,7 +259,7 @@ xf86Wakeup(void *blockData, int err, void *pReadmask)
while (pInfo) {
if (pInfo->read_input && pInfo->fd >= 0 &&
(FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
- OsBlockSIGIO();
+ input_lock();
/*
* 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);
pInfo->read_input(pInfo);
- OsReleaseSIGIO();
+ input_unlock();
}
pInfo = pInfo->next;
}
@@ -291,18 +291,15 @@ xf86Wakeup(void *blockData, int err, void *pReadmask)
}
/*
- * xf86SigioReadInput --
- * signal handler for the SIGIO signal.
+ * xf86ReadInput --
+ * input thread handler
*/
+
static void
-xf86SigioReadInput(int fd, void *closure)
-{
- int errno_save = errno;
+xf86ReadInput(int fd, int ready, void *closure) {
InputInfoPtr pInfo = closure;
pInfo->read_input(pInfo);
-
- errno = errno_save;
}
/*
@@ -312,9 +309,7 @@ xf86SigioReadInput(int fd, void *closure)
void
xf86AddEnabledDevice(InputInfoPtr pInfo)
{
- if (!xf86InstallSIGIOHandler(pInfo->fd, xf86SigioReadInput, pInfo)) {
- AddEnabledDevice(pInfo->fd);
- }
+ SetNotifyFd(pInfo->fd, xf86ReadInput, X_NOTIFY_READ, pInfo);
}
/*
@@ -324,9 +319,7 @@ xf86AddEnabledDevice(InputInfoPtr pInfo)
void
xf86RemoveEnabledDevice(InputInfoPtr pInfo)
{
- if (!xf86RemoveSIGIOHandler(pInfo->fd)) {
- RemoveEnabledDevice(pInfo->fd);
- }
+ RemoveNotifyFd(pInfo->fd);
}
static int *xf86SignalIntercept = NULL;
@@ -402,9 +395,9 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
for (i = keyc->xkbInfo->desc->min_key_code;
i < keyc->xkbInfo->desc->max_key_code; i++) {
if (key_is_down(pDev, i, KEY_POSTED)) {
- OsBlockSIGIO();
+ input_lock();
QueueKeyboardEvents(pDev, KeyRelease, i);
- OsReleaseSIGIO();
+ input_unlock();
}
}
}
@@ -487,7 +480,7 @@ xf86VTLeave(void)
for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
xf86DisableInputDeviceForVTSwitch(pInfo);
- OsBlockSIGIO();
+ input_lock();
for (i = 0; i < xf86NumScreens; i++)
xf86Screens[i]->LeaveVT(xf86Screens[i]);
for (i = 0; i < xf86NumGPUScreens; i++)
@@ -545,7 +538,7 @@ switch_failed:
else
xf86EnableGeneralHandler(ih);
}
- OsReleaseSIGIO();
+ input_unlock();
}
void
@@ -603,7 +596,7 @@ xf86VTEnter(void)
xf86UpdateHasVTProperty(TRUE);
- OsReleaseSIGIO();
+ input_unlock();
}
/*
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index c42e93e..b506338 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1729,7 +1729,7 @@ xf86SetSilkenMouse(ScreenPtr pScreen)
* yet. Should handle this differently so that alternate async methods
* work correctly with this too.
*/
- pScrn->silkenMouse = useSM && xf86Info.useSIGIO && xf86SIGIOSupported();
+ pScrn->silkenMouse = useSM && FALSE;
if (serverGeneration == 1)
xf86DrvMsg(pScreen->myNum, from, "Silken mouse %s\n",
pScrn->silkenMouse ? "enabled" : "disabled");
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 017dcb6..5281e3e 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -823,7 +823,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
#endif
xf86AccessEnter();
- OsBlockSIGIO();
+ input_lock();
sigio_blocked = TRUE;
}
}
@@ -931,7 +931,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
xf86VGAarbiterWrapFunctions();
if (sigio_blocked)
- OsReleaseSIGIO();
+ input_unlock();
xf86InitOrigins();
@@ -1077,7 +1077,7 @@ AbortDDX(enum ExitCode error)
{
int i;
- OsBlockSIGIO();
+ input_lock();
/*
* try to restore the original video state
diff --git a/hw/xfree86/common/xf86PM.c b/hw/xfree86/common/xf86PM.c
index 9e49e8e..3f08c81 100644
--- a/hw/xfree86/common/xf86PM.c
+++ b/hw/xfree86/common/xf86PM.c
@@ -107,7 +107,7 @@ suspend(pmEvent event, Bool undo)
DisableDevice(pInfo->dev, TRUE);
pInfo = pInfo->next;
}
- OsBlockSIGIO();
+ input_lock();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->PMEvent)
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
@@ -135,7 +135,7 @@ resume(pmEvent event, Bool undo)
xf86Screens[i]->EnterVT(xf86Screens[i]);
}
}
- OsReleaseSIGIO();
+ input_unlock();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->EnableDisableFBAccess)
(*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE);
@@ -182,13 +182,13 @@ DoApmEvent(pmEvent event, Bool undo)
}
break;
default:
- OsBlockSIGIO();
+ input_lock();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->PMEvent) {
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
}
}
- OsReleaseSIGIO();
+ input_unlock();
break;
}
}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index c56a2b9..481a760 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -925,7 +925,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
/* Enable it if it's properly initialised and we're currently in the VT */
if (enable && dev->inited && dev->startup && xf86VTOwner()) {
- OsBlockSignals();
+ input_lock();
EnableDevice(dev, TRUE);
if (!dev->enabled) {
OsReleaseSignals();
@@ -936,7 +936,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
}
/* send enter/leave event, update sprite window */
CheckMotion(NULL, dev);
- OsReleaseSignals();
+ input_unlock();
}
*pdev = dev;
@@ -1069,7 +1069,7 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
if (pInfo) /* need to get these before RemoveDevice */
drv = pInfo->drv;
- OsBlockSignals();
+ input_lock();
RemoveDevice(pDev, TRUE);
if (!isMaster && pInfo != NULL) {
@@ -1078,7 +1078,7 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
else
xf86DeleteInput(pInfo, 0);
}
- OsReleaseSignals();
+ input_unlock();
}
/*
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 875c9cc..49ecaca 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -2377,56 +2377,6 @@ DRICreatePCIBusID(const struct pci_device *dev)
return busID;
}
-static void
-drmSIGIOHandler(int interrupt, void *closure)
-{
- unsigned long key;
- void *value;
- ssize_t count;
- drm_ctx_t ctx;
- typedef void (*_drmCallback) (int, void *, void *);
- char buf[256];
- drm_context_t old;
- drm_context_t new;
- void *oldctx;
- void *newctx;
- char *pt;
- drmHashEntry *entry;
- void *hash_table;
-
- hash_table = drmGetHashTable();
-
- if (!hash_table)
- return;
- if (drmHashFirst(hash_table, &key, &value)) {
- entry = value;
- do {
-#if 0
- fprintf(stderr, "Trying %d\n", entry->fd);
-#endif
- if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) {
- buf[count] = '\0';
-#if 0
- fprintf(stderr, "Got %s\n", buf);
-#endif
-
- for (pt = buf; *pt != ' '; ++pt); /* Find first space */
- ++pt;
- old = strtol(pt, &pt, 0);
- new = strtol(pt, NULL, 0);
- oldctx = drmGetContextTag(entry->fd, old);
- newctx = drmGetContextTag(entry->fd, new);
-#if 0
- fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
-#endif
- ((_drmCallback) entry->f) (entry->fd, oldctx, newctx);
- ctx.handle = new;
- ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
- }
- } while (drmHashNext(hash_table, &key, &value));
- }
-}
-
int
drmInstallSIGIOHandler(int fd, void (*f) (int, void *, void *))
{
@@ -2435,7 +2385,7 @@ drmInstallSIGIOHandler(int fd, void (*f) (int, void *, void *))
entry = drmGetEntry(fd);
entry->f = f;
- return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
+ return 0;
}
int
@@ -2445,5 +2395,5 @@ drmRemoveSIGIOHandler(int fd)
entry->f = NULL;
- return xf86RemoveSIGIOHandler(fd);
+ return 0;
}
diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index b01ea5b..b2de637 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -56,7 +56,6 @@ AM_CPPFLAGS = $(XORG_INCS)
libbsd_la_SOURCES = \
$(srcdir)/../shared/posix_tty.c \
- $(srcdir)/../shared/sigio.c \
$(srcdir)/../shared/vidmem.c \
bsd_VTsw.c \
bsd_init.c \
diff --git a/hw/xfree86/os-support/hurd/Makefile.am b/hw/xfree86/os-support/hurd/Makefile.am
index 3866054..0ded8c4 100644
--- a/hw/xfree86/os-support/hurd/Makefile.am
+++ b/hw/xfree86/os-support/hurd/Makefile.am
@@ -5,7 +5,6 @@ libhurd_la_SOURCES = hurd_bell.c hurd_init.c \
$(srcdir)/../shared/VTsw_noop.c \
$(srcdir)/../shared/posix_tty.c \
$(srcdir)/../shared/vidmem.c \
- $(srcdir)/../shared/sigiostubs.c \
$(srcdir)/../shared/pm_noop.c \
$(srcdir)/../shared/kmod_noop.c \
$(srcdir)/../shared/agp_noop.c
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index d8cb177..b1b758f 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -28,7 +28,6 @@ liblinux_la_SOURCES = linux.h lnx_init.c lnx_video.c \
$(srcdir)/../shared/VTsw_usl.c \
$(srcdir)/../shared/posix_tty.c \
$(srcdir)/../shared/vidmem.c \
- $(srcdir)/../shared/sigio.c \
$(ACPI_SRCS) \
$(APM_SRCS) \
$(LOGIND_SRCS)
diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c
deleted file mode 100644
index c746d02..0000000
--- a/hw/xfree86/os-support/shared/sigio.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/* sigio.c -- Support for SIGIO handler installation and removal
- * Created: Thu Jun 3 15:39:18 1999 by faith at precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
- *
- * Authors: Rickard E. (Rik) Faith <faith at valinux.com>
- */
-/*
- * Copyright (c) 2002 by The XFree86 Project, 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "inputstr.h"
-
-#ifdef HAVE_STROPTS_H
-#include <stropts.h>
-#endif
-
-#ifdef MAXDEVICES
-/* MAXDEVICES represents the maximimum number of input devices usable
- * at the same time plus one entry for DRM support.
- */
-#define MAX_FUNCS (MAXDEVICES + 1)
-#else
-#define MAX_FUNCS 16
-#endif
-
-typedef struct _xf86SigIOFunc {
- void (*f) (int, void *);
- int fd;
- void *closure;
-} Xf86SigIOFunc;
-
-static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS];
-static int xf86SigIOMax;
-static int xf86SigIOMaxFd;
-static fd_set xf86SigIOMask;
-
-/*
- * SIGIO gives no way of discovering which fd signalled, select
- * to discover
- */
-static void
-xf86SIGIO(int sig)
-{
- int i;
- fd_set ready;
- struct timeval to;
- int save_errno = errno; /* do not clobber the global errno */
- int r;
-
- inSignalContext = TRUE;
-
- ready = xf86SigIOMask;
- to.tv_sec = 0;
- to.tv_usec = 0;
- SYSCALL(r = select(xf86SigIOMaxFd, &ready, 0, 0, &to));
- for (i = 0; r > 0 && i < xf86SigIOMax; i++)
- if (xf86SigIOFuncs[i].f && FD_ISSET(xf86SigIOFuncs[i].fd, &ready)) {
- (*xf86SigIOFuncs[i].f) (xf86SigIOFuncs[i].fd,
- xf86SigIOFuncs[i].closure);
- r--;
- }
- if (r > 0) {
- xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r);
- }
- /* restore global errno */
- errno = save_errno;
-
- inSignalContext = FALSE;
-}
-
-static int
-xf86IsPipe(int fd)
-{
- struct stat buf;
-
- if (fstat(fd, &buf) < 0)
- return 0;
- return S_ISFIFO(buf.st_mode);
-}
-
-int
-xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
-{
- struct sigaction sa;
- struct sigaction osa;
- int i;
- int installed = FALSE;
-
- if (!xf86Info.useSIGIO)
- return 0;
-
- for (i = 0; i < MAX_FUNCS; i++) {
- if (!xf86SigIOFuncs[i].f) {
- if (xf86IsPipe(fd))
- return 0;
- OsBlockSIGIO();
-#ifdef O_ASYNC
- if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n",
- fd, strerror(errno));
- }
- else {
- if (fcntl(fd, F_SETOWN, getpid()) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
- fd, strerror(errno));
- }
- else {
- installed = TRUE;
- }
- }
-#endif
-#ifdef I_SETSIG /* System V Streams - used on Solaris for input devices */
- if (!installed && isastream(fd)) {
- if (ioctl(fd, I_SETSIG, S_INPUT | S_ERROR | S_HANGUP) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG): %s\n",
- fd, strerror(errno));
- }
- else {
- installed = TRUE;
- }
- }
-#endif
- if (!installed) {
- OsReleaseSIGIO();
- return 0;
- }
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGIO);
- sa.sa_flags = SA_RESTART;
- sa.sa_handler = xf86SIGIO;
- sigaction(SIGIO, &sa, &osa);
- xf86SigIOFuncs[i].fd = fd;
- xf86SigIOFuncs[i].closure = closure;
- xf86SigIOFuncs[i].f = f;
- if (i >= xf86SigIOMax)
- xf86SigIOMax = i + 1;
- if (fd >= xf86SigIOMaxFd)
- xf86SigIOMaxFd = fd + 1;
- FD_SET(fd, &xf86SigIOMask);
- OsReleaseSIGIO();
- return 1;
- }
- /* Allow overwriting of the closure and callback */
- else if (xf86SigIOFuncs[i].fd == fd) {
- xf86SigIOFuncs[i].closure = closure;
- xf86SigIOFuncs[i].f = f;
- return 1;
- }
- }
- return 0;
-}
-
-int
-xf86RemoveSIGIOHandler(int fd)
-{
- struct sigaction sa;
- struct sigaction osa;
- int i;
- int max;
- int maxfd;
- int ret;
-
- if (!xf86Info.useSIGIO)
- return 0;
-
- max = 0;
- maxfd = -1;
- ret = 0;
- for (i = 0; i < MAX_FUNCS; i++) {
- if (xf86SigIOFuncs[i].f) {
- if (xf86SigIOFuncs[i].fd == fd) {
- xf86SigIOFuncs[i].f = 0;
- xf86SigIOFuncs[i].fd = 0;
- xf86SigIOFuncs[i].closure = 0;
- FD_CLR(fd, &xf86SigIOMask);
- ret = 1;
- }
- else {
- max = i + 1;
- if (xf86SigIOFuncs[i].fd >= maxfd)
- maxfd = xf86SigIOFuncs[i].fd + 1;
- }
- }
- }
- if (ret) {
-#ifdef O_ASYNC
- fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC);
-#endif
-#ifdef I_SETSIG
- if (isastream(fd)) {
- if (ioctl(fd, I_SETSIG, 0) == -1) {
- xf86Msg(X_WARNING, "fcntl(%d, I_SETSIG, 0): %s\n",
- fd, strerror(errno));
- }
- }
-#endif
- xf86SigIOMax = max;
- xf86SigIOMaxFd = maxfd;
- if (!max) {
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGIO);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_IGN;
- sigaction(SIGIO, &sa, &osa);
- }
- }
- 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;
-}
diff --git a/hw/xfree86/os-support/shared/sigiostubs.c b/hw/xfree86/os-support/shared/sigiostubs.c
deleted file mode 100644
index ba8e234..0000000
--- a/hw/xfree86/os-support/shared/sigiostubs.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1999-2003 by The XFree86 Project, 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-int
-xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
-{
- return 0;
-}
-
-int
-xf86RemoveSIGIOHandler(int fd)
-{
- 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;
-}
diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am
index e534bc8..04cf4aa 100644
--- a/hw/xfree86/os-support/solaris/Makefile.am
+++ b/hw/xfree86/os-support/solaris/Makefile.am
@@ -21,7 +21,6 @@ libsolaris_la_SOURCES = sun_init.c \
sun_vid.c sun_bell.c $(AGP_SRC) sun_apm.c \
$(srcdir)/../shared/kmod_noop.c \
$(srcdir)/../shared/posix_tty.c \
- $(srcdir)/../shared/sigio.c \
$(srcdir)/../shared/vidmem.c \
$(VTSW_SRC)
nodist_libsolaris_la_SOURCES = $(SOLARIS_INOUT_SRC)
diff --git a/hw/xfree86/os-support/stub/Makefile.am b/hw/xfree86/os-support/stub/Makefile.am
index 19468c6..9bc3580 100644
--- a/hw/xfree86/os-support/stub/Makefile.am
+++ b/hw/xfree86/os-support/stub/Makefile.am
@@ -12,7 +12,6 @@ libstub_la_SOURCES = \
$(srcdir)/../shared/pm_noop.c \
$(srcdir)/../shared/vidmem.c \
$(srcdir)/../shared/posix_tty.c \
- $(srcdir)/../shared/sigio.c \
stub_bell.c \
stub_init.c \
stub_video.c
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index fa3ff0e..41a82a4 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -162,18 +162,6 @@ extern _X_EXPORT Bool xf86UnbindGARTMemory(int screenNum, int key);
extern _X_EXPORT Bool xf86EnableAGP(int screenNum, CARD32 mode);
extern _X_EXPORT Bool xf86GARTCloseScreen(int screenNum);
-/* These routines are in shared/sigio.c and are not loaded as part of the
- module. These routines are small, and the code if very POSIX-signal (or
- OS-signal) specific, so it seemed better to provide more complex
- wrappers than to wrap each individual function called. */
-extern _X_EXPORT int xf86InstallSIGIOHandler(int fd, void (*f) (int, void *),
- void *);
-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
typedef void (*PMClose) (void);
extern _X_EXPORT void xf86OpenConsole(void);
diff --git a/include/os.h b/include/os.h
index e7c1936..11f72a1 100644
--- a/include/os.h
+++ b/include/os.h
@@ -336,12 +336,6 @@ OsBlockSignals(void);
extern _X_EXPORT void
OsReleaseSignals(void);
-extern _X_EXPORT int
-OsBlockSIGIO(void);
-
-extern _X_EXPORT void
-OsReleaseSIGIO(void);
-
extern void
OsResetSignals(void);
diff --git a/mi/mieq.c b/mi/mieq.c
index 01812bd..8fbe6c3 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -145,10 +145,10 @@ mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents)
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.
*/
- OsBlockSignals();
+ input_lock();
/* First copy the existing events */
first_hunk = eventQueue->nevents - eventQueue->head;
@@ -181,7 +181,7 @@ mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents)
free(eventQueue->events);
eventQueue->events = new_events;
- OsReleaseSignals();
+ input_unlock();
return TRUE;
}
diff --git a/mi/mipointer.c b/mi/mipointer.c
index ada1ab5..587fe27 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -723,7 +723,7 @@ miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
POINTER_SCREEN | POINTER_ABSOLUTE |
POINTER_NORAW, &mask);
- OsBlockSignals();
+ input_lock();
#ifdef XQUARTZ
darwinEvents_lock();
#endif
@@ -732,5 +732,5 @@ miPointerMove(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
#ifdef XQUARTZ
darwinEvents_unlock();
#endif
- OsReleaseSignals();
+ input_unlock();
}
diff --git a/os/utils.c b/os/utils.c
index ef7a2cc..903fbc9 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1304,9 +1304,7 @@ OsBlockSignals(void)
if (BlockedSignalCount++ == 0) {
sigset_t set;
-#ifdef SIGIO
- OsBlockSIGIO();
-#endif
+ input_lock();
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigaddset(&set, SIGVTALRM);
@@ -1322,57 +1320,13 @@ OsBlockSignals(void)
#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
OsReleaseSignals(void)
{
#ifdef SIG_BLOCK
if (--BlockedSignalCount == 0) {
sigprocmask(SIG_SETMASK, &PreviousSignalMask, 0);
- OsReleaseSIGIO();
+ input_unlock();
}
#endif
}
@@ -1383,10 +1337,6 @@ OsResetSignals(void)
#ifdef SIG_BLOCK
while (BlockedSignalCount > 0)
OsReleaseSignals();
-#ifdef SIGIO
- while (sigio_blocked > 0)
- OsReleaseSIGIO();
-#endif
#endif
}
diff --git a/test/Makefile.am b/test/Makefile.am
index d151b02..a92d7a6 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,7 +5,7 @@ if XORG
# Tests that require at least some DDX functions in order to fully link
# For now, requires xf86 ddx, could be adjusted to use another
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
noinst_PROGRAMS += hashtabletest
endif
diff --git a/test/os.c b/test/os.c
deleted file mode 100644
index d85dcff..0000000
--- a/test/os.c
+++ /dev/null
@@ -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;
-}
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index aeb702c..effda7c 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1526,7 +1526,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags,
return;
events = InitEventList(GetMaximumEventsNum() + 1);
- OsBlockSignals();
+ input_lock();
pScreen = miPointerGetScreen(ptr);
saveWait = miPointerSetWaitForUpdate(pScreen, FALSE);
nevents = GetPointerEvents(events, ptr, type, button, flags, mask);
@@ -1534,10 +1534,10 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags,
UpdateFromMaster(&events[nevents], lastSlave, DEVCHANGE_POINTER_EVENT,
&nevents);
miPointerSetWaitForUpdate(pScreen, saveWait);
- OsReleaseSignals();
for (i = 0; i < nevents; i++)
mieqProcessDeviceEvent(ptr, &events[i], NULL);
+ input_unlock();
FreeEventList(events, GetMaximumEventsNum());
--
2.6.2
More information about the xorg-devel
mailing list