[Xcb] Patches to build X11 w/ XCB on Sol
Travis Spencer
tspencer at cs.pdx.edu
Sun Apr 3 10:21:04 PDT 2005
With much Web surfing, patching and some hacking, I was able to build
X11 with XCB on Solaris 9. I ran into these problems:
1) getpwnam_r was being called with the wrong number of parameters.
2) There were some problems with IPv6 stuff.
3) PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP was unsupported.
The first problem I had was that GetDflt.c
(/cvs/xlibs/X11/src/GetDflt.c) wouldn't compile. I got an error
message like this one [1]:
gcc ... -c GetDflt.c ...
GetDflt.c: In function `GetHomeDir':
GetDflt.c:129: error: too few arguments to function `getpwnam_r'
GetDflt.c:131: error: too few arguments to function `getpwuid_r'
make[3]: *** [GetDflt.lo] Error 1
make[3]: Leaving directory `/src/bdefreese/X11/src'
I fixed this by applying the attached patch to Xos_r.h and GetDflt.c
that Robert Millan made a while back. See
http://lists.gnu.org/archive/html/bug-hurd/2004-05/msg00043.html for
more info.
I fixed the second problem by sidestepping it entirely. Rather than
trying to fix the compilation errors I was getting, I just
reconfigured it with the --disable-ipv6 option.
The third problem is probably no surprise; we talked about it a little
on Friday. I'm not sure if my fix is correct, so make sure and have a
good look at it. I don't know much about threads, but I surfed around
and concluded that using PTHREAD_MUTEX_INITIALIZER when
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP isn't available is an OK thing
to do.
There might have been one other thing I had to do, but I can't
remember now. I'll take better notes next time. After these bugs are
fixed, I'll try it again with a clean slate.
--
Regards,
Travis Spencer
[1] This isn't the output that I got; I didn't keep that around. This
is from a post I found on the Net made by someone with the same
problem, so the line numbers might be different.
-------------- next part --------------
Index: Xos_r.h
===================================================================
RCS file: /cvs/xlibs/Xproto/Xos_r.h,v
retrieving revision 1.20
diff -c -r1.20 Xos_r.h
*** Xos_r.h 28 Jan 2005 20:12:03 -0000 1.20
--- Xos_r.h 3 Apr 2005 16:14:08 -0000
***************
*** 201,208 ****
*
* typedef ... _Xgetpwparams;
*
! * struct passwd* _XGetpwnam(const char *name, _Xgetpwparams);
! * struct passwd* _XGetpwuid(uid_t uid, _Xgetpwparams);
*/
#if defined(X_INCLUDE_PWD_H) && !defined(_XOS_INCLUDED_PWD_H)
--- 201,208 ----
*
* typedef ... _Xgetpwparams;
*
! * struct passwd* _XGetpwnam(const char *name, _Xgetpwparams, struct **dummy);
! * struct passwd* _XGetpwuid(uid_t uid, _Xgetpwparams, struct **dummy);
*/
#if defined(X_INCLUDE_PWD_H) && !defined(_XOS_INCLUDED_PWD_H)
***************
*** 222,229 ****
extern struct passwd *getpwuid(), *getpwnam();
# endif
typedef int _Xgetpwparams; /* dummy */
! # define _XGetpwuid(u,p) getpwuid((u))
! # define _XGetpwnam(u,p) getpwnam((u))
#elif !defined(XOS_USE_MTSAFE_PWDAPI) || defined(XNO_MTSAFE_PWDAPI)
/* UnixWare 2.0, or other systems with thread support but no _r API. */
--- 222,229 ----
extern struct passwd *getpwuid(), *getpwnam();
# endif
typedef int _Xgetpwparams; /* dummy */
! # define _XGetpwuid(u,p,s) getpwuid((u))
! # define _XGetpwnam(u,p,s) getpwnam((u))
#elif !defined(XOS_USE_MTSAFE_PWDAPI) || defined(XNO_MTSAFE_PWDAPI)
/* UnixWare 2.0, or other systems with thread support but no _r API. */
***************
*** 300,311 ****
((p).pwp = &(p).pws), \
0 )
#endif
! # define _XGetpwuid(u,p) \
( (_Xos_processLock), \
(((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 : 0), \
(_Xos_processUnlock), \
--- 300,311 ----
((p).pwp = &(p).pws), \
0 )
#endif
! # define _XGetpwuid(u,p,s) \
( (_Xos_processLock), \
(((p).pwp = getpwuid((u))) ? _Xpw_copyPasswd(p), 0 : 0), \
(_Xos_processUnlock), \
(p).pwp )
! # define _XGetpwnam(u,p,s) \
( (_Xos_processLock), \
(((p).pwp = getpwnam((u))) ? _Xpw_copyPasswd(p), 0 : 0), \
(_Xos_processUnlock), \
***************
*** 320,340 ****
} _Xgetpwparams;
# 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) \
! ((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)
! # define _XGetpwnam(u,p) \
! ((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf)) == NULL) ? NULL : &(p).pws)
# endif /* SVR4 */
#else /* _POSIX_THREAD_SAFE_FUNCTIONS */
--- 320,340 ----
} _Xgetpwparams;
# if defined(_POSIX_REENTRANT_FUNCTIONS) || !defined(SVR4) || defined(Lynx)
# ifndef Lynx
! # define _XGetpwuid(u,p,s) \
! ((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),(s)) == -1) ? NULL : &(p).pws)
! # define _XGetpwnam(u,p,s) \
! ((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),(s)) == -1) ? NULL : &(p).pws)
# else /* Lynx */
! # define _XGetpwuid(u,p,s) \
! ((getpwuid_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf),(s)) == -1) ? NULL : &(p).pws)
! # define _XGetpwnam(u,p,s) \
! ((getpwnam_r(&(p).pws,(u),(p).pwbuf,sizeof((p).pwbuf),(s)) == -1) ? NULL : &(p).pws)
# endif
# else /* SVR4 */
! # define _XGetpwuid(u,p,s) \
! ((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),(s)) == NULL) ? NULL : &(p).pws)
! # define _XGetpwnam(u,p,s) \
! ((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),(s)) == NULL) ? NULL : &(p).pws)
# endif /* SVR4 */
#else /* _POSIX_THREAD_SAFE_FUNCTIONS */
***************
*** 351,360 ****
struct passwd* pwp;
} _Xgetpwparams;
typedef int _Xgetpwret;
! # define _XGetpwuid(u,p) \
((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == -1) ? \
NULL : (p).pwp)
! # define _XGetpwnam(u,p) \
((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == -1) ? \
NULL : (p).pwp)
#endif /* X_INCLUDE_PWD_H */
--- 351,360 ----
struct passwd* pwp;
} _Xgetpwparams;
typedef int _Xgetpwret;
! # define _XGetpwuid(u,p,s) \
((getpwuid_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == -1) ? \
NULL : (p).pwp)
! # define _XGetpwnam(u,p,s) \
((getpwnam_r((u),&(p).pws,(p).pwbuf,sizeof((p).pwbuf),&(p).pwp) == -1) ? \
NULL : (p).pwp)
#endif /* X_INCLUDE_PWD_H */
-------------- next part --------------
Index: xcblock.c
===================================================================
RCS file: /cvs/xlibs/X11/src/xcl/xcblock.c,v
retrieving revision 1.10
diff -c -w -c -r1.10 xcblock.c
*** xcblock.c 2 Apr 2005 23:22:54 -0000 1.10
--- xcblock.c 3 Apr 2005 16:44:03 -0000
***************
*** 1,8 ****
--- 1,12 ----
/* Copyright (C) 2003-2004 Jamey Sharp.
* This file is licensed under the MIT license. See the file COPYING. */
+ #ifdef __GLIBC__
#define _GNU_SOURCE /* for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP */
#include <features.h>
+ #else
+ #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER;
+ #endif /* __GLIBC__ */
#include "Xlibint.h"
#include "locking.h"
-------------- next part --------------
Index: GetDflt.c
===================================================================
RCS file: /cvs/xlibs/X11/src/GetDflt.c,v
retrieving revision 3.25
diff -c -w -r3.25 GetDflt.c
*** GetDflt.c 28 Jun 2004 19:00:43 -0000 3.25
--- GetDflt.c 3 Apr 2005 16:15:16 -0000
***************
*** 125,134 ****
(void) strncpy(dest, ptr, len-1);
dest[len-1] = '\0';
} else {
if ((ptr = getenv("USER")))
! pw = _XGetpwnam(ptr,pwparams);
else
! pw = _XGetpwuid(getuid(),pwparams);
if (pw != NULL) {
(void) strncpy(dest, pw->pw_dir, len-1);
dest[len-1] = '\0';
--- 125,135 ----
(void) strncpy(dest, ptr, len-1);
dest[len-1] = '\0';
} else {
+ struct passwd *dummy;
if ((ptr = getenv("USER")))
! pw = _XGetpwnam(ptr,pwparams,&dummy);
else
! pw = _XGetpwuid(getuid(),pwparams,&dummy);
if (pw != NULL) {
(void) strncpy(dest, pw->pw_dir, len-1);
dest[len-1] = '\0';
More information about the xcb
mailing list