diff options
Diffstat (limited to 'lib/unlocked-io.h')
-rw-r--r-- | lib/unlocked-io.h | 203 |
1 files changed, 104 insertions, 99 deletions
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h index 36a7a48..d009303 100644 --- a/lib/unlocked-io.h +++ b/lib/unlocked-io.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* Prefer faster, non-thread-safe stdio functions if available. | 1 | /* Prefer faster, non-thread-safe stdio functions if available. |
2 | 2 | ||
3 | Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. | 3 | Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
@@ -14,19 +14,13 @@ | |||
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License along | 15 | You should have received a copy of the GNU General Public License along |
16 | with this program; if not, write to the Free Software Foundation, | 16 | with this program; if not, write to the Free Software Foundation, |
17 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 | # ifndef USE_UNLOCKED_IO | ||
25 | # define USE_UNLOCKED_IO 1 | ||
26 | # endif | ||
27 | |||
28 | # if USE_UNLOCKED_IO | ||
29 | |||
30 | /* 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 |
31 | from other C libraries supporting POSIX's optional thread-safe functions. | 25 | from other C libraries supporting POSIX's optional thread-safe functions. |
32 | 26 | ||
@@ -38,95 +32,106 @@ | |||
38 | the *_unlocked functions directly. On hosts that lack those | 32 | the *_unlocked functions directly. On hosts that lack those |
39 | functions, invoke the non-thread-safe versions instead. */ | 33 | functions, invoke the non-thread-safe versions instead. */ |
40 | 34 | ||
41 | # include <stdio.h> | 35 | # include <stdio.h> |
42 | 36 | ||
43 | # if HAVE_DECL_CLEARERR_UNLOCKED | 37 | # if HAVE_DECL_CLEARERR_UNLOCKED |
44 | # undef clearerr | 38 | # undef clearerr |
45 | # define clearerr(x) clearerr_unlocked (x) | 39 | # define clearerr(x) clearerr_unlocked (x) |
46 | # else | 40 | # else |
47 | # define clearerr_unlocked(x) clearerr (x) | 41 | # define clearerr_unlocked(x) clearerr (x) |
48 | # endif | 42 | # endif |
49 | # if HAVE_DECL_FEOF_UNLOCKED | 43 | |
50 | # undef feof | 44 | # if HAVE_DECL_FEOF_UNLOCKED |
51 | # define feof(x) feof_unlocked (x) | 45 | # undef feof |
52 | # else | 46 | # define feof(x) feof_unlocked (x) |
53 | # define feof_unlocked(x) feof (x) | 47 | # else |
54 | # endif | 48 | # define feof_unlocked(x) feof (x) |
55 | # if HAVE_DECL_FERROR_UNLOCKED | 49 | # endif |
56 | # undef ferror | 50 | |
57 | # define ferror(x) ferror_unlocked (x) | 51 | # if HAVE_DECL_FERROR_UNLOCKED |
58 | # else | 52 | # undef ferror |
59 | # define ferror_unlocked(x) ferror (x) | 53 | # define ferror(x) ferror_unlocked (x) |
60 | # endif | 54 | # else |
61 | # if HAVE_DECL_FFLUSH_UNLOCKED | 55 | # define ferror_unlocked(x) ferror (x) |
62 | # undef fflush | 56 | # endif |
63 | # define fflush(x) fflush_unlocked (x) | 57 | |
64 | # else | 58 | # if HAVE_DECL_FFLUSH_UNLOCKED |
65 | # define fflush_unlocked(x) fflush (x) | 59 | # undef fflush |
66 | # endif | 60 | # define fflush(x) fflush_unlocked (x) |
67 | # if HAVE_DECL_FGETS_UNLOCKED | 61 | # else |
68 | # undef fgets | 62 | # define fflush_unlocked(x) fflush (x) |
69 | # define fgets(x,y,z) fgets_unlocked (x,y,z) | 63 | # endif |
70 | # else | 64 | |
71 | # define fgets_unlocked(x,y,z) fgets (x,y,z) | 65 | # if HAVE_DECL_FGETS_UNLOCKED |
72 | # endif | 66 | # undef fgets |
73 | # if HAVE_DECL_FPUTC_UNLOCKED | 67 | # define fgets(x,y,z) fgets_unlocked (x,y,z) |
74 | # undef fputc | 68 | # else |
75 | # define fputc(x,y) fputc_unlocked (x,y) | 69 | # define fgets_unlocked(x,y,z) fgets (x,y,z) |
76 | # else | 70 | # endif |
77 | # define fputc_unlocked(x,y) fputc (x,y) | 71 | |
78 | # endif | 72 | # if HAVE_DECL_FPUTC_UNLOCKED |
79 | # if HAVE_DECL_FPUTS_UNLOCKED | 73 | # undef fputc |
80 | # undef fputs | 74 | # define fputc(x,y) fputc_unlocked (x,y) |
81 | # define fputs(x,y) fputs_unlocked (x,y) | 75 | # else |
82 | # else | 76 | # define fputc_unlocked(x,y) fputc (x,y) |
83 | # define fputs_unlocked(x,y) fputs (x,y) | 77 | # endif |
84 | # endif | 78 | |
85 | # if HAVE_DECL_FREAD_UNLOCKED | 79 | # if HAVE_DECL_FPUTS_UNLOCKED |
86 | # undef fread | 80 | # undef fputs |
87 | # define fread(w,x,y,z) fread_unlocked (w,x,y,z) | 81 | # define fputs(x,y) fputs_unlocked (x,y) |
88 | # else | 82 | # else |
89 | # define fread_unlocked(w,x,y,z) fread (w,x,y,z) | 83 | # define fputs_unlocked(x,y) fputs (x,y) |
90 | # endif | 84 | # endif |
91 | # if HAVE_DECL_FWRITE_UNLOCKED | 85 | |
92 | # undef fwrite | 86 | # if HAVE_DECL_FREAD_UNLOCKED |
93 | # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) | 87 | # undef fread |
94 | # else | 88 | # define fread(w,x,y,z) fread_unlocked (w,x,y,z) |
95 | # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) | 89 | # else |
96 | # endif | 90 | # define fread_unlocked(w,x,y,z) fread (w,x,y,z) |
97 | # if HAVE_DECL_GETC_UNLOCKED | 91 | # endif |
98 | # undef getc | 92 | |
99 | # define getc(x) getc_unlocked (x) | 93 | # if HAVE_DECL_FWRITE_UNLOCKED |
100 | # else | 94 | # undef fwrite |
101 | # define getc_unlocked(x) getc (x) | 95 | # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) |
102 | # endif | 96 | # else |
103 | # if HAVE_DECL_GETCHAR_UNLOCKED | 97 | # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) |
104 | # undef getchar | 98 | # endif |
105 | # define getchar() getchar_unlocked () | 99 | |
106 | # else | 100 | # if HAVE_DECL_GETC_UNLOCKED |
107 | # define getchar_unlocked() getchar () | 101 | # undef getc |
108 | # endif | 102 | # define getc(x) getc_unlocked (x) |
109 | # if HAVE_DECL_PUTC_UNLOCKED | 103 | # else |
110 | # undef putc | 104 | # define getc_unlocked(x) getc (x) |
111 | # define putc(x,y) putc_unlocked (x,y) | 105 | # endif |
112 | # else | 106 | |
113 | # define putc_unlocked(x,y) putc (x,y) | 107 | # if HAVE_DECL_GETCHAR_UNLOCKED |
114 | # endif | 108 | # undef getchar |
115 | # if HAVE_DECL_PUTCHAR_UNLOCKED | 109 | # define getchar() getchar_unlocked () |
116 | # undef putchar | 110 | # else |
117 | # define putchar(x) putchar_unlocked (x) | 111 | # define getchar_unlocked() getchar () |
118 | # else | 112 | # endif |
119 | # define putchar_unlocked(x) putchar (x) | 113 | |
120 | # endif | 114 | # if HAVE_DECL_PUTC_UNLOCKED |
121 | 115 | # undef putc | |
122 | # undef flockfile | 116 | # define putc(x,y) putc_unlocked (x,y) |
123 | # define flockfile(x) ((void) 0) | 117 | # else |
124 | 118 | # define putc_unlocked(x,y) putc (x,y) | |
125 | # undef ftrylockfile | 119 | # endif |
126 | # define ftrylockfile(x) 0 | 120 | |
127 | 121 | # if HAVE_DECL_PUTCHAR_UNLOCKED | |
128 | # undef funlockfile | 122 | # undef putchar |
129 | # define funlockfile(x) ((void) 0) | 123 | # define putchar(x) putchar_unlocked (x) |
130 | 124 | # else | |
131 | # endif /* USE_UNLOCKED_IO */ | 125 | # define putchar_unlocked(x) putchar (x) |
126 | # endif | ||
127 | |||
128 | # undef flockfile | ||
129 | # define flockfile(x) ((void) 0) | ||
130 | |||
131 | # undef ftrylockfile | ||
132 | # define ftrylockfile(x) 0 | ||
133 | |||
134 | # undef funlockfile | ||
135 | # define funlockfile(x) ((void) 0) | ||
136 | |||
132 | #endif /* UNLOCKED_IO_H */ | 137 | #endif /* UNLOCKED_IO_H */ |