Blame lib/unlocked-io.h

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