Commit d84f0f82 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

Merge branch 'sigio-vt-switch-issues' into for-keith



Conflicts:
	test/Makefile.am
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parents 12bfb4cf d04dfe3f
......@@ -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)
dmxSigioBlock();
OsBlockSIGIO();
if (pDev)
enqueueMotion(pDev, localX, localY);
if (block)
dmxSigioUnblock();
OsReleaseSIGIO();
}
else {
/* Screen is new */
DMXDBG4(" New screen: old=%d new=%d localX=%d localY=%d\n",
pScreen->myNum, dmxScreen->index, localX, localY);
if (block)
dmxSigioBlock();
OsBlockSIGIO();
mieqProcessInputEvents();
miPointerSetScreen(inputInfo.pointer, dmxScreen->index,
localX, localY);
if (pDev)
enqueueMotion(pDev, localX, localY);
if (block)
dmxSigioUnblock();
OsReleaseSIGIO();
}
#if 00
miPointerGetPosition(inputInfo.pointer, &localX, &localY);
......@@ -387,12 +387,12 @@ dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
}
if (block)
dmxSigioBlock();
OsBlockSIGIO();
valuator_mask_set_range(&mask, firstAxis, axesCount, v);
QueuePointerEvents(pDevice, MotionNotify, 0, POINTER_ABSOLUTE, &mask);
if (block)
dmxSigioUnblock();
OsReleaseSIGIO();
}
static int
......@@ -492,10 +492,10 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
valuators);
if (block)
dmxSigioBlock();
OsBlockSIGIO();
QueueKeyboardEvents(pDevice, event, ke->keycode, &mask);
if (block)
dmxSigioUnblock();
OsReleaseSIGIO();
break;
case XI_DeviceButtonPress:
case XI_DeviceButtonRelease:
......@@ -503,11 +503,11 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
valuators);
if (block)
dmxSigioBlock();
OsBlockSIGIO();
QueuePointerEvents(pDevice, event, ke->keycode,
POINTER_ABSOLUTE, &mask);
if (block)
dmxSigioUnblock();
OsReleaseSIGIO();
break;
case XI_ProximityIn:
case XI_ProximityOut:
......@@ -515,10 +515,10 @@ dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count,
valuators);
if (block)
dmxSigioBlock();
OsBlockSIGIO();
QueueProximityEvents(pDevice, event, &mask);
if (block)
dmxSigioUnblock();
OsReleaseSIGIO();
break;
break;
......
......@@ -84,28 +84,6 @@ dmxSigioHandler(int sig)
}
}
/** Block SIGIO handling. */
void
dmxSigioBlock(void)
{
sigset_t s;
sigemptyset(&s);
sigaddset(&s, SIGIO);
sigprocmask(SIG_BLOCK, &s, 0);
}
/** Unblock SIGIO handling. */
void
dmxSigioUnblock(void)
{
sigset_t s;
sigemptyset(&s);
sigaddset(&s, SIGIO);
sigprocmask(SIG_UNBLOCK, &s, 0);
}
static void
dmxSigioHook(void)
{
......
......@@ -36,8 +36,6 @@
#ifndef _DMXSIGIO_H_
#define _DMXSIGIO_H_
extern void dmxSigioBlock(void);
extern void dmxSigioUnblock(void);
extern void dmxSigioEnableInput(void);
extern void dmxSigioDisableInput(void);
extern void dmxSigioRegister(DMXInputInfo * dmxInput, int fd);
......
......@@ -772,26 +772,6 @@ ephyrUpdateModifierState(unsigned int state)
}
}
static void
ephyrBlockSigio(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_BLOCK, &set, 0);
}
static void
ephyrUnblockSigio(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_UNBLOCK, &set, 0);
}
static Bool
ephyrCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
{
......@@ -808,11 +788,11 @@ int ephyrCurScreen; /*current event screen */
static void
ephyrWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
ephyrBlockSigio();
OsBlockSIGIO();
ephyrCurScreen = pScreen->myNum;
miPointerWarpCursor(inputInfo.pointer, pScreen, x, y);
ephyrUnblockSigio();
OsReleaseSIGIO();
}
miPointerScreenFuncRec ephyrPointerScreenFuncs = {
......
......@@ -102,26 +102,6 @@ KdSigio(int sig)
(*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
}
static void
KdBlockSigio(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_BLOCK, &set, 0);
}
static void
KdUnblockSigio(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_UNBLOCK, &set, 0);
}
#ifdef DEBUG_SIGIO
void
......@@ -261,7 +241,7 @@ KdDisableInput(void)
KdPointerInfo *pi;
int found = 0, i = 0;
KdBlockSigio();
OsBlockSIGIO();
for (ki = kdKeyboards; ki; ki = ki->next) {
if (ki->driver && ki->driver->Disable)
......@@ -343,7 +323,7 @@ KdEnableInput(void)
NoticeEventTime(&ev, pi->dixdev);
NoticeEventTime(&ev, ki->dixdev);
KdUnblockSigio();
OsReleaseSIGIO();
}
static KdKeyboardDriver *
......@@ -1801,7 +1781,7 @@ KdReleaseAllKeys(void)
int key;
KdKeyboardInfo *ki;
KdBlockSigio();
OsBlockSIGIO();
for (ki = kdKeyboards; ki; ki = ki->next) {
for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) {
......@@ -1812,7 +1792,7 @@ KdReleaseAllKeys(void)
}
}
KdUnblockSigio();
OsReleaseSIGIO();
#endif
}
......@@ -2008,18 +1988,18 @@ KdWakeupHandler(ScreenPtr pScreen, unsigned long lresult, pointer readmask)
if (kdInputEnabled && result > 0) {
for (i = 0; i < kdNumInputFds; i++)
if (FD_ISSET(kdInputFds[i].fd, pReadmask)) {
KdBlockSigio();
OsBlockSIGIO();
(*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
KdUnblockSigio();
OsReleaseSIGIO();
}
}
for (pi = kdPointers; pi; pi = pi->next) {
if (pi->timeoutPending) {
if ((long) (GetTimeInMillis() - pi->emulationTimeout) >= 0) {
pi->timeoutPending = FALSE;
KdBlockSigio();
OsBlockSIGIO();
KdReceiveTimeout(pi);
KdUnblockSigio();
OsReleaseSIGIO();
}
}
}
......@@ -2116,10 +2096,10 @@ int KdCurScreen; /* current event screen */
static void
KdWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
KdBlockSigio();
OsBlockSIGIO();
KdCurScreen = pScreen->myNum;
miPointerWarpCursor(pDev, pScreen, x, y);
KdUnblockSigio();
OsReleaseSIGIO();
}
miPointerScreenFuncRec kdPointerScreenFuncs = {
......
......@@ -199,7 +199,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
ScrnInfoPtr pScr = xf86ScreenToScrn(pScreen);
ScreenPtr pCursorScreen;
Bool Switched;
int px, py, was_blocked;
int px, py;
DeviceIntPtr dev, it;
if (!pScr->vtSema || !mode || !pScr->SwitchMode)
......@@ -228,7 +228,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
if (pScreen == pCursorScreen)
miPointerGetPosition(dev, &px, &py);
was_blocked = xf86BlockSIGIO();
OsBlockSIGIO();
Switched = (*pScr->SwitchMode) (pScr, mode);
if (Switched) {
pScr->currentMode = mode;
......@@ -267,7 +267,7 @@ xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
pScr->frameY1 = pScr->virtualY - 1;
}
}
xf86UnblockSIGIO(was_blocked);
OsReleaseSIGIO();
if (pScr->AdjustFrame)
(*pScr->AdjustFrame) (pScr, pScr->frameX0, pScr->frameY0);
......@@ -469,13 +469,11 @@ xf86CrossScreen(ScreenPtr pScreen, Bool entering)
static void
xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
int sigstate;
sigstate = xf86BlockSIGIO();
OsBlockSIGIO();
miPointerWarpCursor(pDev, pScreen, x, y);
xf86Info.currentScreen = pScreen;
xf86UnblockSIGIO(sigstate);
OsReleaseSIGIO();
}
void *
......
......@@ -254,7 +254,7 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
while (pInfo) {
if (pInfo->read_input && pInfo->fd >= 0 &&
(FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
int sigstate = xf86BlockSIGIO();
OsBlockSIGIO();
/*
* Remove the descriptior from the set because more than one
......@@ -263,7 +263,7 @@ xf86Wakeup(pointer blockData, int err, pointer pReadmask)
FD_CLR(pInfo->fd, &devicesWithInput);
pInfo->read_input(pInfo);
xf86UnblockSIGIO(sigstate);
OsReleaseSIGIO();
}
pInfo = pInfo->next;
}
......@@ -397,9 +397,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)) {
sigstate = xf86BlockSIGIO();
OsBlockSIGIO();
QueueKeyboardEvents(pDev, KeyRelease, i, NULL);
xf86UnblockSIGIO(sigstate);
OsReleaseSIGIO();
}
}
}
......@@ -457,7 +457,7 @@ xf86VTSwitch(void)
}
}
prevSIGIO = xf86BlockSIGIO();
OsBlockSIGIO();
for (i = 0; i < xf86NumScreens; i++)
xf86Screens[i]->LeaveVT(xf86Screens[i]);
......@@ -492,7 +492,7 @@ xf86VTSwitch(void)
for (ih = InputHandlers; ih; ih = ih->next)
xf86EnableInputHandler(ih);
xf86UnblockSIGIO(prevSIGIO);
OsReleaseSIGIO();
}
else {
......@@ -549,7 +549,7 @@ xf86VTSwitch(void)
for (ih = InputHandlers; ih; ih = ih->next)
xf86EnableInputHandler(ih);
xf86UnblockSIGIO(prevSIGIO);
OsReleaseSIGIO();
}
}
......
......@@ -394,7 +394,7 @@ InstallSignalHandlers(void)
void
InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
{
int i, j, k, scr_index, was_blocked = 0;
int i, j, k, scr_index;
char **modulelist;
pointer *optionlist;
Pix24Flags screenpix24, pix24;
......@@ -806,7 +806,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
#endif
xf86AccessEnter();
was_blocked = xf86BlockSIGIO();
OsBlockSIGIO();
}
}
......@@ -879,7 +879,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
}
xf86VGAarbiterWrapFunctions();
xf86UnblockSIGIO(was_blocked);
OsReleaseSIGIO();
xf86InitOrigins();
......@@ -964,6 +964,7 @@ OsVendorInit(void)
}
#endif
#endif
OsReleaseSIGIO();
beenHere = TRUE;
}
......@@ -1022,7 +1023,7 @@ AbortDDX(enum ExitCode error)
{
int i;
xf86BlockSIGIO();
OsBlockSIGIO();
/*
* try to restore the original video state
......
......@@ -92,8 +92,6 @@ eventName(pmEvent event, const char **str)
}
}
static int sigio_blocked_for_suspend;
static void
suspend(pmEvent event, Bool undo)
{
......@@ -109,7 +107,7 @@ suspend(pmEvent event, Bool undo)
DisableDevice(pInfo->dev, TRUE);
pInfo = pInfo->next;
}
sigio_blocked_for_suspend = xf86BlockSIGIO();
OsBlockSIGIO();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->PMEvent)
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
......@@ -137,7 +135,7 @@ resume(pmEvent event, Bool undo)
xf86Screens[i]->EnterVT(xf86Screens[i]);
}
}
xf86UnblockSIGIO(sigio_blocked_for_suspend);
OsReleaseSIGIO();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->EnableDisableFBAccess)
(*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE);
......@@ -153,7 +151,7 @@ resume(pmEvent event, Bool undo)
static void
DoApmEvent(pmEvent event, Bool undo)
{
int i, was_blocked;
int i;
switch (event) {
#if 0
......@@ -184,13 +182,13 @@ DoApmEvent(pmEvent event, Bool undo)
}
break;
default:
was_blocked = xf86BlockSIGIO();
OsBlockSIGIO();
for (i = 0; i < xf86NumScreens; i++) {
if (xf86Screens[i]->PMEvent) {
xf86Screens[i]->PMEvent(xf86Screens[i], event, undo);
}
}
xf86UnblockSIGIO(was_blocked);
OsReleaseSIGIO();
break;
}
}
......
......@@ -136,7 +136,6 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
struct sigaction sa;
struct sigaction osa;
int i;
int blocked;
int installed = FALSE;
if (!xf86Info.useSIGIO)
......@@ -146,7 +145,7 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
if (!xf86SigIOFuncs[i].f) {
if (xf86IsPipe(fd))
return 0;
blocked = xf86BlockSIGIO();
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",
......@@ -174,7 +173,7 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
}
#endif
if (!installed) {
xf86UnblockSIGIO(blocked);
OsReleaseSIGIO();
return 0;
}
sigemptyset(&sa.sa_mask);
......@@ -190,7 +189,7 @@ xf86InstallSIGIOHandler(int fd, void (*f) (int, void *), void *closure)
if (fd >= xf86SigIOMaxFd)
xf86SigIOMaxFd = fd + 1;
FD_SET(fd, &xf86SigIOMask);
xf86UnblockSIGIO(blocked);
OsReleaseSIGIO();
return 1;
}
/* Allow overwriting of the closure and callback */
......@@ -263,26 +262,13 @@ xf86RemoveSIGIOHandler(int fd)
int
xf86BlockSIGIO(void)
{
sigset_t set, old;
int ret;
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_BLOCK, &set, &old);
ret = sigismember(&old, SIGIO);
return ret;
return OsBlockSIGIO();
}
void
xf86UnblockSIGIO(int wasset)
{
sigset_t set;
if (!wasset) {
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_UNBLOCK, &set, NULL);
}
OsReleaseSIGIO();
}
void
......
......@@ -334,6 +334,12 @@ OsBlockSignals(void);
extern _X_EXPORT void
OsReleaseSignals(void);
extern _X_EXPORT int
OsBlockSIGIO(void);
extern _X_EXPORT void
OsReleaseSIGIO(void);
extern _X_EXPORT void
OsAbort(void)
_X_NORETURN;
......
......@@ -1167,14 +1167,14 @@ OsBlockSignals(void)
if (BlockedSignalCount++ == 0) {
sigset_t set;
#ifdef SIGIO
OsBlockSIGIO();
#endif
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigaddset(&set, SIGVTALRM);
#ifdef SIGWINCH
sigaddset(&set, SIGWINCH);
#endif
#ifdef SIGIO
sigaddset(&set, SIGIO);
#endif
sigaddset(&set, SIGTSTP);
sigaddset(&set, SIGTTIN);
......@@ -1185,12 +1185,60 @@ OsBlockSignals(void)
#endif
}
#ifdef SIG_BLOCK
static sig_atomic_t sigio_blocked;
#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, old;
int ret;
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_BLOCK, &set, &old);
ret = sigismember(&old, SIGIO);
return ret;
} else
return 1;
#endif
#endif
}
void
OsReleaseSIGIO(void)
{
#ifdef SIGIO
#ifdef SIG_BLOCK
if (--sigio_blocked == 0) {
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGIO);
sigprocmask(SIG_UNBLOCK, &set, NULL);
} 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();
}
#endif
}
......
......@@ -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 += xi2
noinst_PROGRAMS += xkb input xtest misc fixes xfree86 hashtabletest signal-logging
noinst_PROGRAMS += xkb input xtest misc fixes xfree86 hashtabletest os signal-logging
endif
check_LTLIBRARIES = libxservertest.la
......@@ -38,6 +38,7 @@ xfree86_LDADD=$(TEST_LDADD)
touch_LDADD=$(TEST_LDADD)
signal_logging_LDADD=$(TEST_LDADD)
hashtabletest_LDADD=$(TEST_LDADD) $(top_srcdir)/Xext/hashtable.c
os_LDADD=$(TEST_LDADD)
libxservertest_la_LIBADD = $(XSERVER_LIBS)
if XORG
......
/**
* Copyright © 2012 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a