1 2# Copyright (C) Igor Sysoev 3# Copyright (C) NGINX, Inc. 4 5 6# C language features. 7 8 9nxt_feature="C99 variadic macro" 10nxt_feature_name=NXT_HAVE_C99_VARIADIC_MACRO 11nxt_feature_run=yes 12nxt_feature_path= 13nxt_feature_libs= 14nxt_feature_test="#include <stdio.h> 15 #define set(dummy, ...) sprintf(__VA_ARGS__) 16 17 int main() { 18 char buf[4]; 19 20 buf[0] = '0'; 21 set(0, buf, \"%d\", 1); 22 23 if (buf[0] == '1') 24 return 0; 25 return 1; 26 }" 27. auto/feature 28 29 30if [ $nxt_found = no ]; then 31 32 nxt_feature="GCC variadic macro" 33 nxt_feature_name=NXT_HAVE_GCC_VARIADIC_MACRO 34 nxt_feature_run=yes 35 nxt_feature_path= 36 nxt_feature_libs= 37 nxt_feature_test="#include <stdio.h> 38 #define set(dummy, args...) sprintf(args) 39 40 int main() { 41 char buf[4]; 42 43 buf[0] = '0'; 44 set(0, buf, \"%d\", 1); 45 46 if (buf[0] == '1') 47 return 0; 48 return 1; 49 }" 50 . auto/feature 51fi 52 53 54nxt_feature="GCC __builtin_expect()" 55nxt_feature_name=NXT_HAVE_BUILTIN_EXPECT 56nxt_feature_run=no 57nxt_feature_incs= 58nxt_feature_libs= 59nxt_feature_test="int main(int argc, char *const *argv) { 60 if ((__typeof__(argc == 0)) 61 __builtin_expect((argc == 0), 0)) 62 return 0; 63 return 1; 64 }" 65. auto/feature 66 67 68nxt_feature="GCC __builtin_unreachable()" 69nxt_feature_name=NXT_HAVE_BUILTIN_UNREACHABLE 70nxt_feature_run=no 71nxt_feature_incs= 72nxt_feature_libs= 73nxt_feature_test="int main() { 74 __builtin_unreachable(); 75 }" 76. auto/feature 77 78 79nxt_feature="GCC __builtin_prefetch()" 80nxt_feature_name=NXT_HAVE_BUILTIN_PREFETCH 81nxt_feature_run=no 82nxt_feature_incs= 83nxt_feature_libs= 84nxt_feature_test="int main() { 85 __builtin_prefetch(0); 86 }" 87. auto/feature 88 89 90nxt_feature="GCC __attribute__ visibility" 91nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_VISIBILITY 92nxt_feature_run= 93nxt_feature_path= 94nxt_feature_libs= 95nxt_feature_test="int n __attribute__ ((visibility(\"default\"))); 96 97 int main() { 98 return 1; 99 }" 100. auto/feature 101 102 103nxt_feature="GCC __attribute__ aligned" 104nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_ALIGNED 105nxt_feature_run= 106nxt_feature_path= 107nxt_feature_libs= 108nxt_feature_test="int n __attribute__ ((aligned(64))); 109 110 int main() { 111 return 1; 112 }" 113. auto/feature 114 115 116nxt_feature="GCC __attribute__ malloc" 117nxt_feature_name=NXT_HAVE_GCC_ATTRIBUTE_MALLOC 118nxt_feature_run= 119nxt_feature_path= 120nxt_feature_libs= 121nxt_feature_test="#include <stdlib.h> 122 123 void *f(void) __attribute__ ((__malloc__)); 124 125 void *f(void) { 126 return malloc(1); 127 } 128 129 int main() { 130 if (f() != NULL) { 131 return 1; 132 } 133 return 0; 134 }" 135. auto/feature 136