Skip to content

Commit 8e1d4d7

Browse files
committed
Use gnulib module unlocked-io.
1 parent 9b34596 commit 8e1d4d7

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed

Makefile.devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ CONFIGURES_IN = configure.in
4444
#m4/endian.m4 : $(CLISP_DIR)/src/m4/endian.m4 ; cp -p $< $@-t && mv $@-t $@
4545
#m4/libtool.m4 : $(CLISP_DIR)/src/m4/libtool.m4 ; cp -p $< $@-t && mv $@-t $@
4646

47-
aclocal.m4 : m4/general.m4 m4/proto.m4 m4/cp.m4 m4/ln.m4 m4/codeset.m4 m4/eilseq.m4 m4/endian.m4 m4/glibc21.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/alloca.m4 m4/canonicalize.m4 m4/error.m4 m4/mbstate_t.m4 m4/onceonly.m4 m4/pathmax.m4 m4/relocatable.m4 m4/setenv.m4 m4/stdbool.m4 m4/strerror.m4 m4/strerror_r.m4 m4/xreadlink.m4 m4/libtool.m4 m4/gettext.m4 m4/iconv.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 m4/nls.m4 m4/po.m4 m4/progtest.m4
47+
aclocal.m4 : m4/general.m4 m4/proto.m4 m4/cp.m4 m4/ln.m4 m4/codeset.m4 m4/eilseq.m4 m4/endian.m4 m4/glibc21.m4 m4/isc-posix.m4 m4/lcmessage.m4 m4/alloca.m4 m4/canonicalize.m4 m4/error.m4 m4/mbstate_t.m4 m4/onceonly.m4 m4/pathmax.m4 m4/relocatable.m4 m4/setenv.m4 m4/stdbool.m4 m4/strerror.m4 m4/strerror_r.m4 m4/unlocked-io.m4 m4/xreadlink.m4 m4/libtool.m4 m4/gettext.m4 m4/iconv.m4 m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 m4/nls.m4 m4/po.m4 m4/progtest.m4
4848
aclocal -I m4 --output=$@
4949

5050
configures : $(CONFIGURES)

m4/unlocked-io.m4

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#serial 7 -*- autoconf -*-
2+
3+
dnl From Jim Meyering.
4+
dnl
5+
dnl See if the glibc *_unlocked I/O macros or functions are available.
6+
dnl Use only those *_unlocked macros or functions that are declared
7+
dnl (because some of them were declared in Solaris 2.5.1 but were removed
8+
dnl in Solaris 2.6, whereas we want binaries built on Solaris 2.5.1 to run
9+
dnl on Solaris 2.6).
10+
11+
AC_DEFUN([jm_FUNC_GLIBC_UNLOCKED_IO],
12+
[
13+
dnl Persuade glibc <stdio.h> to declare fgets_unlocked(), fputs_unlocked()
14+
dnl etc.
15+
AC_REQUIRE([AC_GNU_SOURCE])
16+
17+
AC_CHECK_DECLS_ONCE(
18+
[clearerr_unlocked feof_unlocked ferror_unlocked
19+
fflush_unlocked fgets_unlocked fputc_unlocked fputs_unlocked
20+
fread_unlocked fwrite_unlocked getc_unlocked
21+
getchar_unlocked putc_unlocked putchar_unlocked])
22+
])

srclib/unlocked-io.h

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

0 commit comments

Comments
 (0)