1set stdio 2if tst note{ _ALL_SOURCE & _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ 3 #define _ALL_SOURCE 1 4 #define _POSIX_SOURCE 1 5 #define _POSIX_C_SOURCE 21000101L 6 #define _XOPEN_SOURCE 9900 7 #define _GNU_SOURCE 1 8 #define __EXTENSIONS__ 1 9 #include <sys/types.h> 10 #include <sys/stat.h> 11 #include <stdlib.h> 12 #include <unistd.h> 13 }end { 14 #ifndef _ALL_SOURCE 15 #define _ALL_SOURCE 1 16 #endif 17 #ifndef _POSIX_SOURCE 18 #define _POSIX_SOURCE 1 19 #endif 20 #ifndef _POSIX_C_SOURCE 21 #define _POSIX_C_SOURCE 21000101L 22 #endif 23 #ifndef _XOPEN_SOURCE 24 #define _XOPEN_SOURCE 9900 25 #endif 26 #ifndef _GNU_SOURCE 27 #define _GNU_SOURCE 1 28 #endif 29 #ifndef __EXTENSIONS__ 30 #define __EXTENSIONS__ 1 31 #endif 32 } 33elif tst note{ _ALL_SOURCE & _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ 34 #define _ALL_SOURCE 1 35 #define _POSIX_SOURCE 1 36 #define _XOPEN_SOURCE 9900 37 #define _GNU_SOURCE 1 38 #define __EXTENSIONS__ 1 39 #include <sys/types.h> 40 #include <sys/stat.h> 41 #include <stdlib.h> 42 #include <unistd.h> 43 }end { 44 #ifndef _ALL_SOURCE 45 #define _ALL_SOURCE 1 46 #endif 47 #ifndef _POSIX_SOURCE 48 #define _POSIX_SOURCE 1 49 #endif 50 #ifndef _XOPEN_SOURCE 51 #define _XOPEN_SOURCE 9900 52 #endif 53 #ifndef _GNU_SOURCE 54 #define _GNU_SOURCE 1 55 #endif 56 #ifndef __EXTENSIONS__ 57 #define __EXTENSIONS__ 1 58 #endif 59 } 60elif tst note{ _POSIX_SOURCE & _POSIX_C_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ 61 #define _POSIX_SOURCE 1 62 #define _POSIX_C_SOURCE 21000101L 63 #define _XOPEN_SOURCE 9900 64 #define _GNU_SOURCE 1 65 #define __EXTENSIONS__ 1 66 #include <sys/types.h> 67 #include <sys/stat.h> 68 #include <stdlib.h> 69 #include <unistd.h> 70 }end { 71 #ifndef _POSIX_SOURCE 72 #define _POSIX_SOURCE 1 73 #endif 74 #ifndef _POSIX_C_SOURCE 75 #define _POSIX_C_SOURCE 21000101L 76 #endif 77 #ifndef _XOPEN_SOURCE 78 #define _XOPEN_SOURCE 9900 79 #endif 80 #ifndef _GNU_SOURCE 81 #define _GNU_SOURCE 1 82 #endif 83 #ifndef __EXTENSIONS__ 84 #define __EXTENSIONS__ 1 85 #endif 86 } 87elif tst note{ _POSIX_SOURCE & _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ 88 #define _POSIX_SOURCE 1 89 #define _XOPEN_SOURCE 1 90 #define __EXTENSIONS__ 1 91 #include <sys/types.h> 92 #include <sys/stat.h> 93 #include <stdlib.h> 94 #include <unistd.h> 95 }end { 96 #ifndef _POSIX_SOURCE 97 #define _POSIX_SOURCE 1 98 #endif 99 #ifndef _XOPEN_SOURCE 100 #define _XOPEN_SOURCE 1 101 #endif 102 #ifndef __EXTENSIONS__ 103 #define __EXTENSIONS__ 1 104 #endif 105 } 106elif tst note{ _XOPEN_SOURCE & __EXTENSIONS__ works }end compile{ 107 #define _XOPEN_SOURCE 1 108 #define __EXTENSIONS__ 1 109 #include <sys/types.h> 110 #include <sys/stat.h> 111 #include <stdlib.h> 112 #include <unistd.h> 113 }end { 114 #ifndef _XOPEN_SOURCE 115 #define _XOPEN_SOURCE 1 116 #endif 117 #ifndef __EXTENSIONS__ 118 #define __EXTENSIONS__ 1 119 #endif 120 } 121elif tst note{ _XOPEN_SOURCE works }end compile{ 122 #define _XOPEN_SOURCE 1 123 #include <sys/types.h> 124 #include <sys/stat.h> 125 #include <stdlib.h> 126 #include <unistd.h> 127 }end { 128 #ifndef _XOPEN_SOURCE 129 #define _XOPEN_SOURCE 1 130 #endif 131 } 132else tst note{ __EXTENSIONS__ works }end compile{ 133 #define __EXTENSIONS__ 1 134 #include <sys/types.h> 135 #include <sys/stat.h> 136 }end { 137 #ifndef __EXTENSIONS__ 138 #define __EXTENSIONS__ 1 139 #endif 140 } 141endif 142 143if tst -D_ISOC99_SOURCE -lm note{ _ISOC99_SOURCE plays nice }end link{ 144 #include <sys/types.h> 145 #include <sys/stat.h> 146 #include <stdlib.h> 147 #include <unistd.h> 148 #include <math.h> 149 int main() { return signbit(-0.0); } 150 }end { 151 #ifndef _ISOC99_SOURCE 152 #define _ISOC99_SOURCE 1 153 #endif 154 } 155endif 156 157cat{ 158 159/* 160 * this is a nasty game we all play to honor standards symbol visibility 161 * it would help if all implementations had 162 * _KITCHEN_SINK_SOURCE 163 * that enabled all symbols from the latest implemented standards 164 * that's probably the most useful but least portable request 165 */ 166 167#if __MACH__ 168#undef _POSIX_SOURCE 169#endif 170 171}end 172