From: Bruno Haible Date: Thu, 9 Jan 2003 13:35:14 +0000 (+0000) Subject: Make it possible to #include without any #ifdefs. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=458e682cf2b4d55424fe6c1e630a5fdf76c72746;p=pspp Make it possible to #include without any #ifdefs. --- diff --git a/ChangeLog b/ChangeLog index 700a14858a..f06e766b1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-01-09 Bruno Haible + + * modules/stdbool: Change configure.ac, Makefile.am requirements. + Simplify Include requirements. + 2003-01-09 Bruno Haible * gnulib-tool (func_all_modules): Ignore files ending in ~. diff --git a/lib/ChangeLog b/lib/ChangeLog index fc0c246343..710cb16d0b 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2003-01-09 Bruno Haible + + * stdbool.h.in: New file. + 2003-01-08 Bruno Haible * safe-read.c: Include specification header first, to ensure its diff --git a/lib/stdbool.h.in b/lib/stdbool.h.in new file mode 100644 index 0000000000..69f6ef725f --- /dev/null +++ b/lib/stdbool.h.in @@ -0,0 +1,47 @@ +/* Copyright (C) 2001-2002 Free Software Foundation, Inc. + Written by Bruno Haible , 2001. + + 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _STDBOOL_H +#define _STDBOOL_H + +/* ISO C 99 for platforms that lack it. */ + +/* 7.16. Boolean type and values */ + +/* BeOS already #defines false 0, true 1. We use the same + definitions below, but temporarily we have to #undef them. */ +#ifdef __BEOS__ +# undef false +# undef true +#endif + +/* For the sake of symbolic names in gdb, define _Bool as an enum type. */ +#ifndef __cplusplus +# if !@HAVE__BOOL@ +typedef enum { false = 0, true = 1 } _Bool; +# endif +#else +typedef bool _Bool; +#endif +#define bool _Bool + +/* The other macros must be usable in preprocessor directives. */ +#define false 0 +#define true 1 +#define __bool_true_false_are_defined 1 + +#endif /* _STDBOOL_H */ diff --git a/m4/ChangeLog b/m4/ChangeLog index e1afee3a6b..af00c93d8b 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2003-01-09 Bruno Haible + + * stdbool.m4 (AM_STDBOOL_H): New macro. + 2002-12-31 Paul Eggert * memcoll.m4 (gl_MEMCOLL): Require AC_FUNC_MEMCMP. diff --git a/m4/stdbool.m4 b/m4/stdbool.m4 index def6e147f8..ed000c8163 100644 --- a/m4/stdbool.m4 +++ b/m4/stdbool.m4 @@ -1,6 +1,6 @@ # Check for stdbool.h that conforms to C99. -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002-2003 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 @@ -17,7 +17,30 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. -# This file is only needed in autoconf <= 2.54. Newer versions of autoconf +# Prepare for substituting if it is not supported. + +AC_DEFUN([AM_STDBOOL_H], +[ + AC_REQUIRE([AC_HEADER_STDBOOL]) + + # Define two additional variables used in the Makefile substitution. + + if test "$ac_cv_header_stdbool_h" = yes; then + STDBOOL_H='' + else + STDBOOL_H='stdbool.h' + fi + AC_SUBST([STDBOOL_H]) + + if test "$ac_cv_type__Bool" = yes; then + HAVE__BOOL=1 + else + HAVE__BOOL=0 + fi + AC_SUBST([HAVE__BOOL]) +]) + +# This macro is only needed in autoconf <= 2.54. Newer versions of autoconf # have this macro built-in. AC_DEFUN([AC_HEADER_STDBOOL], diff --git a/modules/stdbool b/modules/stdbool index 03acba0c86..bad1377a7f 100644 --- a/modules/stdbool +++ b/modules/stdbool @@ -6,24 +6,18 @@ m4/stdbool.m4 Depends-on: configure.ac: -AC_HEADER_STDBOOL +AM_STDBOOL_H Makefile.am: +EXTRA_DIST += stdbool.h.in + +# The following is needed in order to create an when the system +# doesn't have one that works. +all-local: @STDBOOL_H@ +stdbool.h: stdbool.h.in + sed -e 's/@''HAVE__BOOL''@/@HAVE__BOOL@/g' < $(srcdir)/stdbool.h.in > stdbool.h +MOSTLYCLEANFILES += stdbool.h Include: -#if HAVE_STDBOOL_H -# include -#else -# if ! HAVE__BOOL -# ifdef __cplusplus -typedef bool _Bool; -# else -typedef enum {false = 0, true = 1} _Bool; -# endif -# endif -# define bool _Bool -# define false 0 -# define true 1 -# define __bool_true_false_are_defined 1 -#endif +#include