annotate lib/unlocked-io.h @ 17476:6057744acd2c default tip master

autoupdate
author Karl Berry <karl@freefriends.org>
date Fri, 16 Aug 2013 06:32:22 -0700
parents e542fd46ad6f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
1 /* Prefer faster, non-thread-safe stdio functions if available.
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
2
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16201
diff changeset
3 Copyright (C) 2001-2004, 2009-2013 Free Software Foundation, Inc.
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
4
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5851
diff changeset
5 This program is free software: you can redistribute it and/or modify
4435
d4efdb886b2a Switch from LGPL to GPL.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4064
diff changeset
6 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5851
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5851
diff changeset
8 (at your option) any later version.
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
9
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
4435
d4efdb886b2a Switch from LGPL to GPL.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4064
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d4efdb886b2a Switch from LGPL to GPL.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4064
diff changeset
13 GNU General Public License for more details.
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
14
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5851
diff changeset
15 You should have received a copy of the GNU General Public License
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 5851
diff changeset
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
17
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
18 /* Written by Jim Meyering. */
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
19
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
20 #ifndef UNLOCKED_IO_H
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
21 # define UNLOCKED_IO_H 1
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
22
4778
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
23 /* These are wrappers for functions/macros from the GNU C library, and
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
24 from other C libraries supporting POSIX's optional thread-safe functions.
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
25
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
26 The standard I/O functions are thread-safe. These *_unlocked ones are
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
27 more efficient but not thread-safe. That they're not thread-safe is
4778
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
28 fine since all of the applications in this package are single threaded.
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
29
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
30 Also, some code that is shared with the GNU C library may invoke
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
31 the *_unlocked functions directly. On hosts that lack those
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
32 functions, invoke the non-thread-safe versions instead. */
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
33
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
34 # include <stdio.h>
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
35
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
36 # if HAVE_DECL_CLEARERR_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
37 # undef clearerr
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
38 # define clearerr(x) clearerr_unlocked (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
39 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
40 # define clearerr_unlocked(x) clearerr (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
41 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
42
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
43 # if HAVE_DECL_FEOF_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
44 # undef feof
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
45 # define feof(x) feof_unlocked (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
46 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
47 # define feof_unlocked(x) feof (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
48 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
49
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
50 # if HAVE_DECL_FERROR_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
51 # undef ferror
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
52 # define ferror(x) ferror_unlocked (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
53 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
54 # define ferror_unlocked(x) ferror (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
55 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
56
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
57 # if HAVE_DECL_FFLUSH_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
58 # undef fflush
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
59 # define fflush(x) fflush_unlocked (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
60 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
61 # define fflush_unlocked(x) fflush (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
62 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
63
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
64 # if HAVE_DECL_FGETS_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
65 # undef fgets
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
66 # define fgets(x,y,z) fgets_unlocked (x,y,z)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
67 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
68 # define fgets_unlocked(x,y,z) fgets (x,y,z)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
69 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
70
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
71 # if HAVE_DECL_FPUTC_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
72 # undef fputc
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
73 # define fputc(x,y) fputc_unlocked (x,y)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
74 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
75 # define fputc_unlocked(x,y) fputc (x,y)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
76 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
77
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
78 # if HAVE_DECL_FPUTS_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
79 # undef fputs
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
80 # define fputs(x,y) fputs_unlocked (x,y)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
81 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
82 # define fputs_unlocked(x,y) fputs (x,y)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
83 # endif
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
84
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
85 # if HAVE_DECL_FREAD_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
86 # undef fread
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
87 # define fread(w,x,y,z) fread_unlocked (w,x,y,z)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
88 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
89 # define fread_unlocked(w,x,y,z) fread (w,x,y,z)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
90 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
91
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
92 # if HAVE_DECL_FWRITE_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
93 # undef fwrite
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
94 # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
95 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
96 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
97 # endif
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
98
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
99 # if HAVE_DECL_GETC_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
100 # undef getc
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
101 # define getc(x) getc_unlocked (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
102 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
103 # define getc_unlocked(x) getc (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
104 # endif
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
105
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
106 # if HAVE_DECL_GETCHAR_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
107 # undef getchar
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
108 # define getchar() getchar_unlocked ()
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
109 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
110 # define getchar_unlocked() getchar ()
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
111 # endif
4778
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
112
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
113 # if HAVE_DECL_PUTC_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
114 # undef putc
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
115 # define putc(x,y) putc_unlocked (x,y)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
116 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
117 # define putc_unlocked(x,y) putc (x,y)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
118 # endif
4778
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
119
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
120 # if HAVE_DECL_PUTCHAR_UNLOCKED
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
121 # undef putchar
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
122 # define putchar(x) putchar_unlocked (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
123 # else
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
124 # define putchar_unlocked(x) putchar (x)
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
125 # endif
4778
d68794da5ecb Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4435
diff changeset
126
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
127 # undef flockfile
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
128 # define flockfile(x) ((void) 0)
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
129
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
130 # undef ftrylockfile
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
131 # define ftrylockfile(x) 0
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
132
5851
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
133 # undef funlockfile
d39411e1c5e6 Sync from coreutils.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5848
diff changeset
134 # define funlockfile(x) ((void) 0)
5318
7c24a825b51d Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents: 4913
diff changeset
135
4064
b4c31ea552ff New file, from GNU diffutils, but with proper copyright notice and
Paul Eggert <eggert@cs.ucla.edu>
parents:
diff changeset
136 #endif /* UNLOCKED_IO_H */