stddef: fix NetBSD 5.0 NULL bug, rather than working around it
authorEric Blake <ebb9@byu.net>
Wed, 12 Aug 2009 16:23:03 +0000 (10:23 -0600)
committerEric Blake <ebb9@byu.net>
Fri, 14 Aug 2009 12:45:29 +0000 (06:45 -0600)
* tests/test-locale.c: Revert previous patch related to NULL.
* tests/test-stdio.c: Likewise.
* tests/test-stdlib.c: Likewise.
* tests/test-string.c: Likewise.
* tests/test-unistd.c: Likewise.
* modules/time-tests (Depends-on): Add verify.
* modules/wchar-tests (Depends-on): Likewise.
* tests/test-time.c: Test for NULL compliance.
* tests/test-wchar.c: Likewise.
* modules/locale (Depends-on): Add stddef.
* modules/stdio (Depends-on): Likewise.
* modules/stdlib (Depends-on): Likewise.
* modules/string (Depends-on): Likewise.
* modules/time (Depends-on): Likewise.
* modules/unistd (Depends-on): Likewise.
* modules/wchar (Depends-on): Likewise.
* lib/locale.in.h (includes): Use <stddef.h> to fix NULL.
* lib/stdlib.in.h (includes): Likewise.
* lib/string.in.h (includes): Likewise.
* lib/time.in.h (includes): Likewise.
* lib/unistd.in.h (includes): Likewise.
* m4/locale_h.m4 (gl_LOCALE_H): Replace locale.h if stddef.h was
replaced.
* m4/wchar.m4 (gl_WCHAR_H): Likewise.
* m4/stddef_h.m4: New file.
* modules/stddef: Likewise.
* lib/stddef.in.h: Likewise.
* modules/stddef-tests: Likewise.
* tests/test-stddef.c: Likewise.
* MODULES.html.sh (Basic types <stddef.h>): Mention new module.
* doc/posix-headers/stddef.texi (stddef.h): Document the bug.
* doc/posix-headers/locale.texi (locale.h): Likewise.
* doc/posix-headers/stdio.texi (stdio.h): Likewise.
* doc/posix-headers/stdlib.texi (stdlib.h): Likewise.
* doc/posix-headers/string.texi (string.h): Likewise.
* doc/posix-headers/time.texi (time.h): Likewise.
* doc/posix-headers/unistd.texi (unistd.h): Likewise.
* doc/posix-headers/wchar.texi (wchar.h): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
33 files changed:
ChangeLog
MODULES.html.sh
doc/posix-headers/locale.texi
doc/posix-headers/stddef.texi
doc/posix-headers/stdio.texi
doc/posix-headers/stdlib.texi
doc/posix-headers/string.texi
doc/posix-headers/time.texi
doc/posix-headers/unistd.texi
doc/posix-headers/wchar.texi
lib/locale.in.h
lib/stddef.in.h [new file with mode: 0644]
lib/stdlib.in.h
lib/string.in.h
lib/time.in.h
lib/unistd.in.h
m4/locale_h.m4
m4/stddef_h.m4 [new file with mode: 0644]
m4/wchar.m4
modules/locale
modules/stddef [new file with mode: 0644]
modules/stddef-tests [new file with mode: 0644]
modules/stdio
modules/stdlib
modules/string
modules/time
modules/time-tests
modules/unistd
modules/wchar
modules/wchar-tests
tests/test-stddef.c [new file with mode: 0644]
tests/test-time.c
tests/test-wchar.c

index a18e8ea2e40877545481aae8146ded9397f63e82..3c0089bdbf07c9a2fd833a693877fef54c69e1e2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,46 @@
+2009-08-14  Eric Blake  <ebb9@byu.net>
+       and Bruno Haible  <bruno@clisp.org>
+
+       stddef: fix NetBSD 5.0 NULL bug, rather than working around it
+       * tests/test-locale.c: Revert previous patch related to NULL.
+       * tests/test-stdio.c: Likewise.
+       * tests/test-stdlib.c: Likewise.
+       * tests/test-string.c: Likewise.
+       * tests/test-unistd.c: Likewise.
+       * modules/time-tests (Depends-on): Add verify.
+       * modules/wchar-tests (Depends-on): Likewise.
+       * tests/test-time.c: Test for NULL compliance.
+       * tests/test-wchar.c: Likewise.
+       * modules/locale (Depends-on): Add stddef.
+       * modules/stdio (Depends-on): Likewise.
+       * modules/stdlib (Depends-on): Likewise.
+       * modules/string (Depends-on): Likewise.
+       * modules/time (Depends-on): Likewise.
+       * modules/unistd (Depends-on): Likewise.
+       * modules/wchar (Depends-on): Likewise.
+       * lib/locale.in.h (includes): Use <stddef.h> to fix NULL.
+       * lib/stdlib.in.h (includes): Likewise.
+       * lib/string.in.h (includes): Likewise.
+       * lib/time.in.h (includes): Likewise.
+       * lib/unistd.in.h (includes): Likewise.
+       * m4/locale_h.m4 (gl_LOCALE_H): Replace locale.h if stddef.h was
+       replaced.
+       * m4/wchar.m4 (gl_WCHAR_H): Likewise.
+       * m4/stddef_h.m4: New file.
+       * modules/stddef: Likewise.
+       * lib/stddef.in.h: Likewise.
+       * modules/stddef-tests: Likewise.
+       * tests/test-stddef.c: Likewise.
+       * MODULES.html.sh (Basic types <stddef.h>): Mention new module.
+       * doc/posix-headers/stddef.texi (stddef.h): Document the bug.
+       * doc/posix-headers/locale.texi (locale.h): Likewise.
+       * doc/posix-headers/stdio.texi (stdio.h): Likewise.
+       * doc/posix-headers/stdlib.texi (stdlib.h): Likewise.
+       * doc/posix-headers/string.texi (string.h): Likewise.
+       * doc/posix-headers/time.texi (time.h): Likewise.
+       * doc/posix-headers/unistd.texi (unistd.h): Likewise.
+       * doc/posix-headers/wchar.texi (wchar.h): Likewise.
+
 2009-08-14  Eric Blake  <ebb9@byu.net>
 
        doc: improve git diff of texinfo files
index ce5ac80c0eafd2924db80607ed86ee466cd3c96c..298b65565bc58293a158f44b93dc40fc82ae7c5b 100755 (executable)
@@ -2032,6 +2032,16 @@ func_all_modules ()
   func_module stdbool
   func_end_table
 
+  element="Basic types <stddef.h>"
+  element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"`
+  func_section_wrap isoc_sup_stddef
+  func_wrap H3
+  func_echo "$element"
+
+  func_begin_table
+  func_module stddef
+  func_end_table
+
   element="Integer types and values <stdint.h>"
   element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"`
   func_section_wrap isoc_sup_stdint
index a65da977d73983a2122b49bf2455e4aa41d7d775..df0673b5a88a0104b645b92355e84af146b214f1 100644 (file)
@@ -10,6 +10,11 @@ Portability problems fixed by Gnulib:
 @item
 The definition of @samp{LC_MESSAGES} is missing on some platforms:
 mingw.
+
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index df28e0fb797f56fdb7f984e7f716de08c828d898..92ff294cb485a64ed8a98e095ebaea28fee13f44 100644 (file)
@@ -3,10 +3,17 @@
 
 POSIX specification: @url{http://www.opengroup.org/susv3xbd/stddef.h.html}
 
-Gnulib module: ---
+Gnulib module: stddef
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+Some old platforms fail to provide @code{wchar_t}.
+
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index c4136163488c19d381d0403f34a9af3389d94e81..1135791ff74851235465023a14866025886a90ff 100644 (file)
@@ -7,6 +7,10 @@ Gnulib module: stdio
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 2fc6280f753d3f30972a4857b12c8c142dd53438..6ca0c4b25229f3daf51b0663d1a4ef9bbeacb2c6 100644 (file)
@@ -12,6 +12,11 @@ The macros @code{EXIT_SUCCESS} and @code{EXIT_FAILURE} are not defined on
 some platforms.
 @item
 The macro @code{EXIT_FAILURE} is incorrectly defined on Tandem/NSK.
+
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 42f67b90b6628cf911ff5c841319a6e176713738..56a5dfce72712f05e79de08f42e338530f1ec165 100644 (file)
@@ -7,6 +7,10 @@ Gnulib module: string
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index e9ca581df40cfb665fac3e4f406712e417cf0ecc..7974cea2c3dbc06d39fcb20a37a8ba286e09e83a 100644 (file)
@@ -9,6 +9,11 @@ Portability problems fixed by Gnulib:
 @itemize
 @item
 @samp{struct timespec} is not defined on some platforms.
+
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 855eefbbee47b5adb23cc4073741c4026113ddc3..d550143e11ec1513ee845abf51e1e17e3bbea8ca 100644 (file)
@@ -18,6 +18,11 @@ OS/2 EMX, mingw.
 @item
 The @code{_exit} function is not declared in this file on some platforms:
 mingw.
+
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index bdd8232d4cf9d6e3341aec5c24a3339695a7a091..b797b6b8f78933c3798e0fe2c69caaec8dd950a4 100644 (file)
@@ -16,6 +16,11 @@ OSF/1 with Desktop Toolkit C, BSD/OS 4.0.1.
 @item
 The type @code{wint_t} and macro @code{WEOF} are missing on some platforms:
 IRIX 5.3.
+
+@item
+Some platforms provide a @code{NULL} macro that cannot be used in arbitrary
+expressions:
+NetBSD 5.0
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 10629f6c79c215b23a02c215961b95d987f0342e..0557c9f1705ef64b8d37c841b32cfef33d74e4d4 100644 (file)
@@ -1,5 +1,5 @@
 /* A POSIX <locale.h>.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 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
@@ -26,6 +26,9 @@
 #ifndef _GL_LOCALE_H
 #define _GL_LOCALE_H
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
+
 /* The LC_MESSAGES locale category is specified in POSIX, but not in ISO C.
    On systems that don't define it, use the same value as GNU libintl.  */
 #if !defined LC_MESSAGES
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
new file mode 100644 (file)
index 0000000..8744207
--- /dev/null
@@ -0,0 +1,86 @@
+/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
+
+   Copyright (C) 2009 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Eric Blake.  */
+
+/*
+ * POSIX 2008 <stddef.h> for platforms that have issues.
+ * <http://www.opengroup.org/susv3xbd/stddef.h.html>
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+#if defined __need_wchar_t || defined __need_size_t  \
+  || defined __need_ptrdiff_t || defined __need_NULL \
+  || defined __need_wint_t
+/* Special invocation convention inside gcc header files.  In
+   particular, gcc provides a version of <stddef.h> that blindly
+   redefines NULL even when __need_wint_t was defined, even though
+   wint_t is not normally provided by <stddef.h>.  Hence, we must
+   remember if special invocation has ever been used to obtain wint_t,
+   in which case we need to clean up NULL yet again.  */
+
+# if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T)
+#  ifdef __need_wint_t
+#   undef _GL_STDDEF_H
+#   define _GL_STDDEF_WINT_T
+#  endif
+#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+# endif
+
+#else
+/* Normal invocation convention.  */
+
+# ifndef _GL_STDDEF_H
+
+/* The include_next requires a split double-inclusion guard.  */
+
+#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+
+#  ifndef _GL_STDDEF_H
+#   define _GL_STDDEF_H
+
+/* On NetBSD 5.0, the definition of NULL lacks proper parentheses.  */
+#if @REPLACE_NULL@
+# undef NULL
+# ifdef __cplusplus
+   /* ISO C++ says that the macro NULL must expand to an integer constant
+      expression, hence '((void *) 0)' is not allowed in C++.  */
+#  if __GNUG__ >= 3
+    /* GNU C++ has a __null macro that behaves like an integer ('int' or
+       'long') but has the same size as a pointer.  Use that, to avoid
+       warnings.  */
+#   define NULL __null
+#  else
+#   define NULL 0L
+#  endif
+# else
+#  define NULL ((void *) 0)
+# endif
+#endif
+
+/* Some platforms lack wchar_t.  */
+#if !@HAVE_WCHAR_T@
+# define wchar_t int
+#endif
+
+#  endif /* _GL_STDDEF_H */
+# endif /* _GL_STDDEF_H */
+#endif /* __need_XXX */
index f99767f600f6c721671db6f74b5ce79c59c28d1a..c7c8e8fb7f7f2511b164a3ea012656ef91452168 100644 (file)
@@ -35,6 +35,8 @@
 #ifndef _GL_STDLIB_H
 #define _GL_STDLIB_H
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
 
 /* Solaris declares getloadavg() in <sys/loadavg.h>.  */
 #if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
index 9f98b0df975975fcb65dea05b01ba09fc3416a54..8eaeeb88246c51eb44bca3df592261ba7c593268 100644 (file)
@@ -28,6 +28,8 @@
 #ifndef _GL_STRING_H
 #define _GL_STRING_H
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
 
 #ifndef __attribute__
 /* This feature is available in gcc versions 2.5 and later.  */
index b9c2230d6ebb305a91892d8cff2d7b37c5f58dd4..e8e7c197f6d6318e95eed4c52bd0895e31f9b67e 100644 (file)
@@ -37,6 +37,9 @@
 
 # @INCLUDE_NEXT@ @NEXT_TIME_H@
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
+
 # ifdef __cplusplus
 extern "C" {
 # endif
index 5cad6c8ad98b905bb8ed638ac20704bb4597b365..7696178799ddd5683a1ed4df975da51b066def7b 100644 (file)
@@ -29,6 +29,9 @@
 #ifndef _GL_UNISTD_H
 #define _GL_UNISTD_H
 
+/* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
+#include <stddef.h>
+
 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
 # include <stdio.h>
@@ -375,7 +378,6 @@ extern int gethostname(char *name, size_t len);
    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
  */
 # if !@HAVE_DECL_GETLOGIN_R@
-#  include <stddef.h>
 extern int getlogin_r (char *name, size_t size);
 # endif
 #elif defined GNULIB_POSIXCHECK
@@ -536,7 +538,6 @@ extern int link (const char *path1, const char *path2);
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
 # if !@HAVE_READLINK@
-#  include <stddef.h>
 extern int readlink (const char *file, char *buf, size_t bufsize);
 # endif
 #elif defined GNULIB_POSIXCHECK
index 2bf5abccad83b4d25ac723d2e82467a7f1a2ef51..86123670f95f8150f7ceb0661a2a5ee7de38626b 100644 (file)
@@ -1,5 +1,5 @@
-# locale_h.m4 serial 2
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# locale_h.m4 serial 3
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,11 @@ AC_DEFUN([gl_LOCALE_H],
 int x = LC_MESSAGES;], [],
        [gl_cv_header_working_locale_h=yes],
        [gl_cv_header_working_locale_h=no])])
-  if test $gl_cv_header_working_locale_h = yes; then
+
+  dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
+  AC_REQUIRE([gl_STDDEF_H])
+
+  if test $gl_cv_header_working_locale_h = yes && test -z "$STDDEF_H"; then
     LOCALE_H=
   else
     gl_CHECK_NEXT_HEADERS([locale.h])
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
new file mode 100644 (file)
index 0000000..682e9c6
--- /dev/null
@@ -0,0 +1,45 @@
+dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
+# stddef_h.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDDEF_H],
+[
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  if test $gt_cv_c_wchar_t = no; then
+    HAVE_WCHAR_T=0
+    STDDEF_H=stddef.h
+  fi
+  AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
+    [gl_cv_decl_null_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
+      int test[2 * (sizeof NULL == sizeof (void *)) -1];
+]])],
+      [gl_cv_decl_null_works=yes],
+      [gl_cv_decl_null_works=no])])
+  if test $gl_cv_decl_null_works = no; then
+    REPLACE_NULL=1
+    STDDEF_H=stddef.h
+  fi
+  if test -n "$STDDEF_H"; then
+    gl_CHECK_NEXT_HEADERS([stddef.h])
+  fi
+])
+
+AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_STDDEF_H_DEFAULTS],
+[
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  REPLACE_NULL=0;                AC_SUBST([REPLACE_NULL])
+  HAVE_WCHAR_T=1;                AC_SUBST([HAVE_WCHAR_T])
+  STDDEF_H='';                   AC_SUBST([STDDEF_H])
+])
index 2e52a82acfb9a94e00ca1ef12729f3294995f64b..08cb078dc4a01e3f4eef0ae71b0e5f03978d1023 100644 (file)
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 23
+# wchar.m4 serial 24
 
 AC_DEFUN([gl_WCHAR_H],
 [
@@ -27,7 +27,10 @@ wchar_t w;]],
   fi
   AC_SUBST([HAVE_WINT_T])
 
-  if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes; then
+  dnl If <stddef.h> is replaced, then <wchar.h> must also be replaced.
+  AC_REQUIRE([gl_STDDEF_H])
+
+  if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then
     WCHAR_H=wchar.h
   fi
 
@@ -42,7 +45,9 @@ wchar_t w;]],
     HAVE_WCHAR_H=0
   fi
   AC_SUBST([HAVE_WCHAR_H])
-  gl_CHECK_NEXT_HEADERS([wchar.h])
+  if test -n "$WCHAR_H"; then
+    gl_CHECK_NEXT_HEADERS([wchar.h])
+  fi
 ])
 
 dnl Unconditionally enables the replacement of <wchar.h>.
index d15d5d3473719dbf6d3dc1edae166d4a21ac5c37..0afc5cb6b99e77c8099554ce93df4f08a6ade040 100644 (file)
@@ -7,6 +7,7 @@ m4/locale_h.m4
 
 Depends-on:
 include_next
+stddef
 
 configure.ac:
 gl_LOCALE_H
diff --git a/modules/stddef b/modules/stddef
new file mode 100644 (file)
index 0000000..c68e00b
--- /dev/null
@@ -0,0 +1,40 @@
+Description:
+A <stddef.h> that works around platform issues.
+
+Files:
+lib/stddef.in.h
+m4/stddef_h.m4
+m4/wchar_t.m4
+
+Depends-on:
+include_next
+
+configure.ac:
+gl_STDDEF_H
+
+Makefile.am:
+BUILT_SOURCES += $(STDDEF_H)
+
+# We need the following in order to create <stddef.h> when the system
+# doesn't have one that works with the given compiler.
+stddef.h: stddef.in.h
+       rm -f $@-t $@
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+             -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
+             -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+             < $(srcdir)/stddef.in.h; \
+       } > $@-t
+       mv $@-t $@
+MOSTLYCLEANFILES += stddef.h stddef.h-t
+
+Include:
+#include <stddef.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
diff --git a/modules/stddef-tests b/modules/stddef-tests
new file mode 100644 (file)
index 0000000..04be2f5
--- /dev/null
@@ -0,0 +1,14 @@
+Files:
+tests/test-stddef.c
+
+Depends-on:
+verify
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-stddef
+check_PROGRAMS += test-stddef
+
+License:
+LGPL
index 87308a6ab828d528fcf37669b439e858ffde9bf7..cf886301b62f2e64ba01a6f5308e65c5060d9b8b 100644 (file)
@@ -10,6 +10,7 @@ Depends-on:
 include_next
 link-warning
 raise
+stddef
 
 configure.ac:
 gl_STDIO_H
index fda33728e701f2c313cdb486f683a9891d9076f2..49798ad8bc71f620fc1d0161490e71fc6eca021c 100644 (file)
@@ -9,6 +9,7 @@ Depends-on:
 include_next
 link-warning
 unistd
+stddef
 stdint
 
 configure.ac:
index b2c802c541ccf46dceb0e2cfc1a762912a01c995..738deebf95d8bbea99cab085883feb63dfd35b62 100644 (file)
@@ -9,6 +9,7 @@ Depends-on:
 extensions
 include_next
 link-warning
+stddef
 
 configure.ac:
 gl_HEADER_STRING_H
index a6c9fa74d67407aab23d5d240adda4b0563dba80..6450cb34727c2a247667ff139f82428ab919274a 100644 (file)
@@ -8,6 +8,7 @@ m4/time_h.m4
 Depends-on:
 extensions
 include_next
+stddef
 
 configure.ac:
 gl_HEADER_TIME_H
index c8f6f79adb2d2b798d574562c70c956763d75450..c4b18d2cc1b744b81d288f3e5ea57bf4d6fd72a6 100644 (file)
@@ -2,6 +2,7 @@ Files:
 tests/test-time.c
 
 Depends-on:
+verify
 
 configure.ac:
 
index 06f77c5d34977d1afd5dece4deb4eade0c94d7fe..5977bf986073fb38c0d1e30bb0246b48b1bbfbb9 100644 (file)
@@ -8,6 +8,7 @@ lib/unistd.in.h
 Depends-on:
 include_next
 link-warning
+stddef
 
 configure.ac:
 gl_UNISTD_H
index f46150c5f887ec5cd9e0a0fe4b9ca9d567090cac..d4dad6c809aea4e3948f4411e39b060f085bcbe2 100644 (file)
@@ -9,6 +9,7 @@ m4/wint_t.m4
 Depends-on:
 include_next
 link-warning
+stddef
 
 configure.ac:
 gl_WCHAR_H
index 9a55d2bdfc874f77cc936d2c14c117e470cf245f..dac05ec111bfe4cc5b05c5c6e4d16a39cc941891 100644 (file)
@@ -2,6 +2,7 @@ Files:
 tests/test-wchar.c
 
 Depends-on:
+verify
 
 configure.ac:
 
diff --git a/tests/test-stddef.c b/tests/test-stddef.c
new file mode 100644 (file)
index 0000000..f848498
--- /dev/null
@@ -0,0 +1,38 @@
+/* Test of <stddef.h> substitute.
+   Copyright (C) 2009 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <ebb9@byu.net>, 2009.  */
+
+#include <config.h>
+
+#include <stddef.h>
+
+#include "verify.h"
+
+/* Check that appropriate types are defined.  */
+wchar_t a = 'c';
+ptrdiff_t b = 1;
+size_t c = 2;
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+int
+main ()
+{
+  return 0;
+}
index 9238ac48642117b03acfea66805e9bec476992e2..ea8143737f16cd0099831f868966accabcc4cee4 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of <time.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 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
 
 #include <time.h>
 
+#include "verify.h"
+
 struct timespec a;
 
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
 int
 main ()
 {
index 19da7d93c09d4cfb09e1bb9a63f0631717c04cfb..28660688d2cf6fb2449a66509ddff9968da31bdd 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of <wchar.h> substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 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
 
 #include <wchar.h>
 
+#include "verify.h"
+
 /* Check that the types wchar_t and wint_t are defined.  */
 wchar_t a = 'c';
 wint_t b = 'x';
 
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
 int
 main ()
 {