X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gnulib%2Fimport%2Fm4%2Fflexmember.m4;h=c245ab025f61eddc56a209f25a53ee38fad39e73;hb=c0c3707ff46ccfb78ea175dd42d628d8c90dca8b;hp=155ae9b812023fbc74038e2792c10b395c191a84;hpb=f81e7e2db6d1aaf47561e54356aee12b585533c2;p=deliverable%2Fbinutils-gdb.git diff --git a/gnulib/import/m4/flexmember.m4 b/gnulib/import/m4/flexmember.m4 index 155ae9b812..c245ab025f 100644 --- a/gnulib/import/m4/flexmember.m4 +++ b/gnulib/import/m4/flexmember.m4 @@ -1,7 +1,7 @@ -# serial 4 +# serial 5 # Check for flexible array member support. -# Copyright (C) 2006, 2009-2016 Free Software Foundation, Inc. +# Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -17,12 +17,15 @@ AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER], [[#include #include #include - struct s { int n; double d[]; };]], + struct m { struct m *next, **list; char name[]; }; + struct s { struct s *p; struct m *m; int n; double d[]; };]], [[int m = getchar (); size_t nbytes = offsetof (struct s, d) + m * sizeof (double); nbytes += sizeof (struct s) - 1; nbytes -= nbytes % sizeof (struct s); struct s *p = malloc (nbytes); + p->p = p; + p->m = NULL; p->d[0] = 0.0; return p->d != (double *) NULL;]])], [ac_cv_c_flexmember=yes], @@ -31,12 +34,10 @@ AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER], 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 + { int n; short d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack can be used with pre-C99 compilers. - When computing the size of such an object, don't use 'sizeof (struct s)' - as it overestimates the size. Use 'offsetof (struct s, d)' instead. - Don't use 'offsetof (struct s, d@<:@0@:>@)', as this doesn't work with - MSVC and with C++ compilers.]) + Use 'FLEXSIZEOF (struct s, d, N * sizeof (short))' to calculate + the size in bytes of such a struct containing an N-element array.]) else AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [1]) fi