Mercurial > hg > octave-lojdl > gnulib-hg
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 |
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 | 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 | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 | 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 | 34 # include <stdio.h> |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
35 |
5851 | 36 # if HAVE_DECL_CLEARERR_UNLOCKED |
37 # undef clearerr | |
38 # define clearerr(x) clearerr_unlocked (x) | |
39 # else | |
40 # define clearerr_unlocked(x) clearerr (x) | |
41 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
42 |
5851 | 43 # if HAVE_DECL_FEOF_UNLOCKED |
44 # undef feof | |
45 # define feof(x) feof_unlocked (x) | |
46 # else | |
47 # define feof_unlocked(x) feof (x) | |
48 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
49 |
5851 | 50 # if HAVE_DECL_FERROR_UNLOCKED |
51 # undef ferror | |
52 # define ferror(x) ferror_unlocked (x) | |
53 # else | |
54 # define ferror_unlocked(x) ferror (x) | |
55 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
56 |
5851 | 57 # if HAVE_DECL_FFLUSH_UNLOCKED |
58 # undef fflush | |
59 # define fflush(x) fflush_unlocked (x) | |
60 # else | |
61 # define fflush_unlocked(x) fflush (x) | |
62 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
63 |
5851 | 64 # if HAVE_DECL_FGETS_UNLOCKED |
65 # undef fgets | |
66 # define fgets(x,y,z) fgets_unlocked (x,y,z) | |
67 # else | |
68 # define fgets_unlocked(x,y,z) fgets (x,y,z) | |
69 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
70 |
5851 | 71 # if HAVE_DECL_FPUTC_UNLOCKED |
72 # undef fputc | |
73 # define fputc(x,y) fputc_unlocked (x,y) | |
74 # else | |
75 # define fputc_unlocked(x,y) fputc (x,y) | |
76 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
77 |
5851 | 78 # if HAVE_DECL_FPUTS_UNLOCKED |
79 # undef fputs | |
80 # define fputs(x,y) fputs_unlocked (x,y) | |
81 # else | |
82 # define fputs_unlocked(x,y) fputs (x,y) | |
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 | 85 # if HAVE_DECL_FREAD_UNLOCKED |
86 # undef fread | |
87 # define fread(w,x,y,z) fread_unlocked (w,x,y,z) | |
88 # else | |
89 # define fread_unlocked(w,x,y,z) fread (w,x,y,z) | |
90 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
91 |
5851 | 92 # if HAVE_DECL_FWRITE_UNLOCKED |
93 # undef fwrite | |
94 # define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z) | |
95 # else | |
96 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z) | |
97 # endif | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
98 |
5851 | 99 # if HAVE_DECL_GETC_UNLOCKED |
100 # undef getc | |
101 # define getc(x) getc_unlocked (x) | |
102 # else | |
103 # define getc_unlocked(x) getc (x) | |
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 | 106 # if HAVE_DECL_GETCHAR_UNLOCKED |
107 # undef getchar | |
108 # define getchar() getchar_unlocked () | |
109 # else | |
110 # define getchar_unlocked() getchar () | |
111 # endif | |
4778
d68794da5ecb
Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4435
diff
changeset
|
112 |
5851 | 113 # if HAVE_DECL_PUTC_UNLOCKED |
114 # undef putc | |
115 # define putc(x,y) putc_unlocked (x,y) | |
116 # else | |
117 # define putc_unlocked(x,y) putc (x,y) | |
118 # endif | |
4778
d68794da5ecb
Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4435
diff
changeset
|
119 |
5851 | 120 # if HAVE_DECL_PUTCHAR_UNLOCKED |
121 # undef putchar | |
122 # define putchar(x) putchar_unlocked (x) | |
123 # else | |
124 # define putchar_unlocked(x) putchar (x) | |
125 # endif | |
4778
d68794da5ecb
Merge getpass from libc, plus a few fixes.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4435
diff
changeset
|
126 |
5851 | 127 # undef flockfile |
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 | 130 # undef ftrylockfile |
131 # define ftrylockfile(x) 0 | |
5318
7c24a825b51d
Remove dependencies on unlocked-io.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4913
diff
changeset
|
132 |
5851 | 133 # undef funlockfile |
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 */ |