1 /* Prefer faster, non-thread-safe stdio functions if available.
3 Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
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
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
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,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 /* Written by Jim Meyering. */
22 # define UNLOCKED_IO_H 1
24 # ifndef USE_UNLOCKED_IO
25 # define USE_UNLOCKED_IO 1
30 /* These are wrappers for functions/macros from the GNU C library, and
31 from other C libraries supporting POSIX's optional thread-safe functions.
33 The standard I/O functions are thread-safe. These *_unlocked ones are
34 more efficient but not thread-safe. That they're not thread-safe is
35 fine since all of the applications in this package are single threaded.
37 Also, some code that is shared with the GNU C library may invoke
38 the *_unlocked functions directly. On hosts that lack those
39 functions, invoke the non-thread-safe versions instead. */
43 # if HAVE_DECL_CLEARERR_UNLOCKED
45 # define clearerr(x) clearerr_unlocked (x)
47 # define clearerr_unlocked(x) clearerr (x)
49 # if HAVE_DECL_FEOF_UNLOCKED
51 # define feof(x) feof_unlocked (x)
53 # define feof_unlocked(x) feof (x)
55 # if HAVE_DECL_FERROR_UNLOCKED
57 # define ferror(x) ferror_unlocked (x)
59 # define ferror_unlocked(x) ferror (x)
61 # if HAVE_DECL_FFLUSH_UNLOCKED
63 # define fflush(x) fflush_unlocked (x)
65 # define fflush_unlocked(x) fflush (x)
67 # if HAVE_DECL_FGETS_UNLOCKED
69 # define fgets(x,y,z) fgets_unlocked (x,y,z)
71 # define fgets_unlocked(x,y,z) fgets (x,y,z)
73 # if HAVE_DECL_FPUTC_UNLOCKED
75 # define fputc(x,y) fputc_unlocked (x,y)
77 # define fputc_unlocked(x,y) fputc (x,y)
79 # if HAVE_DECL_FPUTS_UNLOCKED
81 # define fputs(x,y) fputs_unlocked (x,y)
83 # define fputs_unlocked(x,y) fputs (x,y)
85 # if HAVE_DECL_FREAD_UNLOCKED
87 # define fread(w,x,y,z) fread_unlocked (w,x,y,z)
89 # define fread_unlocked(w,x,y,z) fread (w,x,y,z)
91 # if HAVE_DECL_FWRITE_UNLOCKED
93 # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
95 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
97 # if HAVE_DECL_GETC_UNLOCKED
99 # define getc(x) getc_unlocked (x)
101 # define getc_unlocked(x) getc (x)
103 # if HAVE_DECL_GETCHAR_UNLOCKED
105 # define getchar() getchar_unlocked ()
107 # define getchar_unlocked() getchar ()
109 # if HAVE_DECL_PUTC_UNLOCKED
111 # define putc(x,y) putc_unlocked (x,y)
113 # define putc_unlocked(x,y) putc (x,y)
115 # if HAVE_DECL_PUTCHAR_UNLOCKED
117 # define putchar(x) putchar_unlocked (x)
119 # define putchar_unlocked(x) putchar (x)
123 # define flockfile(x) ((void) 0)
126 # define ftrylockfile(x) 0
129 # define funlockfile(x) ((void) 0)
131 # endif /* USE_UNLOCKED_IO */
132 #endif /* UNLOCKED_IO_H */