From: Jarkko Hietaniemi Date: Thu, 17 Apr 2003 14:53:41 +0000 (+0000) Subject: Small tidying up of the selectminbits code, but most X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e6e7e605dfd1c8f7e052b3078d809836c27a2fc0;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/Configure b/Configure index 5e3de68..14bba08 100755 --- a/Configure +++ b/Configure @@ -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$$ < 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 <