xref: /netbsd-src/external/gpl2/diffutils/dist/lib/unlocked-io.h (revision 75f6d617e282811cb173c2ccfbf5df0dd71f7045)
1 /*	$NetBSD: unlocked-io.h,v 1.1.1.1 2016/01/13 03:15:30 christos Exp $	*/
2 
3 #ifndef UNLOCKED_IO_H
4 # define UNLOCKED_IO_H 1
5 
6 # ifndef USE_UNLOCKED_IO
7 #  define USE_UNLOCKED_IO 1
8 # endif
9 
10 # if USE_UNLOCKED_IO
11 
12 /* These are wrappers for functions/macros from GNU libc.
13    The standard I/O functions are thread-safe.  These *_unlocked ones are
14    more efficient but not thread-safe.  That they're not thread-safe is
15    fine since all of the applications in this package are single threaded.  */
16 
17 #  if HAVE_DECL_CLEARERR_UNLOCKED
18 #   undef clearerr
19 #   define clearerr(x) clearerr_unlocked (x)
20 #  endif
21 #  if HAVE_DECL_FEOF_UNLOCKED
22 #   undef feof
23 #   define feof(x) feof_unlocked (x)
24 #  endif
25 #  if HAVE_DECL_FERROR_UNLOCKED
26 #   undef ferror
27 #   define ferror(x) ferror_unlocked (x)
28 #  endif
29 #  if HAVE_DECL_FFLUSH_UNLOCKED
30 #   undef fflush
31 #   define fflush(x) fflush_unlocked (x)
32 #  endif
33 #  if HAVE_DECL_FGETS_UNLOCKED
34 #   undef fgets
35 #   define fgets(x,y,z) fgets_unlocked (x,y,z)
36 #  endif
37 #  if HAVE_DECL_FPUTC_UNLOCKED
38 #   undef fputc
39 #   define fputc(x,y) fputc_unlocked (x,y)
40 #  endif
41 #  if HAVE_DECL_FPUTS_UNLOCKED
42 #   undef fputs
43 #   define fputs(x,y) fputs_unlocked (x,y)
44 #  endif
45 #  if HAVE_DECL_FREAD_UNLOCKED
46 #   undef fread
47 #   define fread(w,x,y,z) fread_unlocked (w,x,y,z)
48 #  endif
49 #  if HAVE_DECL_FWRITE_UNLOCKED
50 #   undef fwrite
51 #   define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
52 #  endif
53 #  if HAVE_DECL_GETC_UNLOCKED
54 #   undef getc
55 #   define getc(x) getc_unlocked (x)
56 #  endif
57 #  if HAVE_DECL_GETCHAR_UNLOCKED
58 #   undef getchar
59 #   define getchar() getchar_unlocked ()
60 #  endif
61 #  if HAVE_DECL_PUTC_UNLOCKED
62 #   undef putc
63 #   define putc(x,y) putc_unlocked (x,y)
64 #  endif
65 #  if HAVE_DECL_PUTCHAR_UNLOCKED
66 #   undef putchar
67 #   define putchar(x) putchar_unlocked (x)
68 #  endif
69 
70 # endif /* USE_UNLOCKED_IO */
71 #endif /* UNLOCKED_IO_H */
72