changeset 11832:ff3dd373542b

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. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Wed, 12 Aug 2009 10:23:03 -0600
parents 60a86ea77948
children 6f88af728ad1
files 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 lib/stdlib.in.h lib/string.in.h lib/time.in.h lib/unistd.in.h m4/locale_h.m4 m4/stddef_h.m4 m4/wchar.m4 modules/locale modules/stddef modules/stddef-tests modules/stdio modules/stdlib modules/string modules/time modules/time-tests modules/unistd modules/wchar modules/wchar-tests tests/test-stddef.c tests/test-time.c tests/test-wchar.c
diffstat 33 files changed, 369 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -2032,6 +2032,16 @@
   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
--- a/doc/posix-headers/locale.texi
+++ b/doc/posix-headers/locale.texi
@@ -10,6 +10,11 @@
 @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:
--- a/doc/posix-headers/stddef.texi
+++ b/doc/posix-headers/stddef.texi
@@ -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:
--- a/doc/posix-headers/stdio.texi
+++ b/doc/posix-headers/stdio.texi
@@ -7,6 +7,10 @@
 
 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:
--- a/doc/posix-headers/stdlib.texi
+++ b/doc/posix-headers/stdlib.texi
@@ -12,6 +12,11 @@
 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:
--- a/doc/posix-headers/string.texi
+++ b/doc/posix-headers/string.texi
@@ -7,6 +7,10 @@
 
 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:
--- a/doc/posix-headers/time.texi
+++ b/doc/posix-headers/time.texi
@@ -9,6 +9,11 @@
 @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:
--- a/doc/posix-headers/unistd.texi
+++ b/doc/posix-headers/unistd.texi
@@ -18,6 +18,11 @@
 @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:
--- a/doc/posix-headers/wchar.texi
+++ b/doc/posix-headers/wchar.texi
@@ -16,6 +16,11 @@
 @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:
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -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
new file mode 100644
--- /dev/null
+++ b/lib/stddef.in.h
@@ -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 */
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -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@
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -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.  */
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -37,6 +37,9 @@
 
 # @INCLUDE_NEXT@ @NEXT_TIME_H@
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
+
 # ifdef __cplusplus
 extern "C" {
 # endif
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -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 @@
    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 @@
    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
--- a/m4/locale_h.m4
+++ b/m4/locale_h.m4
@@ -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 @@
 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])
new file mode 100644
--- /dev/null
+++ b/m4/stddef_h.m4
@@ -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])
+])
--- a/m4/wchar.m4
+++ b/m4/wchar.m4
@@ -7,7 +7,7 @@
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 23
+# wchar.m4 serial 24
 
 AC_DEFUN([gl_WCHAR_H],
 [
@@ -27,7 +27,10 @@
   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 @@
     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>.
--- a/modules/locale
+++ b/modules/locale
@@ -7,6 +7,7 @@
 
 Depends-on:
 include_next
+stddef
 
 configure.ac:
 gl_LOCALE_H
new file mode 100644
--- /dev/null
+++ b/modules/stddef
@@ -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
new file mode 100644
--- /dev/null
+++ b/modules/stddef-tests
@@ -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
--- a/modules/stdio
+++ b/modules/stdio
@@ -10,6 +10,7 @@
 include_next
 link-warning
 raise
+stddef
 
 configure.ac:
 gl_STDIO_H
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -9,6 +9,7 @@
 include_next
 link-warning
 unistd
+stddef
 stdint
 
 configure.ac:
--- a/modules/string
+++ b/modules/string
@@ -9,6 +9,7 @@
 extensions
 include_next
 link-warning
+stddef
 
 configure.ac:
 gl_HEADER_STRING_H
--- a/modules/time
+++ b/modules/time
@@ -8,6 +8,7 @@
 Depends-on:
 extensions
 include_next
+stddef
 
 configure.ac:
 gl_HEADER_TIME_H
--- a/modules/time-tests
+++ b/modules/time-tests
@@ -2,6 +2,7 @@
 tests/test-time.c
 
 Depends-on:
+verify
 
 configure.ac:
 
--- a/modules/unistd
+++ b/modules/unistd
@@ -8,6 +8,7 @@
 Depends-on:
 include_next
 link-warning
+stddef
 
 configure.ac:
 gl_UNISTD_H
--- a/modules/wchar
+++ b/modules/wchar
@@ -9,6 +9,7 @@
 Depends-on:
 include_next
 link-warning
+stddef
 
 configure.ac:
 gl_WCHAR_H
--- a/modules/wchar-tests
+++ b/modules/wchar-tests
@@ -2,6 +2,7 @@
 tests/test-wchar.c
 
 Depends-on:
+verify
 
 configure.ac:
 
new file mode 100644
--- /dev/null
+++ b/tests/test-stddef.c
@@ -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;
+}
--- a/tests/test-time.c
+++ b/tests/test-time.c
@@ -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
@@ -20,8 +20,14 @@
 
 #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 ()
 {
--- a/tests/test-wchar.c
+++ b/tests/test-wchar.c
@@ -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
@@ -20,10 +20,16 @@
 
 #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 ()
 {