From a326ec839ae2123d9464d4f96d732e610f144d23 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Thu, 13 Apr 2023 14:43:39 -0700 Subject: [PATCH] Add autoconf test for stdatomic Also do conditional compilation for stdatomic and pthread. --- configure.ac | 3 +++ src/iperf.h | 7 ++++++- src/iperf_api.h | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 7521f0d1c..92b9ced52 100644 --- a/configure.ac +++ b/configure.ac @@ -91,6 +91,9 @@ CC="$PTHREAD_CC" CXX="$PTHREAD_CXX" ]) +# Atomics +AC_CHECK_HEADERS([stdatomic.h]) + # Check for poll.h (it's in POSIX so everyone should have it?) AC_CHECK_HEADERS([poll.h]) diff --git a/src/iperf.h b/src/iperf.h index 87b7b0ed2..87f787fd5 100644 --- a/src/iperf.h +++ b/src/iperf.h @@ -1,5 +1,5 @@ /* - * iperf, Copyright (c) 2014-2020, The Regents of the University of + * iperf, Copyright (c) 2014-2020, 2023, The Regents of the University of * California, through Lawrence Berkeley National Laboratory (subject * to receipt of any required approvals from the U.S. Dept. of * Energy). All rights reserved. @@ -73,8 +73,13 @@ #include #endif // HAVE_SSL +#ifdef HAVE_PTHREAD #include +#endif // HAVE_PTHREAD + +#ifdef HAVE_STDATOMIC_H #include +#endif // HAVE_STDATOMIC_H #if !defined(__IPERF_API_H) //typedef uint64_t iperf_size_t; diff --git a/src/iperf_api.h b/src/iperf_api.h index 1c2cb7ec3..fd2ab6bc6 100644 --- a/src/iperf_api.h +++ b/src/iperf_api.h @@ -1,5 +1,5 @@ /* - * iperf, Copyright (c) 2014-2022, The Regents of the University of + * iperf, Copyright (c) 2014-2023, The Regents of the University of * California, through Lawrence Berkeley National Laboratory (subject * to receipt of any required approvals from the U.S. Dept. of * Energy). All rights reserved. @@ -38,7 +38,9 @@ extern "C" { /* open extern "C" */ #endif +#ifdef HAVE_STDATOMIC_H #include +#endif // HAVE_STDATOMIC_H struct iperf_test; struct iperf_stream_result;