i_neterrno=''
i_niin=''
i_sysin=''
+d_pthreads_created_joinable=''
d_pwage=''
d_pwchange=''
d_pwclass=''
privlib=''
privlibexp=''
prototype=''
-pthreads_created_joinable=''
randbits=''
installscript=''
scriptdir=''
. ./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
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
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
*) 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
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
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 *'
: 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().
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'
: 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
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
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'
privlib='$privlib'
privlibexp='$privlibexp'
prototype='$prototype'
-pthreads_created_joinable='$pthreads_created_joinable'
randbits='$randbits'
ranlib='$ranlib'
rd_nodata='$rd_nodata'
*/
#$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
*/
#$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.
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;
}