summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-12-08 14:39:46 -0800
committerKeith Packard <keithp@keithp.com>2016-05-26 16:07:54 -0700
commit6a5a4e60373c1386b311b2a8bb666c32d68a9d99 (patch)
tree1643ea974c60cefb7dbd6d646e40d77263babaa3 /test
parent8cf832c288dec13cbf3c25478a8ccef52d61f3db (diff)
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>
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am2
-rw-r--r--test/os.c166
2 files changed, 1 insertions, 167 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 9f13e269d..f5e54680b 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 d85dcffbe..000000000
--- 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(&current);
- assert(sigprocmask(SIG_BLOCK, NULL, &current) == 0);
- return sigismember(&current, sig);
-}
-
-static void block_sigio_test(void)
-{
-#ifdef SIG_BLOCK
- sigset_t current;
-
- sigemptyset(&current);
- 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;
-}