diff options
Diffstat (limited to 'xorg-server/os')
-rw-r--r-- | xorg-server/os/WaitFor.c | 6 | ||||
-rw-r--r-- | xorg-server/os/connection.c | 4 | ||||
-rw-r--r-- | xorg-server/os/io.c | 1 | ||||
-rw-r--r-- | xorg-server/os/log.c | 6 | ||||
-rw-r--r-- | xorg-server/os/makefile | 4 | ||||
-rw-r--r-- | xorg-server/os/oscolor.c | 4 | ||||
-rw-r--r-- | xorg-server/os/osinit.c | 2 | ||||
-rw-r--r-- | xorg-server/os/utils.c | 48 | ||||
-rw-r--r-- | xorg-server/os/xprintf.c | 12 | ||||
-rw-r--r-- | xorg-server/os/xstrans.c | 2 |
10 files changed, 73 insertions, 16 deletions
diff --git a/xorg-server/os/WaitFor.c b/xorg-server/os/WaitFor.c index d6dd99553..7235708f7 100644 --- a/xorg-server/os/WaitFor.c +++ b/xorg-server/os/WaitFor.c @@ -208,6 +208,12 @@ WaitForSomething(int *pClientsReady) wt = &waittime; } } + if (!wt) + { + wt = &waittime; + waittime.tv_sec = 0; + waittime.tv_usec = 100; + } XFD_COPYSET(&AllSockets, &LastSelectMask); } SmartScheduleStopTimer (); diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c index 8f1f73e43..9148b4ea8 100644 --- a/xorg-server/os/connection.c +++ b/xorg-server/os/connection.c @@ -111,6 +111,10 @@ SOFTWARE. #include "dixstruct.h" #include "xace.h" +#ifdef _MSC_VER +typedef int pid_t; +#endif + #define Pid_t pid_t #ifdef DNETCONN diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c index f07993e5a..afe6d99d4 100644 --- a/xorg-server/os/io.c +++ b/xorg-server/os/io.c @@ -914,6 +914,7 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount) /* If we've arrived here, then the client is stuffed to the gills and not ready to accept more. Make a note of it and buffer the rest. */ + errno=0; FD_SET(connection, &ClientsWriteBlocked); AnyClientsWriteBlocked = TRUE; diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c index 692e78ad3..ef34b1afe 100644 --- a/xorg-server/os/log.c +++ b/xorg-server/os/log.c @@ -95,8 +95,14 @@ OR PERFORMANCE OF THIS SOFTWARE. #ifdef WIN32 #include <process.h> +#ifndef _MSC_VER #define getpid(x) _getpid(x) #endif +#endif + +#ifdef _MSC_VER +#define S_ISREG(m) (((m)&_S_IFMT) == _S_IFREG) +#endif #ifdef DDXOSVERRORF diff --git a/xorg-server/os/makefile b/xorg-server/os/makefile new file mode 100644 index 000000000..cf9eaf53f --- /dev/null +++ b/xorg-server/os/makefile @@ -0,0 +1,4 @@ +CSRCS=access.c auth.c backtrace.c connection.c io.c log.c mitauth.c os.c oscolor.c osinit.c rpcauth.c strlcat.c strlcpy.c utils.c WaitFor.c xdmauth.c xdmcp.c xprintf.c xstrans.c
+
+LIBRARY=libos
+
diff --git a/xorg-server/os/oscolor.c b/xorg-server/os/oscolor.c index 7f6b93880..4e1513f53 100644 --- a/xorg-server/os/oscolor.c +++ b/xorg-server/os/oscolor.c @@ -49,6 +49,10 @@ SOFTWARE. #include <dix-config.h> #endif +#ifdef _MSC_VER +#define strncasecmp _strnicmp +#endif + #include <X11/keysym.h> #include "os.h" diff --git a/xorg-server/os/osinit.c b/xorg-server/os/osinit.c index 74e2457f2..49dfe4999 100644 --- a/xorg-server/os/osinit.c +++ b/xorg-server/os/osinit.c @@ -139,8 +139,10 @@ OsInit(void) #endif } +#ifndef _MSC_VER if (getpgrp () == 0) setpgid (0, 0); +#endif #ifdef RLIMIT_DATA if (limitDataSpace >= 0) diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index b1009494b..2d73a0c2d 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -56,6 +56,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #ifdef __CYGWIN__ #include <stdlib.h> #include <signal.h> +__stdcall unsigned long GetTickCount(void); #endif #if defined(WIN32) && !defined(__CYGWIN__) @@ -217,6 +218,9 @@ OsSignal(sig, handler) int sig; OsSigHandlerPtr handler; { +#ifdef X_NOT_POSIX + return signal(sig, handler); +#else struct sigaction act, oact; sigemptyset(&act.sa_mask); @@ -227,6 +231,7 @@ OsSignal(sig, handler) if (sigaction(sig, &act, &oact)) perror("sigaction"); return oact.sa_handler; +#endif } /* @@ -252,7 +257,7 @@ OsSignal(sig, handler) #endif static Bool StillLocking = FALSE; -static char LockFile[PATH_MAX]; +static char szLockFile[PATH_MAX]; static Bool nolock = FALSE; /* @@ -264,26 +269,34 @@ static Bool nolock = FALSE; void LockServer(void) { +#if defined(WIN32) && !defined(__CYGWIN__) + char MutexName[100]; + sprintf(MutexName, "Global\\VcXsrv_Mutex_%d\n", getpid()); + if (!CreateMutex(NULL,TRUE,MutexName) || GetLastError()== ERROR_ALREADY_EXISTS) + { + FatalError("Server is already active for display %d\n", atoi(display)); + } +#else + char port[20]; char tmp[PATH_MAX], pid_str[12]; int lfd, i, haslock, l_pid, t; char *tmppath = NULL; int len; - char port[20]; if (nolock) return; /* * Path names */ tmppath = LOCK_DIR; - sprintf(port, "%d", atoi(display)); + len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) : strlen(LOCK_TMP_PREFIX); len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1; - if (len > sizeof(LockFile)) + if (len > sizeof(szLockFile)) FatalError("Display name `%s' is too long\n", port); (void)sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port); - (void)sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port); + (void)sprintf(szLockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port); /* * Create a temporary file containing our PID. Attempt three times @@ -325,7 +338,7 @@ LockServer(void) i = 0; haslock = 0; while ((!haslock) && (i++ < 3)) { - haslock = (link(tmp,LockFile) == 0); + haslock = (link(tmp,szLockFile) == 0); if (haslock) { /* * We're done. @@ -336,17 +349,17 @@ LockServer(void) /* * Read the pid from the existing file */ - lfd = open(LockFile, O_RDONLY); + lfd = open(szLockFile, O_RDONLY); if (lfd < 0) { unlink(tmp); - FatalError("Can't read lock file %s\n", LockFile); + FatalError("Can't read lock file %s\n", szLockFile); } pid_str[0] = '\0'; if (read(lfd, pid_str, 11) != 11) { /* * Bogus lock file. */ - unlink(LockFile); + unlink(szLockFile); close(lfd); continue; } @@ -363,7 +376,7 @@ LockServer(void) /* * Stale lock file. */ - unlink(LockFile); + unlink(szLockFile); continue; } else if (((t < 0) && (errno == EPERM)) || (t == 0)) { @@ -373,14 +386,15 @@ LockServer(void) unlink(tmp); FatalError("Server is already active for display %s\n%s %s\n%s\n", port, "\tIf this server is no longer running, remove", - LockFile, "\tand start again."); + szLockFile, "\tand start again."); } } } unlink(tmp); if (!haslock) - FatalError("Could not create server lock file: %s\n", LockFile); + FatalError("Could not create server lock file: %s\n", szLockFile); StillLocking = FALSE; +#endif } /* @@ -394,7 +408,7 @@ UnlockServer(void) if (!StillLocking){ - (void) unlink(LockFile); + (void) unlink(szLockFile); } } @@ -424,7 +438,7 @@ GiveUp(int sig) errno = olderrno; } -#if defined WIN32 && defined __MINGW32__ +#if (defined WIN32 && defined __MINGW32__) || defined(__CYGWIN__) _X_EXPORT CARD32 GetTimeInMillis (void) { @@ -1196,7 +1210,7 @@ XNFstrdup(const char *s) } -#ifdef SIGVTALRM +#if defined(SIGVTALRM) && !defined(__CYGWIN__) #define SMART_SCHEDULE_POSSIBLE #endif @@ -1634,6 +1648,7 @@ Fclose(pointer iop) */ /* Consider LD* variables insecure? */ +#ifndef _MSC_VER #ifndef REMOVE_ENV_LD #define REMOVE_ENV_LD 1 #endif @@ -1642,6 +1657,7 @@ Fclose(pointer iop) #ifndef REMOVE_LONG_ENV #define REMOVE_LONG_ENV 1 #endif +#endif /* * Disallow stdout or stderr as pipes? It's possible to block the X server @@ -1672,7 +1688,7 @@ Fclose(pointer iop) #endif #define MAX_ARG_LENGTH 128 -#define MAX_ENV_LENGTH 256 +#define MAX_ENV_LENGTH 2048 #define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */ #if USE_ISPRINT diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c index 07eaa1f58..bf70661ac 100644 --- a/xorg-server/os/xprintf.c +++ b/xorg-server/os/xprintf.c @@ -39,7 +39,9 @@ # ifdef __va_copy # define va_copy __va_copy # else +# ifndef _MSC_VER # error "no working va_copy was found" +# endif # endif #endif @@ -48,11 +50,16 @@ Xvprintf(const char *format, va_list va) { char *ret; int size; + +#ifdef _MSC_VER + size = vsnprintf(NULL, 0, format, va); +#else va_list va2; va_copy(va2, va); size = vsnprintf(NULL, 0, format, va2); va_end(va2); +#endif ret = (char *)Xalloc(size + 1); if (ret == NULL) @@ -78,11 +85,16 @@ XNFvprintf(const char *format, va_list va) { char *ret; int size; + +#ifdef _MSC_VER + size = vsnprintf(NULL, 0, format, va); +#else va_list va2; va_copy(va2, va); size = vsnprintf(NULL, 0, format, va2); va_end(va2); +#endif ret = (char *)XNFalloc(size + 1); if (ret == NULL) diff --git a/xorg-server/os/xstrans.c b/xorg-server/os/xstrans.c index c086e225b..86c8688da 100644 --- a/xorg-server/os/xstrans.c +++ b/xorg-server/os/xstrans.c @@ -5,4 +5,6 @@ #define TRANS_REOPEN #define TRANS_SERVER #define XSERV_t +#define TCPCONN + #include <X11/Xtrans/transport.c> |