diff options
| author | Paul Eggert | 2016-01-17 14:10:26 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-01-17 14:11:09 -0800 |
| commit | fabb1fa31d1fd60764c025925e6c76c9145e5a59 (patch) | |
| tree | 9bb5e66cb3fac71c258e37954210e2be056a44b2 /src | |
| parent | 05e8148a24ebe51fbe758dd16265e8fb81f85953 (diff) | |
| download | emacs-fabb1fa31d1fd60764c025925e6c76c9145e5a59.tar.gz emacs-fabb1fa31d1fd60764c025925e6c76c9145e5a59.zip | |
Port cleanup attribute to OpenBSD
The OpenBSD C compiler issues false alarms about strcpy, strcat, and
sprintf, and this messes up 'configure' when it tests for the cleanup
attribute. Work around the problem by using __has_attribute directly.
Problem reported by Joakim Jalap (Bug#22385).
* configure.ac: Don’t use AX_GCC_VAR_ATTRIBUTE.
* m4/ax_gcc_var_attribute.m4: Remove.
* src/conf_post.h (__has_attribute): Provide a substitute, for
non-GCC or older GCC compilers. All uses changed to assume
the substitute. Check for the cleanup attribute.
* src/emacs-module.c (module_has_cleanup): Just use __has_attribute.
Diffstat (limited to 'src')
| -rw-r--r-- | src/conf_post.h | 28 | ||||
| -rw-r--r-- | src/emacs-module.c | 3 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/conf_post.h b/src/conf_post.h index 98ff12e5a53..5c332a05a5c 100644 --- a/src/conf_post.h +++ b/src/conf_post.h | |||
| @@ -51,10 +51,21 @@ typedef bool bool_bf; | |||
| 51 | #endif | 51 | #endif |
| 52 | #endif | 52 | #endif |
| 53 | 53 | ||
| 54 | /* When not using Clang, assume its attributes and features are absent. */ | 54 | /* Simulate __has_attribute on compilers that lack it. It is used only |
| 55 | on arguments like alloc_size that are handled in this simulation. */ | ||
| 55 | #ifndef __has_attribute | 56 | #ifndef __has_attribute |
| 56 | # define __has_attribute(a) false | 57 | # define __has_attribute(a) __has_attribute_##a |
| 57 | #endif | 58 | # define __has_attribute_alloc_size (4 < __GNUC__ + (3 <= __GNUC_MINOR__)) |
| 59 | # define __has_attribute_cleanup (3 < __GNUC__ + (4 <= __GNUC_MINOR__)) | ||
| 60 | # define __has_attribute_externally_visible \ | ||
| 61 | (4 < __GNUC__ + (1 <= __GNUC_MINOR__)) | ||
| 62 | # define __has_attribute_no_address_safety_analysis false | ||
| 63 | # define __has_attribute_no_sanitize_address \ | ||
| 64 | (4 < __GNUC__ + (8 <= __GNUC_MINOR__)) | ||
| 65 | #endif | ||
| 66 | |||
| 67 | /* Simulate __has_feature on compilers that lack it. It is used only | ||
| 68 | to define ADDRESS_SANITIZER below. */ | ||
| 58 | #ifndef __has_feature | 69 | #ifndef __has_feature |
| 59 | # define __has_feature(a) false | 70 | # define __has_feature(a) false |
| 60 | #endif | 71 | #endif |
| @@ -222,9 +233,7 @@ extern int emacs_setenv_TZ (char const *); | |||
| 222 | #define NO_INLINE | 233 | #define NO_INLINE |
| 223 | #endif | 234 | #endif |
| 224 | 235 | ||
| 225 | #if (__clang__ \ | 236 | #if __has_attribute (externally_visible) |
| 226 | ? __has_attribute (externally_visible) \ | ||
| 227 | : (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))) | ||
| 228 | #define EXTERNALLY_VISIBLE __attribute__((externally_visible)) | 237 | #define EXTERNALLY_VISIBLE __attribute__((externally_visible)) |
| 229 | #else | 238 | #else |
| 230 | #define EXTERNALLY_VISIBLE | 239 | #define EXTERNALLY_VISIBLE |
| @@ -253,9 +262,7 @@ extern int emacs_setenv_TZ (char const *); | |||
| 253 | # define ATTRIBUTE_MALLOC | 262 | # define ATTRIBUTE_MALLOC |
| 254 | #endif | 263 | #endif |
| 255 | 264 | ||
| 256 | #if (__clang__ \ | 265 | #if __has_attribute (alloc_size) |
| 257 | ? __has_attribute (alloc_size) \ | ||
| 258 | : 4 < __GNUC__ + (3 <= __GNUC_MINOR__)) | ||
| 259 | # define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) | 266 | # define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) |
| 260 | #else | 267 | #else |
| 261 | # define ATTRIBUTE_ALLOC_SIZE(args) | 268 | # define ATTRIBUTE_ALLOC_SIZE(args) |
| @@ -278,8 +285,7 @@ extern int emacs_setenv_TZ (char const *); | |||
| 278 | /* Attribute of functions whose code should not have addresses | 285 | /* Attribute of functions whose code should not have addresses |
| 279 | sanitized. */ | 286 | sanitized. */ |
| 280 | 287 | ||
| 281 | #if (__has_attribute (no_sanitize_address) \ | 288 | #if __has_attribute (no_sanitize_address) |
| 282 | || 4 < __GNUC__ + (8 <= __GNUC_MINOR__)) | ||
| 283 | # define ATTRIBUTE_NO_SANITIZE_ADDRESS \ | 289 | # define ATTRIBUTE_NO_SANITIZE_ADDRESS \ |
| 284 | __attribute__ ((no_sanitize_address)) ADDRESS_SANITIZER_WORKAROUND | 290 | __attribute__ ((no_sanitize_address)) ADDRESS_SANITIZER_WORKAROUND |
| 285 | #elif __has_attribute (no_address_safety_analysis) | 291 | #elif __has_attribute (no_address_safety_analysis) |
diff --git a/src/emacs-module.c b/src/emacs-module.c index b5e044e758f..79a077b3cb4 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -35,8 +35,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 35 | 35 | ||
| 36 | /* Feature tests. */ | 36 | /* Feature tests. */ |
| 37 | 37 | ||
| 38 | /* True if __attribute__ ((cleanup (...))) works, false otherwise. */ | 38 | #if __has_attribute (cleanup) |
| 39 | #ifdef HAVE_VAR_ATTRIBUTE_CLEANUP | ||
| 40 | enum { module_has_cleanup = true }; | 39 | enum { module_has_cleanup = true }; |
| 41 | #else | 40 | #else |
| 42 | enum { module_has_cleanup = false }; | 41 | enum { module_has_cleanup = false }; |