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
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: Copyright (c) 1999, Jarkko Hietaniemi
4 ?RCS:
5 ?RCS: You may redistribute only under the terms of the Artistic License,
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
8 ?RCS: that same Artistic License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?MAKE:d_stdio_stream_array stdio_stream_array: run \
12         Compile cat rm_try Oldconfig Myread Setvar
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  /**/
31 ?H:?%<:#ifdef HAS_STDIO_STREAM_ARRAY
32 ?H:?%<:#define STDIO_STREAM_ARRAY       $stdio_stream_array
33 ?H:?%<:#endif
34 ?H:.
35 ?T:s
36 ?F:!try
37 : Check stream access
38 $cat >&4 <<EOM
39 Checking how to access stdio streams by file descriptor number...
40 EOM
41 case "$stdio_stream_array" in
42 '')     $cat >try.c <<EOCP
43 #include <stdio.h>
44 int main() {
45   if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
46     printf("yes\n");
47 }
48 EOCP
49         for s in _iob __iob __sF
50         do
51                 set try -DSTDIO_STREAM_ARRAY=$s
52                 if eval $compile; then
53                         case "`$run ./try`" in
54                         yes)    stdio_stream_array=$s; break ;;
55                         esac
56                 fi
57         done
58         $rm_try
59 esac
60 case "$stdio_stream_array" in
61 '')     $cat >&4 <<EOM
62 I can't figure out how to access stdio streams by file descriptor number.
63 EOM
64         d_stdio_stream_array="$undef"
65         ;;
66 *)      $cat >&4 <<EOM
67 You can access stdio streams by file descriptor number by the $stdio_stream_array array.
68 EOM
69         d_stdio_stream_array="$define"
70         ;;
71 esac
72