Debian Codegraph @

Modules/ThirdParty/HDF5/src/itkhdf5/config/cmake_ext_mod/HDFTests.c

raw
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Copyright by The HDF Group. *
3 * All rights reserved. *
4 * *
5 * This file is part of HDF5. The full HDF5 copyright notice, including *
6 * terms governing use, modification, and redistribution, is contained in *
7 * the COPYING file, which can be found at the root of the source code *
8 * distribution tree, or in https://www.hdfgroup.org/licenses. *
9 * If you do not have access to either file, you may request a copy from *
10 * [email protected]. *
11 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12 #define SIMPLE_TEST(x) int main(){ x; return 0; }
13
14 #ifdef HAVE_C99_DESIGNATED_INITIALIZER
15
16 #ifdef FC_DUMMY_MAIN
17 #ifndef FC_DUMMY_MAIN_EQ_F77
18 # ifdef __cplusplus
19 extern "C"
20 # endif
21 int FC_DUMMY_MAIN()
22 { return 1;}
23 #endif
24 #endif
25 int
26 main ()
27 {
28
29 typedef struct
30 {
31 int x;
32 union
33 {
34 int i;
35 double d;
36 }u;
37 }di_struct_t;
38 di_struct_t x =
39 { 0,
40 { .d = 0.0}};
41 ;
42 return 0;
43 }
44
45 #endif
46
47 #ifdef HAVE_C99_FUNC
48
49 #ifdef FC_DUMMY_MAIN
50 #ifndef FC_DUMMY_MAIN_EQ_F77
51 # ifdef __cplusplus
52 extern "C"
53 # endif
54 int FC_DUMMY_MAIN() { return 1; }
55 #endif
56 #endif
57 int
58 main ()
59 {
60 const char *fname = __func__;
61 ;
62 return 0;
63 }
64
65 #endif
66
67 #ifdef VSNPRINTF_WORKS
68 #include <stdio.h>
69 #include <stdlib.h>
70 #include <stdarg.h>
71
72 int test_vsnprintf(const char *fmt,...)
73 {
74 va_list ap;
75 char *s = malloc(16);
76 int ret;
77
78 va_start(ap, fmt);
79 ret=vsnprintf(s,16,"%s",ap);
80 va_end(ap);
81
82 return(ret!=42 ? 1 : 0);
83 }
84
85 int main(void)
86 {
87 return(test_vsnprintf("%s","A string that is longer than 16 characters"));
88 }
89 #endif
90
91 #ifdef STDC_HEADERS
92 #include <stdlib.h>
93 #include <stdarg.h>
94 #include <string.h>
95 #include <float.h>
96 int main() { return 0; }
97 #endif /* STDC_HEADERS */
98
99
100 #ifdef HAVE_ATTRIBUTE
101
102 #if 0
103 static void test int __attribute((unused)) var)
104 {
105 int __attribute__((unused)) x = var;
106 }
107
108 int main(void)
109 {
110 test(19);
111 }
112
113 #else
114 int
115 main ()
116 {
117 int __attribute__((unused)) x
118 ;
119 return 0;
120 }
121 #endif
122
123
124 #endif /* HAVE_ATTRIBUTE */
125
126 #ifdef HAVE_FUNCTION
127
128 #ifdef FC_DUMMY_MAIN
129 #ifndef FC_DUMMY_MAIN_EQ_F77
130 # ifdef __cplusplus
131 extern "C"
132 # endif
133 int FC_DUMMY_MAIN() { return 1; }
134 #endif
135 #endif
136 int
137 main ()
138 {
139 (void)__FUNCTION__
140 ;
141 return 0;
142 }
143
144 #endif /* HAVE_FUNCTION */
145
146 #ifdef HAVE_TIMEZONE
147
148 #ifdef HAVE_SYS_TIME_H
149 #include <sys/time.h>
150 #endif
151 #include <time.h>
152 SIMPLE_TEST(timezone=0);
153
154 #endif /* HAVE_TIMEZONE */
155
156 #ifdef PRINTF_LL_WIDTH
157
158 #ifdef HAVE_LONG_LONG
159 # define LL_TYPE long long
160 #else /* HAVE_LONG_LONG */
161 # define LL_TYPE __int64
162 #endif /* HAVE_LONG_LONG */
163
164 #include <stdio.h>
165 #include <stdlib.h>
166 #include <string.h>
167
168 #if defined(_MSC_VER) && defined(_DEBUG)
169 # include <crtdbg.h>
170 int DebugReport(int reportType, char* message, int* returnValue)
171 {
172 (void)reportType;
173 (void)message;
174 (void)returnValue;
175 return 1; /* no further handling required */
176 }
177 #endif
178
179 int main(void)
180 {
181 char *llwidthArgs[] = { "I64", "l64", "ll", "l", "L", "q", NULL };
182 char *s = malloc(128);
183 char **currentArg = NULL;
184 LL_TYPE x = (LL_TYPE)1048576 * (LL_TYPE)1048576;
185 #if defined(_MSC_VER) && defined(_DEBUG)
186 _CrtSetReportHook(DebugReport);
187 #endif
188 for (currentArg = llwidthArgs; *currentArg != NULL; currentArg++)
189 {
190 char formatString[64];
191 sprintf(formatString, "%%%sd", *currentArg);
192 sprintf(s, formatString, x);
193 if (strcmp(s, "1099511627776") == 0)
194 {
195 printf("PRINTF_LL_WIDTH=[%s]\n", *currentArg);
196 return 0;
197 }
198 }
199 return 1;
200 }
201
202 #endif /* PRINTF_LL_WIDTH */
203
204 #ifdef SYSTEM_SCOPE_THREADS
205 #include <stdlib.h>
206 #include <pthread.h>
207
208 int main(void)
209 {
210 pthread_attr_t attribute;
211 int ret;
212
213 pthread_attr_init(&attribute);
214 ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM);
215 if (ret==0)
216 return 0;
217 return 1;
218 }
219
220 #endif /* SYSTEM_SCOPE_THREADS */
221
222 #ifdef HAVE_SOCKLEN_T
223
224 #include <stdio.h>
225 #include <stdlib.h>
226 #ifdef HAVE_UNISTD_H
227 #include <unistd.h>
228 #endif
229 #ifdef HAVE_SYS_TYPES_H
230 #include <sys/types.h>
231 #endif
232 #ifdef HAVE_SYS_SOCKET_H
233 #include <sys/socket.h>
234 #endif
235
236 SIMPLE_TEST(socklen_t foo);
237
238 #endif /* HAVE_SOCKLEN_T */
239
240 #ifdef DEV_T_IS_SCALAR
241
242 #ifdef HAVE_SYS_TYPES_H
243 #include <sys/types.h>
244 #endif
245
246 int main ()
247 {
248 dev_t d1, d2;
249 if(d1==d2)
250 return 0;
251 return 1;
252 }
253
254 #endif /* DEV_T_IS_SCALAR */
255
256 #ifdef HAVE_OFF64_T
257 #include <sys/types.h>
258 int main()
259 {
260 off64_t n = 0;
261 return (int)n;
262 }
263 #endif
264
265 #ifdef TEST_DIRECT_VFD_WORKS
266 #include <sys/types.h>
267 #include <sys/stat.h>
268 #include <fcntl.h>
269 int main(void)
270 {
271 int fid;
272 if((fid=open("tst_file", O_CREAT | O_TRUNC | O_DIRECT, 0755))<0)
273 return 1;
274 close(fid);
275 remove("tst_file");
276 return 0;
277 }
278 #endif
279
280 #ifdef HAVE_DIRECT
281 SIMPLE_TEST(posix_memalign());
282 #endif
283
284 #ifdef HAVE_DEFAULT_SOURCE
285 /* check default source */
286 #include <features.h>
287
288 int
289 main(void)
290 {
291 #ifdef __GLIBC_PREREQ
292 return __GLIBC_PREREQ(2,19);
293 #else
294 return 0;
295 #endif /* defined(__GLIBC_PREREQ) */
296 }
297 #endif
298
299 #ifdef TEST_LFS_WORKS
300 /* Return 0 when LFS is available and 1 otherwise. */
301 #define _LARGEFILE_SOURCE
302 #define _LARGEFILE64_SOURCE
303 #define _LARGE_FILES
304 #define _FILE_OFFSET_BITS 64
305 #include <sys/types.h>
306 #include <sys/stat.h>
307 #include <assert.h>
308 #include <stdio.h>
309
310 int main(int argc, char **argv)
311 {
312 /* check that off_t can hold 2^63 - 1 and perform basic operations... */
313 #define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
314 if (OFF_T_64 % 2147483647 != 1)
315 return 1;
316
317 /* stat breaks on SCO OpenServer */
318 struct stat buf;
319 stat( argv[0], &buf );
320 if (!S_ISREG(buf.st_mode))
321 return 2;
322
323 FILE *file = fopen( argv[0], "r" );
324 off_t offset = ftello( file );
325 fseek( file, offset, SEEK_CUR );
326 fclose( file );
327 return 0;
328 }
329 #endif
330
331 #ifdef GETTIMEOFDAY_GIVES_TZ
332 #include <time.h>
333 #ifdef HAVE_SYS_TIME_H
334 #include <sys/time.h>
335 #endif
336 int main(void)
337 {
338 struct timeval tv;
339 struct timezone tz;
340 tz.tz_minuteswest = 7777; /* Initialize to an unreasonable number */
341 tz.tz_dsttime = 7;
342 gettimeofday(&tv, &tz);
343 /* Check whether the function returned any value at all */
344 if(tz.tz_minuteswest == 7777 && tz.tz_dsttime == 7)
345 return 1;
346 else return 0;
347 }
348 #endif
349
350 #ifdef HAVE_IOEO
351
352 #include <windows.h>
353 typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
354 int main ()
355 {
356 PGNSI pGNSI;
357 pGNSI = (PGNSI) GetProcAddress(
358 GetModuleHandle(TEXT("kernel32.dll")),
359 "InitOnceExecuteOnce");
360 if(NULL == pGNSI)
361 return 1;
362 else
363 return 0;
364 }
365
366 #endif /* HAVE_IOEO */
367
368 #if defined( HAVE_INLINE ) || defined( HAVE___INLINE__ ) || defined( HAVE___INLINE )
369 #ifndef __cplusplus
370 #if defined( HAVE_INLINE )
371 # define INLINE_KW inline
372 #elif defined ( HAVE___INLINE__ )
373 # define INLINE_KW __inline__
374 #elif defined ( HAVE___INLINE )
375 # define INLINE_KW __inline
376 #endif /* HAVE_INLINE */
377 typedef int foo_t;
378 static INLINE_KW foo_t static_foo () { return 0; }
379 INLINE_KW foo_t foo () {return 0; }
380 int main(void) { return 0; }
381 #endif /* __cplusplus */
382 #endif /* defined( HAVE_INLINE ) || defined( HAVE___INLINE__ ) || defined( HAVE___INLINE ) */
383