summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xConfigure134
-rw-r--r--config_h.SH14
-rw-r--r--embed.h2
-rw-r--r--global.sym1
-rw-r--r--objXSUB.h2
-rw-r--r--perl.h6
-rw-r--r--proto.h1
-rw-r--r--util.c34
8 files changed, 181 insertions, 13 deletions
diff --git a/Configure b/Configure
index e4f5cbb483..4a9ea7019e 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 12 14:07:09 EET DST 1999 [metaconfig 3.0 PL70]
+# Generated on Thu May 13 15:54:16 EET DST 1999 [metaconfig 3.0 PL70]
# (with additional metaconfig patches by perlbug@perl.com)
cat >/tmp/c1$$ <<EOF
@@ -573,6 +573,7 @@ usedl=''
doublesize=''
ebcdic=''
fflushNULL=''
+fflushall=''
fpostype=''
gidtype=''
groupstype=''
@@ -797,6 +798,7 @@ d_fsetpos64=''
d_ftell64=''
d_ftello64=''
d_tmpfile64=''
+stdio_stream_array=''
sysman=''
trnl=''
uidtype=''
@@ -10918,29 +10920,93 @@ $rm -f tebcdic.c tebcdic
set ebcdic
eval $setvar
-: check for fflush NULL behaviour
-case "$fflushNULL" in
-'') $cat <<EOM
+$cat >&4 <<EOM
+Checking how to access stdio streams by file descriptor number...
+EOM
+case "$stdio_stream_array" in
+'') $cat >try.c <<EOCP
+#include <stdio.h>
+int main() {
+ if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
+ printf("yes\n");
+}
+EOCP
+ for s in _iob __iob __sF
+ do
+ set try -DSTDIO_STREAM_ARRAY=$s
+ if eval $compile_ok; then
+ case "`./try$exe_ext`" in
+ yes) stdio_stream_array=$s; break ;;
+ esac
+ fi
+ done
+ $rm -f try.* try$exe_ext
+esac
+case "$stdio_stream_array" in
+'') $cat >&4 <<EOM
+I can't figure out how to access stdio streams by file descriptor number.
+EOM
+ ;;
+*) $cat >&4 <<EOM
+You can access stdio streams by file descriptor number by using $stdio_stream_array.
+EOM
+ ;;
+esac
-Checking to see whether fflush(NULL) flushes all pending stdio output...
+$cat >&4 <<EOM
+Checking how to flush all pending stdio output...
EOM
- $cat >try.c <<EOCP
+$cat >try.c <<EOCP
#include <stdio.h>
+#$i_unistd I_UNISTD
+#ifdef I_UNISTD
+#include <unistd.h>
+#endif
+#$d_sysconf HAS_SYSCONF
int main() {
FILE* p = fopen("try.out", "w");
fputc('x', p);
+#ifdef TRY_FFLUSH_NULL
fflush(NULL);
- _exit(0);
+#endif
+#ifdef TRY_FFLUSH_ALL
+ {
+ long open_max = -1;
+# if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
+ open_max = sysconf(_SC_OPEN_MAX);
+# else
+# ifdef FOPEN_MAX
+# open_max = FOPEN_MAX;
+# else
+# ifdef OPEN_MAX
+# open_max = OPEN_MAX;
+# else
+# ifdef _NFILE
+# open_max = _NFILE;
+# endif
+# endif
+# endif
+# endif
+ if (open_max > 0) {
+ long i;
+ for (i = 0; i < open_max; i++)
+ fflush(&$stdio_stream_array[i]);
+ }
+ }
+#endif
+ _exit(42);
}
EOCP
- set try
+: check for fflush NULL behaviour
+case "$fflushNULL" in
+'') set try -DTRY_FFLUSH_NULL
$rm -f try.out
if eval $compile_ok; then
./try$exe_ext 2>/dev/null
- $rm -f core try.core core.try.*
- if $test -s try.out; then
+ if $test -s try.out -a "X$?" = X42; then
fflushNULL="`$cat try.out`"
fi
+ $rm -f core try.core core.try.*
fi
case "$fflushNULL" in
x) cat >&4 <<EOM
@@ -10960,7 +11026,6 @@ EOM
fflushNULL=undef
;;
esac
- $rm -f try.* try
;;
$define|true|[yY]*)
fflushNULL=define
@@ -10969,6 +11034,51 @@ $define|true|[yY]*)
fflushNULL=undef
;;
esac
+: check for fflush all behaviour
+case "$fflushall" in
+'') set try -DTRY_FFLUSH_ALL
+ $rm -f try.out
+ if eval $compile_ok; then
+ ./try$exe_ext 2>/dev/null
+ if $test -s try.out -a "X$?" = X42; then
+ fflushall="`$cat try.out`"
+ fi
+ $rm -f core try.core core.try.*
+ fi
+ case "$fflushall" in
+ x) cat >&4 <<EOM
+Flushing explicitly all the stdio streams works.
+EOM
+ fflushall=define
+ ;;
+ '') cat >&4 <<EOM
+Flushing explicitly all the stdio streams doesn't work.
+EOM
+ fflushall=undef
+ ;;
+ *) cat >&4 <<EOM
+Cannot figure out whether flushing stdio stream explicitly works or not.
+I'm assuming it doesn't.
+EOM
+ fflushall=undef
+ ;;
+ esac
+ ;;
+$define|true|[yY]*)
+ fflushall=define
+ ;;
+*)
+ fflushall=undef
+ ;;
+esac
+case "$fflushNULL$fflushall" in
+undefundef)
+ cat <<EOM
+I cannot figure out how to flush pending stdio output.
+EOM
+ ;;
+esac
+$rm -f try.* try$exe_ext
: see what type file positions are declared as in the library
rp="What is the type for file position used by fsetpos()?"
@@ -13058,6 +13168,7 @@ exe_ext='$exe_ext'
expr='$expr'
extensions='$extensions'
fflushNULL='$fflushNULL'
+fflushall='$fflushall'
find='$find'
firstmakefile='$firstmakefile'
flex='$flex'
@@ -13304,6 +13415,7 @@ stdio_bufsiz='$stdio_bufsiz'
stdio_cnt='$stdio_cnt'
stdio_filbuf='$stdio_filbuf'
stdio_ptr='$stdio_ptr'
+stdio_stream_array='$stdio_stream_array'
strings='$strings'
submit='$submit'
subversion='$subversion'
diff --git a/config_h.SH b/config_h.SH
index 81dfcaab25..1899e6c584 100644
--- a/config_h.SH
+++ b/config_h.SH
@@ -2217,7 +2217,13 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un-
* This symbol, if defined, tells that fflush(NULL) does flush
* all pending stdio output.
*/
-#$fflushNULL FFLUSH_NULL /**/
+/* FFLUSH_ALL:
+ * This symbol, if defined, tells that to flush
+ * all pending stdio output one must loop through all
+ * the stdio file handles and fflush them.
+ */
+#$fflushNULL FFLUSH_NULL /**/
+#$fflushall FFLUSH_ALL /**/
/* DB_Prefix_t:
* This symbol contains the type of the prefix structure element
@@ -2457,6 +2463,12 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un-
#$d_ftello64 HAS_FTELLO64 /**/
#$d_tmpfile64 HAS_TMPFILE64 /**/
+/* STDIO_STREAM_ARRAY:
+ * This symbol tells the name of the array holding the stdio stream_array,
+ * if any. Usual values include _iob, __iob, and __sF.
+ */
+#define STDIO_STREAM_ARRAY $stdio_stream_array
+
/* USE_64_BITS:
* This symbol, if defined, indicates that 64-bit interfaces should
* be used when available. If not defined, the native default interfaces
diff --git a/embed.h b/embed.h
index aba2f59129..8c2474ad2d 100644
--- a/embed.h
+++ b/embed.h
@@ -320,6 +320,7 @@
#define my_chsize Perl_my_chsize
#define my_exit Perl_my_exit
#define my_failure_exit Perl_my_failure_exit
+#define my_fflush_all Perl_my_fflush_all
#define my_htonl Perl_my_htonl
#define my_lstat Perl_my_lstat
#define my_memcmp Perl_my_memcmp
@@ -1378,6 +1379,7 @@
#define my_exit CPerlObj::Perl_my_exit
#define my_exit_jump CPerlObj::Perl_my_exit_jump
#define my_failure_exit CPerlObj::Perl_my_failure_exit
+#define my_fflush_all CPerlObj::Perl_my_fflush_all
#define my_htonl CPerlObj::Perl_my_htonl
#define my_lstat CPerlObj::Perl_my_lstat
#define my_memcmp CPerlObj::Perl_my_memcmp
diff --git a/global.sym b/global.sym
index 1e739bc773..44417d9444 100644
--- a/global.sym
+++ b/global.sym
@@ -311,6 +311,7 @@ my_bzero
my_chsize
my_exit
my_failure_exit
+my_fflush_all
my_htonl
my_lstat
my_memcmp
diff --git a/objXSUB.h b/objXSUB.h
index 0305bf00cf..f037d3a497 100644
--- a/objXSUB.h
+++ b/objXSUB.h
@@ -1619,6 +1619,8 @@
#define my_exit_jump pPerl->Perl_my_exit_jump
#undef my_failure_exit
#define my_failure_exit pPerl->Perl_my_failure_exit
+#undef my_fflush_all
+#define my_fflush_all pPerl->Perl_my_fflush_all
#undef my_htonl
#define my_htonl pPerl->Perl_my_htonl
#undef my_lstat
diff --git a/perl.h b/perl.h
index 4d8b45ccc4..b6fe80563a 100644
--- a/perl.h
+++ b/perl.h
@@ -1455,8 +1455,12 @@ typedef pthread_key_t perl_key;
* XXX the default needs a Configure test, as it may not work everywhere.
*/
#ifndef PERL_FLUSHALL_FOR_CHILD
-# if (defined(USE_STDIO) && defined(FFLUSH_NULL)) || defined(USE_SFIO)
+# if defined(FFLUSH_NULL) || defined(USE_SFIO)
# define PERL_FLUSHALL_FOR_CHILD PerlIO_flush((PerlIO*)NULL)
+# else
+# ifdef FFLUSH_ALL
+# define PERL_FLUSHALL_FOR_CHILD my_fflush_all()
+# endif
# endif
#endif
diff --git a/proto.h b/proto.h
index f2f45a7b9c..ea364f1b62 100644
--- a/proto.h
+++ b/proto.h
@@ -329,6 +329,7 @@ char* my_bzero _((char* loc, I32 len));
#endif
VIRTUAL void my_exit _((U32 status)) __attribute__((noreturn));
VIRTUAL void my_failure_exit _((void)) __attribute__((noreturn));
+VIRTUAL I32 my_fflush_all _((void));
VIRTUAL I32 my_lstat _((ARGSproto));
#if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP)
VIRTUAL I32 my_memcmp _((const char* s1, const char* s2, I32 len));
diff --git a/util.c b/util.c
index 9ea0851204..79b9f4928e 100644
--- a/util.c
+++ b/util.c
@@ -3195,3 +3195,37 @@ get_vtbl(int vtbl_id)
return result;
}
+I32
+my_fflush_all(void)
+{
+#ifdef FFLUSH_NULL
+ return fflush(NULL);
+#else
+ long open_max = -1;
+# if defined(FFLUSH_ALL) && defined(STDIO_STREAM_ARRAY)
+# if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
+ open_max = sysconf(_SC_OPEN_MAX);
+# else
+# ifdef FOPEN_MAX
+# open_max = FOPEN_MAX;
+# else
+# ifdef OPEN_MAX
+# open_max = OPEN_MAX;
+# else
+# ifdef _NFILE
+# open_max = _NFILE;
+# endif
+# endif
+# endif
+# endif
+ if (open_max > 0) {
+ long i;
+ for (i = 0; i < open_max; i++)
+ fflush(&STDIO_STREAM_ARRAY[i]);
+ return 0;
+ }
+# endif
+ SETERRNO(EBADF,RMS$_IFI);
+ return EOF;
+#endif
+}