From: Jarkko Hietaniemi Date: Sat, 29 Nov 1997 08:35:30 +0000 (-0800) Subject: Patches for IRIX, AIX and some generic stuff: X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ce637636a41b2fef0be4daa6d9d27b84e0907a74;p=p5sagit%2Fp5-mst-13.2.git Patches for IRIX, AIX and some generic stuff: Subject: [PATCH] _55: Mostly AIX stuff but also IRIX and generic (checked/ignored a few rejects; tweaked wording). p4raw-id: //depot/perl@354 --- diff --git a/Configure b/Configure index b8618cb..36cb6d4 100755 --- a/Configure +++ b/Configure @@ -493,6 +493,7 @@ i_netdb='' i_neterrno='' i_niin='' i_sysin='' +d_pthreads_created_joinable='' d_pwage='' d_pwchange='' d_pwclass='' @@ -603,7 +604,6 @@ installprivlib='' privlib='' privlibexp='' prototype='' -pthreads_created_joinable='' randbits='' installscript='' scriptdir='' @@ -2100,7 +2100,7 @@ rp='What is your architecture name' . ./myread case "$usethreads" in $define) archname="$ans-thread" - echo "usethreads selected... architecture name is now $archname." >&4 + echo "Threads selected... architecture name is now $archname." >&4 ;; *) archname="$ans" ;; esac @@ -6613,10 +6613,6 @@ eval $inlibc set gethostbyaddr d_gethbadd eval $inlibc -: see if getnetbyaddr exists -set getnetbyaddr d_getnbadd -eval $inlibc - : see if gethostent exists set gethostent d_gethent eval $inlibc @@ -6625,6 +6621,10 @@ eval $inlibc set getlogin d_getlogin eval $inlibc +: see if getnetbyaddr exists +set getnetbyaddr d_getnbadd +eval $inlibc + : see if getpgid exists set getpgid d_getpgid eval $inlibc @@ -8552,24 +8552,6 @@ EOM *) groupstype="$gidtype";; esac -case "$usethreads" in -$define) - - : see if sched_yield exists - set sched_yield d_sched_yield - eval $inlibc - - : see if pthread_yield exists - set pthread_yield d_pthread_yield - eval $inlibc - - ;; -*) - d_sched_yield=$undef - d_pthread_yield=$undef - ;; -esac - : see what type lseek is declared as in the kernel set off_t lseektype long stdio.h sys/types.h eval $typedef @@ -9289,8 +9271,10 @@ EOCP if $cc $ccflags -c -DGethbadd_addr_t="$xxx" -DGethbadd_alen_t="$yyy" try.c >/dev/null 2>&1 ; then gethbadd_addr_type="$xxx" gethbadd_alen_type="$yyy" - echo "Your system uses $xxx for the 1st argument to gethostbyaddr." >&4 - echo "and the the 2nd argument to gethostbyaddr is $yyy." >&4 + $cat >&4 <&4 <&4 fi ;; *) getnbadd_net_type='long' @@ -9919,8 +9910,8 @@ eval $setvar : test whether pthreads are created in joinable -- aka undetached -- state if test "X$usethreads" != X; then -echo " " -echo 'Checking whether pthreads are created joinable.' >&4 + if test "X$d_pthreads_created_joinable" = X; then + echo >&4 "Checking whether pthreads are created joinable." $cat >try.c <&4 int main() { pthread_attr_t attr; int detachstate; - pthread_attr_init(&attr); - pthread_attr_getdetachstate(&attr, &detachstate); printf("%s\n", - detachstate == PTHREAD_CREATE_DETACHED ? - "detached" : "joinable"); + pthread_attr_init(&attr) == 0 && + pthread_attr_getdetachstate(&attr, &detachstate) == 0 && + detachstate == PTHREAD_CREATE_DETACHED ? + "detached" : "joinable"); exit(0); } EOCP - if $cc $ccflags $ldflags -o try try.c $libs >/dev/null 2>&1; then - yyy=`./try` - else - echo "(I can't seem to compile the test program--assuming they are.)" - yyy=joinable + : Compile and link separately because the used cc might not be + : able to link the right CRT and libs for pthreading. + if $cc $ccflags -c try.c >/dev/null 2>&1 && + $ld $lddlflags $ldflags -o try try$obj_ext $libs >/dev/null 2>&1; then + yyy=`./try` + else + echo "(I can't execute the test program--assuming they are.)" + yyy=joinable + fi + case "$yyy" in + joinable) + val="$define" + echo "Yup, they are." + ;; + *) + val="$undef" + echo "Nope, they aren't." + ;; + esac + set d_pthreads_created_joinable + eval $setvar + $rm -f try try.* fi - case "$yyy" in - joinable) - val="$define" - echo "Yup, they are." - ;; - *) - val="$undef" - echo "Nope, they aren't." - ;; - esac - set d_pthreads_created_joinable - eval $setvar - $rm -f try try.* else d_pthreads_created_joinable=$undef fi +: see whether the various POSIXish _yields exist within given cccmd +$cat >try.c < +main() { + YIELD(); + exit(0); +} +EOP +: see if pthread_yield exists within given cccmd, +: if we do not usethreads this may well end up undef. +if $cc $ccflags -DYIELD=pthread_yield $ldflags -o try try.c $libs > /dev/null 2>&1; then + val="$define" + echo 'pthread_yield() found.' >&4 +else + val="$undef" + echo 'pthread_yield() NOT found.' >&4 +fi +set d_pthread_yield +eval $setvar + +: see if sched_yield exists within given cccmd, +: if we do not usethreads this may well end up undef. +if $cc $ccflags -DYIELD=sched_yield $ldflags -o try try.c $libs > /dev/null 2>&1; then + val="$define" + echo 'sched_yield() found.' >&4 +else + val="$undef" + echo 'sched_yield() NOT found.' >&4 +fi +set d_sched_yield +eval $setvar + +: common to both the pthread_yield and sched_yield tests +rm -f try try.* + echo " " echo "Looking for extensions..." >&4 cd ../ext @@ -10340,6 +10370,7 @@ d_pipe='$d_pipe' d_poll='$d_poll' d_portable='$d_portable' d_pthread_yield='$d_pthread_yield' +d_pthreads_created_joinable='$d_pthreads_created_joinable' d_pwage='$d_pwage' d_pwchange='$d_pwchange' d_pwclass='$d_pwclass' @@ -10608,7 +10639,6 @@ prefixexp='$prefixexp' privlib='$privlib' privlibexp='$privlibexp' prototype='$prototype' -pthreads_created_joinable='$pthreads_created_joinable' randbits='$randbits' ranlib='$ranlib' rd_nodata='$rd_nodata' diff --git a/README.threads b/README.threads index 427f38a..db54f7a 100644 --- a/README.threads +++ b/README.threads @@ -70,6 +70,12 @@ For IRIX: For IRIX 6.3 and 6.4 the pthreads should work out of the box. Thanks to Hannu Napari for the IRIX pthreads patches information. +For AIX: + Change cc to xlc_r or cc_r. + Add -DUSE_THREADS -DNEED_PTHREAD_INIT -DDEBUGGING to ccflags and cppflags + Change optimize to -g + Add -lc_r to libswanted + Change -lc in lddflags to be -lpthread -lc_r -lc Now you can do a make diff --git a/config_h.SH b/config_h.SH index 7b625e3..33009ab 100644 --- a/config_h.SH +++ b/config_h.SH @@ -572,12 +572,6 @@ sed <config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$d_pthread_yield HAS_PTHREAD_YIELD -/* HAS_SCHED_YIELD: - * This symbol, if defined, indicates that the sched_yield routine is - * available to yield the execution of the current thread. - */ -#$d_sched_yield HAS_SCHED_YIELD - /* HAS_READDIR: * This symbol, if defined, indicates that the readdir routine is * available to read directory entries. You may have to include @@ -585,6 +579,12 @@ sed <config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un- */ #$d_readdir HAS_READDIR /**/ +/* HAS_SCHED_YIELD: + * This symbol, if defined, indicates that the sched_yield + * routine is available to yield the execution of the current thread. + */ +#$d_sched_yield HAS_SCHED_YIELD + /* HAS_SEEKDIR: * This symbol, if defined, indicates that the seekdir routine is * available. You may have to include . See I_DIRENT. diff --git a/ext/DynaLoader/dl_aix.xs b/ext/DynaLoader/dl_aix.xs index 548fe41..4e865ed 100644 --- a/ext/DynaLoader/dl_aix.xs +++ b/ext/DynaLoader/dl_aix.xs @@ -77,16 +77,63 @@ static int readExports(ModulePtr); static void terminate(void); static void *findMain(void); +static char *strerror_failed = "(strerror failed)"; +static char *strerror_r_failed = "(strerror_r failed)"; + char *strerrorcat(char *str, int err) { - char buf[8192]; - strerror_r(err, buf, sizeof(buf)); - strcat(str,buf); + int strsiz = strlen(str); + int msgsiz; + char *msg; + +#ifdef USE_THREADS + char *buf = malloc(BUFSIZ); + + if (buf == 0) + return 0; + if (strerror_r(err, buf, sizeof(buf)) == 0) + msg = buf; + else + msg = strerror_r_failed; + msgsiz = strlen(msg); + if (strsiz + msgsiz < BUFSIZ) + strcat(str, msg); + free(buf); +#else + if ((msg = strerror(err)) == 0) + msg = strerror_failed; + msgsiz = strlen(msg); /* Note msg = buf and free() above. */ + if (strsiz + msgsiz < BUFSIZ) /* Do not move this after #endif. */ + strcat(str, msg); +#endif + return str; } + char *strerrorcpy(char *str, int err) { - char buf[8192]; - strerror_r(err, buf, sizeof(buf)); - strcpy(str,buf); + int msgsiz; + char *msg; + +#ifdef USE_THREADS + char *buf = malloc(BUFSIZ); + + if (buf == 0) + return 0; + if (strerror_r(err, buf, sizeof(buf)) == 0) + msg = buf; + else + msg = strerror_r_failed; + msgsiz = strlen(msg); + if (msgsiz < BUFSIZ) + strcpy(str, msg); + free(buf); +#else + if ((msg = strerror(err)) == 0) + msg = strerror_failed; + msgsiz = strlen(msg); /* Note msg = buf and free() above. */ + if (msgsiz < BUFSIZ) /* Do not move this after #endif. */ + strcpy(str, msg); +#endif + return str; } diff --git a/global.sym b/global.sym index 8b8c922..969f752 100644 --- a/global.sym +++ b/global.sym @@ -81,11 +81,8 @@ psig_name psig_ptr rcsid reall_srchlen -regdump regexec_flags regkind -regnext -regprop repeat_amg repeat_ass_amg rshift_amg @@ -881,7 +878,6 @@ q ref refkids regdump -regexec_flags regnext regprop repeatcpy diff --git a/hints/aix.sh b/hints/aix.sh index 41706ac..569a292 100644 --- a/hints/aix.sh +++ b/hints/aix.sh @@ -84,24 +84,19 @@ if [ "X$usethreads" != "X" ]; then xlc_r | cc_r) ;; cc | '') - cc=xlc_r + cc=xlc_r # Let us be stricter. ;; *) - case "$cc" in - gcc) - echo >&4 "You cannot use POSIX threads from GNU cc in AIX." - ;; - *) - echo >&4 "Unknown C compiler." - ;; - esac - echo >&4 "You should use the AIX C compilers called xlc_r or cc_r." - echo >&4 "Cannot continue, aborting." + cat >&4 <