From 5518d301980bdc0f60b1b5d58b140004dfda490e Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 12 Jul 2010 18:54:13 +0200 Subject: [PATCH] New module '_Exit'. --- ChangeLog | 14 ++++++++++++++ doc/posix-functions/_Exit_C99.texi | 8 ++++---- lib/_Exit.c | 27 +++++++++++++++++++++++++++ lib/stdlib.in.h | 23 +++++++++++++++++++++++ m4/_Exit.m4 | 21 +++++++++++++++++++++ m4/stdlib_h.m4 | 6 ++++-- modules/_Exit | 24 ++++++++++++++++++++++++ modules/stdlib | 2 ++ tests/test-stdlib-c++.cc | 4 ++++ 9 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 lib/_Exit.c create mode 100644 m4/_Exit.m4 create mode 100644 modules/_Exit diff --git a/ChangeLog b/ChangeLog index 97a604be2..f644d195b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-07-12 Bruno Haible + + New module '_Exit'. + * lib/stdlib.in.h (__attribute__): New macro. + (_Exit): New declaration. + * lib/_Exit.c: New file. + * m4/_Exit.m4: New file. + * m4/stdlib_h.m4 (gl_STDLIB_H): Check whether _Exit is declared. + (gl_STDLIB_H_DEFAULTS): Initialize GNULIB__EXIT and HAVE__EXIT. + * modules/stdlib (Makefile.am): Substitute GNULIB__EXIT and HAVE__EXIT. + * modules/_Exit: New file. + * tests/test-stdlib-c++.cc (_Exit): Check signature. + * doc/posix-functions/_Exit_C99.texi: Mention the new module. + 2010-07-12 Paul R. Eggert strtod: make it more-accurate typically, and don't require libm diff --git a/doc/posix-functions/_Exit_C99.texi b/doc/posix-functions/_Exit_C99.texi index 655762036..fa9930611 100644 --- a/doc/posix-functions/_Exit_C99.texi +++ b/doc/posix-functions/_Exit_C99.texi @@ -7,15 +7,15 @@ POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/_Exit.html} -Gnulib module: --- +Gnulib module: _Exit Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, Interix 3.5, BeOS. @end itemize Portability problems not fixed by Gnulib: @itemize -@item -This function is missing on some platforms: -AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x, Interix 3.5, BeOS. @end itemize diff --git a/lib/_Exit.c b/lib/_Exit.c new file mode 100644 index 000000000..ee11874cc --- /dev/null +++ b/lib/_Exit.c @@ -0,0 +1,27 @@ +/* Copyright (C) 2010 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 . */ + +#include + +/* Specification. */ +#include + +#include + +void +_Exit (int status) +{ + _exit (status); +} diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index da162599b..d4ac46903 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -74,6 +74,12 @@ struct random_data # include #endif +#ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(Spec) /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ @@ -95,6 +101,23 @@ struct random_data #endif +#if @GNULIB__EXIT@ +/* Terminate the current process with the given return code, without running + the 'atexit' handlers. */ +# if !@HAVE__EXIT@ +_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__))); +# endif +_GL_CXXALIAS_SYS (_Exit, void, (int status)); +_GL_CXXALIASWARN (_Exit); +#elif defined GNULIB_POSIXCHECK +# undef _Exit +# if HAVE_RAW_DECL__EXIT +_GL_WARN_ON_USE (_Exit, "_Exit is unportable - " + "use gnulib module _Exit for portability"); +# endif +#endif + + #if @GNULIB_ATOLL@ /* Parse a signed decimal integer. Returns the value of the integer. Errors are not detected. */ diff --git a/m4/_Exit.m4 b/m4/_Exit.m4 new file mode 100644 index 000000000..d3c5eb772 --- /dev/null +++ b/m4/_Exit.m4 @@ -0,0 +1,21 @@ +# _Exit.m4 serial 1 +dnl Copyright (C) 2010 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_FUNC__EXIT], +[ + AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) + AC_CHECK_FUNCS([_Exit]) + if test $ac_cv_func__Exit = no; then + HAVE__EXIT=0 + AC_LIBOBJ([_Exit]) + gl_PREREQ__EXIT + fi +]) + +# Prerequisites of lib/_Exit.c. +AC_DEFUN([gl_PREREQ__EXIT], [ + : +]) diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index b297ee207..fc150197b 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 29 +# stdlib_h.m4 serial 30 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,7 +33,7 @@ AC_DEFUN([gl_STDLIB_H], #if HAVE_RANDOM_H # include #endif - ]], [atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp + ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt unsetenv]) @@ -50,6 +50,7 @@ AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], AC_DEFUN([gl_STDLIB_H_DEFAULTS], [ + GNULIB__EXIT=0; AC_SUBST([GNULIB__EXIT]) GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL]) GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) @@ -75,6 +76,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) dnl Assume proper GNU behavior unless another module says otherwise. + HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) diff --git a/modules/_Exit b/modules/_Exit new file mode 100644 index 000000000..2b5cc084b --- /dev/null +++ b/modules/_Exit @@ -0,0 +1,24 @@ +Description: +_Exit() function: terminate current process. + +Files: +lib/_Exit.c +m4/_Exit.m4 + +Depends-on: +stdlib + +configure.ac: +gl_FUNC__EXIT +gl_STDLIB_MODULE_INDICATOR([_Exit]) + +Makefile.am: + +Include: + + +License: +LGPL + +Maintainer: +all diff --git a/modules/stdlib b/modules/stdlib index 7af315fd4..489f70a1a 100644 --- a/modules/stdlib +++ b/modules/stdlib @@ -28,6 +28,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ + -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \ -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ @@ -52,6 +53,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ + -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ diff --git a/tests/test-stdlib-c++.cc b/tests/test-stdlib-c++.cc index 3874d2767..c66c1a894 100644 --- a/tests/test-stdlib-c++.cc +++ b/tests/test-stdlib-c++.cc @@ -24,6 +24,10 @@ #include "signature.h" +#if GNULIB_TEST__EXIT +SIGNATURE_CHECK (GNULIB_NAMESPACE::_Exit, void, (int)); +#endif + //SIGNATURE_CHECK (GNULIB_NAMESPACE::atexit, int, (void (*) (void))); #if GNULIB_TEST_ATOLL -- 2.11.0