summaryrefslogtreecommitdiff
path: root/src/sys2.h
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-06-28 21:38:14 +0000
committerJim Meyering <jim@meyering.net>1998-06-28 21:38:14 +0000
commit439fdff851b3a064ccd3961e70495629ddba6702 (patch)
treeaf5ea0a5680a8233a21c53d14812fbe320c1d17d /src/sys2.h
parent933b990ab91c9344c6379d4f61a2cd92ee1a3722 (diff)
downloadcoreutils-439fdff851b3a064ccd3961e70495629ddba6702.tar.xz
Add macro definitions for GNU libc unlocked wrappers.
Diffstat (limited to 'src/sys2.h')
-rw-r--r--src/sys2.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/sys2.h b/src/sys2.h
index e2d41594e..2b3c57e36 100644
--- a/src/sys2.h
+++ b/src/sys2.h
@@ -156,3 +156,81 @@ off_t lseek ();
/* Be CAREFUL that there are no side effects in N. */
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
#endif
+
+/* These are wrappers for functions/macros from GNU libc.
+ The standard I/O functions are thread-safe. These *_unlocked ones
+ are more efficient but not thread-safe. That they're not thread-safe
+ is fine since all these applications are single threaded. */
+
+#ifdef HAVE_FCLOSE_UNLOCKED
+# define FCLOSE(S) fclose_unlocked (S)
+#else
+# define FCLOSE(S) fclose (S)
+#endif
+
+#ifdef HAVE_FFLUSH_UNLOCKED
+# define FFLUSH(S) fflush_unlocked (S)
+#else
+# define FFLUSH(S) fflush (S)
+#endif
+
+#ifdef HAVE_GETC_UNLOCKED
+# define GETC(S) getc_unlocked (S)
+#else
+# define GETC(S) getc (S)
+#endif
+
+#ifdef HAVE_GETCHAR_UNLOCKED
+# define GETCHAR(S) getchar_unlocked (S)
+#else
+# define GETCHAR(S) getchar (S)
+#endif
+
+#ifdef HAVE_PUTCHAR_UNLOCKED
+# define PUTCHAR(C) putchar_unlocked (C)
+#else
+# define PUTCHAR(C) putchar (C)
+#endif
+
+#ifdef HAVE_PUTC_UNLOCKED
+# define PUTC(C, S) putc_unlocked (C, S)
+#else
+# define PUTC(C, S) putc (C, S)
+#endif
+
+#ifdef HAVE_FPUTC_UNLOCKED
+# define FPUTC(C, S) fputc_unlocked (C, S)
+#else
+# define FPUTC(C, S) fputc (C, S)
+#endif
+
+#ifdef HAVE_FREAD_UNLOCKED
+# define FREAD(P, Z, N, S) fread_unlocked (P, Z, N, S)
+#else
+# define FREAD(P, Z, N, S) fread (P, Z, N, S)
+#endif
+
+#ifdef HAVE_FWRITE_UNLOCKED
+# define FWRITE(P, Z, N, S) fwrite_unlocked (P, Z, N, S)
+#else
+# define FWRITE(P, Z, N, S) fwrite (P, Z, N, S)
+#endif
+
+#ifdef HAVE_CLEARERR_UNLOCKED
+# define CLEARERR(S) clearerr_unlocked (S)
+#else
+# define CLEARERR(S) clearerr (S)
+#endif
+
+#ifdef HAVE_FEOF_UNLOCKED
+# define FEOF(S) feof_unlocked (S)
+#else
+# define FEOF(S) feof (S)
+#endif
+
+#ifdef HAVE_FERROR_UNLOCKED
+# define FERROR(S) ferror_unlocked (S)
+#else
+# define FERROR(S) ferror (S)
+#endif
+