diff options
author | marha <marha@users.sourceforge.net> | 2009-07-25 20:12:58 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-07-25 20:12:58 +0000 |
commit | 2553bdd7c359cd87525d367761c86932cec5adff (patch) | |
tree | ae71245933c98474a699d3e392de5820879b2018 /xorg-server/os/utils.c | |
parent | e2c51f2ee7b0a3ea1a052fc49324057b4a4bbc78 (diff) | |
parent | 4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05 (diff) | |
download | vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.tar.gz vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.tar.bz2 vcxsrv-2553bdd7c359cd87525d367761c86932cec5adff.zip |
svn merge file:///D:/svnrepos/vcxsrv/branches/released .
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r-- | xorg-server/os/utils.c | 390 |
1 files changed, 39 insertions, 351 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index f2b54d8dc..a02b73a2b 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -84,7 +84,7 @@ __stdcall unsigned long GetTickCount(void); #include <signal.h> #undef _POSIX_C_SOURCE #else -#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +#if defined(_POSIX_SOURCE) #include <signal.h> #else #define _POSIX_SOURCE @@ -95,18 +95,13 @@ __stdcall unsigned long GetTickCount(void); #ifndef WIN32 #include <sys/wait.h> #endif -#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4) +#if !defined(SYSV) && !defined(WIN32) #include <sys/resource.h> #endif #include <sys/stat.h> #include <ctype.h> /* for isspace */ #include <stdarg.h> -#if defined(DGUX) -#include <sys/resource.h> -#include <netdb.h> -#endif - #include <stdlib.h> /* for malloc() */ #if defined(TCPCONN) || defined(STREAMSCONN) @@ -117,9 +112,7 @@ __stdcall unsigned long GetTickCount(void); #include "opaque.h" -#ifdef SMART_SCHEDULE #include "dixstruct.h" -#endif #ifdef XKB #include <xkbsrv.h> @@ -129,14 +122,7 @@ __stdcall unsigned long GetTickCount(void); #include "picture.h" #endif -#ifdef XPRINT -#include "DiPrint.h" -#endif - _X_EXPORT Bool noTestExtensions; -#ifdef BIGREQS -_X_EXPORT Bool noBigReqExtension = FALSE; -#endif #ifdef COMPOSITE _X_EXPORT Bool noCompositeExtension = FALSE; #endif @@ -150,12 +136,6 @@ _X_EXPORT Bool noDbeExtension = FALSE; #ifdef DPMSExtension _X_EXPORT Bool noDPMSExtension = FALSE; #endif -#ifdef EVI -_X_EXPORT Bool noEVIExtension = FALSE; -#endif -#ifdef FONTCACHE -_X_EXPORT Bool noFontCacheExtension = FALSE; -#endif #ifdef GLXEXT _X_EXPORT Bool noGlxExtension = FALSE; _X_EXPORT Bool noGlxVisualInit = FALSE; @@ -166,9 +146,6 @@ _X_EXPORT Bool noScreenSaverExtension = FALSE; #ifdef MITSHM _X_EXPORT Bool noMITShmExtension = FALSE; #endif -#ifdef MITMISC -_X_EXPORT Bool noMITMiscExtension = FALSE; -#endif #ifdef MULTIBUFFER _X_EXPORT Bool noMultibufferExtension = FALSE; #endif @@ -178,32 +155,12 @@ _X_EXPORT Bool noRRExtension = FALSE; #ifdef RENDER _X_EXPORT Bool noRenderExtension = FALSE; #endif -#ifdef SHAPE -_X_EXPORT Bool noShapeExtension = FALSE; -#endif #ifdef XCSECURITY _X_EXPORT Bool noSecurityExtension = FALSE; #endif -#ifdef XSYNC -_X_EXPORT Bool noSyncExtension = FALSE; -#endif -#ifdef TOGCUP -_X_EXPORT Bool noXcupExtension = FALSE; -#endif #ifdef RES _X_EXPORT Bool noResExtension = FALSE; #endif -#ifdef XAPPGROUP -_X_EXPORT Bool noXagExtension = FALSE; -#endif -#ifdef XCMISC -_X_EXPORT Bool noXCMiscExtension = FALSE; -#endif -#ifdef XEVIE -/* Xevie is disabled by default for now until the - * interface is stable */ -_X_EXPORT Bool noXevieExtension = TRUE; -#endif #ifdef XF86BIGFONT _X_EXPORT Bool noXFree86BigfontExtension = FALSE; #endif @@ -213,9 +170,6 @@ _X_EXPORT Bool noXFree86DGAExtension = FALSE; #ifdef XF86DRI _X_EXPORT Bool noXFree86DRIExtension = FALSE; #endif -#ifdef XF86MISC -_X_EXPORT Bool noXFree86MiscExtension = FALSE; -#endif #ifdef XF86VIDMODE _X_EXPORT Bool noXFree86VidModeExtension = FALSE; #endif @@ -227,14 +181,8 @@ _X_EXPORT Bool noXFixesExtension = FALSE; /* Xinerama is disabled by default unless enabled via +xinerama */ _X_EXPORT Bool noPanoramiXExtension = TRUE; #endif -#ifdef XINPUT -_X_EXPORT Bool noXInputExtension = FALSE; -#endif -#ifdef XIDLE -_X_EXPORT Bool noXIdleExtension = FALSE; -#endif #ifdef XSELINUX -_X_EXPORT Bool noSELinuxExtension = TRUE; +_X_EXPORT Bool noSELinuxExtension = FALSE; _X_EXPORT int selinuxEnforcingState = SELINUX_MODE_DEFAULT; #endif #ifdef XV @@ -244,6 +192,8 @@ _X_EXPORT Bool noXvExtension = FALSE; _X_EXPORT Bool noDRI2Extension = FALSE; #endif +_X_EXPORT Bool noGEExtension = FALSE; + #define X_INCLUDE_NETDB_H #include <X11/Xos_r.h> @@ -257,23 +207,10 @@ Bool PanoramiXExtensionDisabledHack = FALSE; int auditTrailLevel = 1; -_X_EXPORT Bool Must_have_memory = FALSE; - -#ifdef AIXV3 -int SyncOn = 0; -extern int SelectWaitTime; -#endif - #if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) #define HAS_SAVED_IDS_AND_SETEUID #endif -#ifdef MEMBUG -#define MEM_FAIL_SCALE 100000 -long Memory_fail = 0; -#include <stdlib.h> /* for random() */ -#endif - static char *dev_tty_from_init = NULL; /* since we need to parse it anyway */ OsSigHandlerPtr @@ -281,9 +218,6 @@ OsSignal(sig, handler) int sig; OsSigHandlerPtr handler; { -#ifdef X_NOT_POSIX - return signal(sig, handler); -#else struct sigaction act, oact; sigemptyset(&act.sa_mask); @@ -294,10 +228,8 @@ OsSignal(sig, handler) if (sigaction(sig, &act, &oact)) perror("sigaction"); return oact.sa_handler; -#endif } - -#ifdef SERVER_LOCK + /* * Explicit support for a server lock file like the ones used for UUCP. * For architectures with virtual terminals that can run more than one @@ -309,17 +241,8 @@ OsSignal(sig, handler) #define LOCK_PREFIX "/.X" #define LOCK_SUFFIX "-lock" -#if defined(DGUX) -#include <limits.h> -#include <sys/param.h> -#endif - #ifndef PATH_MAX -#ifndef Lynx #include <sys/param.h> -#else -#include <param.h> -#endif #ifndef PATH_MAX #ifdef MAXPATHLEN #define PATH_MAX MAXPATHLEN @@ -393,11 +316,7 @@ LockServer(void) FatalError("Could not create lock file in %s\n", tmp); (void) sprintf(pid_str, "%10ld\n", (long)getpid()); (void) write(lfd, pid_str, 11); -#ifndef USE_CHMOD - (void) fchmod(lfd, 0444); -#else (void) chmod(tmp, 0444); -#endif (void) close(lfd); /* @@ -479,7 +398,6 @@ UnlockServer(void) (void) unlink(LockFile); } } -#endif /* SERVER_LOCK */ /* Force connections to close on SIGHUP from init */ @@ -491,13 +409,6 @@ AutoResetServer (int sig) dispatchException |= DE_RESET; isItTimeToYield = TRUE; -#ifdef GPROF - chdir ("/tmp"); - exit (0); -#endif -#if defined(SYSV) && defined(X_NOT_POSIX) - OsSignal (SIGHUP, AutoResetServer); -#endif errno = olderrno; } @@ -511,10 +422,6 @@ GiveUp(int sig) dispatchException |= DE_TERMINATE; isItTimeToYield = TRUE; -#if defined(SYSV) && defined(X_NOT_POSIX) - if (sig) - OsSignal(sig, SIG_IGN); -#endif errno = olderrno; } @@ -567,13 +474,9 @@ AdjustWaitForDelay (pointer waitTime, unsigned long newdelay) void UseMsg(void) { -#if !defined(AIXrt) && !defined(AIX386) ErrorF("use: X [:<display>] [option]\n"); ErrorF("-a # mouse acceleration (pixels)\n"); ErrorF("-ac disable access control restrictions\n"); -#ifdef MEMBUG - ErrorF("-alloc int chance alloc should fail\n"); -#endif ErrorF("-audit int set audit trail level\n"); ErrorF("-auth file select authorization file\n"); ErrorF("-br create root window with black background\n"); @@ -582,9 +485,6 @@ void UseMsg(void) ErrorF("-c turns off key-click\n"); ErrorF("c # key-click volume (0-100)\n"); ErrorF("-cc int default color visual class\n"); -#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS - ErrorF("-config file read options from file\n"); -#endif ErrorF("-core generate core dump on fatal error\n"); ErrorF("-dpi int screen resolution in dots per inch\n"); #ifdef DPMSExtension @@ -625,11 +525,8 @@ void UseMsg(void) #ifdef RENDER ErrorF("-render [default|mono|gray|color] set render color alloc policy\n"); #endif + ErrorF("-retro start with classic stipple and cursor\n"); ErrorF("-s # screen-saver timeout (minutes)\n"); -#ifdef XPRINT - PrinterUseMsg(); -#endif - ErrorF("-su disable any save under support\n"); ErrorF("-t # mouse threshold (pixels)\n"); ErrorF("-terminate terminate at server reset\n"); ErrorF("-to # connection time out\n"); @@ -645,16 +542,13 @@ void UseMsg(void) ErrorF("+xinerama Enable XINERAMA extension\n"); ErrorF("-xinerama Disable XINERAMA extension\n"); #endif -#ifdef SMART_SCHEDULE ErrorF("-dumbSched Disable smart scheduling, enable old behavior\n"); ErrorF("-schedInterval int Set scheduler interval in msec\n"); -#endif ErrorF("+extension name Enable extension\n"); ErrorF("-extension name Disable extension\n"); #ifdef XDMCP XdmcpUseMsg(); #endif -#endif /* !AIXrt && ! AIX386 */ #ifdef XKB XkbUseMsg(); #endif @@ -680,17 +574,6 @@ VerifyDisplayName(const char *d) } /* - * This function is responsible for doing initalisation of any global - * variables at an very early point of server startup (even before - * |ProcessCommandLine()|. - */ -void InitGlobals(void) -{ - ddxInitGlobals(); -} - - -/* * This function parses the command line. Handles device-independent fields * and allows ddx to handle additional fields. It is not allowed to modify * argc or any of the strings pointed to by argv. @@ -737,15 +620,6 @@ ProcessCommandLine(int argc, char *argv[]) { defeatAccessControl = TRUE; } -#ifdef MEMBUG - else if ( strcmp( argv[i], "-alloc") == 0) - { - if(++i < argc) - Memory_fail = atoi(argv[i]); - else - UseMsg(); - } -#endif else if ( strcmp( argv[i], "-audit") == 0) { if(++i < argc) @@ -760,8 +634,7 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } - else if ( strcmp( argv[i], "-br") == 0) - blackRoot = TRUE; + else if ( strcmp( argv[i], "-br") == 0) ; /* default */ else if ( strcmp( argv[i], "+bs") == 0) enableBackingStore = TRUE; else if ( strcmp( argv[i], "-bs") == 0) @@ -947,6 +820,8 @@ ProcessCommandLine(int argc, char *argv[]) defaultKeyboardControl.autoRepeat = TRUE; else if ( strcmp( argv[i], "-r") == 0) defaultKeyboardControl.autoRepeat = FALSE; + else if ( strcmp( argv[i], "-retro") == 0) + party_like_its_1989 = TRUE; else if ( strcmp( argv[i], "-s") == 0) { if(++i < argc) @@ -955,8 +830,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } - else if ( strcmp( argv[i], "-su") == 0) - disableSaveUnders = TRUE; else if ( strcmp( argv[i], "-t") == 0) { if(++i < argc) @@ -1040,26 +913,6 @@ ProcessCommandLine(int argc, char *argv[]) i = skip - 1; } #endif -#ifdef XPRINT - else if ((skip = PrinterOptions(argc, argv, i)) != i) - { - i = skip - 1; - } -#endif -#ifdef AIXV3 - else if ( strcmp( argv[i], "-timeout") == 0) - { - if(++i < argc) - SelectWaitTime = atoi(argv[i]); - else - UseMsg(); - } - else if ( strcmp( argv[i], "-sync") == 0) - { - SyncOn++; - } -#endif -#ifdef SMART_SCHEDULE else if ( strcmp( argv[i], "-dumbSched") == 0) { SmartScheduleDisable = TRUE; @@ -1083,7 +936,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } -#endif #ifdef RENDER else if ( strcmp( argv[i], "-render" ) == 0) { @@ -1129,118 +981,6 @@ ProcessCommandLine(int argc, char *argv[]) } } -#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS -static void -InsertFileIntoCommandLine( - int *resargc, char ***resargv, - int prefix_argc, char **prefix_argv, - char *filename, - int suffix_argc, char **suffix_argv) -{ - struct stat st; - FILE *f; - char *p; - char *q; - int insert_argc; - char *buf; - int len; - int i; - - f = fopen(filename, "r"); - if (!f) - FatalError("Can't open option file %s\n", filename); - - fstat(fileno(f), &st); - - buf = (char *) xalloc((unsigned) st.st_size + 1); - if (!buf) - FatalError("Out of Memory\n"); - - len = fread(buf, 1, (unsigned) st.st_size, f); - - fclose(f); - - if (len < 0) - FatalError("Error reading option file %s\n", filename); - - buf[len] = '\0'; - - p = buf; - q = buf; - insert_argc = 0; - - while (*p) - { - while (isspace(*p)) - p++; - if (!*p) - break; - if (*p == '#') - { - while (*p && *p != '\n') - p++; - } else - { - while (*p && !isspace(*p)) - *q++ = *p++; - /* Since p and q might still be pointing at the same place, we */ - /* need to step p over the whitespace now before we add the null. */ - if (*p) - p++; - *q++ = '\0'; - insert_argc++; - } - } - - buf = (char *) xrealloc(buf, q - buf); - if (!buf) - FatalError("Out of memory reallocing option buf\n"); - - *resargc = prefix_argc + insert_argc + suffix_argc; - *resargv = (char **) xalloc((*resargc + 1) * sizeof(char *)); - if (!*resargv) - FatalError("Out of Memory\n"); - - memcpy(*resargv, prefix_argv, prefix_argc * sizeof(char *)); - - p = buf; - for (i = 0; i < insert_argc; i++) - { - (*resargv)[prefix_argc + i] = p; - p += strlen(p) + 1; - } - - memcpy(*resargv + prefix_argc + insert_argc, - suffix_argv, suffix_argc * sizeof(char *)); - - (*resargv)[*resargc] = NULL; -} /* end InsertFileIntoCommandLine */ - - -void -ExpandCommandLine(int *pargc, char ***pargv) -{ - int i; - -#if !defined(WIN32) && !defined(__CYGWIN__) - if (getuid() != geteuid()) - return; -#endif - - for (i = 1; i < *pargc; i++) - { - if ( (0 == strcmp((*pargv)[i], "-config")) && (i < (*pargc - 1)) ) - { - InsertFileIntoCommandLine(pargc, pargv, - i, *pargv, - (*pargv)[i+1], /* filename */ - *pargc - i - 2, *pargv + i + 2); - i--; - } - } -} /* end ExpandCommandLine */ -#endif - /* Implement a simple-minded font authorization scheme. The authorization name is "hp-hostname-1", the contents are simply the host name. */ int @@ -1308,65 +1048,40 @@ set_font_authorizations(char **authorizations, int *authlen, pointer client) #endif /* TCPCONN */ } -/* XALLOC -- X's internal memory allocator. Why does it return unsigned - * long * instead of the more common char *? Well, if you read K&R you'll - * see they say that alloc must return a pointer "suitable for conversion" - * to whatever type you really want. In a full-blown generic allocator - * there's no way to solve the alignment problems without potentially - * wasting lots of space. But we have a more limited problem. We know - * we're only ever returning pointers to structures which will have to - * be long word aligned. So we are making a stronger guarantee. It might - * have made sense to make Xalloc return char * to conform with people's - * expectations of malloc, but this makes lint happier. - */ - #ifndef INTERNAL_MALLOC _X_EXPORT void * Xalloc(unsigned long amount) { - register pointer ptr; - + void *ptr; + if ((long)amount <= 0) { - return (unsigned long *)NULL; + return NULL; } /* aligned extra on long word boundary */ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1); -#ifdef MEMBUG - if (!Must_have_memory && Memory_fail && - ((random() % MEM_FAIL_SCALE) < Memory_fail)) - return (unsigned long *)NULL; -#endif - if ((ptr = (pointer)malloc(amount))) { - return (unsigned long *)ptr; - } - if (Must_have_memory) - FatalError("Out of memory"); - return (unsigned long *)NULL; + ptr = malloc(amount); + return ptr; } /***************** * XNFalloc - * "no failure" realloc, alternate interface to Xalloc w/o Must_have_memory + * "no failure" realloc *****************/ _X_EXPORT void * XNFalloc(unsigned long amount) { - register pointer ptr; + void *ptr; if ((long)amount <= 0) - { - return (unsigned long *)NULL; - } + return NULL; /* aligned extra on long word boundary */ amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1); - ptr = (pointer)malloc(amount); + ptr = malloc(amount); if (!ptr) - { FatalError("Out of memory"); - } - return ((unsigned long *)ptr); + return ptr; } /***************** @@ -1376,11 +1091,11 @@ XNFalloc(unsigned long amount) _X_EXPORT void * Xcalloc(unsigned long amount) { - unsigned long *ret; + void *ret; ret = Xalloc (amount); if (ret) - bzero ((char *) ret, (int) amount); + bzero (ret, (int) amount); return ret; } @@ -1391,11 +1106,11 @@ Xcalloc(unsigned long amount) _X_EXPORT void * XNFcalloc(unsigned long amount) { - unsigned long *ret; + void *ret; ret = Xalloc (amount); if (ret) - bzero ((char *) ret, (int) amount); + bzero (ret, (int) amount); else if ((long)amount > 0) FatalError("Out of memory"); return ret; @@ -1408,43 +1123,35 @@ XNFcalloc(unsigned long amount) _X_EXPORT void * Xrealloc(pointer ptr, unsigned long amount) { -#ifdef MEMBUG - if (!Must_have_memory && Memory_fail && - ((random() % MEM_FAIL_SCALE) < Memory_fail)) - return (unsigned long *)NULL; -#endif if ((long)amount <= 0) { if (ptr && !amount) free(ptr); - return (unsigned long *)NULL; + return NULL; } amount = (amount + (sizeof(long) - 1)) & ~(sizeof(long) - 1); if (ptr) - ptr = (pointer)realloc((char *)ptr, amount); + ptr = realloc(ptr, amount); else - ptr = (pointer)malloc(amount); - if (ptr) - return (unsigned long *)ptr; - if (Must_have_memory) - FatalError("Out of memory"); - return (unsigned long *)NULL; + ptr = malloc(amount); + + return ptr; } /***************** * XNFrealloc - * "no failure" realloc, alternate interface to Xrealloc w/o Must_have_memory + * "no failure" realloc *****************/ _X_EXPORT void * XNFrealloc(pointer ptr, unsigned long amount) { - if (( ptr = (pointer)Xrealloc( ptr, amount ) ) == NULL) + if ((ptr = Xrealloc(ptr, amount)) == NULL) { if ((long)amount > 0) FatalError( "Out of memory" ); } - return ((unsigned long *)ptr); + return ptr; } /***************** @@ -1456,21 +1163,7 @@ _X_EXPORT void Xfree(pointer ptr) { if (ptr) - free((char *)ptr); -} - -void -OsInitAllocator (void) -{ -#ifdef MEMBUG - static int been_here; - - /* Check the memory system after each generation */ - if (been_here) - CheckMemory (); - else - been_here = 1; -#endif + free(ptr); } #endif /* !INTERNAL_MALLOC */ @@ -1483,7 +1176,7 @@ Xstrdup(const char *s) if (s == NULL) return NULL; - sd = (char *)Xalloc(strlen(s) + 1); + sd = Xalloc(strlen(s) + 1); if (sd != NULL) strcpy(sd, s); return sd; @@ -1498,12 +1191,11 @@ XNFstrdup(const char *s) if (s == NULL) return NULL; - sd = (char *)XNFalloc(strlen(s) + 1); + sd = XNFalloc(strlen(s) + 1); strcpy(sd, s); return sd; } -#ifdef SMART_SCHEDULE #if defined(SIGVTALRM) && !defined(__CYGWIN__) #define SMART_SCHEDULE_POSSIBLE @@ -1579,7 +1271,6 @@ SmartScheduleInit (void) return FALSE; #endif } -#endif #ifdef SIG_BLOCK static sigset_t PreviousSignalMask; @@ -1703,7 +1394,7 @@ static struct pid { int pid; } *pidlist; -void (*old_alarm)(int) = NULL; /* XXX horrible awful hack */ +OsSigHandlerPtr old_alarm = NULL; /* XXX horrible awful hack */ pointer Popen(char *command, char *type) @@ -1727,7 +1418,7 @@ Popen(char *command, char *type) } /* Ignore the smart scheduler while this is going on */ - old_alarm = signal(SIGALRM, SIG_IGN); + old_alarm = OsSignal(SIGALRM, SIG_IGN); if (old_alarm == SIG_ERR) { perror("signal"); return NULL; @@ -1738,7 +1429,7 @@ Popen(char *command, char *type) close(pdes[0]); close(pdes[1]); xfree(cur); - if (signal(SIGALRM, old_alarm) == SIG_ERR) + if (OsSignal(SIGALRM, old_alarm) == SIG_ERR) perror("signal"); return NULL; case 0: /* child */ @@ -1915,7 +1606,7 @@ Pclose(pointer iop) /* allow EINTR again */ OsReleaseSignals (); - if (old_alarm && signal(SIGALRM, old_alarm) == SIG_ERR) { + if (old_alarm && OsSignal(SIGALRM, old_alarm) == SIG_ERR) { perror("signal"); return -1; } @@ -2018,9 +1709,6 @@ CheckUserParameters(int argc, char **argv, char **envp) enum BadCode bad = NotBad; int i = 0, j; char *a, *e = NULL; -#if defined(__QNX__) && !defined(__QNXNTO__) - char cmd_name[64]; -#endif #if CHECK_EUID if (geteuid() == 0 && getuid() != geteuid()) |