# $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$$ <<EOF
set ebcdic
eval $setvar
-# SunOS has a <unistd.h> 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 <<EOM
Checking how to flush all pending stdio output...
EOM
-$cat >try.c <<EOCP
+# I only know how to find the first 32 possibly open files on SunOS.
+# See also hints/sunos_4_1.sh and util.c --AD
+case "$osname" in
+sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
+esac
+$cat >>try.c <<EOCP
#include <stdio.h>
-#$t_unistd I_UNISTD
+#$i_unistd I_UNISTD
#ifdef I_UNISTD
# include <unistd.h>
#endif
#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
i_unistd='undef'
# See util.c for another: We need _SC_OPEN_MAX, which is in
# <unistd.h>.
-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
#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