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