diff mbox series

open_posix_testsuite: Avoid non portable GCC extensions without a guard

Message ID trinity-3d4cbcc6-9f74-4c0e-a556-de3b554a217a-1714907088044@3c-app-webde-bs13
State Accepted
Headers show
Series open_posix_testsuite: Avoid non portable GCC extensions without a guard | expand

Commit Message

Detlef Riekenberg May 5, 2024, 11:04 a.m. UTC
The GCC extension "__attribute__" breaks other compiler
and produces 458 test failures.


--
Regards ... Detlef

Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
---
 .../open_posix_testsuite/include/posixtest.h  | 27 ++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

--
2.40.1

Comments

Cyril Hrubis May 7, 2024, 4:07 p.m. UTC | #1
Hi!
Pushed with a minor whitespace changes, thanks.
diff mbox series

Patch

diff --git a/testcases/open_posix_testsuite/include/posixtest.h b/testcases/open_posix_testsuite/include/posixtest.h
index d1b298488..07979b736 100644
--- a/testcases/open_posix_testsuite/include/posixtest.h
+++ b/testcases/open_posix_testsuite/include/posixtest.h
@@ -20,9 +20,30 @@ 
 #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)) { \