Skip to content

Commit a835b07

Browse files
Detlef Riekenberg via ltpmetan-ucw
authored andcommitted
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 <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]>
1 parent ef286ba commit a835b07

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

testcases/open_posix_testsuite/include/posixtest.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,29 @@
2020
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
2121
#endif
2222

23-
#define PTS_ATTRIBUTE_NORETURN __attribute__((noreturn))
24-
#define PTS_ATTRIBUTE_UNUSED __attribute__((unused))
25-
#define PTS_ATTRIBUTE_UNUSED_RESULT __attribute__((warn_unused_result))
23+
/* __attribute__ is a non portable gcc extension */
24+
/* TODO: Add support for C23 attributes */
25+
#if defined __has_attribute
26+
# if __has_attribute(noreturn)
27+
# define PTS_ATTRIBUTE_NORETURN __attribute__((noreturn))
28+
# endif
29+
# if __has_attribute(unused)
30+
# define PTS_ATTRIBUTE_UNUSED __attribute__((unused))
31+
# endif
32+
# if __has_attribute(warn_unused_result)
33+
# define PTS_ATTRIBUTE_UNUSED_RESULT __attribute__((warn_unused_result))
34+
# endif
35+
#endif
36+
37+
#ifndef PTS_ATTRIBUTE_NORETURN
38+
# define PTS_ATTRIBUTE_NORETURN
39+
#endif
40+
#ifndef PTS_ATTRIBUTE_UNUSED
41+
# define PTS_ATTRIBUTE_UNUSED
42+
#endif
43+
#ifndef PTS_ATTRIBUTE_UNUSED_RESULT
44+
# define PTS_ATTRIBUTE_UNUSED_RESULT
45+
#endif
2646

2747
#define PTS_WRITE_MSG(msg) do { \
2848
if (write(STDOUT_FILENO, msg, sizeof(msg) - 1)) { \

0 commit comments

Comments
 (0)