Blame gettext-runtime/gnulib-lib/unlocked-io.h

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