summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1997-11-29 00:35:30 -0800
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-12-10 10:41:25 +0000
commitce637636a41b2fef0be4daa6d9d27b84e0907a74 (patch)
tree9042d85dec63727158133a0f99357eb7ed498d53
parentc4826df72d2d8ad93e7363e4709fc5003146a3cb (diff)
downloadperl-ce637636a41b2fef0be4daa6d9d27b84e0907a74.tar.gz
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
-rwxr-xr-xConfigure134
-rw-r--r--README.threads6
-rw-r--r--config_h.SH12
-rw-r--r--ext/DynaLoader/dl_aix.xs59
-rw-r--r--global.sym4
-rw-r--r--hints/aix.sh21
6 files changed, 155 insertions, 81 deletions
diff --git a/Configure b/Configure
index b8618cbe2b..36cb6d4cab 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 <<EOM
+Your system uses $xxx for the 1st argument to gethostbyaddr.
+and the 2nd argument to gethostbyaddr is $yyy.
+EOM
break
fi
done
@@ -9311,6 +9295,11 @@ EOCP
gethbadd_alen_type="$ans"
fi
$rm -f try.[co]
+ else
+ $cat >&4 <<EOM
+Your system uses $gethbadd_addr_type for the 1st argument to gethostbyaddr.
+and the 2nd argument to gethostbyaddr is $gethbadd_alen_type.
+EOM
fi
;;
*) gethbadd_addr_type='void *'
@@ -9323,7 +9312,7 @@ esac
: getnetbyaddr.
case "$d_getnbadd" in
$define)
- if test "X$getnbadd_addr_type" = X -o "X$getnbadd_alen_type" = X; then
+ if test "X$getnbadd_net_type" = X; then
$cat <<EOM
Checking to see what type of arguments are expected by getnetbyaddr().
@@ -9370,6 +9359,8 @@ EOCP
getnbadd_net_type="$ans"
fi
$rm -f try.[co]
+ else
+ echo "Your system uses $getnbadd_net_type for the 1st argument to getnetbyaddr." >&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 <<EOCP
/* Note: this program returns 1 if detached, 0 if not.
* Easier this way because the PTHREAD_CREATE_DETACHED is more
@@ -9933,37 +9924,76 @@ echo 'Checking whether pthreads are created joinable.' >&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 <<EOP
+#include <pthread.h>
+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 427f38ad74..db54f7a1ce 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 <Hannu.Napari@hut.fi> 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 7b625e3119..33009ab3c2 100644
--- a/config_h.SH
+++ b/config_h.SH
@@ -572,12 +572,6 @@ sed <<!GROK!THIS! >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 <<!GROK!THIS! >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 <dirent.h>. See I_DIRENT.
diff --git a/ext/DynaLoader/dl_aix.xs b/ext/DynaLoader/dl_aix.xs
index 548fe41a9c..4e865edd3b 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 8b8c922bbf..969f752ab6 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 41706ac3a6..569a292870 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 <<EOM
+Unknown C compiler '$cc'.
+For pthreads you should use the AIX C compilers xlc_r or cc_r.
+Cannot continue, aborting.
+EOM
exit 1
;;
esac
- # Add the POSIX threads library and use the re-entrant libc.
+ # Add the POSIX threads library and the re-entrant libc.
- lddlflags=`echo $lddlflags | sed 's/ -lc$/ -lpthreads -lc_r/'`
+ lddlflags=`echo $lddlflags | sed 's/ -lc$/ -lpthreads -lc_r -lc/'`
fi