diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-17 14:53:41 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-17 14:53:41 +0000 |
commit | e6e7e605dfd1c8f7e052b3078d809836c27a2fc0 (patch) | |
tree | 5972458fc15d27405707798f84a3ff72dcff1705 /Configure | |
parent | c5b94a97fd82571950babee90bae3a327a5936a9 (diff) | |
download | perl-e6e7e605dfd1c8f7e052b3078d809836c27a2fc0.tar.gz |
Small tidying up of the selectminbits code, but most
importantly allocate the buffer from the heap using
malloc, not from the stack: using stack causes unaligned
access in LP64 Solaris since stack data is not guaranteed
to be 64-bit aligned, while a fd_set is (it has 1024 longs).
(via Alan Burlison)
p4raw-id: //depot/perl@19248
Diffstat (limited to 'Configure')
-rwxr-xr-x | Configure | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -20,7 +20,7 @@ # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $ # -# Generated on Wed Apr 16 12:35:41 EET DST 2003 [metaconfig 3.0 PL70] +# Generated on Thu Apr 17 18:50:57 EET DST 2003 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.org) cat >c1$$ <<EOF @@ -18673,7 +18673,8 @@ esac : check for the select 'width' case "$selectminbits" in -'') case "$d_select" in +'') safebits=`expr $ptrsize \* 8` + case "$d_select" in $define) $cat <<EOM @@ -18715,19 +18716,21 @@ $selecttype b; #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8) #define NBITS (NBYTES * 8) int main() { - char s[NBYTES]; + char *s = malloc(NBYTES); struct timeval t; int i; FILE* fp; int fd; + if (!s) + exit(1); fclose(stdin); fp = fopen("try.c", "r"); if (fp == 0) - exit(1); + exit(2); fd = fileno(fp); if (fd < 0) - exit(2); + exit(3); b = ($selecttype)s; for (i = 0; i < NBITS; i++) FD_SET(i, b); @@ -18735,6 +18738,7 @@ int main() { t.tv_usec = 0; select(fd + 1, b, 0, 0, &t); for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--); + free(s); printf("%d\n", i + 1); return 0; } @@ -18745,10 +18749,10 @@ EOCP case "$selectminbits" in '') cat >&4 <<EOM Cannot figure out on how many bits at a time your select() operates. -I'll play safe and guess it is 32 bits. +I'll play safe and guess it is $safebits bits. EOM - selectminbits=32 - bits="32 bits" + selectminbits=$safebits + bits="$safebits bits" ;; 1) bits="1 bit" ;; *) bits="$selectminbits bits" ;; @@ -18757,7 +18761,8 @@ EOM else rp='What is the minimum number of bits your select() operates on?' case "$byteorder" in - 1234|12345678) dflt=32 ;; + 12345678) dflt=64 ;; + 1234) dflt=32 ;; *) dflt=1 ;; esac . ./myread @@ -18767,7 +18772,7 @@ EOM $rm -f try.* try ;; *) : no select, so pick a harmless default - selectminbits='32' + selectminbits=$safebits ;; esac ;; |