bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] maintain unlocked-io.h by hand instead of generating it?


From: Paul Eggert
Subject: [Bug-gnulib] maintain unlocked-io.h by hand instead of generating it?
Date: Sun, 24 Nov 2002 21:39:15 -0800 (PST)

I ran into a few problems in bison and diffutils in generating
unlocked-io.h automatically (dependency mismatches, etc), and have
changed those packages so that unlocked-io.h is maintained by hand
instead.  Is it OK to propagate this change into gnulib?  This change
will make the entire gnulib source code a tiny bit smaller, and will
make it easier to follow (at least for me).  I've been using this
change in diffutils for a year or so, so it should be pretty portable.

Here's a proposed patch.  I've tested this with coreutils by building
coreutils under Solaris 8.

2002-11-24  Paul Eggert  <address@hidden>

        Maintain unlocked-io.h by hand instead of generating it.

        * lib/unlocked-io.h: New file.
        * lib/gen-uio: Remove.
        * lib/Makefile.am (libfetish_a_SOURCES): Add unlocked-io.h.
        (BUILT_SOURCES, DISTCLEANFILES, all-local): Remove unlocked-io.h.
        (EXTRA_DIST): Remove gen-uio.
        (getdate$U.o, io_functions, unlocked-io.h): Remove.

diff -Naur -x'*~' gnulib/lib/Makefile.am gnulib-uio/lib/Makefile.am
--- gnulib/lib/Makefile.am      2002-11-24 20:32:31.584363000 -0800
+++ gnulib-uio/lib/Makefile.am  2002-11-24 20:32:08.712362000 -0800
@@ -85,6 +85,7 @@
   timespec.h \
   unicodeio.c unicodeio.h \
   unistd-safer.h \
+  unlocked-io.h \
   userspec.c \
   version-etc.c version-etc.h \
   xalloc.h \
@@ -105,11 +106,11 @@
 libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
 
 
-BUILT_SOURCES = getdate.c lstat.c stat.c unlocked-io.h
+BUILT_SOURCES = getdate.c lstat.c stat.c
 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
-DISTCLEANFILES = lstat.c stat.c unlocked-io.h
+DISTCLEANFILES = lstat.c stat.c
 
-EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin gen-uio \
+EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin \
   fnmatch_loop.c
 
 lstat.c: xstat.in
@@ -137,7 +138,7 @@
 # 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 lstat.c stat.c unlocked-io.h
+all-local: charset.alias ref-add.sed ref-del.sed lstat.c stat.c
 
 charset_alias = $(DESTDIR)$(libdir)/charset.alias
 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
@@ -177,21 +178,3 @@
        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 $@
diff -Naur -x'*~' gnulib/lib/gen-uio gnulib-uio/lib/gen-uio
--- gnulib/lib/gen-uio  2001-09-26 01:27:42.000000000 -0700
+++ gnulib-uio/lib/gen-uio      1969-12-31 16:00:00.000000000 -0800
@@ -1,53 +0,0 @@
-#!/bin/sh
-
-fail=0
-cat <<\EOF || fail=1
-#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.  */
-
-EOF
-
-for f in $@; do
-  u=`echo $f|tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
-  cat <<EOF || fail=1
-#  if HAVE_${u}_UNLOCKED
-#   undef $f
-EOF
-  case $f in
-    getchar)
-      params=;;
-    putchar | clearerr | feof | ferror | fflush | getc )
-      params=x;;
-    putc | fputc | fputs )
-      params=x,y;;
-    fgets )
-      params=x,y,z;;
-    fread | fwrite )
-      params=w,x,y,z;;
-    *)
-      echo $0: missing case for $f 2>&1; fail=1;;
-  esac
-  cat <<EOF || fail=1
-#   define $f($params) ${f}_unlocked ($params)
-#  endif
-EOF
-done
-
-cat <<\EOF || fail=1
-
-# endif /* USE_UNLOCKED_IO */
-#endif /* UNLOCKED_IO_H */
-EOF
-
-(exit $fail); exit
diff -Naur -x'*~' gnulib/lib/unlocked-io.h gnulib-uio/lib/unlocked-io.h
--- gnulib/lib/unlocked-io.h    1969-12-31 16:00:00.000000000 -0800
+++ gnulib-uio/lib/unlocked-io.h        2001-11-19 21:37:31.000000000 -0800
@@ -0,0 +1,69 @@
+#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 */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]