comparison lib/unlocked-io.h @ 5851:d39411e1c5e6

Sync from coreutils. * modules/yesno (Depends-on): Add getline. * gethrxtime.c, gethrxtime.h, getpass.h, mountlist.h, path-concat.c, regex.h, strtoll.c, unlocked-io.h, xtime.h: White space changes only. * makepath.c (make_path): Port to hosts where leading "//" is special. * yesno.c: Include getline.h, not ctype.h. (yesno): Don't remove leading white space; POSIX doesn't allow it. Use getline to remove arbitrary restriction on response length.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 15 May 2005 04:45:43 +0000
parents a48fb0e98c8c
children bbbbbf4cd1c5
comparison
equal deleted inserted replaced
5850:1b7017c2d9b8 5851:d39411e1c5e6
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 18
19 /* Written by Jim Meyering. */ 19 /* Written by Jim Meyering. */
20 20
21 #ifndef UNLOCKED_IO_H 21 #ifndef UNLOCKED_IO_H
22 #define UNLOCKED_IO_H 1 22 # define UNLOCKED_IO_H 1
23 23
24 /* These are wrappers for functions/macros from the GNU C library, and 24 /* These are wrappers for functions/macros from the GNU C library, and
25 from other C libraries supporting POSIX's optional thread-safe functions. 25 from other C libraries supporting POSIX's optional thread-safe functions.
26 26
27 The standard I/O functions are thread-safe. These *_unlocked ones are 27 The standard I/O functions are thread-safe. These *_unlocked ones are
30 30
31 Also, some code that is shared with the GNU C library may invoke 31 Also, some code that is shared with the GNU C library may invoke
32 the *_unlocked functions directly. On hosts that lack those 32 the *_unlocked functions directly. On hosts that lack those
33 functions, invoke the non-thread-safe versions instead. */ 33 functions, invoke the non-thread-safe versions instead. */
34 34
35 #include <stdio.h> 35 # include <stdio.h>
36 36
37 #if HAVE_DECL_CLEARERR_UNLOCKED 37 # if HAVE_DECL_CLEARERR_UNLOCKED
38 # undef clearerr 38 # undef clearerr
39 # define clearerr(x) clearerr_unlocked (x) 39 # define clearerr(x) clearerr_unlocked (x)
40 #else 40 # else
41 # define clearerr_unlocked(x) clearerr (x) 41 # define clearerr_unlocked(x) clearerr (x)
42 #endif 42 # endif
43 43
44 #if HAVE_DECL_FEOF_UNLOCKED 44 # if HAVE_DECL_FEOF_UNLOCKED
45 # undef feof 45 # undef feof
46 # define feof(x) feof_unlocked (x) 46 # define feof(x) feof_unlocked (x)
47 #else 47 # else
48 # define feof_unlocked(x) feof (x) 48 # define feof_unlocked(x) feof (x)
49 #endif 49 # endif
50 50
51 #if HAVE_DECL_FERROR_UNLOCKED 51 # if HAVE_DECL_FERROR_UNLOCKED
52 # undef ferror 52 # undef ferror
53 # define ferror(x) ferror_unlocked (x) 53 # define ferror(x) ferror_unlocked (x)
54 #else 54 # else
55 # define ferror_unlocked(x) ferror (x) 55 # define ferror_unlocked(x) ferror (x)
56 #endif 56 # endif
57 57
58 #if HAVE_DECL_FFLUSH_UNLOCKED 58 # if HAVE_DECL_FFLUSH_UNLOCKED
59 # undef fflush 59 # undef fflush
60 # define fflush(x) fflush_unlocked (x) 60 # define fflush(x) fflush_unlocked (x)
61 #else 61 # else
62 # define fflush_unlocked(x) fflush (x) 62 # define fflush_unlocked(x) fflush (x)
63 #endif 63 # endif
64 64
65 #if HAVE_DECL_FGETS_UNLOCKED 65 # if HAVE_DECL_FGETS_UNLOCKED
66 # undef fgets 66 # undef fgets
67 # define fgets(x,y,z) fgets_unlocked (x,y,z) 67 # define fgets(x,y,z) fgets_unlocked (x,y,z)
68 #else 68 # else
69 # define fgets_unlocked(x,y,z) fgets (x,y,z) 69 # define fgets_unlocked(x,y,z) fgets (x,y,z)
70 #endif 70 # endif
71 71
72 #if HAVE_DECL_FPUTC_UNLOCKED 72 # if HAVE_DECL_FPUTC_UNLOCKED
73 # undef fputc 73 # undef fputc
74 # define fputc(x,y) fputc_unlocked (x,y) 74 # define fputc(x,y) fputc_unlocked (x,y)
75 #else 75 # else
76 # define fputc_unlocked(x,y) fputc (x,y) 76 # define fputc_unlocked(x,y) fputc (x,y)
77 #endif 77 # endif
78 78
79 #if HAVE_DECL_FPUTS_UNLOCKED 79 # if HAVE_DECL_FPUTS_UNLOCKED
80 # undef fputs 80 # undef fputs
81 # define fputs(x,y) fputs_unlocked (x,y) 81 # define fputs(x,y) fputs_unlocked (x,y)
82 #else 82 # else
83 # define fputs_unlocked(x,y) fputs (x,y) 83 # define fputs_unlocked(x,y) fputs (x,y)
84 #endif 84 # endif
85 85
86 #if HAVE_DECL_FREAD_UNLOCKED 86 # if HAVE_DECL_FREAD_UNLOCKED
87 # undef fread 87 # undef fread
88 # define fread(w,x,y,z) fread_unlocked (w,x,y,z) 88 # define fread(w,x,y,z) fread_unlocked (w,x,y,z)
89 #else 89 # else
90 # define fread_unlocked(w,x,y,z) fread (w,x,y,z) 90 # define fread_unlocked(w,x,y,z) fread (w,x,y,z)
91 #endif 91 # endif
92 92
93 #if HAVE_DECL_FWRITE_UNLOCKED 93 # if HAVE_DECL_FWRITE_UNLOCKED
94 # undef fwrite 94 # undef fwrite
95 # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) 95 # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
96 #else 96 # else
97 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) 97 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
98 #endif 98 # endif
99 99
100 #if HAVE_DECL_GETC_UNLOCKED 100 # if HAVE_DECL_GETC_UNLOCKED
101 # undef getc 101 # undef getc
102 # define getc(x) getc_unlocked (x) 102 # define getc(x) getc_unlocked (x)
103 #else 103 # else
104 # define getc_unlocked(x) getc (x) 104 # define getc_unlocked(x) getc (x)
105 #endif 105 # endif
106 106
107 #if HAVE_DECL_GETCHAR_UNLOCKED 107 # if HAVE_DECL_GETCHAR_UNLOCKED
108 # undef getchar 108 # undef getchar
109 # define getchar() getchar_unlocked () 109 # define getchar() getchar_unlocked ()
110 #else 110 # else
111 # define getchar_unlocked() getchar () 111 # define getchar_unlocked() getchar ()
112 #endif 112 # endif
113 113
114 #if HAVE_DECL_PUTC_UNLOCKED 114 # if HAVE_DECL_PUTC_UNLOCKED
115 # undef putc 115 # undef putc
116 # define putc(x,y) putc_unlocked (x,y) 116 # define putc(x,y) putc_unlocked (x,y)
117 #else 117 # else
118 # define putc_unlocked(x,y) putc (x,y) 118 # define putc_unlocked(x,y) putc (x,y)
119 #endif 119 # endif
120 120
121 #if HAVE_DECL_PUTCHAR_UNLOCKED 121 # if HAVE_DECL_PUTCHAR_UNLOCKED
122 # undef putchar 122 # undef putchar
123 # define putchar(x) putchar_unlocked (x) 123 # define putchar(x) putchar_unlocked (x)
124 #else 124 # else
125 # define putchar_unlocked(x) putchar (x) 125 # define putchar_unlocked(x) putchar (x)
126 #endif 126 # endif
127 127
128 #undef flockfile 128 # undef flockfile
129 #define flockfile(x) ((void) 0) 129 # define flockfile(x) ((void) 0)
130 130
131 #undef ftrylockfile 131 # undef ftrylockfile
132 #define ftrylockfile(x) 0 132 # define ftrylockfile(x) 0
133 133
134 #undef funlockfile 134 # undef funlockfile
135 #define funlockfile(x) ((void) 0) 135 # define funlockfile(x) ((void) 0)
136 136
137 #endif /* UNLOCKED_IO_H */ 137 #endif /* UNLOCKED_IO_H */