From f1bc0c97a93b84ef429b2240e4ae8466029ed4db Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 2 Mar 2021 03:22:50 -0800 Subject: Makes libgen.h functions ready for implementation on Windows --- config/cmake/H5pubconf.h.in | 3 +++ config/cmake_ext_mod/ConfigureChecks.cmake | 1 + configure.ac | 2 +- src/H5private.h | 13 +++++++++++++ test/page_buffer.c | 5 ++--- test/vfd_swmr_bigset_writer.c | 3 +-- test/vfd_swmr_group_writer.c | 3 +-- test/vfd_swmr_zoo_writer.c | 4 +--- tools/lib/h5tools.c | 2 -- 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 64b4852..56cc264 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -222,6 +222,9 @@ /* Define to 1 if you have the `dmalloc' library (-ldmalloc). */ #cmakedefine H5_HAVE_LIBDMALLOC @H5_HAVE_LIBDMALLOC@ +/* Define to 1 if you have the header file. */ +#cmakedefine H5_HAVE_LIBGEN_H @H5_HAVE_LIBGEN_H@ + /* Proceed to build with libhdfs */ #cmakedefine H5_HAVE_LIBHDFS @H5_HAVE_LIBHDFS@ diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 0ddb6d0..3a4f711 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -136,6 +136,7 @@ CHECK_INCLUDE_FILE_CONCAT ("setjmp.h" ${HDF_PREFIX}_HAVE_SETJMP_H) CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) CHECK_INCLUDE_FILE_CONCAT ("stdint.h" ${HDF_PREFIX}_HAVE_STDINT_H) CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) +CHECK_INCLUDE_FILE_CONCAT ("libgen.h" ${HDF_PREFIX}_HAVE_LIBGEN_H) # Windows CHECK_INCLUDE_FILE_CONCAT ("io.h" ${HDF_PREFIX}_HAVE_IO_H) diff --git a/configure.ac b/configure.ac index 6d869f9..bb5561e 100644 --- a/configure.ac +++ b/configure.ac @@ -1144,7 +1144,7 @@ AC_HEADER_TIME AC_CHECK_HEADERS([sys/resource.h sys/time.h unistd.h sys/ioctl.h sys/stat.h]) AC_CHECK_HEADERS([sys/socket.h sys/types.h sys/file.h]) AC_CHECK_HEADERS([stddef.h setjmp.h features.h]) -AC_CHECK_HEADERS([dirent.h]) +AC_CHECK_HEADERS([dirent.h libgen.h]) AC_CHECK_HEADERS([stdint.h], [C9x=yes]) AC_CHECK_HEADERS([stdbool.h]) AC_CHECK_HEADERS([netdb.h netinet/in.h arpa/inet.h]) diff --git a/src/H5private.h b/src/H5private.h index 3e11b4f..6479032 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -154,6 +154,13 @@ #endif /* + * Needed for dirname and basename on POSIX systems + */ +#ifdef H5_HAVE_LIBGEN_H +#include +#endif + +/* * Dynamic library handling. These are needed for dynamically loading I/O * filters and VFDs. */ @@ -727,6 +734,9 @@ typedef struct { #ifndef HDatoll #define HDatoll(S) atoll(S) #endif /* HDatol */ +#ifndef HDbasename + #define HDbasename(P) basename(P) +#endif /* HDbasename */ #ifndef HDbind #define HDbind(A,B,C) bind((A),(B),(C)) /* mirror VFD */ #endif /* HDbind */ @@ -803,6 +813,9 @@ typedef struct { #define HDdifftime(X,Y) ((double)(X)-(double)(Y)) #endif /* H5_HAVE_DIFFTIME */ #endif /* HDdifftime */ +#ifndef HDdirname + #define HDdirname(P) dirname(P) +#endif /* HDdirname */ #ifndef HDdiv #define HDdiv(X,Y) div(X,Y) #endif /* HDdiv */ diff --git a/test/page_buffer.c b/test/page_buffer.c index 88b3317..112ea77 100644 --- a/test/page_buffer.c +++ b/test/page_buffer.c @@ -20,7 +20,6 @@ *************************************************************/ #include -#include #include "h5test.h" @@ -151,8 +150,8 @@ swmr_fapl_augment(hid_t fapl, const char *filename, uint32_t max_lag) HDfprintf(stderr, "temporary string allocation failed\n"); return -1; } - dname = dirname(tname[0]); - bname = basename(tname[1]); + dname = HDdirname(tname[0]); + bname = HDbasename(tname[1]); snprintf(config.md_file_path, sizeof(config.md_file_path), "%s/%s.shadow", dname, bname); free(tname[0]); diff --git a/test/vfd_swmr_bigset_writer.c b/test/vfd_swmr_bigset_writer.c index 4bf08fd..7b0f451 100644 --- a/test/vfd_swmr_bigset_writer.c +++ b/test/vfd_swmr_bigset_writer.c @@ -67,7 +67,6 @@ */ #include -#include #define H5C_FRIEND /*suppress error about including H5Cpkg */ #define H5F_FRIEND /*suppress error about including H5Fpkg */ @@ -271,7 +270,7 @@ state_init(state_t *s, int argc, char **argv) *s = state_initializer(); esnprintf(tfile, sizeof(tfile), "%s", argv[0]); - esnprintf(s->progname, sizeof(s->progname), "%s", basename(tfile)); + esnprintf(s->progname, sizeof(s->progname), "%s", HDbasename(tfile)); while ((ch = getopt(argc, argv, "FMSVWa:bc:d:n:qr:s:u:")) != -1) { switch (ch) { diff --git a/test/vfd_swmr_group_writer.c b/test/vfd_swmr_group_writer.c index 155e9b1..2f355c2 100644 --- a/test/vfd_swmr_group_writer.c +++ b/test/vfd_swmr_group_writer.c @@ -12,7 +12,6 @@ */ #include -#include #define H5F_FRIEND /*suppress error about including H5Fpkg */ @@ -85,7 +84,7 @@ state_init(state_t *s, int argc, char **argv) *s = ALL_HID_INITIALIZER; esnprintf(tfile, sizeof(tfile), "%s", argv[0]); - esnprintf(s->progname, sizeof(s->progname), "%s", basename(tfile)); + esnprintf(s->progname, sizeof(s->progname), "%s", HDbasename(tfile)); while ((ch = getopt(argc, argv, "SWa:bn:qu:")) != -1) { switch (ch) { diff --git a/test/vfd_swmr_zoo_writer.c b/test/vfd_swmr_zoo_writer.c index 901e1cb..1792a93 100644 --- a/test/vfd_swmr_zoo_writer.c +++ b/test/vfd_swmr_zoo_writer.c @@ -12,7 +12,6 @@ */ #include -#include /* basename(3) */ #define H5C_FRIEND /* suppress error about including H5Cpkg */ #define H5F_FRIEND /* suppress error about including H5Fpkg */ @@ -23,7 +22,6 @@ #include "H5retry_private.h" #include "H5Cpkg.h" #include "H5Fpkg.h" -// #include "H5Iprivate.h" #include "H5HGprivate.h" #include "H5VLprivate.h" @@ -225,7 +223,7 @@ main(int argc, char **argv) const char *seedvar = "H5_ZOO_STEP_SEED"; bool use_vfd_swmr = true; bool print_estack = false; - const char *progname = basename(argv[0]); + const char *progname = HDbasename(argv[0]); const char *personality = strstr(progname, "vfd_swmr_zoo_"); estack_state_t es; char step = 'b'; diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index e6df7c8..f68eb3b 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -16,8 +16,6 @@ * amongst the various HDF5 tools. */ -#include - #include "h5tools.h" #include "h5tools_dump.h" #include "h5tools_ref.h" -- cgit v0.12