1170754Sdelphij/* Prefer faster, non-thread-safe stdio functions if available. 2170754Sdelphij 3170754Sdelphij Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 4170754Sdelphij 5170754Sdelphij This program is free software; you can redistribute it and/or modify 6170754Sdelphij it under the terms of the GNU General Public License as published by 7170754Sdelphij the Free Software Foundation; either version 2, or (at your option) 8170754Sdelphij any later version. 9170754Sdelphij 10170754Sdelphij This program is distributed in the hope that it will be useful, 11170754Sdelphij but WITHOUT ANY WARRANTY; without even the implied warranty of 12170754Sdelphij MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13170754Sdelphij GNU General Public License for more details. 14170754Sdelphij 15170754Sdelphij You should have received a copy of the GNU General Public License along 16170754Sdelphij with this program; if not, write to the Free Software Foundation, 17170754Sdelphij Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 18170754Sdelphij 19170754Sdelphij/* Written by Jim Meyering. */ 20170754Sdelphij 21170754Sdelphij#ifndef UNLOCKED_IO_H 22170754Sdelphij# define UNLOCKED_IO_H 1 23170754Sdelphij 24170754Sdelphij# ifndef USE_UNLOCKED_IO 25170754Sdelphij# define USE_UNLOCKED_IO 1 26170754Sdelphij# endif 27170754Sdelphij 28170754Sdelphij# if USE_UNLOCKED_IO 29170754Sdelphij 30170754Sdelphij/* These are wrappers for functions/macros from the GNU C library, and 31170754Sdelphij from other C libraries supporting POSIX's optional thread-safe functions. 32170754Sdelphij 33170754Sdelphij The standard I/O functions are thread-safe. These *_unlocked ones are 34170754Sdelphij more efficient but not thread-safe. That they're not thread-safe is 35170754Sdelphij fine since all of the applications in this package are single threaded. 36170754Sdelphij 37170754Sdelphij Also, some code that is shared with the GNU C library may invoke 38170754Sdelphij the *_unlocked functions directly. On hosts that lack those 39170754Sdelphij functions, invoke the non-thread-safe versions instead. */ 40170754Sdelphij 41170754Sdelphij# include <stdio.h> 42170754Sdelphij 43170754Sdelphij# if HAVE_DECL_CLEARERR_UNLOCKED 44170754Sdelphij# undef clearerr 45170754Sdelphij# define clearerr(x) clearerr_unlocked (x) 46170754Sdelphij# else 47170754Sdelphij# define clearerr_unlocked(x) clearerr (x) 48170754Sdelphij# endif 49170754Sdelphij# if HAVE_DECL_FEOF_UNLOCKED 50170754Sdelphij# undef feof 51170754Sdelphij# define feof(x) feof_unlocked (x) 52170754Sdelphij# else 53170754Sdelphij# define feof_unlocked(x) feof (x) 54170754Sdelphij# endif 55170754Sdelphij# if HAVE_DECL_FERROR_UNLOCKED 56170754Sdelphij# undef ferror 57170754Sdelphij# define ferror(x) ferror_unlocked (x) 58170754Sdelphij# else 59170754Sdelphij# define ferror_unlocked(x) ferror (x) 60170754Sdelphij# endif 61170754Sdelphij# if HAVE_DECL_FFLUSH_UNLOCKED 62170754Sdelphij# undef fflush 63170754Sdelphij# define fflush(x) fflush_unlocked (x) 64170754Sdelphij# else 65170754Sdelphij# define fflush_unlocked(x) fflush (x) 66170754Sdelphij# endif 67170754Sdelphij# if HAVE_DECL_FGETS_UNLOCKED 68170754Sdelphij# undef fgets 69170754Sdelphij# define fgets(x,y,z) fgets_unlocked (x,y,z) 70170754Sdelphij# else 71170754Sdelphij# define fgets_unlocked(x,y,z) fgets (x,y,z) 72170754Sdelphij# endif 73170754Sdelphij# if HAVE_DECL_FPUTC_UNLOCKED 74170754Sdelphij# undef fputc 75170754Sdelphij# define fputc(x,y) fputc_unlocked (x,y) 76170754Sdelphij# else 77170754Sdelphij# define fputc_unlocked(x,y) fputc (x,y) 78170754Sdelphij# endif 79170754Sdelphij# if HAVE_DECL_FPUTS_UNLOCKED 80170754Sdelphij# undef fputs 81170754Sdelphij# define fputs(x,y) fputs_unlocked (x,y) 82170754Sdelphij# else 83170754Sdelphij# define fputs_unlocked(x,y) fputs (x,y) 84170754Sdelphij# endif 85170754Sdelphij# if HAVE_DECL_FREAD_UNLOCKED 86170754Sdelphij# undef fread 87170754Sdelphij# define fread(w,x,y,z) fread_unlocked (w,x,y,z) 88170754Sdelphij# else 89170754Sdelphij# define fread_unlocked(w,x,y,z) fread (w,x,y,z) 90170754Sdelphij# endif 91170754Sdelphij# if HAVE_DECL_FWRITE_UNLOCKED 92170754Sdelphij# undef fwrite 93170754Sdelphij# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) 94170754Sdelphij# else 95170754Sdelphij# define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) 96170754Sdelphij# endif 97170754Sdelphij# if HAVE_DECL_GETC_UNLOCKED 98170754Sdelphij# undef getc 99170754Sdelphij# define getc(x) getc_unlocked (x) 100170754Sdelphij# else 101170754Sdelphij# define getc_unlocked(x) getc (x) 102170754Sdelphij# endif 103170754Sdelphij# if HAVE_DECL_GETCHAR_UNLOCKED 104170754Sdelphij# undef getchar 105170754Sdelphij# define getchar() getchar_unlocked () 106170754Sdelphij# else 107170754Sdelphij# define getchar_unlocked() getchar () 108170754Sdelphij# endif 109170754Sdelphij# if HAVE_DECL_PUTC_UNLOCKED 110170754Sdelphij# undef putc 111170754Sdelphij# define putc(x,y) putc_unlocked (x,y) 112170754Sdelphij# else 113170754Sdelphij# define putc_unlocked(x,y) putc (x,y) 114170754Sdelphij# endif 115170754Sdelphij# if HAVE_DECL_PUTCHAR_UNLOCKED 116170754Sdelphij# undef putchar 117170754Sdelphij# define putchar(x) putchar_unlocked (x) 118170754Sdelphij# else 119170754Sdelphij# define putchar_unlocked(x) putchar (x) 120170754Sdelphij# endif 121170754Sdelphij 122170754Sdelphij# undef flockfile 123170754Sdelphij# define flockfile(x) ((void) 0) 124170754Sdelphij 125170754Sdelphij# undef ftrylockfile 126170754Sdelphij# define ftrylockfile(x) 0 127170754Sdelphij 128170754Sdelphij# undef funlockfile 129170754Sdelphij# define funlockfile(x) ((void) 0) 130170754Sdelphij 131170754Sdelphij# endif /* USE_UNLOCKED_IO */ 132170754Sdelphij#endif /* UNLOCKED_IO_H */ 133