From 670078f981b5add4f88fff6475e44b0b76554ceb Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Fri, 17 Apr 2020 16:45:20 +0200 Subject: [PATCH 1/2] fix musl build --- CMakeLists.txt | 10 ++++++++-- config.h.cmake.in | 3 +++ libhdf5/hdf5debug.c | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2153f22d95..5dac91dd55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1078,9 +1078,15 @@ OPTION(ENABLE_BYTERANGE "Enable byte-range access to remote datasets.." OFF) # Check for the math library so it can be explicitly linked. IF(NOT WIN32) FIND_LIBRARY(HAVE_LIBM NAMES math m libm) - MESSAGE(STATUS "Found Math library: ${HAVE_LIBM}") IF(NOT HAVE_LIBM) - MESSAGE(FATAL_ERROR "Unable to find the math library.") + CHECK_FUNCTION_EXISTS(exp HAVE_LIBM_FUNC) + IF(NOT HAVE_LIBM_FUNC) + MESSAGE(FATAL_ERROR "Unable to find the math library.") + ELSE(NOT HAVE_LIBM_FUNC) + SET(HAVE_LIBM "") + ENDIF() + ELSE(NOT HAVE_LIBM) + MESSAGE(STATUS "Found Math library: ${HAVE_LIBM}") ENDIF() ENDIF() diff --git a/config.h.cmake.in b/config.h.cmake.in index 97004f62c1..7273971f31 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -441,6 +441,9 @@ with zip */ /* if true, HDF5 is at least version 1.10.5 and supports UTF8 paths */ #cmakedefine HDF5_UTF8_PATHS 1 +/* if true, backtrace support will be used. */ +#cmakedefine HAVE_EXECINFO_H 1 + /* if true, include JNA bug fix */ #cmakedefine JNA 1 diff --git a/libhdf5/hdf5debug.c b/libhdf5/hdf5debug.c index 4eed2c5bf6..ca5c6cd68e 100644 --- a/libhdf5/hdf5debug.c +++ b/libhdf5/hdf5debug.c @@ -5,7 +5,7 @@ #include "config.h" #include #include -#if !defined _WIN32 && !defined __CYGWIN__ +#ifdef HAVE_EXECINFO_H #include #endif @@ -15,15 +15,18 @@ #define STSIZE 1000 +#ifdef HAVE_EXECINFO_H #ifdef H5BACKTRACE # if !defined _WIN32 && !defined __CYGWIN__ static void* stacktrace[STSIZE]; # endif #endif +#endif int nch5breakpoint(int err) { +#ifdef HAVE_EXECINFO_H #ifdef H5BACKTRACE # if !defined _WIN32 && !defined __CYGWIN__ int count = 0; @@ -39,6 +42,7 @@ nch5breakpoint(int err) if(trace != NULL) free(trace); # endif # endif +#endif #endif return err; } From 5ec50071d7c5decf08782918f16cdd94e9732c2f Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Sat, 16 Jul 2022 13:54:55 +0200 Subject: [PATCH 2/2] Use int64_t instead of __int64 --- libsrc/posixio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsrc/posixio.c b/libsrc/posixio.c index 5e541faac4..31dbf771b1 100644 --- a/libsrc/posixio.c +++ b/libsrc/posixio.c @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef HAVE_FCNTL_H #include @@ -120,7 +121,7 @@ static off_t nc_get_filelen(const int fd) { off_t flen; #ifdef HAVE_FILE_LENGTH_I64 - __int64 file_len = 0; + int64_t file_len = 0; if ((file_len = _filelengthi64(fd)) < 0) { return file_len; } @@ -1829,7 +1830,7 @@ ncio_px_filesize(ncio *nciop, off_t *filesizep) Use _filelengthi64 isntead. */ #ifdef HAVE_FILE_LENGTH_I64 - __int64 file_len = 0; + int64_t file_len = 0; if( (file_len = _filelengthi64(nciop->fd)) < 0) { return errno; }