This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / stdio_streams.U
CommitLineData
959f3c4c
JH
1?RCS: $Id$
2?RCS:
3?RCS: Copyright (c) 1999, Jarkko Hietaniemi
0065f4af 4?RCS:
65a32477 5?RCS: You may redistribute only under the terms of the Artistic License,
959f3c4c
JH
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
65a32477 8?RCS: that same Artistic License; a copy of which may be found at the root
959f3c4c
JH
9?RCS: of the source tree for dist 3.0.
10?RCS:
0f00356b 11?MAKE:d_stdio_stream_array stdio_stream_array: run \
2cb64bf6 12 Compile cat rm_try Oldconfig Myread Setvar
959f3c4c
JH
13?MAKE: -pick add $@ %<
14?S:d_stdio_stream_array:
15?S: This variable tells whether there is an array holding
16?S: the stdio streams.
17?S:.
18?S:stdio_stream_array:
19?S: This variable tells the name of the array holding the stdio streams.
20?S: Usual values include _iob, __iob, and __sF.
21?S:.
22?C:HAS_STDIO_STREAM_ARRAY:
23?C: This symbol, if defined, tells that there is an array
24?C: holding the stdio streams.
25?C:.
26?C:STDIO_STREAM_ARRAY:
27?C: This symbol tells the name of the array holding the stdio streams.
28?C: Usual values include _iob, __iob, and __sF.
29?C:.
30?H:#$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY /**/
8ed53ccb
MB
31?H:?%<:#ifdef HAS_STDIO_STREAM_ARRAY
32?H:?%<:#define STDIO_STREAM_ARRAY $stdio_stream_array
33?H:?%<:#endif
959f3c4c
JH
34?H:.
35?T:s
0065f4af 36?F:!try
0065f4af 37: Check stream access
959f3c4c
JH
38$cat >&4 <<EOM
39Checking how to access stdio streams by file descriptor number...
40EOM
41case "$stdio_stream_array" in
42'') $cat >try.c <<EOCP
43#include <stdio.h>
44int main() {
45 if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
46 printf("yes\n");
47}
48EOCP
49 for s in _iob __iob __sF
50 do
51 set try -DSTDIO_STREAM_ARRAY=$s
52 if eval $compile; then
0f00356b 53 case "`$run ./try`" in
959f3c4c
JH
54 yes) stdio_stream_array=$s; break ;;
55 esac
56 fi
57 done
2cb64bf6 58 $rm_try
959f3c4c
JH
59esac
60case "$stdio_stream_array" in
61'') $cat >&4 <<EOM
62I can't figure out how to access stdio streams by file descriptor number.
63EOM
64 d_stdio_stream_array="$undef"
65 ;;
66*) $cat >&4 <<EOM
67You can access stdio streams by file descriptor number by the $stdio_stream_array array.
68EOM
69 d_stdio_stream_array="$define"
70 ;;
71esac
72