]> git.ipfire.org Git - thirdparty/bash.git/blob - portbash/stdio.sh
Imported from ../bash-1.14.7.tar.gz.
[thirdparty/bash.git] / portbash / stdio.sh
1 #! /bin/sh
2 #
3 # test certain aspects of stdio
4 CC=cc
5 export CC
6
7 cat > x.c << EOF
8 #include <stdio.h>
9 #include <varargs.h>
10
11 xp(va_alist)
12 va_dcl
13 {
14 va_list args;
15 va_start (args);
16 vfprintf(stdout, "abcde", args);
17 }
18
19 main()
20 {
21 xp();
22 exit(0);
23 }
24 EOF
25
26 if ${CC} x.c >/dev/null 2>&1
27 then
28 echo '#define HAVE_VFPRINTF'
29 rm -f x.c x.o a.out
30 else
31
32 cat > x.c << EOF
33 #include <stdio.h>
34
35 main()
36 {
37 _doprnt();
38 }
39 EOF
40
41 if ${CC} x.c >/dev/null 2>&1
42 then
43 echo '#define USE_VFPRINTF_EMULATION'
44 rm -f x.c x.o a.out
45 fi
46 fi
47
48 cat > x.c << EOF
49 #include <stdio.h>
50 main()
51 {
52 setlinebuf(stdout);
53 }
54 EOF
55
56 if ${CC} x.c > /dev/null 2>&1
57 then
58 rm -f x.c x.o a.out
59 echo '#define HAVE_SETLINEBUF'
60 else
61 # check for setvbuf
62 # If this compiles, the system has setvbuf. If this segfaults while
63 # running, non-reversed systems get a seg violation
64
65 cat > x.c << EOF
66 #include <stdio.h>
67
68 main()
69 {
70 setvbuf(stdout, _IOLBF, (char *)0, BUFSIZ); /* reversed */
71 exit(0); /* non-reversed systems segv */
72 }
73 EOF
74
75 if ${CC} x.c >/dev/null 2>&1 ; then
76 echo '#define HAVE_SETVBUF'
77 if a.out; then
78 :
79 else
80 rm -f core
81 echo '#define REVERSED_SETVBUF_ARGS'
82 fi
83 fi
84 fi
85
86 rm -f x.c x.o a.out
87 exit 0