White-space changes only; from coreutils.
[gnulib.git] / lib / unlocked-io.h
1 /* Prefer faster, non-thread-safe stdio functions if available.
2
3    Copyright (C) 2001, 2002 Free Software Foundation, Inc.
4
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)
8    any later version.
9
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.
14
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.  */
18
19 /* Written by Jim Meyering.  */
20
21 #ifndef UNLOCKED_IO_H
22 # define UNLOCKED_IO_H 1
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 GNU libc.
31    The standard I/O functions are thread-safe.  These *_unlocked ones are
32    more efficient but not thread-safe.  That they're not thread-safe is
33    fine since all of the applications in this package are single threaded.  */
34
35 #  if HAVE_DECL_CLEARERR_UNLOCKED
36 #   undef clearerr
37 #   define clearerr(x) clearerr_unlocked (x)
38 #  endif
39 #  if HAVE_DECL_FEOF_UNLOCKED
40 #   undef feof
41 #   define feof(x) feof_unlocked (x)
42 #  endif
43 #  if HAVE_DECL_FERROR_UNLOCKED
44 #   undef ferror
45 #   define ferror(x) ferror_unlocked (x)
46 #  endif
47 #  if HAVE_DECL_FFLUSH_UNLOCKED
48 #   undef fflush
49 #   define fflush(x) fflush_unlocked (x)
50 #  endif
51 #  if HAVE_DECL_FGETS_UNLOCKED
52 #   undef fgets
53 #   define fgets(x,y,z) fgets_unlocked (x,y,z)
54 #  endif
55 #  if HAVE_DECL_FPUTC_UNLOCKED
56 #   undef fputc
57 #   define fputc(x,y) fputc_unlocked (x,y)
58 #  endif
59 #  if HAVE_DECL_FPUTS_UNLOCKED
60 #   undef fputs
61 #   define fputs(x,y) fputs_unlocked (x,y)
62 #  endif
63 #  if HAVE_DECL_FREAD_UNLOCKED
64 #   undef fread
65 #   define fread(w,x,y,z) fread_unlocked (w,x,y,z)
66 #  endif
67 #  if HAVE_DECL_FWRITE_UNLOCKED
68 #   undef fwrite
69 #   define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
70 #  endif
71 #  if HAVE_DECL_GETC_UNLOCKED
72 #   undef getc
73 #   define getc(x) getc_unlocked (x)
74 #  endif
75 #  if HAVE_DECL_GETCHAR_UNLOCKED
76 #   undef getchar
77 #   define getchar() getchar_unlocked ()
78 #  endif
79 #  if HAVE_DECL_PUTC_UNLOCKED
80 #   undef putc
81 #   define putc(x,y) putc_unlocked (x,y)
82 #  endif
83 #  if HAVE_DECL_PUTCHAR_UNLOCKED
84 #   undef putchar
85 #   define putchar(x) putchar_unlocked (x)
86 #  endif
87
88 # endif /* USE_UNLOCKED_IO */
89 #endif /* UNLOCKED_IO_H */