diff --git a/Xext/shm.c b/Xext/shm.c index 605178c20f..92d00bf289 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -160,7 +160,7 @@ static ShmFuncs fbFuncs = { fbShmCreatePixmap, NULL }; } \ } -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) static Bool badSysCall = FALSE; diff --git a/Xext/xf86bigfont.c b/Xext/xf86bigfont.c index 576d965b8e..0944e56ea3 100644 --- a/Xext/xf86bigfont.c +++ b/Xext/xf86bigfont.c @@ -43,6 +43,10 @@ #include #ifdef CONFIG_MITSHM +# if defined(__CYGWIN__) +# include +# include +# endif #include #include #include @@ -88,7 +92,7 @@ static unsigned int pagesize; static Bool badSysCall = FALSE; -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) static void SigSysHandler(int signo) @@ -639,7 +643,7 @@ XFree86BigfontExtensionInit(void) FontShmdescIndex = xfont2_allocate_font_private_index(); -#if !defined(CSRG_BASED) +#if !defined(CSRG_BASED) && !defined(__CYGWIN__) pagesize = SHMLBA; #else #ifdef _SC_PAGESIZE diff --git a/glx/indirect_reqsize.c b/glx/indirect_reqsize.c index 0e8e8baddc..422f64c2d0 100644 --- a/glx/indirect_reqsize.c +++ b/glx/indirect_reqsize.c @@ -33,9 +33,6 @@ #include "indirect_reqsize.h" #include "misc.h" -#if defined(__MINGW32__) -#undef HAVE_ALIAS -#endif #ifdef HAVE_ALIAS #define ALIAS2(from,to) \ GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap, int reqlen ) \ diff --git a/glx/indirect_size_get.c b/glx/indirect_size_get.c index 2498938844..739c033239 100644 --- a/glx/indirect_size_get.c +++ b/glx/indirect_size_get.c @@ -43,10 +43,6 @@ #define FASTCALL #endif - -#if defined(__MINGW32__) || defined(GLX_USE_APPLEGL) -#undef HAVE_ALIAS -#endif #ifdef HAVE_ALIAS #define ALIAS2(from,to) \ _X_INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \ diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 8260ab16ce..0a2e3a7454 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -122,6 +122,11 @@ static ModuleDefault ModuleDefaults[] = { #ifdef GLXEXT {.name = "glx",.toLoad = TRUE,.load_opt = NULL}, +#endif +#ifdef __CYGWIN__ + /* load DIX modules used by drivers first */ + {.name = "fb",.toLoad = TRUE,.load_opt = NULL}, + {.name = "shadow",.toLoad = TRUE,.load_opt = NULL}, #endif {.name = NULL,.toLoad = FALSE,.load_opt = NULL} }; diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index 22536305d0..db0a3da69f 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -279,9 +279,15 @@ static const char *stdSubdirs[] = { * to port this DDX to, say, Darwin, we'll need to fix this. */ static PatternRec stdPatterns[] = { +#ifdef __CYGWIN__ + {"^cyg(.*)\\.dll$",}, + {"(.*)_drv\\.dll$",}, + {"(.*)\\.dll$",}, +#else {"^lib(.*)\\.so$",}, {"(.*)_drv\\.so$",}, {"(.*)\\.so$",}, +#endif {NULL,} }; @@ -370,21 +376,33 @@ FindModuleInSubdir(const char *dirpath, const char *module) continue; } +#ifdef __CYGWIN__ + snprintf(tmpBuf, PATH_MAX, "cyg%s.dll", module); +#else snprintf(tmpBuf, PATH_MAX, "lib%s.so", module); +#endif if (strcmp(direntry->d_name, tmpBuf) == 0) { if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1) ret = NULL; break; } +#ifdef __CYGWIN__ + snprintf(tmpBuf, PATH_MAX, "%s_drv.dll", module); +#else snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module); +#endif if (strcmp(direntry->d_name, tmpBuf) == 0) { if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1) ret = NULL; break; } +#ifdef __CYGWIN__ + snprintf(tmpBuf, PATH_MAX, "%s.dll", module); +#else snprintf(tmpBuf, PATH_MAX, "%s.so", module); +#endif if (strcmp(direntry->d_name, tmpBuf) == 0) { if (asprintf(&ret, "%s%s", dirpath, tmpBuf) == -1) ret = NULL; diff --git a/hw/xfree86/meson.build b/hw/xfree86/meson.build index 6341418bf6..4bf1dddaf6 100644 --- a/hw/xfree86/meson.build +++ b/hw/xfree86/meson.build @@ -80,7 +80,7 @@ if build_dri2 xorg_link += xorg_dri2 endif -if host_machine.system() == 'windows' +if host_machine.system() == 'cygwin' or host_machine.system() == 'windows' linker_export_flags = '-Wl,--export-all-symbols' elif host_machine.system() == 'sunos' or host_machine.system() == 'darwin' linker_export_flags = [] diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h index 3d601b92c3..01b9eeb625 100644 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -106,7 +106,7 @@ /**************************************************************************/ /* Linux or Glibc-based system */ /**************************************************************************/ -#if defined(__linux__) || defined(__GLIBC__) +#if defined(__linux__) || defined(__GLIBC__) || defined(__CYGWIN__) #include #include #include diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c index ed1af62b29..c50464a60c 100644 --- a/hw/xwin/InitInput.c +++ b/hw/xwin/InitInput.c @@ -75,6 +75,18 @@ DDXRingBell(int volume, int pitch, int duration) return; } + +#ifdef HAS_DEVWINDOWS +static void +xwinDevWindowsHandlerNotify(int fd, int ready, void *data) +{ + /* This should process Windows messages, but instead all of that is delayed + * until the wakeup handler is called. + */ + ; +} +#endif + /* See Porting Layer Definition - p. 17 */ void InitInput(int argc, char *argv[]) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index b338c85bd2..27fe2e0e21 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -48,6 +48,9 @@ from The Open Group. #ifdef DPMSExtension #include "dpmsproc.h" #endif +#ifdef __CYGWIN__ +#include +#endif #ifdef RELOCATE_PROJECTROOT #pragma push_macro("Status") #undef Status @@ -207,6 +210,17 @@ ddxGiveUp(enum ExitCode error) /* Notify the worker threads we're exiting */ winDeinitMultiWindowWM(); +#ifdef HAS_DEVWINDOWS + /* Close our handle to our message queue */ + if (g_fdMessageQueue != WIN_FD_INVALID) { + /* Close /dev/windows */ + close(g_fdMessageQueue); + + /* Set the file handle to invalid */ + g_fdMessageQueue = WIN_FD_INVALID; + } +#endif + if (!g_fLogInited) { g_pszLogFile = LogInit(g_pszLogFile, ".old"); g_fLogInited = TRUE; @@ -243,6 +257,95 @@ ddxGiveUp(enum ExitCode error) winDebug("ddxGiveUp - End\n"); } +#ifdef __CYGWIN__ +/* hasmntopt is currently not implemented for cygwin */ +static const char * +winCheckMntOpt(const struct mntent *mnt, const char *opt) +{ + const char *s; + size_t len; + + if (mnt == NULL) + return NULL; + if (opt == NULL) + return NULL; + if (mnt->mnt_opts == NULL) + return NULL; + + len = strlen(opt); + s = strstr(mnt->mnt_opts, opt); + if (s == NULL) + return NULL; + if ((s == mnt->mnt_opts || *(s - 1) == ',') && + (s[len] == 0 || s[len] == ',')) + return (char *) opt; + return NULL; +} + +static void +winCheckMount(void) +{ + FILE *mnt; + struct mntent *ent; + + enum { none = 0, sys_root, user_root, sys_tmp, user_tmp } + level = none, curlevel; + BOOL binary = TRUE; + + mnt = setmntent("/etc/mtab", "r"); + if (mnt == NULL) { + ErrorF("setmntent failed"); + return; + } + + while ((ent = getmntent(mnt)) != NULL) { + BOOL sys = (winCheckMntOpt(ent, "user") != NULL); + BOOL root = (strcmp(ent->mnt_dir, "/") == 0); + BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0); + + if (sys) { + if (root) + curlevel = sys_root; + else if (tmp) + curlevel = sys_tmp; + else + continue; + } + else { + if (root) + curlevel = user_root; + else if (tmp) + curlevel = user_tmp; + else + continue; + } + + if (curlevel <= level) + continue; + level = curlevel; + + if ((winCheckMntOpt(ent, "binary") == NULL) && + (winCheckMntOpt(ent, "binmode") == NULL)) + binary = FALSE; + else + binary = TRUE; + } + + if (endmntent(mnt) != 1) { + ErrorF("endmntent failed"); + return; + } + + if (!binary) + winMsg(X_WARNING, "/tmp mounted in textmode\n"); +} +#else +static void +winCheckMount(void) +{ +} +#endif + #ifdef RELOCATE_PROJECTROOT const char * winGetBaseDir(void) @@ -539,6 +642,8 @@ OsVendorInit(void) if (serverGeneration == 1) winLogVersionInfo(); + winCheckMount(); + /* Add a default screen if no screens were specified */ if (g_iNumScreens == 0) { winDebug("OsVendorInit - Creating default screen 0\n"); diff --git a/hw/xwin/meson.build b/hw/xwin/meson.build index 7c2ec792e9..a3d2caaf4d 100644 --- a/hw/xwin/meson.build +++ b/hw/xwin/meson.build @@ -7,8 +7,12 @@ build_windowsdri = windowsdri_dep.found() xwin_sys_libs = [] xwin_sys_libs += '-ldxguid' -server_name = 'Xming' -xwin_sys_libs += ['-lpthread', '-lws2_32'] +if host_machine.system() == 'cygwin' + server_name = 'XWin' +else + server_name = 'Xming' + xwin_sys_libs += ['-lpthread', '-lws2_32'] +endif xwin_c_args = [] xwin_c_args += '-DHAVE_XWIN_CONFIG_H' diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 060206b0c9..c5fd8112a6 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -520,6 +520,9 @@ extern winScreenInfo *g_ScreenInfo; extern miPointerScreenFuncRec g_winPointerCursorFuncs; extern DWORD g_dwEvents; +#ifdef HAS_DEVWINDOWS +extern int g_fdMessageQueue; +#endif extern DevPrivateKeyRec g_iScreenPrivateKeyRec; #define g_iScreenPrivateKey (&g_iScreenPrivateKeyRec) diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c index ff6ff2c224..18d2392e4b 100644 --- a/hw/xwin/winblock.c +++ b/hw/xwin/winblock.c @@ -43,6 +43,7 @@ winBlockHandler(ScreenPtr pScreen, void *pTimeout) { winScreenPriv(pScreen); +#ifndef HAS_DEVWINDOWS struct timeval **tvp = pTimeout; if (*tvp != NULL) { @@ -62,6 +63,7 @@ winBlockHandler(ScreenPtr pScreen, void *pTimeout) (*tvp)->tv_usec = 100; } } +#endif /* Signal threaded modules to begin */ if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) { diff --git a/hw/xwin/winclipboard/thread.c b/hw/xwin/winclipboard/thread.c index c012db07c3..0e60c1b24a 100644 --- a/hw/xwin/winclipboard/thread.c +++ b/hw/xwin/winclipboard/thread.c @@ -61,6 +61,9 @@ #define WIN_CLIPBOARD_WINDOW_CLASS "xwinclip" #define WIN_CLIPBOARD_WINDOW_TITLE "xwinclip" +#ifdef HAS_DEVWINDOWS +#define WIN_MSG_QUEUE_FNAME "/dev/windows" +#endif /* * Global variables @@ -107,7 +110,11 @@ winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info) int iReturn; HWND hwnd = NULL; int iConnectionNumber = 0; +#ifdef HAS_DEVWINDOWS + int fdMessageQueue = 0; +#else struct timeval tvTimeout; +#endif fd_set fdsRead; int iMaxDescriptor; xcb_connection_t *conn; @@ -132,7 +139,19 @@ winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info) /* Get our connection number */ iConnectionNumber = xcb_get_file_descriptor(conn); +#ifdef HAS_DEVWINDOWS + /* Open a file descriptor for the windows message queue */ + fdMessageQueue = open(WIN_MSG_QUEUE_FNAME, O_RDONLY); + if (fdMessageQueue == -1) { + ErrorF("winClipboardProc - Failed opening %s\n", WIN_MSG_QUEUE_FNAME); + goto winClipboardProc_Done; + } + + /* Find max of our file descriptors */ + iMaxDescriptor = MAX(fdMessageQueue, iConnectionNumber) + 1; +#else iMaxDescriptor = iConnectionNumber + 1; +#endif const xcb_query_extension_reply_t *xfixes_query; xfixes_query = xcb_get_extension_data(conn, &xcb_xfixes_id); @@ -253,15 +272,23 @@ winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info) */ FD_ZERO(&fdsRead); FD_SET(iConnectionNumber, &fdsRead); +#ifdef HAS_DEVWINDOWS + FD_SET(fdMessageQueue, &fdsRead); +#else tvTimeout.tv_sec = 0; tvTimeout.tv_usec = 100; +#endif /* Wait for a Windows event or an X event */ iReturn = select(iMaxDescriptor, /* Highest fds number */ &fdsRead, /* Read mask */ NULL, /* No write mask */ NULL, /* No exception mask */ +#ifdef HAS_DEVWINDOWS + NULL /* No timeout */ +#else &tvTimeout /* Set timeout */ +#endif ); #ifndef HAS_WINSOCK @@ -287,6 +314,24 @@ winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info) winDebug ("winClipboardProc - X connection ready, pumping X event queue\n"); } + +#ifdef HAS_DEVWINDOWS + /* Check for Windows event ready */ + if (FD_ISSET(fdMessageQueue, &fdsRead)) +#else + if (1) +#endif + { + winDebug + ("winClipboardProc - /dev/windows ready, pumping Windows message queue\n"); + } + +#ifdef HAS_DEVWINDOWS + if (!(FD_ISSET(iConnectionNumber, &fdsRead)) && + !(FD_ISSET(fdMessageQueue, &fdsRead))) { + winDebug("winClipboardProc - Spurious wake, select() returned %d\n", iReturn); + } +#endif } /* broke out of while loop on a shutdown message */ @@ -308,6 +353,12 @@ winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info) free(error); } +#ifdef HAS_DEVWINDOWS + /* Close our Win32 message handle */ + if (fdMessageQueue) + close(fdMessageQueue); +#endif + /* * xcb_disconnect() does not sync, so is safe to call even when we are built * into the server. Unlike XCloseDisplay() there will be no deadlock if the diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index dacb3aa1d8..489fc03f6c 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -42,6 +42,9 @@ int g_iNumScreens = 0; winScreenInfo *g_ScreenInfo = 0; +#ifdef HAS_DEVWINDOWS +int g_fdMessageQueue = WIN_FD_INVALID; +#endif DevPrivateKeyRec g_iScreenPrivateKeyRec; DevPrivateKeyRec g_iCmapPrivateKeyRec; DevPrivateKeyRec g_iGCPrivateKeyRec; diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index 09ce4e225a..5b9dd33d1d 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -471,6 +471,12 @@ winKeybdReleaseKeys(void) { int i; +#ifdef HAS_DEVWINDOWS + /* Verify that the mi input system has been initialized */ + if (g_fdMessageQueue == WIN_FD_INVALID) + return; +#endif + /* Loop through all keys */ for (i = 0; i < NUM_KEYCODES; ++i) { /* Pop key if pressed */ diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index a6bb96d45d..99e9815adb 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -37,6 +37,9 @@ #include #include #include +#ifdef __CYGWIN__ +#include +#endif #include #include #define HANDLE void * @@ -84,6 +87,9 @@ extern void winUpdateRgnMultiWindow(WindowPtr pWin); #define WIN_CONNECT_RETRIES 5 #define WIN_CONNECT_DELAY 5 +#ifdef HAS_DEVWINDOWS +#define WIN_MSG_QUEUE_FNAME "/dev/windows" +#endif /* * Local structures diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index 4524739215..9730a78790 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -35,6 +35,10 @@ #endif #include #include +#ifdef __CYGWIN__ +#include +#include +#endif #include "win.h" #include @@ -309,6 +313,28 @@ HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv) if (command == m->menuItem[j].commandID) { /* Match! */ switch (m->menuItem[j].cmd) { +#ifdef __CYGWIN__ + case CMD_EXEC: + if (fork() == 0) { + struct rlimit rl; + int fd; + + /* Close any open descriptors except for STD* */ + getrlimit(RLIMIT_NOFILE, &rl); + for (fd = STDERR_FILENO + 1; fd < rl.rlim_cur; fd++) + close(fd); + + /* Disassociate any TTYs */ + setsid(); + + execl("/bin/sh", + "/bin/sh", "-c", m->menuItem[j].param, NULL); + exit(0); + } + else + return TRUE; + break; +#else case CMD_EXEC: { /* Start process without console window */ @@ -334,6 +360,7 @@ HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv) MB_OK | MB_ICONEXCLAMATION); } return TRUE; +#endif case CMD_ALWAYSONTOP: if (!hwnd) return FALSE; @@ -515,6 +542,9 @@ LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags) } else { char *file = calloc(1, PATH_MAX + NAME_MAX + 2); +#ifdef __CYGWIN__ + Bool convert = FALSE; +#endif if (!file) return NULL; @@ -523,6 +553,14 @@ LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags) /* If fname starts 'X:\', it's an absolute Windows path, do nothing */ if (!(fname[0] && fname[1] == ':' && fname[2] == '\\')) { +#ifdef __CYGWIN__ + /* If fname starts with '/', it's an absolute cygwin path, we'll + need to convert it */ + if (fname[0] == '/') { + convert = TRUE; + } + else +#endif if (iconDirectory) { /* Otherwise, prepend the default icon directory, which currently must be in absolute Windows path form */ @@ -543,6 +581,17 @@ LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags) i = -1; } +#ifdef __CYGWIN__ + /* Convert from Cygwin path to Windows path */ + if (convert) { + char *converted_file = cygwin_create_path(CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, file); + if (converted_file) { + free(file); + file = converted_file; + } + } +#endif + if (i >= 0) { /* Specified as , */ hicon = ExtractIcon(g_hInstance, file, i); @@ -616,7 +665,23 @@ winIconIsOverride(HICON hicon) static int winPrefsLoadPreferences(const char *path) { - FILE *prefFile = fopen(path, "r"); + FILE *prefFile = NULL; + + if (path) + prefFile = fopen(path, "r"); +#ifdef __CYGWIN__ + else { + char defaultPrefs[] = + "MENU rmenu {\n" + " \"How to customize this menu\" EXEC \"xterm +tb -e man XWinrc\"\n" + " \"Launch xterm\" EXEC xterm\n" + " \"Load .XWinrc\" RELOAD\n" + " SEPARATOR\n" "}\n" "\n" "ROOTMENU rmenu\n"; + + path = "built-in default"; + prefFile = fmemopen(defaultPrefs, strlen(defaultPrefs), "r"); + } +#endif if (!prefFile) { ErrorF("LoadPreferences: %s not found\n", path); diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h index 4732f7804b..2ad4b475e0 100644 --- a/hw/xwin/winwindow.h +++ b/hw/xwin/winwindow.h @@ -52,6 +52,9 @@ #define WINDOW_CLASS_X_MSG "cygwin/x X msg" #define WINDOW_TITLE_X PROJECT_NAME " X" #define WIN_WINDOW_PROP "cyg_window_prop_rl" +#ifdef HAS_DEVWINDOWS +#define WIN_MSG_QUEUE_FNAME "/dev/windows" +#endif #define WIN_WID_PROP "cyg_wid_prop_rl" #define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl" diff --git a/include/meson.build b/include/meson.build index 19a6441ed3..269265149b 100644 --- a/include/meson.build +++ b/include/meson.build @@ -395,6 +395,8 @@ xwin_data = configuration_data() xwin_data.set_quoted('DEFAULT_LOGDIR', log_dir) xwin_data.set('HAS_WINSOCK', host_machine.system() == 'windows' ? '1' : false, description: 'Use Windows sockets') +xwin_data.set('HAS_DEVWINDOWS', host_machine.system() == 'cygwin' ? '1' : false, + description: 'Has /dev/windows for signaling new win32 messages') xwin_data.set('RELOCATE_PROJECTROOT', host_machine.system() == 'windows' ? '1' : false, description: 'Make paths relative to the xserver installation location') xwin_data.set10('ENABLE_DEBUG', enable_debugging) diff --git a/include/xwin-config.h.meson.in b/include/xwin-config.h.meson.in index 1066fd5257..22b97fbefc 100644 --- a/include/xwin-config.h.meson.in +++ b/include/xwin-config.h.meson.in @@ -13,6 +13,9 @@ /* Winsock networking */ #mesondefine HAS_WINSOCK +/* Cygwin has /dev/windows for signaling new win32 messages */ +#mesondefine HAS_DEVWINDOWS + /* Switch on debug messages */ #mesondefine ENABLE_DEBUG diff --git a/meson.build b/meson.build index 3527729181..8fe02b7130 100644 --- a/meson.build +++ b/meson.build @@ -254,7 +254,8 @@ build_xnest = get_option('xnest') != 'false' build_xwin = false if get_option('xwin') == 'auto' - if host_machine.system() == 'windows' + if (host_machine.system() == 'cygwin' or + host_machine.system() == 'windows') build_xwin = true endif else @@ -536,7 +537,8 @@ build_modesetting = libdrm_dep.found() and dri2proto_dep.found() build_vgahw = false if get_option('vgahw') == 'auto' if (host_machine.system() != 'darwin' and - host_machine.system() != 'windows') + host_machine.system() != 'windows' and + host_machine.system() != 'cygwin') build_vgahw = true endif else @@ -878,7 +880,8 @@ if build_xorg # On Windows, modules built with the SDK will need to link with server and # module implibs to resolve symbols - if host_machine.system() == 'windows' + if (host_machine.system() == 'cygwin' or + host_machine.system() == 'windows') sdkconfig.set('XORG_DRIVER_LIBS', '-lXorg.exe -L\${moduledir} -lshadow -no-undefined') endif diff --git a/os/access.c b/os/access.c index db28c7c0a4..1f98b75148 100644 --- a/os/access.c +++ b/os/access.c @@ -166,7 +166,7 @@ SOFTWARE. #endif /* WIN32 */ -#if !defined(WIN32) +#if !defined(WIN32) || defined(__CYGWIN__) #include #endif @@ -1073,7 +1073,7 @@ ComputeLocalClient(ClientPtr client) */ char *tok = strtok(cmd, ":"); -#if !defined(WIN32) +#if !defined(WIN32) || defined(__CYGWIN__) ret = strcmp(basename(tok), "ssh") != 0; #else ret = strcmp(tok, "ssh") != 0; diff --git a/os/osdep.h b/os/osdep.h index 2117d81eb9..757f3484ec 100644 --- a/os/osdep.h +++ b/os/osdep.h @@ -103,9 +103,10 @@ _X_EXPORT Bool TimerForce(OsTimerPtr); #ifdef WIN32 #include -#include +#if ! defined(__CYGWIN__) typedef _sigset_t sigset_t; +#endif #undef CreateWindow diff --git a/os/osinit.c b/os/osinit.c index 21d594b969..d01d9d2f42 100644 --- a/os/osinit.c +++ b/os/osinit.c @@ -94,7 +94,7 @@ OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper) * OsSigHandler -- * Catch unexpected signals and exit or continue cleanly. */ -#if !defined(WIN32) +#if !defined(WIN32) || defined(__CYGWIN__) static void #ifdef SA_SIGINFO OsSigHandler(int signo, siginfo_t * sip, void *unused) @@ -144,7 +144,7 @@ OsSigHandler(int signo) FatalError("Caught signal %d (%s). Server aborting\n", signo, strsignal(signo)); } -#endif /* !WIN32 */ +#endif /* !WIN32 || __CYGWIN__ */ void OsInit(void) @@ -152,7 +152,7 @@ OsInit(void) static Bool been_here = FALSE; if (!been_here) { -#if !defined(WIN32) +#if !defined(WIN32) || defined(__CYGWIN__) struct sigaction act, oact; int i; @@ -180,7 +180,7 @@ OsInit(void) siglist[i], strerror(errno)); } } -#endif /* !WIN32 */ +#endif /* !WIN32 || __CYGWIN__ */ busfault_init(); server_poll = ospoll_create(); if (!server_poll) @@ -210,7 +210,7 @@ OsInit(void) } #endif -#if !defined(WIN32) +#if !defined(WIN32) || defined(__CYGWIN__) if (getpgrp() == 0) setpgid(0, 0); #endif diff --git a/os/utils.c b/os/utils.c index 465d30c911..709681fbb3 100644 --- a/os/utils.c +++ b/os/utils.c @@ -50,7 +50,17 @@ OR PERFORMANCE OF THIS SOFTWARE. #include -#if defined(WIN32) +#ifdef __CYGWIN__ +#include +#include +/* + Sigh... We really need a prototype for this to know it is stdcall, + but #include-ing here is not a good idea... +*/ +__stdcall unsigned long GetTickCount(void); +#endif + +#if defined(WIN32) && !defined(__CYGWIN__) #include #endif #include @@ -141,7 +151,7 @@ static clockid_t clockid; OsSigHandlerPtr OsSignal(int sig, OsSigHandlerPtr handler) { -#if defined(WIN32) +#if defined(WIN32) && !defined(__CYGWIN__) return signal(sig, handler); #else struct sigaction act, oact; @@ -187,7 +197,7 @@ ForceClockId(clockid_t forced_clockid) } #endif -#if (defined WIN32 && defined __MINGW32__) +#if (defined WIN32 && defined __MINGW32__) || defined(__CYGWIN__) CARD32 GetTimeInMillis(void) { @@ -555,7 +565,7 @@ ProcessCommandLine(int argc, char *argv[]) } #ifdef LOCK_SERVER else if (strcmp(argv[i], "-nolock") == 0) { -#if !defined(WIN32) +#if !defined(WIN32) && !defined(__CYGWIN__) if (getuid() != 0) ErrorF ("Warning: the -nolock option can only be used by root\n"); @@ -990,7 +1000,7 @@ OsAbort(void) #ifndef __APPLE__ OsBlockSignals(); #endif -#if !defined(WIN32) +#if !defined(WIN32) || defined(__CYGWIN__) /* abort() raises SIGABRT, so we have to stop handling that to prevent * recursion */ @@ -1430,7 +1440,7 @@ CheckUserAuthorization(void) #endif } -#if !defined(WIN32) +#if !defined(WIN32) || defined(__CYGWIN__) /* Move a file descriptor out of the way of our select mask; this * is useful for file descriptors which will never appear in the * select mask to avoid reducing the number of clients that can diff --git a/os/xserver_poll.c b/os/xserver_poll.c index c13fddd690..deb492d49e 100644 --- a/os/xserver_poll.c +++ b/os/xserver_poll.c @@ -81,7 +81,7 @@ #include /* assertion macros */ #include /* string functions */ -#if defined(WIN32) +#if defined(WIN32) && !defined(__CYGWIN__) #include #endif diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 458bae11ce..20f7046a4d 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -738,7 +738,7 @@ XkbProcessArguments(int argc, char *argv[], int i) { if (strncmp(argv[i], "-xkbdir", 7) == 0) { if (++i < argc) { -#if !defined(WIN32) +#if !defined(WIN32) && !defined(__CYGWIN__) if (getuid() != geteuid()) { LogMessage(X_WARNING, "-xkbdir is not available for setuid X servers\n");