diff options
author | Detlef Riekenberg via ltp <ltp@lists.linux.it> | 2024-05-05 13:04:48 +0200 |
---|---|---|
committer | Cyril Hrubis <chrubis@suse.cz> | 2024-05-07 18:07:30 +0200 |
commit | a835b0730e397307c3ef9e770271b0e8e9487620 (patch) | |
tree | 22945872153b57859bb167874a690c7dd4bde7d6 | |
parent | ef286ba37a5ffe326d26569b6c7d082d27516b4f (diff) | |
download | ltp-a835b0730e397307c3ef9e770271b0e8e9487620.tar.gz |
open_posix_testsuite: Avoid non portable GCC extensions without a guard
The GCC extension "__attribute__" breaks other compiler
and produces 458 test failures.
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
-rw-r--r-- | testcases/open_posix_testsuite/include/posixtest.h | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/testcases/open_posix_testsuite/include/posixtest.h b/testcases/open_posix_testsuite/include/posixtest.h index d1b298488..01d9ef2a5 100644 --- a/testcases/open_posix_testsuite/include/posixtest.h +++ b/testcases/open_posix_testsuite/include/posixtest.h @@ -20,9 +20,29 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #endif -#define PTS_ATTRIBUTE_NORETURN __attribute__((noreturn)) -#define PTS_ATTRIBUTE_UNUSED __attribute__((unused)) -#define PTS_ATTRIBUTE_UNUSED_RESULT __attribute__((warn_unused_result)) +/* __attribute__ is a non portable gcc extension */ +/* TODO: Add support for C23 attributes */ +#if defined __has_attribute +# if __has_attribute(noreturn) +# define PTS_ATTRIBUTE_NORETURN __attribute__((noreturn)) +# endif +# if __has_attribute(unused) +# define PTS_ATTRIBUTE_UNUSED __attribute__((unused)) +# endif +# if __has_attribute(warn_unused_result) +# define PTS_ATTRIBUTE_UNUSED_RESULT __attribute__((warn_unused_result)) +# endif +#endif + +#ifndef PTS_ATTRIBUTE_NORETURN +# define PTS_ATTRIBUTE_NORETURN +#endif +#ifndef PTS_ATTRIBUTE_UNUSED +# define PTS_ATTRIBUTE_UNUSED +#endif +#ifndef PTS_ATTRIBUTE_UNUSED_RESULT +# define PTS_ATTRIBUTE_UNUSED_RESULT +#endif #define PTS_WRITE_MSG(msg) do { \ if (write(STDOUT_FILENO, msg, sizeof(msg) - 1)) { \ |