From 4a3dbb926ae3f5410198d7cc4f4ebe4f62eebf05 Mon Sep 17 00:00:00 2001 From: marha Date: Sat, 25 Jul 2009 19:39:46 +0000 Subject: Added xorg-server-1.6.2.tar.gz --- xorg-server/os/utils.c | 390 +++++-------------------------------------------- 1 file changed, 39 insertions(+), 351 deletions(-) (limited to 'xorg-server/os/utils.c') diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index f58c76366..b1009494b 100644 --- a/xorg-server/os/utils.c +++ b/xorg-server/os/utils.c @@ -83,7 +83,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include #undef _POSIX_C_SOURCE #else -#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE) +#if defined(_POSIX_SOURCE) #include #else #define _POSIX_SOURCE @@ -94,18 +94,13 @@ OR PERFORMANCE OF THIS SOFTWARE. #ifndef WIN32 #include #endif -#if !defined(SYSV) && !defined(WIN32) && !defined(Lynx) && !defined(QNX4) +#if !defined(SYSV) && !defined(WIN32) #include #endif #include #include /* for isspace */ #include -#if defined(DGUX) -#include -#include -#endif - #include /* for malloc() */ #if defined(TCPCONN) || defined(STREAMSCONN) @@ -116,9 +111,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #include "opaque.h" -#ifdef SMART_SCHEDULE #include "dixstruct.h" -#endif #ifdef XKB #include @@ -128,14 +121,7 @@ OR PERFORMANCE OF THIS SOFTWARE. #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 @@ -149,12 +135,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; @@ -165,9 +145,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 @@ -177,32 +154,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 @@ -212,9 +169,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 @@ -226,14 +180,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 @@ -243,6 +191,8 @@ _X_EXPORT Bool noXvExtension = FALSE; _X_EXPORT Bool noDRI2Extension = FALSE; #endif +_X_EXPORT Bool noGEExtension = FALSE; + #define X_INCLUDE_NETDB_H #include @@ -256,23 +206,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 /* for random() */ -#endif - static char *dev_tty_from_init = NULL; /* since we need to parse it anyway */ OsSigHandlerPtr @@ -280,9 +217,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); @@ -293,10 +227,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 @@ -308,17 +240,8 @@ OsSignal(sig, handler) #define LOCK_PREFIX "/.X" #define LOCK_SUFFIX "-lock" -#if defined(DGUX) -#include -#include -#endif - #ifndef PATH_MAX -#ifndef Lynx #include -#else -#include -#endif #ifndef PATH_MAX #ifdef MAXPATHLEN #define PATH_MAX MAXPATHLEN @@ -392,11 +315,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); /* @@ -478,7 +397,6 @@ UnlockServer(void) (void) unlink(LockFile); } } -#endif /* SERVER_LOCK */ /* Force connections to close on SIGHUP from init */ @@ -490,13 +408,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; } @@ -510,10 +421,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; } @@ -566,13 +473,9 @@ AdjustWaitForDelay (pointer waitTime, unsigned long newdelay) void UseMsg(void) { -#if !defined(AIXrt) && !defined(AIX386) ErrorF("use: X [:] [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"); @@ -581,9 +484,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 @@ -624,11 +524,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"); @@ -644,16 +541,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 @@ -678,17 +572,6 @@ VerifyDisplayName(const char *d) return( 1 ); } -/* - * 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 @@ -736,15 +619,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) @@ -759,8 +633,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) @@ -946,6 +819,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) @@ -954,8 +829,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) @@ -1039,26 +912,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; @@ -1082,7 +935,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } -#endif #ifdef RENDER else if ( strcmp( argv[i], "-render" ) == 0) { @@ -1128,118 +980,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 @@ -1307,65 +1047,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; } /***************** @@ -1375,11 +1090,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; } @@ -1390,11 +1105,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; @@ -1407,43 +1122,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; } /***************** @@ -1455,21 +1162,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 */ @@ -1482,7 +1175,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; @@ -1497,12 +1190,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 #ifdef SIGVTALRM #define SMART_SCHEDULE_POSSIBLE @@ -1578,7 +1270,6 @@ SmartScheduleInit (void) return FALSE; #endif } -#endif #ifdef SIG_BLOCK static sigset_t PreviousSignalMask; @@ -1702,7 +1393,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) @@ -1726,7 +1417,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; @@ -1737,7 +1428,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 */ @@ -1914,7 +1605,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; } @@ -2015,9 +1706,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()) -- cgit v1.2.3