]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Update gnulib files.
authorSimon Josefsson <simon@josefsson.org>
Wed, 3 Jun 2009 10:38:03 +0000 (12:38 +0200)
committerSimon Josefsson <simon@josefsson.org>
Wed, 3 Jun 2009 10:38:03 +0000 (12:38 +0200)
gl/Makefile.am
gl/alignof.h
gl/m4/gnulib-cache.m4
gl/m4/gnulib-comp.m4
gl/tests/Makefile.am
gl/tests/test-alignof.c [new file with mode: 0644]
lib/gl/alignof.h

index e04d7f454015f90d7ead89f7982cd181c20e1838..c6c10ea6801b90ef2a613b515b8a73185763673a 100644 (file)
@@ -9,7 +9,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat version-etc-fsf warnings
+# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat version-etc-fsf warnings
 
 AUTOMAKE_OPTIONS = 1.5 gnits
 
index 896382b0f2109079236a631fd65a14e000911fd8..0d2099cfd3d1f31cf7044a98315706d01168268c 100644 (file)
 
 #include <stddef.h>
 
-/* Determine the alignment of a type at compile time.  */
-#if defined __GNUC__
-# define alignof __alignof__
-#elif defined __cplusplus
+/* Determine the alignment of a structure slot (field) of a given type,
+   at compile time.  Note that the result depends on the ABI.
+   Note: The result cannot be used as a value for an 'enum' constant,
+   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
+#if defined __cplusplus
   template <class type> struct alignof_helper { char __slot1; type __slot2; };
-# define alignof(type) offsetof (alignof_helper<type>, __slot2)
+# define alignof_slot(type) offsetof (alignof_helper<type>, __slot2)
+#else
+# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+#endif
+
+/* Determine the good alignment of a object of the given type at compile time.
+   Note that this is not necessarily the same as alignof_slot(type).
+   For example, with GNU C on x86 platforms: alignof_type(double) = 8, but
+   - when -malign-double is not specified:  alignof_slot(double) = 4,
+   - when -malign-double is specified:      alignof_slot(double) = 8.
+   Note: The result cannot be used as a value for an 'enum' constant,
+   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
+#if defined __GNUC__
+# define alignof_type __alignof__
 #else
-# define alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+# define alignof_type alignof_slot
 #endif
 
+/* alignof is an alias for alignof_slot semantics, since that's what most
+   callers need.
+   Note: The result cannot be used as a value for an 'enum' constant,
+   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
+#define alignof alignof_slot
+
 #endif /* _ALIGNOF_H */
index a55309bd7fb8a7e1382f0c50971fcb2684573e73..628c18763043808affd2f60c48a81e17a87680b1 100644 (file)
@@ -15,7 +15,7 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --avoid=alignof-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat version-etc-fsf warnings
+#   gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat version-etc-fsf warnings
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([gl/override])
@@ -57,7 +57,7 @@ gl_MODULES([
   version-etc-fsf
   warnings
 ])
-gl_AVOID([alignof-tests])
+gl_AVOID([])
 gl_SOURCE_BASE([gl])
 gl_M4_BASE([gl/m4])
 gl_PO_BASE([])
index df5963f79d69aeafa1d0ae5206e142faafe92e32..42ad7b2500269f1825de5c6f041cc4ac8bd50017 100644 (file)
@@ -485,6 +485,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/wchar_t.m4
   m4/wint_t.m4
   m4/xsize.m4
+  tests/test-alignof.c
   tests/test-alloca-opt.c
   tests/test-arpa_inet.c
   tests/test-c-ctype.c
index 421303a3a876e6d57cbc236782399269c515ce63..a37a580ca750543c7f1c6c2fd97cb2fb0403bb0c 100644 (file)
@@ -42,6 +42,15 @@ libtests_a_DEPENDENCIES = $(gltests_LIBOBJS)
 EXTRA_libtests_a_SOURCES =
 AM_LIBTOOLFLAGS = --preserve-dup-deps
 
+## begin gnulib module alignof-tests
+
+TESTS += test-alignof
+check_PROGRAMS += test-alignof
+
+EXTRA_DIST += test-alignof.c
+
+## end   gnulib module alignof-tests
+
 ## begin gnulib module alloca-opt-tests
 
 TESTS += test-alloca-opt
diff --git a/gl/tests/test-alignof.c b/gl/tests/test-alignof.c
new file mode 100644 (file)
index 0000000..93d5ded
--- /dev/null
@@ -0,0 +1,57 @@
+/* Test of <alignof.h>.
+   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 Bruno Haible <bruno@clisp.org>, 2009.  */
+
+#include <config.h>
+
+#include <alignof.h>
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "verify.h"
+
+typedef long double longdouble;
+typedef struct { char a[1]; } struct1;
+typedef struct { char a[2]; } struct2;
+typedef struct { char a[3]; } struct3;
+typedef struct { char a[4]; } struct4;
+
+#define CHECK(type) \
+  typedef struct { char slot1; type slot2; } type##_helper; \
+  verify (alignof_slot (type) == offsetof (type##_helper, slot2)); \
+  const int type##_slot_alignment = alignof_slot (type); \
+  const int type##_type_alignment = alignof_type (type);
+
+CHECK (char)
+CHECK (short)
+CHECK (int)
+CHECK (long)
+CHECK (float)
+CHECK (double)
+CHECK (long double)
+CHECK (int64_t)
+CHECK (struct1)
+CHECK (struct2)
+CHECK (struct3)
+CHECK (struct4)
+
+int
+main ()
+{
+  return 0;
+}
index 13e9d54c6db313b07fcc770619fbef73d3530e14..e492dbc035b12f62605d08237bf3b3bd21d71e56 100644 (file)
 
 #include <stddef.h>
 
-/* Determine the alignment of a type at compile time.  */
-#if defined __GNUC__
-# define alignof __alignof__
-#elif defined __cplusplus
+/* Determine the alignment of a structure slot (field) of a given type,
+   at compile time.  Note that the result depends on the ABI.
+   Note: The result cannot be used as a value for an 'enum' constant,
+   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
+#if defined __cplusplus
   template <class type> struct alignof_helper { char __slot1; type __slot2; };
-# define alignof(type) offsetof (alignof_helper<type>, __slot2)
+# define alignof_slot(type) offsetof (alignof_helper<type>, __slot2)
+#else
+# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+#endif
+
+/* Determine the good alignment of a object of the given type at compile time.
+   Note that this is not necessarily the same as alignof_slot(type).
+   For example, with GNU C on x86 platforms: alignof_type(double) = 8, but
+   - when -malign-double is not specified:  alignof_slot(double) = 4,
+   - when -malign-double is specified:      alignof_slot(double) = 8.
+   Note: The result cannot be used as a value for an 'enum' constant,
+   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
+#if defined __GNUC__
+# define alignof_type __alignof__
 #else
-# define alignof(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
+# define alignof_type alignof_slot
 #endif
 
+/* alignof is an alias for alignof_slot semantics, since that's what most
+   callers need.
+   Note: The result cannot be used as a value for an 'enum' constant,
+   due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc.  */
+#define alignof alignof_slot
+
 #endif /* _ALIGNOF_H */