From: Andy Dougherty Date: Thu, 27 May 1999 12:26:28 +0000 (-0400) Subject: Re: 5.005_57 NOT OK on SunOS 4.1.3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d2201af29f5816f4d8147ff7af9b9a71b084ce41;p=p5sagit%2Fp5-mst-13.2.git Re: 5.005_57 NOT OK on SunOS 4.1.3 To: Perl Porters Message-Id: p4raw-id: //depot/cfgperl@3488 --- diff --git a/Configure b/Configure index bb507e4..2cc2bf4 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 May 26 01:56:24 EET DST 1999 [metaconfig 3.0 PL70] +# Generated on Thu May 27 19:42:20 EET DST 1999 [metaconfig 3.0 PL70] # (with additional metaconfig patches by perlbug@perl.com) cat >/tmp/c1$$ < which we generally avoid, but need for this test. -# For everyone else, we'll trust i_unistd. -t_unistd=$i_unistd -case "$osname" in -sunos) $test -f /usr/include/unistd.h && t_unistd=$define ;; -esac $cat >&4 <try.c < try.c ;; +esac +$cat >>try.c < -#$t_unistd I_UNISTD +#$i_unistd I_UNISTD #ifdef I_UNISTD # include #endif @@ -10997,26 +10996,32 @@ int main() { #ifdef TRY_FFLUSH_ALL { long open_max = -1; -# if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX) - open_max = sysconf(_SC_OPEN_MAX); +# ifdef PERL_FFLUSH_ALL_FOPEN_MAX + open_max = PERL_FFLUSH_ALL_FOPEN_MAX; # else -# ifdef FOPEN_MAX -# open_max = FOPEN_MAX; +# if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX) + open_max = sysconf(_SC_OPEN_MAX); # else -# ifdef OPEN_MAX -# open_max = OPEN_MAX; +# ifdef FOPEN_MAX + open_max = FOPEN_MAX; # else -# ifdef _NFILE -# open_max = _NFILE; +# ifdef OPEN_MAX + open_max = OPEN_MAX; +# else +# ifdef _NFILE + open_max = _NFILE; +# endif # endif # endif # endif -# endif # ifdef HAS_STDIO_STREAM_ARRAY if (open_max > 0) { long i; for (i = 0; i < open_max; i++) - fflush(&$stdio_stream_array[i]); + if (STDIO_STREAM_ARRAY[i]._file >= 0 && + STDIO_STREAM_ARRAY[i]._file < open_max && + STDIO_STREAM_ARRAY[i]._flag) + fflush(&STDIO_STREAM_ARRAY[i]); } } # endif diff --git a/hints/sunos_4_1.sh b/hints/sunos_4_1.sh index 6d94bdb..af0bca1 100644 --- a/hints/sunos_4_1.sh +++ b/hints/sunos_4_1.sh @@ -30,7 +30,15 @@ d_tzname='undef' i_unistd='undef' # See util.c for another: We need _SC_OPEN_MAX, which is in # . -util_cflags='ccflags="$ccflags -DI_UNISTD"' + +# fflush(NULL) will core dump on SunOS 4.1.3. In util.c we'll +# try explicitly fflushing all open files. Unfortunately, +# on my SunOS 4.1.3 system, sysconf(_SC_OPEN_MAX) returns +# 64, but only 32 of those file pointers can be accessed +# directly by _iob[i]. The remainder are off in dynamically +# allocated memory somewhere and I don't know to automatically +# fflush() them. -- Andy Dougherty Wed May 26 15:25:22 EDT 1999 +util_cflags='ccflags="$ccflags -DPERL_FFLUSH_ALL_FOPEN_MAX=32"' cat << 'EOM' >&4 diff --git a/util.c b/util.c index 82f6ea6..5615d47 100644 --- a/util.c +++ b/util.c @@ -3333,25 +3333,32 @@ my_fflush_all(void) #else long open_max = -1; # if defined(FFLUSH_ALL) && defined(HAS_STDIO_STREAM_ARRAY) +# ifdef PERL_FFLUSH_ALL_FOPEN_MAX + open_max = PERL_FFLUSH_ALL_FOPEN_MAX; +# else # if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX) open_max = sysconf(_SC_OPEN_MAX); # else # ifdef FOPEN_MAX -# open_max = FOPEN_MAX; + open_max = FOPEN_MAX; # else # ifdef OPEN_MAX -# open_max = OPEN_MAX; + open_max = OPEN_MAX; # else # ifdef _NFILE -# open_max = _NFILE; + open_max = _NFILE; # endif # endif # endif # endif +# endif if (open_max > 0) { long i; for (i = 0; i < open_max; i++) - PerlIO_flush(&STDIO_STREAM_ARRAY[i]); + if (STDIO_STREAM_ARRAY[i]._file >= 0 && + STDIO_STREAM_ARRAY[i]._file < open_max && + STDIO_STREAM_ARRAY[i]._flag) + PerlIO_flush(&STDIO_STREAM_ARRAY[i]); return 0; } # endif