*** empty log message ***
[gnulib.git] / lib / gen-uio
blobe7ef6a365caf3f0c573573e5be79800d258bb4af
1 #!/bin/sh
3 fail=0
4 cat <<\EOF || fail=1
5 #ifndef UNLOCKED_IO_H
6 # define UNLOCKED_IO_H 1
8 # ifndef USE_UNLOCKED_IO
9 # define USE_UNLOCKED_IO 1
10 # endif
12 # if USE_UNLOCKED_IO
14 /* These are wrappers for functions/macros from GNU libc.
15 The standard I/O functions are thread-safe. These *_unlocked ones are
16 more efficient but not thread-safe. That they're not thread-safe is
17 fine since all of the applications in this package are single threaded. */
19 EOF
21 for f in $@; do
22 u=`echo $f|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
23 cat <<EOF || fail=1
24 # if HAVE_${u}_UNLOCKED
25 # undef $f
26 EOF
27 case $f in
28 getchar)
29 params=;;
30 putchar | clearerr | feof | ferror | fflush | getc )
31 params=x;;
32 putc | fputc | fputs )
33 params=x,y;;
34 fgets )
35 params=x,y,z;;
36 fread | fwrite )
37 params=w,x,y,z;;
39 echo $0: missing case for $f 2>&1; fail=1;;
40 esac
41 cat <<EOF || fail=1
42 # define $f($params) ${f}_unlocked ($params)
43 # endif
44 EOF
45 done
47 cat <<\EOF || fail=1
49 # endif /* USE_UNLOCKED_IO */
50 #endif /* UNLOCKED_IO_H */
51 EOF
53 (exit $fail); exit