*** empty log message ***
[gnulib.git] / lib / gen-uio
1 #!/bin/sh
2
3 fail=0
4 cat <<\EOF || fail=1
5 #ifndef UNLOCKED_IO_H
6 # define UNLOCKED_IO_H 1
7
8 # ifndef USE_UNLOCKED_IO
9 #  define USE_UNLOCKED_IO 1
10 # endif
11
12 # if USE_UNLOCKED_IO
13
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.  */
18
19 EOF
20
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;;
38     *)
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
46
47 cat <<\EOF || fail=1
48
49 # endif /* USE_UNLOCKED_IO */
50 #endif /* UNLOCKED_IO_H */
51 EOF
52
53 (exit $fail); exit