README | 2 configure.ac | 10 + include/X11/fonts/FSlib.h | 4 src/FSErrDis.c | 9 - src/FSOpenServ.c | 13 - src/FSlibInt.c | 412 +--------------------------------------------- src/FSlibint.h | 105 ----------- src/FSlibos.h | 5 8 files changed, 35 insertions(+), 525 deletions(-)
New commits: commit 88be5c37c40070305e64c4b8dc0a1c1f6ca80440 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Sun Mar 16 10:44:14 2014 -0700 libFS 1.0.6 Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index 26fffb1..03ecca4 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([libFS], [1.0.5], +AC_INIT([libFS], [1.0.6], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libFS]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) commit e5be46eceee9c0c0d5f0363d3e08b19f86f85fcb Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 23:07:12 2014 -0800 Use strlcpy instead of strcpy/strncpy if it is available Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/configure.ac b/configure.ac index bcc4187..26fffb1 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,9 @@ PKG_CHECK_MODULES(FS, xproto >= 7.0.17 fontsproto xtrans) # Find needed libraries for TCP sockets (pre-pended in $LIBS) XTRANS_CONNECTION_FLAGS +# Checks for library functions. +AC_CHECK_FUNCS([strlcpy]) + # Allow checking code with lint, sparse, etc. XORG_WITH_LINT XORG_LINT_LIBRARY([FS]) diff --git a/src/FSErrDis.c b/src/FSErrDis.c index 1a712ff..76ebab6 100644 --- a/src/FSErrDis.c +++ b/src/FSErrDis.c @@ -84,9 +84,14 @@ int FSGetErrorDatabaseText( { if (nbytes == 0) return 0; +#ifdef HAVE_STRLCPY + if (strlcpy(buffer, defaultp, nbytes) >= nbytes) + return 0; +#else (void) strncpy(buffer, defaultp, nbytes); if ((strlen(defaultp) + 1) > nbytes) buffer[nbytes - 1] = '\0'; +#endif return 1; } diff --git a/src/FSlibInt.c b/src/FSlibInt.c index 71f6ac1..090da3f 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -850,7 +850,11 @@ _FSPrintDefaultError( ext && (ext->codes.major_opcode != event->request_code); ext = ext->next); if (ext) +#ifdef HAVE_STRLCPY + strlcpy(buffer, ext->name, sizeof(buffer)); +#else strcpy(buffer, ext->name); +#endif else buffer[0] = '\0'; } commit e831ef9246684298c147f9b26de0810b8218c3cb Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 21:33:10 2014 -0800 Replace malloc(strlen + 1); strcpy() with strdup() Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Jasper St. Pierre <jstpie...@mecheye.net> diff --git a/src/FSOpenServ.c b/src/FSOpenServ.c index b8ccb2f..faebe13 100644 --- a/src/FSOpenServ.c +++ b/src/FSOpenServ.c @@ -127,10 +127,9 @@ FSOpenServer(const char *server) return (FSServer *) NULL; } - if ((svr->server_name = FSmalloc(strlen(server) + 1)) == NULL) { + if ((svr->server_name = strdup(server)) == NULL) { goto fail; } - (void) strcpy(svr->server_name, server); if ((svr->trans_conn = _FSConnectServer(svr->server_name)) == NULL) { goto fail; commit 980cf8ac0c636ff7ef1fccb9e74f116ac5ea34ae Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 21:13:30 2014 -0800 Remove unused internal helper _FSWireToEvent Since we build with -export-symbols-regex '^FS.*', it wasn't available to callers outside libFS, and was never called by anything inside libFS. Seems to have been imported from XlibInt.c without ever being used. Flagged by cppcheck 1.62: [FSlibInt.c:753]: (style) The function '_FSWireToEvent' is never used. Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Jasper St. Pierre <jstpie...@mecheye.net> diff --git a/src/FSlibInt.c b/src/FSlibInt.c index eeab20c..71f6ac1 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -746,35 +746,6 @@ _FSUnknownNativeEvent( return (0); } -/* - * reformat a wire event into an FSEvent structure of the right type. - */ -Bool -_FSWireToEvent( - register FSServer *svr, /* pointer to display structure */ - register FSEvent *re, /* pointer to where event should be - * reformatted */ - register fsEvent *event) /* wire protocol event */ -{ - - re->type = event->type & 0x7f; - ((FSAnyEvent *) re)->serial = _FSSetLastRequestRead(svr, - (fsGenericReply *) event); - ((FSAnyEvent *) re)->send_event = ((event->type & 0x80) != 0); - ((FSAnyEvent *) re)->server = svr; - - /* - * Ignore the leading bit of the event type since it is set when a client - * sends an event rather than the server. - */ - - switch (event->type & 0177) { - default: - return (_FSUnknownWireEvent(svr, re, event)); - } -} - - static const char * _SysErrorMsg(int n) { diff --git a/src/FSlibint.h b/src/FSlibint.h index b5aba87..5e539be 100644 --- a/src/FSlibint.h +++ b/src/FSlibint.h @@ -87,7 +87,6 @@ extern unsigned long _FSSetLastRequestRead ( FSServer *svr, extern int _FSUnknownWireEvent ( FSServer *svr, FSEvent *re, fsEvent *event ); extern int _FSUnknownNativeEvent ( FSServer *svr, FSEvent *re, fsEvent *event ); -extern int _FSWireToEvent ( FSServer *svr, FSEvent *re, fsEvent *event ); extern int _FSDefaultIOError ( FSServer *svr ) _X_NORETURN; extern int _FSPrintDefaultError ( FSServer *svr, FSErrorEvent *event, FILE *fp ); commit b9f27dc863c3ca01bb231ee48e84bc60b39d4f1f Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 20:55:33 2014 -0800 Remove unused internal helper _FSEventsQueued Since we build with -export-symbols-regex '^FS.*', it wasn't available to callers outside libFS, and was never called by anything inside libFS. Seems to have been imported from XlibInt.c without ever being used. Flagged by cppcheck 1.62: [FSlibInt.c:180]: (style) The function '_FSEventsQueued' is never used. Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Jasper St. Pierre <jstpie...@mecheye.net> diff --git a/src/FSlibInt.c b/src/FSlibInt.c index 48091cf..eeab20c 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -176,42 +176,6 @@ _FSFlush(register FSServer *svr) svr->last_req = (char *) &_dummy_request; } -int -_FSEventsQueued( - register FSServer *svr, - int mode) -{ - register BytesReadable_t len; - BytesReadable_t pend; - char buf[BUFSIZE]; - register fsReply *rep; - - if (mode == QueuedAfterFlush) { - _FSFlush(svr); - if (svr->qlen) - return (svr->qlen); - } - if (_FSTransBytesReadable(svr->trans_conn, &pend) < 0) - (*_FSIOErrorFunction) (svr); - if ((len = pend) < SIZEOF(fsReply)) - return (svr->qlen); /* _FSFlush can enqueue events */ - else if (len > BUFSIZE) - len = BUFSIZE; - len /= SIZEOF(fsReply); - pend = len * SIZEOF(fsReply); - _FSRead(svr, buf, (long) pend); - - /* no space between comma and type or else macro will die */ - STARTITERATE(rep, fsReply, buf, (len > 0), len--) { - if (rep->generic.type == FS_Error) - _FSError(svr, (fsError *) rep); - else /* must be an event packet */ - _FSEnq(svr, (fsEvent *) rep); - } - ENDITERATE - return (svr->qlen); -} - /* _FSReadEvents - Flush the output queue, * then read as many events as possible (but at least 1) and enqueue them */ diff --git a/src/FSlibint.h b/src/FSlibint.h index b50509b..b5aba87 100644 --- a/src/FSlibint.h +++ b/src/FSlibint.h @@ -82,7 +82,6 @@ extern int _FSReply ( FSServer *svr, fsReply *rep, int extra, int discard ); extern XtransConnInfo _FSConnectServer ( char *server_name ); extern void _FSDisconnectServer ( XtransConnInfo trans_conn ); extern void _FSSendClientPrefix ( FSServer *svr, fsConnClientPrefix *client ); -extern int _FSEventsQueued ( FSServer *svr, int mode ); extern unsigned long _FSSetLastRequestRead ( FSServer *svr, fsGenericReply *rep ); extern int _FSUnknownWireEvent ( FSServer *svr, FSEvent *re, fsEvent *event ); commit 37772516acb95b3c9934252994b7dfdc147dfd23 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 20:50:32 2014 -0800 Remove unused internal helper _FSAllocScratch Since we build with -export-symbols-regex '^FS.*', it wasn't available to callers outside libFS, and was never called by anything inside libFS. Seems to have been imported from XlibInt.c without ever being used. The _FSserver fields that it used (and nothing else did) are replaced with "unused" placeholders to maintain struct layout/size. Flagged by cppcheck 1.62: [FSlibInt.c:973]: (style) The function '_FSAllocScratch' is never used. Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Jasper St. Pierre <jstpie...@mecheye.net> diff --git a/include/X11/fonts/FSlib.h b/include/X11/fonts/FSlib.h index 11b3ba6..1cd7f13 100644 --- a/include/X11/fonts/FSlib.h +++ b/include/X11/fonts/FSlib.h @@ -148,8 +148,8 @@ struct _FSServer { int ext_number; Bool (*event_vec[132]) (FSServer *, FSEvent *, fsEvent *); Status (*wire_vec[132]) (FSServer *, FSEvent *, fsEvent *); - char *scratch_buffer; - unsigned long scratch_length; + void *unused_1; /* previously scratch_buffer */ + unsigned long unused_2; /* previously scratch_length */ FSSyncHandler synchandler; unsigned long flags; struct _XtransConnInfo *trans_conn; /* transport connection object */ diff --git a/src/FSlibInt.c b/src/FSlibInt.c index cd996d1..48091cf 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -964,25 +964,6 @@ _FSDefaultError( FSIOErrorHandler _FSIOErrorFunction = _FSDefaultIOError; FSErrorHandler _FSErrorFunction = _FSDefaultError; -/* - * This routine can be used to (cheaply) get some memory within a single - * Xlib routine for scratch space. It is reallocated from the same place - * each time, unless the library needs a large scratch space. - */ -char * -_FSAllocScratch( - register FSServer *svr, - unsigned long nbytes) -{ - if (nbytes > svr->scratch_length) { - if (svr->scratch_buffer != NULL) - FSfree(svr->scratch_buffer); - return (svr->scratch_length = nbytes, - svr->scratch_buffer = FSmalloc(nbytes)); - } - return (svr->scratch_buffer); -} - int FSFree(char *data) { diff --git a/src/FSlibint.h b/src/FSlibint.h index 7669778..b50509b 100644 --- a/src/FSlibint.h +++ b/src/FSlibint.h @@ -93,7 +93,6 @@ extern int _FSDefaultIOError ( FSServer *svr ) _X_NORETURN; extern int _FSPrintDefaultError ( FSServer *svr, FSErrorEvent *event, FILE *fp ); extern int _FSDefaultError ( FSServer *svr, FSErrorEvent *event ); -extern char * _FSAllocScratch ( FSServer *svr, unsigned long nbytes ); extern void _FSFreeQ ( void ); extern FSErrorHandler FSSetErrorHandler ( FSErrorHandler handler ); commit ac1eb6e3ea54724cf3ab3ad1ccf0595df9e34786 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 20:46:48 2014 -0800 Remove unused internal helper _FSGetHostname Since we build with -export-symbols-regex '^FS.*', it wasn't available to callers outside libFS, and was never called by anything inside libFS. Xtrans provides it's own exact copy of this function, which gets the name _FSTransGetHostname when built in libFS, nothing in libFS outside the Xtrans code calls a gethostname() function. Flagged by cppcheck 1.62: [FSlibInt.c:1060]: (style) The function '_FSGetHostname' is never used. Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Jasper St. Pierre <jstpie...@mecheye.net> diff --git a/src/FSlibInt.c b/src/FSlibInt.c index cb53e44..cd996d1 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -1034,57 +1034,6 @@ _FSFreeQ(void) return; } -#ifdef _POSIX_SOURCE /* stupid makedepend [need if] */ -#ifndef __QNX__ /* QNX's uname nodename entry is not same as tcpip hostname */ -#define NEED_UTSNAME -#endif -#endif -#ifdef hpux -#define NEED_UTSNAME -#endif -#ifdef SVR4 -#ifndef _SEQUENT_ -#define NEED_UTSNAME -#endif -#endif - -#ifdef NEED_UTSNAME -#include <sys/utsname.h> -#endif - - -/* - * _FSGetHostname - similar to gethostname but allows special processing. - */ -int -_FSGetHostname( - char *buf, - int maxlen) -{ - int len; - -#ifdef NEED_UTSNAME - /* - * same host name crock as in server and xinit. - */ - struct utsname name; - - uname(&name); - len = strlen(name.nodename); - if (len >= maxlen) - len = maxlen - 1; - strncpy(buf, name.nodename, len); - buf[len] = '\0'; -#else - buf[0] = '\0'; - (void) gethostname(buf, maxlen); - buf[maxlen - 1] = '\0'; - len = strlen(buf); -#endif /* NEED_UTSNAME */ - - return len; -} - #ifndef _FSANYSET /* * This is not always a macro. diff --git a/src/FSlibint.h b/src/FSlibint.h index 60a2ce6..7669778 100644 --- a/src/FSlibint.h +++ b/src/FSlibint.h @@ -95,7 +95,6 @@ extern int _FSPrintDefaultError ( FSServer *svr, FSErrorEvent *event, extern int _FSDefaultError ( FSServer *svr, FSErrorEvent *event ); extern char * _FSAllocScratch ( FSServer *svr, unsigned long nbytes ); extern void _FSFreeQ ( void ); -extern int _FSGetHostname ( char *buf, int maxlen ); extern FSErrorHandler FSSetErrorHandler ( FSErrorHandler handler ); extern FSIOErrorHandler FSSetIOErrorHandler ( FSIOErrorHandler handler ); commit a4c12fe0ca5cb359bffe08b26a92ddcf8e194441 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 20:04:33 2014 -0800 If EAGAIN == EWOULDBLOCK, only need to check errno for one of them Solaris <sys/errno.h> has: #define EWOULDBLOCK EAGAIN so checking (errno == EAGAIN || errno == EWOULDBLOCK) is overkill. This leads cppcheck 1.62 to complain: [FSlibInt.c:153] -> [FSlibInt.c:153]: (style) Same expression on both sides of '||'. [FSlibInt.c:301] -> [FSlibInt.c:301]: (style) Same expression on both sides of '||'. [FSlibInt.c:379] -> [FSlibInt.c:379]: (style) Same expression on both sides of '||'. [FSlibInt.c:472] -> [FSlibInt.c:472]: (style) Same expression on both sides of '||'. This quiets it, and reduces the number of calls Solaris Studio cc generates to the __errno() function to get the thread-specific errno value. Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Jasper St. Pierre <jstpie...@mecheye.net> diff --git a/src/FSlibInt.c b/src/FSlibInt.c index 0fabc96..cb53e44 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -66,11 +66,14 @@ static const char * _SysErrorMsg ( int n ); /* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX * systems are broken and return EWOULDBLOCK when they should return EAGAIN + * + * Solaris defines EWOULDBLOCK to be EAGAIN, so don't need to check twice + * for it. */ #ifdef WIN32 #define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK) #else -#if defined(EAGAIN) && defined(EWOULDBLOCK) +#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN != EWOULDBLOCK) #define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK) #else #ifdef EAGAIN commit b6885f7aedc3b6eba62ffa1edac1e8488d938cea Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Jan 3 19:57:09 2014 -0800 Reduce scope & remove unneeded assignment of defaultp in FSGetErrorText() Suggested by cppcheck 1.62 Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/FSErrDis.c b/src/FSErrDis.c index e3d296e..1a712ff 100644 --- a/src/FSErrDis.c +++ b/src/FSErrDis.c @@ -96,8 +96,6 @@ int FSGetErrorText( char *buffer, int nbytes) { - - const char *defaultp = NULL; char buf[32]; register _FSExtension *ext; @@ -105,7 +103,7 @@ int FSGetErrorText( return 0; snprintf(buf, sizeof(buf), "%d", code); if (code < (FSErrorListSize / sizeof(char *)) && code >= 0) { - defaultp = FSErrorList[code]; + const char *defaultp = FSErrorList[code]; FSGetErrorDatabaseText(svr, "FSProtoError", buf, defaultp, buffer, nbytes); } ext = svr->ext_procs; commit dcb6c39feb63dcf7e843bd2394a2544fd4e79f9f Author: Jeremy Huddleston Sequoia <jerem...@apple.com> Date: Thu Jan 2 01:03:49 2014 -0800 FSOpenServer: Fix double-free in error path FSOpenServ.c:266:5: warning: Use of memory after it is freed OutOfMemory(svr, setup); ^~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Jeremy Huddleston Sequoia <jerem...@apple.com> diff --git a/src/FSOpenServ.c b/src/FSOpenServ.c index 9b51e20..b8ccb2f 100644 --- a/src/FSOpenServ.c +++ b/src/FSOpenServ.c @@ -66,7 +66,7 @@ static fsReq _dummy_request = { 0, 0, 0 }; -static void OutOfMemory ( FSServer *svr, char *setup ); +static void OutOfMemory ( FSServer *svr ); FSServer *_FSHeadOfServerList = NULL; @@ -85,13 +85,11 @@ void _FSFreeServerStructure(FSServer *svr) static void OutOfMemory( - FSServer *svr, - char *setup) + FSServer *svr) { if (svr->trans_conn) _FSDisconnectServer(svr->trans_conn); _FSFreeServerStructure(svr); - FSfree(setup); errno = ENOMEM; } @@ -263,7 +261,7 @@ FSOpenServer(const char *server) FSfree(alts); FSfree(alt_data); FSfree(auth_data); - OutOfMemory(svr, setup); + OutOfMemory(svr); return (FSServer *) NULL; } commit 4b0b74f953619164dc2863ee2cd3f09d15c65a51 Author: Jeremy Huddleston Sequoia <jerem...@apple.com> Date: Thu Jan 2 00:49:27 2014 -0800 Update error loop to correctly handle error in i==0 case FSOpenServ.c:183:3: warning: Function call argument is an uninitialized value FSfree(alts[i].name); ^~~~~~~~~~~~~~~~~~~~ ./FSlibos.h:273:21: note: expanded from macro 'FSfree' ^~~~~~~~~~~ Signed-off-by: Jeremy Huddleston Sequoia <jerem...@apple.com> diff --git a/src/FSOpenServ.c b/src/FSOpenServ.c index 15a657a..9b51e20 100644 --- a/src/FSOpenServ.c +++ b/src/FSOpenServ.c @@ -179,7 +179,7 @@ FSOpenServer(const char *server) altlen = (unsigned int) *ad++; alts[i].name = FSmalloc(altlen + 1); if (!alts[i].name) { - while (--i) { + while (--i >= 0) { FSfree(alts[i].name); } goto fail; commit 5ed8b4cf1f1c35ef35a3c94350e6b96646a2a0b7 Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Fri Dec 27 11:01:35 2013 -0800 Add AC_USE_SYSTEM_EXTENSIONS to expose non-standard extensions Required on Solaris to expose fd_mask in <sys/select.h> now that xtrans 1.3 defines _XOPEN_SOURCE to 600 on Solaris, since fd_mask is not defined in that version of the XPG standards. Fixes build failure: ../../src/FSConnServ.c: In function '_FSWaitForWritable': ../../src/FSConnServ.c:166:6: error: 'fd_mask' undeclared (first use in this function) ../../src/FSConnServ.c:166:6: note: each undeclared identifier is reported only once for each function it appears in Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> Reviewed-by: Daniel Stone <dan...@fooishbar.org> diff --git a/configure.ac b/configure.ac index b00749f..bcc4187 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,11 @@ AC_CONFIG_HEADERS([config.h]) # Initialize Automake AM_INIT_AUTOMAKE([foreign dist-bzip2]) +# Set common system defines for POSIX extensions, such as _GNU_SOURCE +# Must be called before any macros that run the compiler (like +# AC_PROG_LIBTOOL) to avoid autoconf errors. +AC_USE_SYSTEM_EXTENSIONS + # Initialize libtool AC_PROG_LIBTOOL commit 19ca53de0aae67b1f23085c832b445576c6a0b25 Author: Adam Jackson <a...@redhat.com> Date: Fri Nov 1 11:14:58 2013 -0400 Fix build with xtrans 1.3 ->Readv was in fact being used, oops. Just call straight down to readv() instead. Reviewed-by: Peter Harris <phar...@opentext.com> Signed-off-by: Adam Jackson <a...@redhat.com> diff --git a/src/FSlibInt.c b/src/FSlibInt.c index edc66ba..0fabc96 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -58,6 +58,7 @@ in this Software without prior written authorization from The Open Group. #endif #include <stdio.h> #include "FSlibint.h" +#include <X11/Xtrans/Xtransint.h> #include <X11/Xos.h> static void _EatData32 ( FSServer *svr, unsigned long n ); @@ -360,7 +361,7 @@ _FSReadPad( size += iov[1].iov_len; ESET(0); - while ((bytes_read = _FSTransReadv(svr->trans_conn, iov, 2)) != size) { + while ((bytes_read = readv(svr->trans_conn->fd, iov, 2)) != size) { if (bytes_read > 0) { size -= bytes_read; commit 96243bfec19d0f543de3ef590a482f7f6dcdaa3d Author: Alan Coopersmith <alan.coopersm...@oracle.com> Date: Mon Jun 24 22:52:09 2013 -0700 Drop Cray (WORD64/MUSTCOPY) support Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com> diff --git a/src/FSlibInt.c b/src/FSlibInt.c index c6b1cb6..edc66ba 100644 --- a/src/FSlibInt.c +++ b/src/FSlibInt.c @@ -330,137 +330,6 @@ _FSRead( } } -#ifdef WORD64 -/* - * XXX This is a *really* stupid way of doing this.... - */ - -#define PACKBUFFERSIZE 4096 - - -/* - * _FSRead32 - Read bytes from the socket unpacking each 32 bits - * into a long (64 bits on a CRAY computer). - * - */ -static void -_doFSRead32( - register FSServer *svr, - register long *data, - register long size, - register char *packbuffer) -{ - long *lpack, - *lp; - long mask32 = 0x00000000ffffffff; - long maskw, - nwords, - i, - bits; - - _FSReadPad(svr, packbuffer, size); - - lp = data; - lpack = (long *) packbuffer; - nwords = size >> 2; - bits = 32; - - for (i = 0; i < nwords; i++) { - maskw = mask32 << bits; - *lp++ = (*lpack & maskw) >> bits; - bits = bits ^ 32; - if (bits) { - lpack++; - } - } -} - -void -_FSRead32( - FSServer *svr, - long *data, - long len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nwords = (PACKBUFFERSIZE >> 2); /* bytes to CARD32 */ - - for (; len > nwords; len -= nwords, data += nwords) { - _doFSRead32(svr, data, nwords, packbuffer); - } - _doFSRead32(svr, data, len, packbuffer); -} - - - -/* - * _FSRead16 - Read bytes from the socket unpacking each 16 bits - * into a long (64 bits on a CRAY computer). - * - */ -static void -_doFSRead16( - register FSServer *svr, - register short *data, - register long size, - char *packbuffer) -{ - long *lpack, - *lp; - long mask16 = 0x000000000000ffff; - long maskw, - nwords, - i, - bits; - - _FSRead(svr, packbuffer, size); /* don't do a padded read... */ - - lp = (long *) data; - lpack = (long *) packbuffer; - nwords = size >> 1; /* number of 16 bit words to be unpacked */ - bits = 48; - for (i = 0; i < nwords; i++) { - maskw = mask16 << bits; - *lp++ = (*lpack & maskw) >> bits; - bits -= 16; - if (bits < 0) { - lpack++; - bits = 48; - } - } -} - -void -_FSRead16( - FSServer *svr, - short *data, - long len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nwords = (PACKBUFFERSIZE >> 1); /* bytes to CARD16 */ - - for (; len > nwords; len -= nwords, data += nwords) { - _doFSRead16(svr, data, nwords, packbuffer); - } - _doFSRead16(svr, data, len, packbuffer); -} - -void -_FSRead16Pad( - FSServer *svr, - short *data, - long size) -{ - int slop = (size & 3); - short slopbuf[3]; - - _FSRead16(svr, data, size); - if (slop > 0) { - _FSRead16(svr, slopbuf, 4 - slop); - } -} - -#endif /* WORD64 */ - /* * _FSReadPad - Read bytes from the socket taking into account incomplete @@ -1141,138 +1010,6 @@ Data( #endif /* DataRoutineIsProcedure */ -#ifdef WORD64 -/* - * XXX This is a *really* stupid way of doing this. It should just use - * svr->bufptr directly, taking into account where in the word it is. - */ - -/* - * Data16 - Place 16 bit data in the buffer. - * - * "svr" is a pointer to a FSServer. - * "data" is a pointer to the data. - * "len" is the length in bytes of the data. - */ - -static void -doData16( - register FSServer *svr, - short *data, - unsigned len, - char *packbuffer) -{ - long *lp, - *lpack; - long i, - nwords, - bits; - long mask16 = 0x000000000000ffff; - - lp = (long *) data; - lpack = (long *) packbuffer; - *lpack = 0; - -/* nwords is the number of 16 bit values to be packed, - * the low order 16 bits of each word will be packed - * into 64 bit words - */ - nwords = len >> 1; - bits = 48; - - for (i = 0; i < nwords; i++) { - *lpack ^= (*lp & mask16) << bits; - bits -= 16; - lp++; - if (bits < 0) { - lpack++; - *lpack = 0; - bits = 48; - } - } - Data(svr, packbuffer, len); -} - -void -Data16( - FSServer *svr, - short *data, - unsigned len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nwords = (PACKBUFFERSIZE >> 1); /* bytes to CARD16 */ - - for (; len > nwords; len -= nwords, data += nwords) { - doData16(svr, data, nwords, packbuffer); - } - doData16(svr, data, len, packbuffer); -} - -/* - * Data32 - Place 32 bit data in the buffer. - * - * "svr" is a pointer to a FSServer. - * "data" is a pointer to the data. - * "len" is the length in bytes of the data. - */ - -static -doData32( - register FSServer *svr, - long *data, - unsigned len, - char *packbuffer) -{ - long *lp, - *lpack; - long i, - bits, - nwords; - long mask32 = 0x00000000ffffffff; - - lpack = (long *) packbuffer; - lp = data; - - *lpack = 0; - -/* nwords is the number of 32 bit values to be packed - * the low order 32 bits of each word will be packed - * into 64 bit words - */ - nwords = len >> 2; - bits = 32; - - for (i = 0; i < nwords; i++) { - *lpack ^= (*lp & mask32) << bits; - bits = bits ^ 32; - lp++; - if (bits) { - lpack++; - *lpack = 0; - } - } - Data(svr, packbuffer, len); -} - -void -Data32( - FSServer *svr, - short *data, - unsigned len) -{ - char packbuffer[PACKBUFFERSIZE]; - unsigned nwords = (PACKBUFFERSIZE >> 2); /* bytes to CARD32 */ - - for (; len > nwords; len -= nwords, data += nwords) { - doData32(svr, data, nwords, packbuffer); - } - doData32(svr, data, len, packbuffer); -} - -#endif /* WORD64 */ - - - /* * _FSFreeQ - free the queue of events, called by XCloseServer when there are * no more displays left on the display list diff --git a/src/FSlibint.h b/src/FSlibint.h index 00900fc..60a2ce6 100644 --- a/src/FSlibint.h +++ b/src/FSlibint.h @@ -113,27 +113,6 @@ extern FSServer *_FSHeadOfServerList; #define FSlibServerIOError (1L << 0) #define FSlibServerClosing (1L << 1) -/* Need to start requests on 64 bit word boundries - * on a CRAY computer so add a NoOp (127) if needed. - * A character pointer on a CRAY computer will be non-zero - * after shifting right 61 bits of it is not pointing to - * a word boundary. - */ - -#ifdef WORD64 -#define WORD64ALIGN if ((long)svr->bufptr >> 61) {\ - svr->last_req = svr->bufptr;\ - *(svr->bufptr) = FS_Noop;\ - *(svr->bufptr+1) = 0;\ - *(svr->bufptr+2) = 0;\ - *(svr->bufptr+3) = 1;\ - svr->request += 1;\ - svr->bufptr += 4;\ - } -#else /* else does not require alignment on 64-bit - * boundaries */ -#define WORD64ALIGN -#endif /* WORD64 */ /* * GetReq - Get the next available FS request packet in the buffer and @@ -145,7 +124,6 @@ extern FSServer *_FSHeadOfServerList; */ #define GetReq(name, req) \ - WORD64ALIGN\ if ((svr->bufptr + SIZEOF(fs##name##Req)) > svr->bufmax)\ _FSFlush(svr);\ req = (fs##name##Req *)(svr->last_req = svr->bufptr);\ @@ -158,7 +136,6 @@ extern FSServer *_FSHeadOfServerList; bytes after the request. "n" must be a multiple of 4! */ #define GetReqExtra(name, n, req) \ - WORD64ALIGN\ if ((svr->bufptr + SIZEOF(fs##name##Req) + n) > svr->bufmax)\ _FSFlush(svr);\ req = (fs##name##Req *)(svr->last_req = svr->bufptr);\ @@ -174,7 +151,6 @@ extern FSServer *_FSHeadOfServerList; */ #define GetResReq(name, rid, req) \ - WORD64ALIGN\ -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: https://lists.debian.org/e1x66wx-0005vc...@moszumanska.debian.org