diff options
| author | Paul Eggert | 2013-07-07 23:15:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-07-07 23:15:38 -0700 |
| commit | 2a74a90a033ec2bf2580ca1c7163209f1cd3faed (patch) | |
| tree | 888b313d913d9ac5da8161784a39c85b4ca5241e | |
| parent | 6602769357bba5616c4d36a12d2dce254f4b5fee (diff) | |
| download | emacs-2a74a90a033ec2bf2580ca1c7163209f1cd3faed.tar.gz emacs-2a74a90a033ec2bf2580ca1c7163209f1cd3faed.zip | |
Try to fix FreeBSD 9.1 porting problem.
This incorporates the following merge from gnulib:
2013-07-07 stdalign, verify: port to FreeBSD 9.1, to C11, and to C++11
Fixes: debbugs:14812
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | lib/stdalign.in.h | 39 | ||||
| -rw-r--r-- | lib/verify.h | 112 | ||||
| -rw-r--r-- | m4/stdalign.m4 | 3 |
4 files changed, 97 insertions, 63 deletions
| @@ -1,3 +1,9 @@ | |||
| 1 | 2013-07-08 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Try to fix FreeBSD 9.1 porting problem (Bug#14812). | ||
| 4 | This incorporates the following merge from gnulib: | ||
| 5 | 2013-07-07 stdalign, verify: port to FreeBSD 9.1, to C11, and to C++11 | ||
| 6 | |||
| 1 | 2013-07-07 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2013-07-07 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | Port to Ubuntu 10 (Bug#14803). | 9 | Port to Ubuntu 10 (Bug#14803). |
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h index c3a67321b0e..7254a3dec17 100644 --- a/lib/stdalign.in.h +++ b/lib/stdalign.in.h | |||
| @@ -41,13 +41,28 @@ | |||
| 41 | are 4 unless the option '-malign-double' is used. | 41 | are 4 unless the option '-malign-double' is used. |
| 42 | 42 | ||
| 43 | The result cannot be used as a value for an 'enum' constant, if you | 43 | The result cannot be used as a value for an 'enum' constant, if you |
| 44 | want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. */ | 44 | want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc. |
| 45 | |||
| 46 | Include <stddef.h> for offsetof. */ | ||
| 45 | #include <stddef.h> | 47 | #include <stddef.h> |
| 46 | #if defined __cplusplus | 48 | |
| 49 | /* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other | ||
| 50 | standard headers, defines conflicting implementations of _Alignas | ||
| 51 | and _Alignof that are no better than ours; override them. */ | ||
| 52 | #undef _Alignas | ||
| 53 | #undef _Alignof | ||
| 54 | |||
| 55 | #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 | ||
| 56 | # ifdef __cplusplus | ||
| 57 | # if 201103 <= __cplusplus | ||
| 58 | # define _Alignof(type) alignof (type) | ||
| 59 | # else | ||
| 47 | template <class __t> struct __alignof_helper { char __a; __t __b; }; | 60 | template <class __t> struct __alignof_helper { char __a; __t __b; }; |
| 48 | # define _Alignof(type) offsetof (__alignof_helper<type>, __b) | 61 | # define _Alignof(type) offsetof (__alignof_helper<type>, __b) |
| 49 | #else | 62 | # endif |
| 50 | # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) | 63 | # else |
| 64 | # define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) | ||
| 65 | # endif | ||
| 51 | #endif | 66 | #endif |
| 52 | #define alignof _Alignof | 67 | #define alignof _Alignof |
| 53 | #define __alignof_is_defined 1 | 68 | #define __alignof_is_defined 1 |
| @@ -77,12 +92,16 @@ | |||
| 77 | 92 | ||
| 78 | */ | 93 | */ |
| 79 | 94 | ||
| 80 | #if __GNUC__ || __IBMC__ || __IBMCPP__ || 0x5110 <= __SUNPRO_C | 95 | #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 |
| 81 | # define _Alignas(a) __attribute__ ((__aligned__ (a))) | 96 | # if defined __cplusplus && 201103 <= __cplusplus |
| 82 | #elif 1300 <= _MSC_VER | 97 | # define _Alignas(a) alignas (a) |
| 83 | # define _Alignas(a) __declspec (align (a)) | 98 | # elif __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C |
| 99 | # define _Alignas(a) __attribute__ ((__aligned__ (a))) | ||
| 100 | # elif 1300 <= _MSC_VER | ||
| 101 | # define _Alignas(a) __declspec (align (a)) | ||
| 102 | # endif | ||
| 84 | #endif | 103 | #endif |
| 85 | #ifdef _Alignas | 104 | #if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__) |
| 86 | # define alignas _Alignas | 105 | # define alignas _Alignas |
| 87 | # define __alignas_is_defined 1 | 106 | # define __alignas_is_defined 1 |
| 88 | #endif | 107 | #endif |
diff --git a/lib/verify.h b/lib/verify.h index 03492efcd3f..d42d0750ee1 100644 --- a/lib/verify.h +++ b/lib/verify.h | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | /* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ | 18 | /* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ |
| 19 | 19 | ||
| 20 | #ifndef _GL_VERIFY_H | 20 | #ifndef _GL_VERIFY_H |
| 21 | # define _GL_VERIFY_H | 21 | #define _GL_VERIFY_H |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | /* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. | 24 | /* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11. |
| @@ -31,16 +31,24 @@ | |||
| 31 | Use this only with GCC. If we were willing to slow 'configure' | 31 | Use this only with GCC. If we were willing to slow 'configure' |
| 32 | down we could also use it with other compilers, but since this | 32 | down we could also use it with other compilers, but since this |
| 33 | affects only the quality of diagnostics, why bother? */ | 33 | affects only the quality of diagnostics, why bother? */ |
| 34 | # if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ | 34 | #if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \ |
| 35 | && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ | 35 | && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \ |
| 36 | && !defined __cplusplus) | 36 | && !defined __cplusplus) |
| 37 | # define _GL_HAVE__STATIC_ASSERT 1 | 37 | # define _GL_HAVE__STATIC_ASSERT 1 |
| 38 | # endif | 38 | #endif |
| 39 | /* The condition (99 < __GNUC__) is temporary, until we know about the | 39 | /* The condition (99 < __GNUC__) is temporary, until we know about the |
| 40 | first G++ release that supports static_assert. */ | 40 | first G++ release that supports static_assert. */ |
| 41 | # if (99 < __GNUC__) && defined __cplusplus | 41 | #if (99 < __GNUC__) && defined __cplusplus |
| 42 | # define _GL_HAVE_STATIC_ASSERT 1 | 42 | # define _GL_HAVE_STATIC_ASSERT 1 |
| 43 | # endif | 43 | #endif |
| 44 | |||
| 45 | /* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other | ||
| 46 | system headers, defines a conflicting _Static_assert that is no | ||
| 47 | better than ours; override it. */ | ||
| 48 | #ifndef _GL_HAVE_STATIC_ASSERT | ||
| 49 | # include <stddef.h> | ||
| 50 | # undef _Static_assert | ||
| 51 | #endif | ||
| 44 | 52 | ||
| 45 | /* Each of these macros verifies that its argument R is nonzero. To | 53 | /* Each of these macros verifies that its argument R is nonzero. To |
| 46 | be portable, R should be an integer constant expression. Unlike | 54 | be portable, R should be an integer constant expression. Unlike |
| @@ -143,50 +151,50 @@ | |||
| 143 | Use a template type to work around the problem. */ | 151 | Use a template type to work around the problem. */ |
| 144 | 152 | ||
| 145 | /* Concatenate two preprocessor tokens. */ | 153 | /* Concatenate two preprocessor tokens. */ |
| 146 | # define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) | 154 | #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) |
| 147 | # define _GL_CONCAT0(x, y) x##y | 155 | #define _GL_CONCAT0(x, y) x##y |
| 148 | 156 | ||
| 149 | /* _GL_COUNTER is an integer, preferably one that changes each time we | 157 | /* _GL_COUNTER is an integer, preferably one that changes each time we |
| 150 | use it. Use __COUNTER__ if it works, falling back on __LINE__ | 158 | use it. Use __COUNTER__ if it works, falling back on __LINE__ |
| 151 | otherwise. __LINE__ isn't perfect, but it's better than a | 159 | otherwise. __LINE__ isn't perfect, but it's better than a |
| 152 | constant. */ | 160 | constant. */ |
| 153 | # if defined __COUNTER__ && __COUNTER__ != __COUNTER__ | 161 | #if defined __COUNTER__ && __COUNTER__ != __COUNTER__ |
| 154 | # define _GL_COUNTER __COUNTER__ | 162 | # define _GL_COUNTER __COUNTER__ |
| 155 | # else | 163 | #else |
| 156 | # define _GL_COUNTER __LINE__ | 164 | # define _GL_COUNTER __LINE__ |
| 157 | # endif | 165 | #endif |
| 158 | 166 | ||
| 159 | /* Generate a symbol with the given prefix, making it unique if | 167 | /* Generate a symbol with the given prefix, making it unique if |
| 160 | possible. */ | 168 | possible. */ |
| 161 | # define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) | 169 | #define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) |
| 162 | 170 | ||
| 163 | /* Verify requirement R at compile-time, as an integer constant expression | 171 | /* Verify requirement R at compile-time, as an integer constant expression |
| 164 | that returns 1. If R is false, fail at compile-time, preferably | 172 | that returns 1. If R is false, fail at compile-time, preferably |
| 165 | with a diagnostic that includes the string-literal DIAGNOSTIC. */ | 173 | with a diagnostic that includes the string-literal DIAGNOSTIC. */ |
| 166 | 174 | ||
| 167 | # define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ | 175 | #define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \ |
| 168 | (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) | 176 | (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC))) |
| 169 | 177 | ||
| 170 | # ifdef __cplusplus | 178 | #ifdef __cplusplus |
| 171 | # if !GNULIB_defined_struct__gl_verify_type | 179 | # if !GNULIB_defined_struct__gl_verify_type |
| 172 | template <int w> | 180 | template <int w> |
| 173 | struct _gl_verify_type { | 181 | struct _gl_verify_type { |
| 174 | unsigned int _gl_verify_error_if_negative: w; | 182 | unsigned int _gl_verify_error_if_negative: w; |
| 175 | }; | 183 | }; |
| 176 | # define GNULIB_defined_struct__gl_verify_type 1 | 184 | # define GNULIB_defined_struct__gl_verify_type 1 |
| 177 | # endif | ||
| 178 | # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ | ||
| 179 | _gl_verify_type<(R) ? 1 : -1> | ||
| 180 | # elif defined _GL_HAVE__STATIC_ASSERT | ||
| 181 | # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ | ||
| 182 | struct { \ | ||
| 183 | _Static_assert (R, DIAGNOSTIC); \ | ||
| 184 | int _gl_dummy; \ | ||
| 185 | } | ||
| 186 | # else | ||
| 187 | # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ | ||
| 188 | struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } | ||
| 189 | # endif | 185 | # endif |
| 186 | # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ | ||
| 187 | _gl_verify_type<(R) ? 1 : -1> | ||
| 188 | #elif defined _GL_HAVE__STATIC_ASSERT | ||
| 189 | # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ | ||
| 190 | struct { \ | ||
| 191 | _Static_assert (R, DIAGNOSTIC); \ | ||
| 192 | int _gl_dummy; \ | ||
| 193 | } | ||
| 194 | #else | ||
| 195 | # define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \ | ||
| 196 | struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; } | ||
| 197 | #endif | ||
| 190 | 198 | ||
| 191 | /* Verify requirement R at compile-time, as a declaration without a | 199 | /* Verify requirement R at compile-time, as a declaration without a |
| 192 | trailing ';'. If R is false, fail at compile-time, preferably | 200 | trailing ';'. If R is false, fail at compile-time, preferably |
| @@ -195,23 +203,23 @@ template <int w> | |||
| 195 | Unfortunately, unlike C11, this implementation must appear as an | 203 | Unfortunately, unlike C11, this implementation must appear as an |
| 196 | ordinary declaration, and cannot appear inside struct { ... }. */ | 204 | ordinary declaration, and cannot appear inside struct { ... }. */ |
| 197 | 205 | ||
| 198 | # ifdef _GL_HAVE__STATIC_ASSERT | 206 | #ifdef _GL_HAVE__STATIC_ASSERT |
| 199 | # define _GL_VERIFY _Static_assert | 207 | # define _GL_VERIFY _Static_assert |
| 200 | # else | 208 | #else |
| 201 | # define _GL_VERIFY(R, DIAGNOSTIC) \ | 209 | # define _GL_VERIFY(R, DIAGNOSTIC) \ |
| 202 | extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ | 210 | extern int (*_GL_GENSYM (_gl_verify_function) (void)) \ |
| 203 | [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] | 211 | [_GL_VERIFY_TRUE (R, DIAGNOSTIC)] |
| 204 | # endif | 212 | #endif |
| 205 | 213 | ||
| 206 | /* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ | 214 | /* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ |
| 207 | # ifdef _GL_STATIC_ASSERT_H | 215 | #ifdef _GL_STATIC_ASSERT_H |
| 208 | # if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert | 216 | # if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert |
| 209 | # define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) | 217 | # define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC) |
| 210 | # endif | 218 | # endif |
| 211 | # if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert | 219 | # if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert |
| 212 | # define static_assert _Static_assert /* C11 requires this #define. */ | 220 | # define static_assert _Static_assert /* C11 requires this #define. */ |
| 213 | # endif | ||
| 214 | # endif | 221 | # endif |
| 222 | #endif | ||
| 215 | 223 | ||
| 216 | /* @assert.h omit start@ */ | 224 | /* @assert.h omit start@ */ |
| 217 | 225 | ||
| @@ -229,18 +237,18 @@ template <int w> | |||
| 229 | 237 | ||
| 230 | verify_true is obsolescent; please use verify_expr instead. */ | 238 | verify_true is obsolescent; please use verify_expr instead. */ |
| 231 | 239 | ||
| 232 | # define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") | 240 | #define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")") |
| 233 | 241 | ||
| 234 | /* Verify requirement R at compile-time. Return the value of the | 242 | /* Verify requirement R at compile-time. Return the value of the |
| 235 | expression E. */ | 243 | expression E. */ |
| 236 | 244 | ||
| 237 | # define verify_expr(R, E) \ | 245 | #define verify_expr(R, E) \ |
| 238 | (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) | 246 | (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E)) |
| 239 | 247 | ||
| 240 | /* Verify requirement R at compile-time, as a declaration without a | 248 | /* Verify requirement R at compile-time, as a declaration without a |
| 241 | trailing ';'. */ | 249 | trailing ';'. */ |
| 242 | 250 | ||
| 243 | # define verify(R) _GL_VERIFY (R, "verify (" #R ")") | 251 | #define verify(R) _GL_VERIFY (R, "verify (" #R ")") |
| 244 | 252 | ||
| 245 | /* @assert.h omit end@ */ | 253 | /* @assert.h omit end@ */ |
| 246 | 254 | ||
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index a866ff670b1..20be01aaf20 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 | |||
| @@ -31,7 +31,8 @@ AC_DEFUN([gl_STDALIGN_H], | |||
| 31 | 31 | ||
| 32 | /* Test _Alignas only on platforms where gnulib can help. */ | 32 | /* Test _Alignas only on platforms where gnulib can help. */ |
| 33 | #if \ | 33 | #if \ |
| 34 | (__GNUC__ || __IBMC__ || __IBMCPP__ \ | 34 | ((defined __cplusplus && 201103 <= __cplusplus) \ |
| 35 | || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \ | ||
| 35 | || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) | 36 | || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER) |
| 36 | struct alignas_test { char c; char alignas (8) alignas_8; }; | 37 | struct alignas_test { char c; char alignas (8) alignas_8; }; |
| 37 | char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 | 38 | char test_alignas[offsetof (struct alignas_test, alignas_8) == 8 |