xref: /aosp_15_r20/external/ltp/testcases/open_posix_testsuite/include/posixtest.h (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 /*
2  * Copyright (c) 2002, Intel Corporation. All rights reserved.
3  * Created by:  julie.n.fleischer REMOVE-THIS AT intel DOT com
4  * This file is licensed under the GPL license.  For the full content
5  * of this license, see the COPYING file at the top level of this
6  * source tree.
7  */
8 
9 /*
10  * return codes
11  */
12 
13 #define PTS_PASS        0
14 #define PTS_FAIL        1
15 #define PTS_UNRESOLVED  2
16 #define PTS_UNSUPPORTED 4
17 #define PTS_UNTESTED    5
18 
19 #ifndef ARRAY_SIZE
20 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
21 #endif
22 
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
46 
47 #define PTS_WRITE_MSG(msg) do { \
48          if (write(STDOUT_FILENO, msg, sizeof(msg) - 1)) { \
49                  /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 */ \
50          } \
51 } while (0)
52