From 8e2bac0a69173b51e17a39d70e1d154b47fd0139 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Fri, 20 Apr 2012 13:46:21 +0100 Subject: [PATCH 1/6] os/osinit.c, os/utils.c: Exclude sigaction code when building for MinGW MinGW doesn't have sigaction, so this patch is needed for building. No attempt is made to actually install the fatal error signal handler, as MinGW will simply terminate the process rather than deliver a fatal signal. Also avoid using strsignal Signed-off-by: Ryan Pavlik Reviewed-by: Jon TURNEY Tested-by: Yaakov Selkowitz Reviewed-by: Keith Packard --- os/osinit.c | 5 +++++ os/utils.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/os/osinit.c b/os/osinit.c index 45ab5271b..2a946a456 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -102,6 +102,7 @@ OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper) * OsSigHandler -- * Catch unexpected signals and exit or continue cleanly. */ +#if !defined(WIN32) || defined(__CYGWIN__) static void #ifdef SA_SIGINFO OsSigHandler(int signo, siginfo_t * sip, void *unused) @@ -146,6 +147,7 @@ OsSigHandler(int signo) FatalError("Caught signal %d (%s). Server aborting\n", signo, strsignal(signo)); } +#endif /* !WIN32 || __CYGWIN__ */ void OsInit(void) @@ -155,6 +157,7 @@ OsInit(void) char fname[PATH_MAX]; if (!been_here) { +#if !defined(WIN32) || defined(__CYGWIN__) struct sigaction act, oact; int i; @@ -181,6 +184,8 @@ OsInit(void) siglist[i], strerror(errno)); } } +#endif /* !WIN32 || __CYGWIN__ */ + #ifdef HAVE_BACKTRACE /* * initialize the backtracer, since the ctor calls dlopen(), which diff --git a/os/utils.c b/os/utils.c index 3c520add5..58df70902 100644 --- a/os/utils.c +++ b/os/utils.c @@ -212,6 +212,9 @@ sig_atomic_t inSignalContext = FALSE; OsSigHandlerPtr OsSignal(int sig, OsSigHandlerPtr handler) { +#if defined(WIN32) && !defined(__CYGWIN__) + return signal(sig, handler); +#else struct sigaction act, oact; sigemptyset(&act.sa_mask); @@ -222,6 +225,7 @@ OsSignal(int sig, OsSigHandlerPtr handler) if (sigaction(sig, &act, &oact)) perror("sigaction"); return oact.sa_handler; +#endif } /* From 98d5acc1213b2ec71c2a7bd3a3b77a1b5536e963 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Fri, 17 Aug 2012 13:43:29 +0100 Subject: [PATCH 2/6] os/utils.c: Fix compilation of OsBlockSIGIO when SIGIO isn't defined Fix compilation of OsBlockSIGIO with -Werror=return-type when SIGIO isn't defined. /jhbuild/checkout/xorg/xserver/os/utils.c: In function 'OsBlockSIGIO': /jhbuild/checkout/xorg/xserver/os/utils.c:1248:1: error: control reaches end of non-void function [-Wreturn-type] v2: Shuffle around to avoid writing unreachable code Signed-off-by: Jon TURNEY Tested-by: Yaakov Selkowitz Reviewed-by: Keith Packard --- os/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/utils.c b/os/utils.c index 58df70902..411daa047 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1231,10 +1231,10 @@ OsBlockSIGIO(void) sigprocmask(SIG_BLOCK, &set, &PreviousSigIOMask); ret = sigismember(&PreviousSigIOMask, SIGIO); return ret; - } else - return 1; + } #endif #endif + return 1; } void From 2c712d094a49de0b96e2e9f5bcc1043b54ad0f61 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Sun, 14 Oct 2012 23:05:30 -0500 Subject: [PATCH 3/6] hw/xwin: use raise() instead of kill() MinGW doesn't have kill(), so use raise() instead Signed-off-by: Yaakov Selkowitz Reviewed-by: Jon TURNEY Reviewed-by: Keith Packard --- hw/xwin/winclipboardthread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 891278279..c8508a9b8 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -36,6 +36,7 @@ #define HAS_WINSOCK 1 #endif #include +#include #include "winclipboard.h" #ifdef __CYGWIN__ #include @@ -431,7 +432,7 @@ winClipboardProc(void *pvNotUsed) else { ErrorF("winClipboardProc - Clipboard disabled - Exit from server \n"); /* clipboard thread has exited, stop server as well */ - kill(getpid(), SIGTERM); + raise(SIGTERM); } return NULL; From b20d2998cd9a1320ef0e45ab6b741c7e25f646e0 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Thu, 3 Nov 2011 19:25:57 -0500 Subject: [PATCH 4/6] os/osinit.c: no getpgrp() and setpgrp() on WIN32 Signed-off-by: Ryan Pavlik Reviewed-by: Jon TURNEY Tested-by: Yaakov Selkowitz Reviewed-by: Keith Packard --- os/osinit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/os/osinit.c b/os/osinit.c index 2a946a456..6c66f9c12 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -246,8 +246,10 @@ OsInit(void) #endif } +#if !defined(WIN32) || defined(__CYGWIN__) if (getpgrp() == 0) setpgid(0, 0); +#endif #ifdef RLIMIT_DATA if (limitDataSpace >= 0) { From fb170498abc746a850864b59db2ddcba7ee29215 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Tue, 13 Nov 2012 13:22:44 +0000 Subject: [PATCH 5/6] dix/dispatch.c, os/utils.c: Disable smart scheduler on WIN32 setitimer() and SIGALRM aren't available on WIN32, so smart scheduler code cannot be built. Provide only stubs for smart scheduler timer code, and disable smart scheduler by default. Signed-off-by: Ryan Pavlik Reviewed-by: Jon TURNEY Tested-by: Yaakov Selkowitz Reviewed-by: Keith Packard --- dix/dispatch.c | 4 ++++ os/utils.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/dix/dispatch.c b/dix/dispatch.c index 2df1a6ea5..99ba277fb 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -223,7 +223,11 @@ UpdateCurrentTimeIf(void) #define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */ #define SMART_SCHEDULE_MAX_SLICE 200 /* ms */ +#if defined(WIN32) && !defined(__CYGWIN__) +Bool SmartScheduleDisable = TRUE; +#else Bool SmartScheduleDisable = FALSE; +#endif long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; diff --git a/os/utils.c b/os/utils.c index 411daa047..6f75c1704 100644 --- a/os/utils.c +++ b/os/utils.c @@ -71,6 +71,7 @@ __stdcall unsigned long GetTickCount(void); #if !defined(WIN32) || !defined(__MINGW32__) #include #include +# define SMART_SCHEDULE_POSSIBLE #endif #include "misc.h" #include @@ -898,6 +899,7 @@ ProcessCommandLine(int argc, char *argv[]) i = skip - 1; } #endif +#ifdef SMART_SCHEDULE_POSSIBLE else if (strcmp(argv[i], "-dumbSched") == 0) { SmartScheduleDisable = TRUE; } @@ -916,6 +918,7 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } +#endif else if (strcmp(argv[i], "-render") == 0) { if (++i < argc) { int policy = PictureParseCmapPolicy(argv[i]); @@ -1127,6 +1130,7 @@ XNFstrdup(const char *s) void SmartScheduleStopTimer(void) { +#ifdef SMART_SCHEDULE_POSSIBLE struct itimerval timer; if (SmartScheduleDisable) @@ -1136,11 +1140,13 @@ SmartScheduleStopTimer(void) timer.it_value.tv_sec = 0; timer.it_value.tv_usec = 0; (void) setitimer(ITIMER_REAL, &timer, 0); +#endif } void SmartScheduleStartTimer(void) { +#ifdef SMART_SCHEDULE_POSSIBLE struct itimerval timer; if (SmartScheduleDisable) @@ -1150,6 +1156,7 @@ SmartScheduleStartTimer(void) timer.it_value.tv_sec = 0; timer.it_value.tv_usec = SmartScheduleInterval * 1000; setitimer(ITIMER_REAL, &timer, 0); +#endif } static void @@ -1161,6 +1168,7 @@ SmartScheduleTimer(int sig) void SmartScheduleInit(void) { +#ifdef SMART_SCHEDULE_POSSIBLE struct sigaction act; if (SmartScheduleDisable) @@ -1176,6 +1184,7 @@ SmartScheduleInit(void) perror("sigaction for smart scheduler"); SmartScheduleDisable = TRUE; } +#endif } #ifdef SIG_BLOCK From 338bec30054bb5d41cb6fdb5d37439f3c8124cad Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Fri, 9 Nov 2012 12:19:31 -0600 Subject: [PATCH 6/6] hw/xwin: Fix for MinGW-w64 DirectDraw headers mingw-w64 headers handle NONAMELESSUNION earlier than mingw.org's, so it must be defined before including any headers. It also provides a ddraw.h, so use it. Signed-off-by: Yaakov Selkowitz Reviewed-by: Jon TURNEY Reviewed-by: Keith Packard --- hw/xwin/ddraw.h | 4 ++++ hw/xwin/win.h | 2 ++ hw/xwin/winms.h | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/xwin/ddraw.h b/hw/xwin/ddraw.h index 9463049c8..1871d9551 100644 --- a/hw/xwin/ddraw.h +++ b/hw/xwin/ddraw.h @@ -1,3 +1,7 @@ +#ifdef __MINGW64_VERSION_MAJOR +#include_next +#define __XWIN_DDRAW_H +#endif #ifndef __XWIN_DDRAW_H #define __XWIN_DDRAW_H diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 7b34e84d9..6c524f909 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -133,6 +133,8 @@ #define WIN_MAX_KEYS_PER_KEY 4 +#define NONAMELESSUNION + #include #include #include diff --git a/hw/xwin/winms.h b/hw/xwin/winms.h index 5282fc982..32923e503 100644 --- a/hw/xwin/winms.h +++ b/hw/xwin/winms.h @@ -30,7 +30,6 @@ * Authors: Harold L Hunt II */ -#define NONAMELESSUNION #define DIRECTDRAW_VERSION 0x0300 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN