Files
hdf5/config/cmake/HDFTests.c
T
Quincey Koziol 9fd88560d5 Refactor threading and other concurrency support (#4469)
Complete overhaul of the concurrency-related aspects of the library (threading, atomics, locking, etc.), adding private routines in the H5TS package to allow internal algorithms to use all of these capabilities.

Adds many new features & components in the H5TS package that are equivalent to common concurrency data structures and capabilities: "regular" and recursive mutices, condition variables, semaphores, thread barriers, 'once' support, thread pools, atomic variables, thread-local keys, and spawning & joining internal threads.

Now supports C11, pthreads, and Windows threading for all H5TS capabilities, except the recursive readers/writers lock, which is not supported on Windows (because Windows threads don't provide a callback on thread-local variable deletion).

The "global" API lock is switched to use a recursive mutex from the H5TS package, instead of its own variant.

API context code (H5CX package) and error stacks (H5E package) now use the common thread-local info, instead of their own variants.

Subfiling code is switched from using Mercury threading features to the new internal H5TS features.

Removes the mercury threading code.

Adds a configure option (--enable-threads / HDF5_ENABLE_THREADS), enabled by default, to control whether threading is enabled within the library.
2024-07-31 12:34:43 -05:00

131 lines
2.5 KiB
C

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* A simple test program to see if a function "works" */
#define SIMPLE_TEST(x) int main(void){ x; return 0; }
#ifdef HAVE___FLOAT128
/* Check if __float128 works (only used in the Fortran interface) */
int
main ()
{
__float128 x;
return 0;
}
#endif /* HAVE___FLOAT128 */
#ifdef HAVE_BUILTIN_EXPECT
int
main ()
{
void *ptr = (void*) 0;
if (__builtin_expect (ptr != (void*) 0, 1))
return 0;
return 0;
}
#endif /* HAVE_BUILTIN_EXPECT */
#ifdef HAVE_ATTRIBUTE
int
main ()
{
int __attribute__((unused)) x;
return 0;
}
#endif /* HAVE_ATTRIBUTE */
#ifdef HAVE_TIMEZONE
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#include <time.h>
SIMPLE_TEST(timezone = 0);
#endif /* HAVE_TIMEZONE */
#ifdef PTHREAD_BARRIER
#include <pthread.h>
int main(void)
{
pthread_barrier_t barr;
int ret;
ret = pthread_barrier_init(&barr, NULL, 1);
if (ret == 0)
return 0;
return 1;
}
#endif /* PTHREAD_BARRIER */
#ifdef HAVE_SOCKLEN_T
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
SIMPLE_TEST(socklen_t foo);
#endif /* HAVE_SOCKLEN_T */
#ifdef DEV_T_IS_SCALAR
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
int main ()
{
dev_t d1, d2;
if (d1 == d2)
return 0;
return 1;
}
#endif /* DEV_T_IS_SCALAR */
#ifdef HAVE_DEFAULT_SOURCE
/* Check default source */
#include <features.h>
int
main(void)
{
#ifdef __GLIBC_PREREQ
return __GLIBC_PREREQ(2,19);
#else
return 0;
#endif
}
#endif