Skip to content

Commit c2775cc

Browse files
committed
Add re-entrant qsort detection
1 parent 26a76ba commit c2775cc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

config/ConfigureChecks.cmake

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

446+
# Check for reentrant qsort variants (qsort_r on Unix/BSD, qsort_s on Windows)
447+
# Note: qsort_r has different signatures on GNU/Linux vs BSD/macOS, but we just
448+
# check for existence here. Signature differences will be handled in the code.
449+
CHECK_FUNCTION_EXISTS (qsort_r _HAVE_QSORT_R_TMP)
450+
CHECK_FUNCTION_EXISTS (qsort_s _HAVE_QSORT_S_TMP)
451+
if (_HAVE_QSORT_R_TMP OR _HAVE_QSORT_S_TMP)
452+
set (${HDF_PREFIX}_HAVE_QSORT_REENTRANT 1)
453+
endif ()
454+
446455
#-----------------------------------------------------------------------------
447456
# sigsetjmp is special; may actually be a macro
448457
#-----------------------------------------------------------------------------

src/H5pubconf.h.in

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

261+
/* Define to 1 if you have a reentrant qsort function (qsort_r or qsort_s). */
262+
#cmakedefine H5_HAVE_QSORT_REENTRANT @H5_HAVE_QSORT_REENTRANT@
263+
261264
/* Define whether the Read-Only S3 virtual file driver (VFD) should be
262265
compiled */
263266
#cmakedefine H5_HAVE_ROS3_VFD @H5_HAVE_ROS3_VFD@

0 commit comments

Comments
 (0)