118fd37a7SXin LI /* Prefer faster, non-thread-safe stdio functions if available. 218fd37a7SXin LI 318fd37a7SXin LI Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. 418fd37a7SXin LI 518fd37a7SXin LI This program is free software; you can redistribute it and/or modify 618fd37a7SXin LI it under the terms of the GNU General Public License as published by 718fd37a7SXin LI the Free Software Foundation; either version 2, or (at your option) 818fd37a7SXin LI any later version. 918fd37a7SXin LI 1018fd37a7SXin LI This program is distributed in the hope that it will be useful, 1118fd37a7SXin LI but WITHOUT ANY WARRANTY; without even the implied warranty of 1218fd37a7SXin LI MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1318fd37a7SXin LI GNU General Public License for more details. 1418fd37a7SXin LI 1518fd37a7SXin LI You should have received a copy of the GNU General Public License along 1618fd37a7SXin LI with this program; if not, write to the Free Software Foundation, 1718fd37a7SXin LI Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 1818fd37a7SXin LI 1918fd37a7SXin LI /* Written by Jim Meyering. */ 2018fd37a7SXin LI 2118fd37a7SXin LI #ifndef UNLOCKED_IO_H 2218fd37a7SXin LI # define UNLOCKED_IO_H 1 2318fd37a7SXin LI 2418fd37a7SXin LI # ifndef USE_UNLOCKED_IO 2518fd37a7SXin LI # define USE_UNLOCKED_IO 1 2618fd37a7SXin LI # endif 2718fd37a7SXin LI 2818fd37a7SXin LI # if USE_UNLOCKED_IO 2918fd37a7SXin LI 3018fd37a7SXin LI /* These are wrappers for functions/macros from the GNU C library, and 3118fd37a7SXin LI from other C libraries supporting POSIX's optional thread-safe functions. 3218fd37a7SXin LI 3318fd37a7SXin LI The standard I/O functions are thread-safe. These *_unlocked ones are 3418fd37a7SXin LI more efficient but not thread-safe. That they're not thread-safe is 3518fd37a7SXin LI fine since all of the applications in this package are single threaded. 3618fd37a7SXin LI 3718fd37a7SXin LI Also, some code that is shared with the GNU C library may invoke 3818fd37a7SXin LI the *_unlocked functions directly. On hosts that lack those 3918fd37a7SXin LI functions, invoke the non-thread-safe versions instead. */ 4018fd37a7SXin LI 4118fd37a7SXin LI # include <stdio.h> 4218fd37a7SXin LI 4318fd37a7SXin LI # if HAVE_DECL_CLEARERR_UNLOCKED 4418fd37a7SXin LI # undef clearerr 4518fd37a7SXin LI # define clearerr(x) clearerr_unlocked (x) 4618fd37a7SXin LI # else 4718fd37a7SXin LI # define clearerr_unlocked(x) clearerr (x) 4818fd37a7SXin LI # endif 4918fd37a7SXin LI # if HAVE_DECL_FEOF_UNLOCKED 5018fd37a7SXin LI # undef feof 5118fd37a7SXin LI # define feof(x) feof_unlocked (x) 5218fd37a7SXin LI # else 5318fd37a7SXin LI # define feof_unlocked(x) feof (x) 5418fd37a7SXin LI # endif 5518fd37a7SXin LI # if HAVE_DECL_FERROR_UNLOCKED 5618fd37a7SXin LI # undef ferror 5718fd37a7SXin LI # define ferror(x) ferror_unlocked (x) 5818fd37a7SXin LI # else 5918fd37a7SXin LI # define ferror_unlocked(x) ferror (x) 6018fd37a7SXin LI # endif 6118fd37a7SXin LI # if HAVE_DECL_FFLUSH_UNLOCKED 6218fd37a7SXin LI # undef fflush 6318fd37a7SXin LI # define fflush(x) fflush_unlocked (x) 6418fd37a7SXin LI # else 6518fd37a7SXin LI # define fflush_unlocked(x) fflush (x) 6618fd37a7SXin LI # endif 6718fd37a7SXin LI # if HAVE_DECL_FGETS_UNLOCKED 6818fd37a7SXin LI # undef fgets 6918fd37a7SXin LI # define fgets(x,y,z) fgets_unlocked (x,y,z) 7018fd37a7SXin LI # else 7118fd37a7SXin LI # define fgets_unlocked(x,y,z) fgets (x,y,z) 7218fd37a7SXin LI # endif 7318fd37a7SXin LI # if HAVE_DECL_FPUTC_UNLOCKED 7418fd37a7SXin LI # undef fputc 7518fd37a7SXin LI # define fputc(x,y) fputc_unlocked (x,y) 7618fd37a7SXin LI # else 7718fd37a7SXin LI # define fputc_unlocked(x,y) fputc (x,y) 7818fd37a7SXin LI # endif 7918fd37a7SXin LI # if HAVE_DECL_FPUTS_UNLOCKED 8018fd37a7SXin LI # undef fputs 8118fd37a7SXin LI # define fputs(x,y) fputs_unlocked (x,y) 8218fd37a7SXin LI # else 8318fd37a7SXin LI # define fputs_unlocked(x,y) fputs (x,y) 8418fd37a7SXin LI # endif 8518fd37a7SXin LI # if HAVE_DECL_FREAD_UNLOCKED 8618fd37a7SXin LI # undef fread 8718fd37a7SXin LI # define fread(w,x,y,z) fread_unlocked (w,x,y,z) 8818fd37a7SXin LI # else 8918fd37a7SXin LI # define fread_unlocked(w,x,y,z) fread (w,x,y,z) 9018fd37a7SXin LI # endif 9118fd37a7SXin LI # if HAVE_DECL_FWRITE_UNLOCKED 9218fd37a7SXin LI # undef fwrite 9318fd37a7SXin LI # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) 9418fd37a7SXin LI # else 9518fd37a7SXin LI # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) 9618fd37a7SXin LI # endif 9718fd37a7SXin LI # if HAVE_DECL_GETC_UNLOCKED 9818fd37a7SXin LI # undef getc 9918fd37a7SXin LI # define getc(x) getc_unlocked (x) 10018fd37a7SXin LI # else 10118fd37a7SXin LI # define getc_unlocked(x) getc (x) 10218fd37a7SXin LI # endif 10318fd37a7SXin LI # if HAVE_DECL_GETCHAR_UNLOCKED 10418fd37a7SXin LI # undef getchar 10518fd37a7SXin LI # define getchar() getchar_unlocked () 10618fd37a7SXin LI # else 10718fd37a7SXin LI # define getchar_unlocked() getchar () 10818fd37a7SXin LI # endif 10918fd37a7SXin LI # if HAVE_DECL_PUTC_UNLOCKED 11018fd37a7SXin LI # undef putc 11118fd37a7SXin LI # define putc(x,y) putc_unlocked (x,y) 11218fd37a7SXin LI # else 11318fd37a7SXin LI # define putc_unlocked(x,y) putc (x,y) 11418fd37a7SXin LI # endif 11518fd37a7SXin LI # if HAVE_DECL_PUTCHAR_UNLOCKED 11618fd37a7SXin LI # undef putchar 11718fd37a7SXin LI # define putchar(x) putchar_unlocked (x) 11818fd37a7SXin LI # else 11918fd37a7SXin LI # define putchar_unlocked(x) putchar (x) 12018fd37a7SXin LI # endif 12118fd37a7SXin LI 12218fd37a7SXin LI # undef flockfile 12318fd37a7SXin LI # define flockfile(x) ((void) 0) 12418fd37a7SXin LI 12518fd37a7SXin LI # undef ftrylockfile 12618fd37a7SXin LI # define ftrylockfile(x) 0 12718fd37a7SXin LI 12818fd37a7SXin LI # undef funlockfile 12918fd37a7SXin LI # define funlockfile(x) ((void) 0) 13018fd37a7SXin LI 13118fd37a7SXin LI # endif /* USE_UNLOCKED_IO */ 13218fd37a7SXin LI #endif /* UNLOCKED_IO_H */ 133