Subject: | Does not compile under Solaris for multi-threaded perl |
I'm trying to compile Proc::ProcessTable for Solaris 8 with multi-threaded Perl 5.8.1 . This gives an error message because readdir_r is defined differently for POSIX compiles:
gcc -c -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -DNO_HASH_SEED -fno-strict-aliasing -O -DVERSION=\"0.39\" -DXS_VERSION=\"0.39\" -fPIC "-I/usr/local/ActivePerl-5.8/lib/5.8.3/sun4-solaris-thread-multi/CORE" -DPROCESSTABLE_THREAD -DPROC_FS OS.c
OS.c: In function `OS_get_table':
OS.c:46: error: too few arguments to function `readdir_r'
*** Error code 1
make: Fatal error: Command failed for target `OS.o'
The fix is the following patch:
*** os/Solaris.c.old Wed May 25 09:58:38 2005
--- os/Solaris.c Wed May 25 10:18:48 2005
***************
*** 40,49 ****
char pctcpu[7];
int numthr;
char pctmem[7];
!
if( (procdir = opendir( "/proc" )) == NULL ) return;
! while( readdir_r(procdir, procdirp) != NULL ){
/* Only look at this file if it's a proc id; that is, all numbers */
if( strtok(procdirp->d_name, "0123456789") != NULL ){ continue; }
--- 40,58 ----
char pctcpu[7];
int numthr;
char pctmem[7];
!
! /* MR: quick hack for different readdir_r versions */
! #if defined(_POSIX_PTHREAD_SEMANTICS)
! struct dirent *procdirp_r;
! #endif
!
if( (procdir = opendir( "/proc" )) == NULL ) return;
! #if defined(_POSIX_PTHREAD_SEMANTICS)
! while( readdir_r(procdir, procdirp, &procdirp_r ) == 0 && procdirp_r != NULL ){
! #else
! while( readdir_r(procdir, procdirp ) != NULL ){
! #endif
/* Only look at this file if it's a proc id; that is, all numbers */
if( strtok(procdirp->d_name, "0123456789") != NULL ){ continue; }
------------------------------------------------------