[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] maintain unlocked-io.h by hand instead of generating it
From: |
Paul Eggert |
Subject: |
Re: [Bug-gnulib] maintain unlocked-io.h by hand instead of generating it? |
Date: |
Wed, 4 Dec 2002 12:57:21 -0800 |
> Cc: address@hidden
> From: Jim Meyering <address@hidden>
> Date: Tue, 26 Nov 2002 07:03:20 +0100
>
> Other people have had problems with that, too.
> Thanks!
OK, inspired by your work on safe-* and *stat.c, I installed the
following change (and I removed lib/gen-uio). This is slightly
different from my earlier proposal since I added proper copyright
notices and attribution.
2002-12-04 Paul Eggert <address@hidden>
Do not generate unlocked-io.h automatically, since it's easier to
maintain it by hand.
* unlocked-io.h: New file, from GNU diffutils,
but with proper copyright notice and attribution.
* gen-uio: Remove.
* Makefile.am: Add copyright notice.
(libfetish_a_SOURCES): Add unlocked-io.h.
(BUILT_SOURCES, all-local): Remove unlocked-io.h.
(DISTCLEANFILES, io_functions): Remove macros.
(EXTRA_DIST): Remove gen_uio.
(unlocked-io.h): Remove rule.
--- /dev/null 2002-10-01 00:56:28.000000000 +0000
+++ lib/unlocked-io.h 2002-12-04 20:41:43.000000000 +0000
@@ -0,0 +1,90 @@
+/* Prefer faster, non-thread-safe stdio functions if available.
+
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+
+/* Written by Jim Meyering. */
+
+#ifndef UNLOCKED_IO_H
+# define UNLOCKED_IO_H 1
+
+# ifndef USE_UNLOCKED_IO
+# define USE_UNLOCKED_IO 1
+# endif
+
+# if USE_UNLOCKED_IO
+
+/* 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 of the applications in this package are single threaded. */
+
+# if HAVE_DECL_CLEARERR_UNLOCKED
+# undef clearerr
+# define clearerr(x) clearerr_unlocked (x)
+# endif
+# if HAVE_DECL_FEOF_UNLOCKED
+# undef feof
+# define feof(x) feof_unlocked (x)
+# endif
+# if HAVE_DECL_FERROR_UNLOCKED
+# undef ferror
+# define ferror(x) ferror_unlocked (x)
+# endif
+# if HAVE_DECL_FFLUSH_UNLOCKED
+# undef fflush
+# define fflush(x) fflush_unlocked (x)
+# endif
+# if HAVE_DECL_FGETS_UNLOCKED
+# undef fgets
+# define fgets(x,y,z) fgets_unlocked (x,y,z)
+# endif
+# if HAVE_DECL_FPUTC_UNLOCKED
+# undef fputc
+# define fputc(x,y) fputc_unlocked (x,y)
+# endif
+# if HAVE_DECL_FPUTS_UNLOCKED
+# undef fputs
+# define fputs(x,y) fputs_unlocked (x,y)
+# endif
+# if HAVE_DECL_FREAD_UNLOCKED
+# undef fread
+# define fread(w,x,y,z) fread_unlocked (w,x,y,z)
+# endif
+# if HAVE_DECL_FWRITE_UNLOCKED
+# undef fwrite
+# define fwrite(w,x,y,z) fwrite_unlocked (w,x,y,z)
+# endif
+# if HAVE_DECL_GETC_UNLOCKED
+# undef getc
+# define getc(x) getc_unlocked (x)
+# endif
+# if HAVE_DECL_GETCHAR_UNLOCKED
+# undef getchar
+# define getchar() getchar_unlocked ()
+# endif
+# if HAVE_DECL_PUTC_UNLOCKED
+# undef putc
+# define putc(x,y) putc_unlocked (x,y)
+# endif
+# if HAVE_DECL_PUTCHAR_UNLOCKED
+# undef putchar
+# define putchar(x) putchar_unlocked (x)
+# endif
+
+# endif /* USE_UNLOCKED_IO */
+#endif /* UNLOCKED_IO_H */
Index: lib/Makefile.am
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/Makefile.am,v
retrieving revision 1.132
diff -p -u -r1.132 Makefile.am
--- lib/Makefile.am 4 Dec 2002 10:12:13 -0000 1.132
+++ lib/Makefile.am 4 Dec 2002 20:48:24 -0000
@@ -1,4 +1,22 @@
-## Process this file with automake to produce Makefile.in -*-Makefile-*-
+## Makefile for gnulib/lib -*-Makefile-*-
+
+# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free
+# Software Foundation, Inc.
+
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+## 02111-1307, USA.
AUTOMAKE_OPTIONS = ../src/ansi2knr
@@ -85,6 +103,7 @@ libfetish_a_SOURCES = \
timespec.h \
unicodeio.c unicodeio.h \
unistd-safer.h \
+ unlocked-io.h \
userspec.c \
version-etc.c version-etc.h \
xalloc.h \
@@ -105,11 +124,10 @@ libfetish_a_LIBADD = @LIBOBJS@ @ALLOCA@
libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
-BUILT_SOURCES = getdate.c unlocked-io.h
+BUILT_SOURCES = getdate.c
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
-DISTCLEANFILES = unlocked-io.h
-EXTRA_DIST = config.charset ref-add.sin ref-del.sin gen-uio \
+EXTRA_DIST = config.charset ref-add.sin ref-del.sin \
fnmatch_loop.c
# The following is needed in order to install a simple file in $(libdir)
@@ -119,7 +137,7 @@ EXTRA_DIST = config.charset ref-add.sin
# On systems with glibc-2.1 or newer, the file is redundant, therefore we
# avoid installing it.
-all-local: charset.alias ref-add.sed ref-del.sed unlocked-io.h
+all-local: charset.alias ref-add.sed ref-del.sed
charset_alias = $(DESTDIR)$(libdir)/charset.alias
charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
@@ -159,21 +177,3 @@ SUFFIXES = .sed .sin
mv t-$@ $@
CLEANFILES = charset.alias ref-add.sed ref-del.sed
-
-###############################################
-
-# FIXME: remove this dependency once automake handles it.
-# As of cvs automake of about 2002-01-13,
-# this dependency is necessary to avoid a build failure
-# when running `make check' before running `make all'.
-# Otherwise, unlocked-io.h is not built before it's needed.
-getdate$U.o: unlocked-io.h
-
-# FIXME: CAUTION this list is a duplicate of one in ../Makefile.cfg.
-io_functions = \
- clearerr feof ferror fflush fgets fputc fputs \
- fread fwrite getc getchar putc putchar
-
-unlocked-io.h: $(srcdir)/gen-uio Makefile.am
- srcdir=$(srcdir) $(SHELL) $(srcdir)/gen-uio $(io_functions) >
address@hidden
- mv address@hidden $@
- Re: [Bug-gnulib] maintain unlocked-io.h by hand instead of generating it?,
Paul Eggert <=