* 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>
+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
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
@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:
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:
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:
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:
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:
@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:
@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:
@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 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
#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
--- /dev/null
+/* 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 */
#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@
#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. */
# @INCLUDE_NEXT@ @NEXT_TIME_H@
+/* NetBSD 5.0 mis-defines NULL. */
+#include <stddef.h>
+
# ifdef __cplusplus
extern "C" {
# endif
#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>
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
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
-# 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.
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])
--- /dev/null
+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])
+])
dnl Written by Eric Blake.
-# wchar.m4 serial 23
+# wchar.m4 serial 24
AC_DEFUN([gl_WCHAR_H],
[
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
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>.
Depends-on:
include_next
+stddef
configure.ac:
gl_LOCALE_H
--- /dev/null
+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
--- /dev/null
+Files:
+tests/test-stddef.c
+
+Depends-on:
+verify
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-stddef
+check_PROGRAMS += test-stddef
+
+License:
+LGPL
include_next
link-warning
raise
+stddef
configure.ac:
gl_STDIO_H
include_next
link-warning
unistd
+stddef
stdint
configure.ac:
extensions
include_next
link-warning
+stddef
configure.ac:
gl_HEADER_STRING_H
Depends-on:
extensions
include_next
+stddef
configure.ac:
gl_HEADER_TIME_H
tests/test-time.c
Depends-on:
+verify
configure.ac:
Depends-on:
include_next
link-warning
+stddef
configure.ac:
gl_UNISTD_H
Depends-on:
include_next
link-warning
+stddef
configure.ac:
gl_WCHAR_H
tests/test-wchar.c
Depends-on:
+verify
configure.ac:
--- /dev/null
+/* 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;
+}
/* 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 ()
{
/* 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 ()
{