Skip to content

Commit 6b687a9

Browse files
committed
Add re-entrant qsort detection
1 parent 0af437a commit 6b687a9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

config/cmake/ConfigureChecks.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,15 @@ CHECK_FUNCTION_EXISTS (asprintf ${HDF_PREFIX}_HAVE_ASPRINTF)
425425
CHECK_FUNCTION_EXISTS (vasprintf ${HDF_PREFIX}_HAVE_VASPRINTF)
426426
CHECK_FUNCTION_EXISTS (waitpid ${HDF_PREFIX}_HAVE_WAITPID)
427427

428+
# Check for reentrant qsort variants (qsort_r on Unix/BSD, qsort_s on Windows)
429+
# Note: qsort_r has different signatures on GNU/Linux vs BSD/macOS, but we just
430+
# check for existence here. Signature differences will be handled in the code.
431+
CHECK_FUNCTION_EXISTS (qsort_r _HAVE_QSORT_R_TMP)
432+
CHECK_FUNCTION_EXISTS (qsort_s _HAVE_QSORT_S_TMP)
433+
if (_HAVE_QSORT_R_TMP OR _HAVE_QSORT_S_TMP)
434+
set (${HDF_PREFIX}_HAVE_QSORT_REENTRANT 1)
435+
endif ()
436+
428437
#-----------------------------------------------------------------------------
429438
# sigsetjmp is special; may actually be a macro
430439
#-----------------------------------------------------------------------------

config/cmake/H5pubconf.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@
270270
/* Define to 1 if you have the <pwd.h> header file. */
271271
#cmakedefine H5_HAVE_PWD_H @H5_HAVE_PWD_H@
272272

273+
/* Define to 1 if you have a reentrant qsort function (qsort_r or qsort_s). */
274+
#cmakedefine H5_HAVE_QSORT_REENTRANT @H5_HAVE_QSORT_REENTRANT@
275+
273276
/* Define whether the Read-Only S3 virtual file driver (VFD) should be
274277
compiled */
275278
#cmakedefine H5_HAVE_ROS3_VFD @H5_HAVE_ROS3_VFD@

0 commit comments

Comments
 (0)