From: Paul Eggert Date: Mon, 6 Nov 2006 21:58:29 +0000 (+0000) Subject: * MODULES.html.sh (Core language properties): New module flexmember. X-Git-Tag: cvs-readonly~1608 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=ef3605f1b2c75155b1525057bbe1e82a38cecd77;p=gnulib.git * MODULES.html.sh (Core language properties): New module flexmember. * modules/flexmember, m4/flexmember.m4: New files. --- diff --git a/ChangeLog b/ChangeLog index d16ef09f4..8481fd748 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-11-06 Paul Eggert + * MODULES.html.sh (Core language properties): New module flexmember. + * modules/flexmember, m4/flexmember.m4: New files. + * lib/xalloc.h (xnmalloc, xnrealloc, x2nrealloc): Now static inline functions that are identical with the old xnmalloc_inline, xnrealloc_inline, x2nrealloc_inline of lib/xmalloc.c. This is so diff --git a/MODULES.html.sh b/MODULES.html.sh index e7032040f..f7b164377 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1704,6 +1704,7 @@ func_all_modules () func_echo "$element" func_begin_table + func_module flexmember func_module vararrays func_end_table diff --git a/m4/flexmember.m4 b/m4/flexmember.m4 new file mode 100644 index 000000000..2a6ae474e --- /dev/null +++ b/m4/flexmember.m4 @@ -0,0 +1,48 @@ +# Check for flexible array member support. + +# Copyright (C) 2006 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 Paul Eggert. + +AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER], +[ + AC_CACHE_CHECK([for flexible array member], + ac_cv_c_flexmember, + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + #include + struct s { int n; double d[]; };]], + [[int m = getchar (); + struct s *p = malloc (offsetof (struct s, d) + + m * sizeof (double)); + p->d[0] = 0.0; + return p->d != (double *) NULL;]])], + [ac_cv_c_flexmember=yes], + [ac_cv_c_flexmember=no])]) + if test $ac_cv_c_flexmember = yes; then + AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [], + [Define to nothing if C supports flexible array members, and to + 1 if it does not. That way, with a declaration like `struct s + { int n; double d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack + can be used with pre-C99 compilers.]) + else + AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], 1) + fi +]) diff --git a/modules/flexmember b/modules/flexmember new file mode 100644 index 000000000..6d39e140d --- /dev/null +++ b/modules/flexmember @@ -0,0 +1,20 @@ +Description: +Flexible array member support + +Files: +m4/flexmember.m4 + +Depends-on: + +configure.ac: +AC_C_FLEXIBLE_ARRAY_MEMBER + +Makefile.am: + +Include: + +License: +GPL + +Maintainer: +Paul Eggert, Jim Meyering