Debian Codegraph @

BLOSC/config/cmake/H5BLOSCTests.c

raw
1 #define SIMPLE_TEST(x) int main(){ x; return 0; }
2
3 #ifdef HAVE_C99_DESIGNATED_INITIALIZER
4
5 #ifdef FC_DUMMY_MAIN
6 #ifndef FC_DUMMY_MAIN_EQ_F77
7 # ifdef __cplusplus
8 extern "C"
9 # endif
10 int FC_DUMMY_MAIN()
11 { return 1;}
12 #endif
13 #endif
14 int
15 main ()
16 {
17
18 typedef struct
19 {
20 int x;
21 union
22 {
23 int i;
24 double d;
25 }u;
26 }di_struct_t;
27 di_struct_t x =
28 { 0,
29 { .d = 0.0}};
30 ;
31 return 0;
32 }
33
34 #endif
35
36 #ifdef HAVE_C99_FUNC
37
38 #ifdef FC_DUMMY_MAIN
39 #ifndef FC_DUMMY_MAIN_EQ_F77
40 # ifdef __cplusplus
41 extern "C"
42 # endif
43 int FC_DUMMY_MAIN() { return 1; }
44 #endif
45 #endif
46 int
47 main ()
48 {
49 const char *fname = __func__;
50 ;
51 return 0;
52 }
53
54 #endif
55
56 #ifdef VSNPRINTF_WORKS
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <stdarg.h>
60
61 int test_vsnprintf(const char *fmt,...)
62 {
63 va_list ap;
64 char *s = malloc(16);
65 int ret;
66
67 va_start(ap, fmt);
68 ret=vsnprintf(s,16,"%s",ap);
69 va_end(ap);
70
71 return(ret!=42 ? 1 : 0);
72 }
73
74 int main(void)
75 {
76 return(test_vsnprintf("%s","A string that is longer than 16 characters"));
77 }
78 #endif
79
80
81 #ifdef TIME_WITH_SYS_TIME
82 /* Time with sys/time test */
83
84 #include <sys/types.h>
85 #include <sys/time.h>
86 #include <time.h>
87
88 int
89 main ()
90 {
91 if ((struct tm *) 0)
92 return 0;
93 ;
94 return 0;
95 }
96
97 #endif
98
99 #ifdef STDC_HEADERS
100 #include <stdlib.h>
101 #include <stdarg.h>
102 #include <string.h>
103 #include <float.h>
104 int main() { return 0; }
105 #endif /* STDC_HEADERS */
106
107
108 #ifdef HAVE_ATTRIBUTE
109
110 #if 0
111 static void test int __attribute((unused)) var)
112 {
113 int __attribute__((unused)) x = var;
114 }
115
116 int main(void)
117 {
118 test(19);
119 }
120
121 #else
122 int
123 main ()
124 {
125 int __attribute__((unused)) x
126 ;
127 return 0;
128 }
129 #endif
130
131
132 #endif /* HAVE_ATTRIBUTE */
133
134 #ifdef HAVE_FUNCTION
135
136 #ifdef FC_DUMMY_MAIN
137 #ifndef FC_DUMMY_MAIN_EQ_F77
138 # ifdef __cplusplus
139 extern "C"
140 # endif
141 int FC_DUMMY_MAIN() { return 1; }
142 #endif
143 #endif
144 int
145 main ()
146 {
147 (void)__FUNCTION__
148 ;
149 return 0;
150 }
151
152 #endif /* HAVE_FUNCTION */
153
154 #ifdef HAVE_TM_GMTOFF
155
156 #ifdef HAVE_SYS_TIME_H
157 #include <sys/time.h>
158 #endif
159 #include <time.h>
160 SIMPLE_TEST(struct tm tm; tm.tm_gmtoff=0);
161
162 #endif /* HAVE_TM_GMTOFF */
163
164 #ifdef HAVE___TM_GMTOFF
165
166 #ifdef HAVE_SYS_TIME_H
167 #include <sys/time.h>
168 #endif
169 #include <time.h>
170 SIMPLE_TEST(struct tm tm; tm.__tm_gmtoff=0);
171
172 #endif /* HAVE_TM_GMTOFF */
173
174 #ifdef HAVE_TIMEZONE
175
176 #ifdef HAVE_SYS_TIME_H
177 #include <sys/time.h>
178 #endif
179 #include <time.h>
180 SIMPLE_TEST(timezone=0);
181
182 #endif /* HAVE_TIMEZONE */
183
184 #ifdef HAVE_STRUCT_TIMEZONE
185
186 #include <sys/types.h>
187 #ifdef HAVE_SYS_TIME_H
188 #include <sys/time.h>
189 #endif
190 #include <time.h>
191 SIMPLE_TEST(struct timezone tz; tz.tz_minuteswest=0);
192
193 #endif /* HAVE_STRUCT_TIMEZONE */
194
195 #ifdef HAVE_STAT_ST_BLOCKS
196
197 #include <sys/stat.h>
198 SIMPLE_TEST(struct stat sb; sb.st_blocks=0);
199
200 #endif /* HAVE_STAT_ST_BLOCKS */
201
202 #ifdef PRINTF_LL_WIDTH
203
204 #ifdef HAVE_LONG_LONG
205 # define LL_TYPE long long
206 #else /* HAVE_LONG_LONG */
207 # define LL_TYPE __int64
208 #endif /* HAVE_LONG_LONG */
209
210 #include <stdio.h>
211 #include <stdlib.h>
212 #include <string.h>
213
214 int main(void)
215 {
216 char *llwidthArgs[] = { "I64", "l64", "l", "L", "q", "ll", NULL };
217 char *s = malloc(128);
218 char **currentArg = NULL;
219 LL_TYPE x = (LL_TYPE)1048576 * (LL_TYPE)1048576;
220 for (currentArg = llwidthArgs; *currentArg != NULL; currentArg++)
221 {
222 char formatString[64];
223 sprintf(formatString, "%%%sd", *currentArg);
224 sprintf(s, formatString, x);
225 if (strcmp(s, "1099511627776") == 0)
226 {
227 printf("PRINTF_LL_WIDTH=[%s]\n", *currentArg);
228 return 0;
229 }
230 }
231 return 1;
232 }
233
234 #endif /* PRINTF_LL_WIDTH */
235
236 #ifdef SYSTEM_SCOPE_THREADS
237 #include <stdlib.h>
238 #include <pthread.h>
239
240 int main(void)
241 {
242 pthread_attr_t attribute;
243 int ret;
244
245 pthread_attr_init(&attribute);
246 ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
247 if (ret==0)
248 return 0;
249 return 1;
250 }
251
252 #endif /* SYSTEM_SCOPE_THREADS */
253
254 #ifdef HAVE_SOCKLEN_T
255
256 #include <stdio.h>
257 #include <stdlib.h>
258 #ifdef HAVE_UNISTD_H
259 #include <unistd.h>
260 #endif
261 #ifdef HAVE_SYS_TYPES_H
262 #include <sys/types.h>
263 #endif
264 #ifdef HAVE_SYS_SOCKET_H
265 #include <sys/socket.h>
266 #endif
267
268 SIMPLE_TEST(socklen_t foo);
269
270 #endif /* HAVE_SOCKLEN_T */
271
272 #ifdef DEV_T_IS_SCALAR
273
274 #ifdef HAVE_SYS_TYPES_H
275 #include <sys/types.h>
276 #endif
277
278 int main ()
279 {
280 dev_t d1, d2;
281 if(d1==d2)
282 return 0;
283 return 1;
284 }
285
286 #endif /* DEV_T_IS_SCALAR */
287
288 #ifdef HAVE_OFF64_T
289 #include <sys/types.h>
290 int main()
291 {
292 off64_t n = 0;
293 return (int)n;
294 }
295 #endif
296
297 #ifdef HAVE_STAT64_STRUCT
298 #include <sys/types.h>
299 #include <sys/stat.h>],
300 struct stat64 sb;
301 int main()
302 {
303 return 0;
304 }
305 #endif
306
307 #ifdef TEST_DIRECT_VFD_WORKS
308 #include <sys/types.h>
309 #include <sys/stat.h>
310 #include <fcntl.h>
311 int main(void)
312 {
313 int fid;
314 if((fid=open("tst_file", O_CREAT | O_TRUNC | O_DIRECT, 0755))<0)
315 return 1;
316 close(fid);
317 remove("tst_file");
318 return 0;
319 }
320 #endif
321
322 #ifdef HAVE_DIRECT
323 SIMPLE_TEST(posix_memalign());
324 #endif
325
326 #ifdef HAVE_DEFAULT_SOURCE
327 /* check default source */
328 #include <features.h>
329
330 int
331 main(void)
332 {
333 #ifdef __GLIBC_PREREQ
334 return __GLIBC_PREREQ(2,19);
335 #else
336 return 0;
337 #endif /* defined(__GLIBC_PREREQ) */
338 }
339 #endif
340
341 #ifdef TEST_LFS_WORKS
342 /* Return 0 when LFS is available and 1 otherwise. */
343 #define _LARGEFILE_SOURCE
344 #define _LARGEFILE64_SOURCE
345 #define _LARGE_FILES
346 #define _FILE_OFFSET_BITS 64
347 #include <sys/types.h>
348 #include <sys/stat.h>
349 #include <assert.h>
350 #include <stdio.h>
351
352 int main(int argc, char **argv)
353 {
354 /* check that off_t can hold 2^63 - 1 and perform basic operations... */
355 #define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
356 if (OFF_T_64 % 2147483647 != 1)
357 return 1;
358
359 /* stat breaks on SCO OpenServer */
360 struct stat buf;
361 stat( argv[0], &buf );
362 if (!S_ISREG(buf.st_mode))
363 return 2;
364
365 FILE *file = fopen( argv[0], "r" );
366 off_t offset = ftello( file );
367 fseek( file, offset, SEEK_CUR );
368 fclose( file );
369 return 0;
370 }
371 #endif
372
373 #ifdef GETTIMEOFDAY_GIVES_TZ
374 #include <time.h>
375 #ifdef HAVE_SYS_TIME_H
376 #include <sys/time.h>
377 #endif
378 int main(void)
379 {
380 struct timeval tv;
381 struct timezone tz;
382 tz.tz_minuteswest = 7777; /* Initialize to an unreasonable number */
383 tz.tz_dsttime = 7;
384 gettimeofday(&tv, &tz);
385 /* Check whether the function returned any value at all */
386 if(tz.tz_minuteswest == 7777 && tz.tz_dsttime == 7)
387 return 1;
388 else return 0;
389 }
390 #endif
391
392 #ifdef CXX_HAVE_OFFSETOF
393
394 #include <stdio.h>
395 #include <stddef.h>
396
397 #ifdef FC_DUMMY_MAIN
398 #ifndef FC_DUMMY_MAIN_EQ_F77
399 # ifdef __cplusplus
400 extern "C"
401 # endif
402 int FC_DUMMY_MAIN()
403 { return 1;}
404 #endif
405 #endif
406 int
407 main ()
408 {
409
410 struct index_st
411 {
412 unsigned char type;
413 unsigned char num;
414 unsigned int len;
415 };
416 typedef struct index_st index_t;
417 int x,y;
418 x = offsetof(struct index_st, len);
419 y = offsetof(index_t, num)
420
421 ;
422 return 0;
423 }
424
425 #endif
426
427 #ifdef HAVE_IOEO
428
429 #include <windows.h>
430 typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
431 int main ()
432 {
433 PGNSI pGNSI;
434 pGNSI = (PGNSI) GetProcAddress(
435 GetModuleHandle(TEXT("kernel32.dll")),
436 "InitOnceExecuteOnce");
437 if(NULL == pGNSI)
438 return 1;
439 else
440 return 0;
441 }
442
443 #endif /* HAVE_IOEO */
444
445 #ifdef HAVE_STRUCT_VIDEOCONFIG
446
447 SIMPLE_TEST(struct videoconfig w; w.numtextcols=0);
448
449 #endif /* HAVE_TM_GMTOFF */
450
451 #ifdef HAVE_STRUCT_TEXT_INFO
452
453 SIMPLE_TEST(struct text_info w; w.screenwidth=0);
454
455 #endif /* HAVE_TM_GMTOFF */
456
457
458 #if defined( INLINE_TEST_inline ) || defined( INLINE_TEST___inline__ ) || defined( INLINE_TEST___inline )
459 #ifndef __cplusplus
460 typedef int foo_t;
461 static INLINE_TEST_INLINE foo_t static_foo () { return 0; }
462 INLINE_TEST_INLINE foo_t foo () {return 0; }
463 int main() { return 0; }
464 #endif
465
466 #endif /* INLINE_TEST */