unlocked-io.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Prefer faster, non-thread-safe stdio functions if available.
  2. Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU Library General Public License as published
  5. by the Free Software Foundation; either version 2, or (at your option)
  6. any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  14. USA. */
  15. /* Written by Jim Meyering. */
  16. #ifndef UNLOCKED_IO_H
  17. # define UNLOCKED_IO_H 1
  18. # ifndef USE_UNLOCKED_IO
  19. # define USE_UNLOCKED_IO 1
  20. # endif
  21. # if USE_UNLOCKED_IO
  22. /* These are wrappers for functions/macros from GNU libc.
  23. The standard I/O functions are thread-safe. These *_unlocked ones are
  24. more efficient but not thread-safe. That they're not thread-safe is
  25. fine since all of the applications in this package are single threaded. */
  26. # if HAVE_DECL_CLEARERR_UNLOCKED
  27. # undef clearerr
  28. # define clearerr(x) clearerr_unlocked (x)
  29. # endif
  30. # if HAVE_DECL_FEOF_UNLOCKED
  31. # undef feof
  32. # define feof(x) feof_unlocked (x)
  33. # endif
  34. # if HAVE_DECL_FERROR_UNLOCKED
  35. # undef ferror
  36. # define ferror(x) ferror_unlocked (x)
  37. # endif
  38. # if HAVE_DECL_FFLUSH_UNLOCKED
  39. # undef fflush
  40. # define fflush(x) fflush_unlocked (x)
  41. # endif
  42. # if HAVE_DECL_FGETS_UNLOCKED
  43. # undef fgets
  44. # define fgets(x,y,z) fgets_unlocked (x,y,z)
  45. # endif
  46. # if HAVE_DECL_FPUTC_UNLOCKED
  47. # undef fputc
  48. # define fputc(x,y) fputc_unlocked (x,y)
  49. # endif
  50. # if HAVE_DECL_FPUTS_UNLOCKED
  51. # undef fputs
  52. # define fputs(x,y) fputs_unlocked (x,y)
  53. # endif
  54. # if HAVE_DECL_FREAD_UNLOCKED
  55. # undef fread
  56. # define fread(w,x,y,z) fread_unlocked (w,x,y,z)
  57. # endif
  58. # if HAVE_DECL_FWRITE_UNLOCKED
  59. # undef fwrite
  60. # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
  61. # endif
  62. # if HAVE_DECL_GETC_UNLOCKED
  63. # undef getc
  64. # define getc(x) getc_unlocked (x)
  65. # endif
  66. # if HAVE_DECL_GETCHAR_UNLOCKED
  67. # undef getchar
  68. # define getchar() getchar_unlocked ()
  69. # endif
  70. # if HAVE_DECL_PUTC_UNLOCKED
  71. # undef putc
  72. # define putc(x,y) putc_unlocked (x,y)
  73. # endif
  74. # if HAVE_DECL_PUTCHAR_UNLOCKED
  75. # undef putchar
  76. # define putchar(x) putchar_unlocked (x)
  77. # endif
  78. # endif /* USE_UNLOCKED_IO */
  79. #endif /* UNLOCKED_IO_H */