Blame lib/unlocked-io.h

Packit 33f14e
/* Prefer faster, non-thread-safe stdio functions if available.
Packit 33f14e
Packit 33f14e
   Copyright (C) 2001-2004, 2009-2017 Free Software Foundation, Inc.
Packit 33f14e
Packit 33f14e
   This program is free software: you can redistribute it and/or modify
Packit 33f14e
   it under the terms of the GNU General Public License as published by
Packit 33f14e
   the Free Software Foundation; either version 3 of the License, or
Packit 33f14e
   (at your option) any later version.
Packit 33f14e
Packit 33f14e
   This program is distributed in the hope that it will be useful,
Packit 33f14e
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 33f14e
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 33f14e
   GNU General Public License for more details.
Packit 33f14e
Packit 33f14e
   You should have received a copy of the GNU General Public License
Packit 33f14e
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 33f14e
Packit 33f14e
/* Written by Jim Meyering.  */
Packit 33f14e
Packit 33f14e
#ifndef UNLOCKED_IO_H
Packit 33f14e
# define UNLOCKED_IO_H 1
Packit 33f14e
Packit 33f14e
/* These are wrappers for functions/macros from the GNU C library, and
Packit 33f14e
   from other C libraries supporting POSIX's optional thread-safe functions.
Packit 33f14e
Packit 33f14e
   The standard I/O functions are thread-safe.  These *_unlocked ones are
Packit 33f14e
   more efficient but not thread-safe.  That they're not thread-safe is
Packit 33f14e
   fine since all of the applications in this package are single threaded.
Packit 33f14e
Packit 33f14e
   Also, some code that is shared with the GNU C library may invoke
Packit 33f14e
   the *_unlocked functions directly.  On hosts that lack those
Packit 33f14e
   functions, invoke the non-thread-safe versions instead.  */
Packit 33f14e
Packit 33f14e
# include <stdio.h>
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_CLEARERR_UNLOCKED
Packit 33f14e
#  undef clearerr
Packit 33f14e
#  define clearerr(x) clearerr_unlocked (x)
Packit 33f14e
# else
Packit 33f14e
#  define clearerr_unlocked(x) clearerr (x)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FEOF_UNLOCKED
Packit 33f14e
#  undef feof
Packit 33f14e
#  define feof(x) feof_unlocked (x)
Packit 33f14e
# else
Packit 33f14e
#  define feof_unlocked(x) feof (x)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FERROR_UNLOCKED
Packit 33f14e
#  undef ferror
Packit 33f14e
#  define ferror(x) ferror_unlocked (x)
Packit 33f14e
# else
Packit 33f14e
#  define ferror_unlocked(x) ferror (x)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FFLUSH_UNLOCKED
Packit 33f14e
#  undef fflush
Packit 33f14e
#  define fflush(x) fflush_unlocked (x)
Packit 33f14e
# else
Packit 33f14e
#  define fflush_unlocked(x) fflush (x)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FGETS_UNLOCKED
Packit 33f14e
#  undef fgets
Packit 33f14e
#  define fgets(x,y,z) fgets_unlocked (x,y,z)
Packit 33f14e
# else
Packit 33f14e
#  define fgets_unlocked(x,y,z) fgets (x,y,z)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FPUTC_UNLOCKED
Packit 33f14e
#  undef fputc
Packit 33f14e
#  define fputc(x,y) fputc_unlocked (x,y)
Packit 33f14e
# else
Packit 33f14e
#  define fputc_unlocked(x,y) fputc (x,y)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FPUTS_UNLOCKED
Packit 33f14e
#  undef fputs
Packit 33f14e
#  define fputs(x,y) fputs_unlocked (x,y)
Packit 33f14e
# else
Packit 33f14e
#  define fputs_unlocked(x,y) fputs (x,y)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FREAD_UNLOCKED
Packit 33f14e
#  undef fread
Packit 33f14e
#  define fread(w,x,y,z) fread_unlocked (w,x,y,z)
Packit 33f14e
# else
Packit 33f14e
#  define fread_unlocked(w,x,y,z) fread (w,x,y,z)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_FWRITE_UNLOCKED
Packit 33f14e
#  undef fwrite
Packit 33f14e
#  define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
Packit 33f14e
# else
Packit 33f14e
#  define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_GETC_UNLOCKED
Packit 33f14e
#  undef getc
Packit 33f14e
#  define getc(x) getc_unlocked (x)
Packit 33f14e
# else
Packit 33f14e
#  define getc_unlocked(x) getc (x)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_GETCHAR_UNLOCKED
Packit 33f14e
#  undef getchar
Packit 33f14e
#  define getchar() getchar_unlocked ()
Packit 33f14e
# else
Packit 33f14e
#  define getchar_unlocked() getchar ()
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_PUTC_UNLOCKED
Packit 33f14e
#  undef putc
Packit 33f14e
#  define putc(x,y) putc_unlocked (x,y)
Packit 33f14e
# else
Packit 33f14e
#  define putc_unlocked(x,y) putc (x,y)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# if HAVE_DECL_PUTCHAR_UNLOCKED
Packit 33f14e
#  undef putchar
Packit 33f14e
#  define putchar(x) putchar_unlocked (x)
Packit 33f14e
# else
Packit 33f14e
#  define putchar_unlocked(x) putchar (x)
Packit 33f14e
# endif
Packit 33f14e
Packit 33f14e
# undef flockfile
Packit 33f14e
# define flockfile(x) ((void) 0)
Packit 33f14e
Packit 33f14e
# undef ftrylockfile
Packit 33f14e
# define ftrylockfile(x) 0
Packit 33f14e
Packit 33f14e
# undef funlockfile
Packit 33f14e
# define funlockfile(x) ((void) 0)
Packit 33f14e
Packit 33f14e
#endif /* UNLOCKED_IO_H */