diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:42 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:42 +0000 |
commit | 5ec315b967cb1ae519f514896f0b48fb5407f863 (patch) | |
tree | e4e72bdbe972af362cebc19b9e1b02a4767a04ee /Xos_r.h | |
parent | f2001f5bd5316842106a98b23f09400688575fa3 (diff) |
XFree86 4.3.0.1
Diffstat (limited to 'Xos_r.h')
-rw-r--r-- | Xos_r.h | 93 |
1 files changed, 84 insertions, 9 deletions
@@ -22,6 +22,7 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/include/Xos_r.h,v 1.18 2002/08/28 23:08:22 torrey Exp $ */ /* * Various and sundry Thread-Safe functions used by X11, Motif, and CDE. @@ -149,7 +150,9 @@ extern void (*_XUnlockMutex_fn)( # endif # endif # elif defined(XOS_USE_XT_LOCKING) -extern void (*_XtProcessLock)(); +# ifndef _XtThreadsI_h +extern void (*_XtProcessLock)(void); +# endif # ifndef _XtintrinsicP_h # include <X11/Xfuncproto.h> /* for NeedFunctionPrototypes */ extern void XtProcessLock( @@ -194,6 +197,14 @@ extern void XtProcessUnlock( # undef _POSIX_THREAD_SAFE_FUNCTIONS #endif +/* + * LynxOS 3.1 defines _POSIX_THREAD_SAFE_FUNCTIONS but + * getpwuid_r has different semantics than defined by POSIX + */ +#if defined(Lynx) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) +# undef _POSIX_THREAD_SAFE_FUNCTIONS +#endif + /***** <pwd.h> wrappers *****/ @@ -217,6 +228,7 @@ extern void XtProcessUnlock( # endif #endif +#undef X_NEEDS_PWPARAMS #if !defined(X_INCLUDE_PWD_H) || defined(_XOS_INCLUDED_PWD_H) /* Do nothing */ @@ -231,12 +243,53 @@ typedef int _Xgetpwparams; /* dummy */ #elif !defined(XOS_USE_MTSAFE_PWDAPI) || defined(XNO_MTSAFE_PWDAPI) /* UnixWare 2.0, or other systems with thread support but no _r API. */ +# define X_NEEDS_PWPARAMS typedef struct { struct passwd pws; char pwbuf[1024]; struct passwd* pwp; size_t len; } _Xgetpwparams; + +/* + * NetBSD and FreeBSD, at least, are missing several of the unixware passwd + * fields. + */ + +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__APPLE__) +static __inline__ void _Xpw_copyPasswd(_Xgetpwparams p) +{ + memcpy(&(p).pws, (p).pwp, sizeof(struct passwd)); + + (p).pws.pw_name = (p).pwbuf; + (p).len = strlen((p).pwp->pw_name); + strcpy((p).pws.pw_name, (p).pwp->pw_name); + + (p).pws.pw_passwd = (p).pws.pw_name + (p).len + 1; + (p).len = strlen((p).pwp->pw_passwd); + strcpy((p).pws.pw_passwd,(p).pwp->pw_passwd); + + (p).pws.pw_class = (p).pws.pw_passwd + (p).len + 1; + (p).len = strlen((p).pwp->pw_class); + strcpy((p).pws.pw_class, (p).pwp->pw_class); + + (p).pws.pw_gecos = (p).pws.pw_class + (p).len + 1; + (p).len = strlen((p).pwp->pw_gecos); + strcpy((p).pws.pw_gecos, (p).pwp->pw_gecos); + + (p).pws.pw_dir = (p).pws.pw_gecos + (p).len + 1; + (p).len = strlen((p).pwp->pw_dir); + strcpy((p).pws.pw_dir, (p).pwp->pw_dir); + + (p).pws.pw_shell = (p).pws.pw_dir + (p).len + 1; + (p).len = strlen((p).pwp->pw_shell); + strcpy((p).pws.pw_shell, (p).pwp->pw_shell); + + (p).pwp = &(p).pws; +} + +#else # define _Xpw_copyPasswd(p) \ (memcpy(&(p).pws, (p).pwp, sizeof(struct passwd)), \ ((p).pws.pw_name = (p).pwbuf), \ @@ -262,28 +315,37 @@ typedef struct { strcpy((p).pws.pw_shell, (p).pwp->pw_shell), \ ((p).pwp = &(p).pws), \ 0 ) +#endif # define _XGetpwuid(u,p) \ ( (_Xos_processLock), \ - (((p).pwp = getpwuid((u))) ? _Xpw_copyPasswd(p) : 0), \ + (((p).pwp = getpwuid((u))) ? _Xpw_copyPasswd(p), 0 : 0), \ (_Xos_processUnlock), \ (p).pwp ) # define _XGetpwnam(u,p) \ ( (_Xos_processLock), \ - (((p).pwp = getpwnam((u))) ? _Xpw_copyPasswd(p) : 0), \ + (((p).pwp = getpwnam((u))) ? _Xpw_copyPasswd(p), 0 : 0), \ (_Xos_processUnlock), \ (p).pwp ) -#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) +#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(__APPLE__) /* SVR4 threads, AIX 4.2.0 and earlier and OSF/1 3.2 and earlier pthreads */ +# define X_NEEDS_PWPARAMS typedef struct { struct passwd pws; char pwbuf[X_LINE_MAX]; } _Xgetpwparams; -# if defined(_POSIX_REENTRANT_FUNCTIONS) || !defined(SVR4) -# define _XGetpwuid(u,p) \ +# if defined(_POSIX_REENTRANT_FUNCTIONS) || !defined(SVR4) || defined(Lynx) +# ifndef Lynx +# define _XGetpwuid(u,p) \ ((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws) -# define _XGetpwnam(u,p) \ +# define _XGetpwnam(u,p) \ ((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws) +# else /* Lynx */ +# define _XGetpwuid(u,p) \ +((getpwuid_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws) +# define _XGetpwnam(u,p) \ +((getpwnam_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf)) == -1) ? NULL : &(p).pws) +# endif # else /* SVR4 */ # define _XGetpwuid(u,p) \ ((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == NULL) ? NULL : &(p).pws) @@ -298,6 +360,7 @@ typedef struct { extern int _Pgetpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **); extern int _Pgetpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); # endif +# define X_NEEDS_PWPARAMS typedef struct { struct passwd pws; char pwbuf[X_LINE_MAX]; @@ -340,6 +403,7 @@ typedef int _Xgetpwret; * _Xgetservbynameparams); */ +#undef XTHREADS_NEEDS_BYNAMEPARAMS #if defined(X_INCLUDE_NETDB_H) && !defined(_XOS_INCLUDED_NETDB_H) \ && !defined(WIN32) # include <netdb.h> @@ -363,6 +427,10 @@ typedef int _Xgetservbynameparams; /* dummy */ /* UnixWare 2.0, or other systems with thread support but no _r API. */ /* WARNING: The h_addr_list and s_aliases values are *not* copied! */ +#if defined(__NetBSD__) || defined(__FreeBSD__) +#include <sys/param.h> +#endif + typedef struct { struct hostent hent; char h_name[MAXHOSTNAMELEN]; @@ -374,6 +442,9 @@ typedef struct { char s_proto[255]; struct servent *sptr; } _Xgetservbynameparams; + +# define XTHREADS_NEEDS_BYNAMEPARAMS + # define _Xg_copyHostent(hp) \ (memcpy(&(hp).hent, (hp).hptr, sizeof(struct hostent)), \ strcpy((hp).h_name, (hp).hptr->h_name), \ @@ -420,6 +491,8 @@ typedef struct { # define X_POSIX_THREAD_SAFE_FUNCTIONS 1 # endif +# define XTHREADS_NEEDS_BYNAMEPARAMS + # ifndef X_POSIX_THREAD_SAFE_FUNCTIONS typedef struct { struct hostent hent; @@ -546,7 +619,8 @@ typedef struct { # endif } _Xreaddirparams; -# if defined(AIXV3) || defined(AIXV4) || defined(_POSIX_THREAD_SAFE_FUNCTIONS) +# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) || defined(AIXV3) || \ + defined(AIXV4) || defined(__APPLE__) /* AIX defines the draft POSIX symbol, but uses the final API. */ /* POSIX final API, returns (int)0 on success. */ # if defined(__osf__) @@ -765,7 +839,8 @@ typedef struct { #elif !defined(XTHREADS) && !defined(X_FORCE_USE_MTSAFE_API) /* Use regular, unsafe API. */ typedef int _Xstrtokparams; /* dummy */ -# define _XStrtok(s1,s2,p) strtok((s1),(s2)) +# define _XStrtok(s1,s2,p) \ + ( (void)(p), strtok((s1),(s2)) ) #elif !defined(XOS_USE_MTSAFE_STRINGAPI) || defined(XNO_MTSAFE_STRINGAPI) /* Systems with thread support but no _r API. */ |