From 3ed53d17fb018c0415be2d668c6765217deff16f Mon Sep 17 00:00:00 2001 From: Dana Robinson <43805+derobins@users.noreply.github.com> Date: Thu, 30 Jun 2022 19:50:42 -0700 Subject: Removes workaround for platforms that lack C99 stuct initializers (#1842) --- config/cmake/H5pubconf.h.in | 4 - config/cmake_ext_mod/ConfigureChecks.cmake | 1 - config/cmake_ext_mod/HDFTests.c | 32 ------- configure.ac | 15 ---- src/H5Pdcpl.c | 133 ----------------------------- 5 files changed, 185 deletions(-) diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 4b2d2ee..e32c3b3 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -98,10 +98,6 @@ /* Define if the __attribute__(()) extension is present */ #cmakedefine H5_HAVE_ATTRIBUTE @H5_HAVE_ATTRIBUTE@ -/* Define if the compiler understands C99 designated initialization of structs - and unions */ -#cmakedefine H5_HAVE_C99_DESIGNATED_INITIALIZER @H5_HAVE_C99_DESIGNATED_INITIALIZER@ - /* Define to 1 if you have the `clock_gettime' function. */ #cmakedefine H5_HAVE_CLOCK_GETTIME @H5_HAVE_CLOCK_GETTIME@ diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index c4516c7..2312929 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -493,7 +493,6 @@ endif () if (MINGW OR NOT WINDOWS) foreach (other_test HAVE_ATTRIBUTE - HAVE_C99_DESIGNATED_INITIALIZER SYSTEM_SCOPE_THREADS HAVE_SOCKLEN_T ) diff --git a/config/cmake_ext_mod/HDFTests.c b/config/cmake_ext_mod/HDFTests.c index 16686ba..66b9bf6 100644 --- a/config/cmake_ext_mod/HDFTests.c +++ b/config/cmake_ext_mod/HDFTests.c @@ -11,38 +11,6 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #define SIMPLE_TEST(x) int main(){ x; return 0; } -#ifdef HAVE_C99_DESIGNATED_INITIALIZER - -#ifdef FC_DUMMY_MAIN -#ifndef FC_DUMMY_MAIN_EQ_F77 -# ifdef __cplusplus -extern "C" -# endif -int FC_DUMMY_MAIN() -{ return 1;} -#endif -#endif -int -main () -{ - - typedef struct - { - int x; - union - { - int i; - double d; - }u; - }di_struct_t; - di_struct_t x = - { 0, - { .d = 0.0}}; - ; - return 0; -} - -#endif #ifdef HAVE_ATTRIBUTE diff --git a/configure.ac b/configure.ac index 7c9d990..d493873 100644 --- a/configure.ac +++ b/configure.ac @@ -2140,21 +2140,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[int __attribute__((unused)) x]])], AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) -AC_MSG_CHECKING([for C99 designated initialization support]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ - typedef struct { - int x; - union { - int i; - double d; - } u; - } di_struct_t; - di_struct_t x = {0, { .d = 0.0}}; ]])], - [AC_DEFINE([HAVE_C99_DESIGNATED_INITIALIZER], [1], - [Define if the compiler understands C99 designated initialization of structs and unions]) - AC_MSG_RESULT([yes])], - [AC_MSG_RESULT([no])]) - ## ---------------------------------------------------------------------- ## Remove old ways of determining debug/production build. ## These were used in 1.8.x and earlier. We should probably keep these checks diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 4926cbd..3561c65 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -93,7 +93,6 @@ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \ H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE \ } -#ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER #define H5D_DEF_STORAGE_COMPACT \ { \ H5D_COMPACT, \ @@ -142,41 +141,6 @@ H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ H5D_DEF_STORAGE_VIRTUAL \ } -#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ -/* Note that the compact & chunked layout initialization values are using the - * contiguous layout initialization in the union, because the contiguous - * layout is first in the union. These values are overridden in the - * H5P__init_def_layout() routine. -QAK - */ -#define H5D_DEF_LAYOUT_COMPACT \ - { \ - H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ - { \ - H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ - } \ - } -#define H5D_DEF_LAYOUT_CONTIG \ - { \ - H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ - { \ - H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ - } \ - } -#define H5D_DEF_LAYOUT_CHUNK \ - { \ - H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ - { \ - H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ - } \ - } -#define H5D_DEF_LAYOUT_VIRTUAL \ - { \ - H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, \ - { \ - H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT \ - } \ - } -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* ======== Dataset creation properties ======== */ /* Definitions for storage layout property */ @@ -245,9 +209,6 @@ /* General routines */ static herr_t H5P__set_layout(H5P_genplist_t *plist, const H5O_layout_t *layout); -#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER -static herr_t H5P__init_def_layout(void); -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Property class callbacks */ static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass); @@ -320,18 +281,10 @@ static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default static const unsigned H5O_ohdr_min_g = H5D_CRT_MIN_DSET_HDR_SIZE_DEF; /* Default object header minimization */ /* Defaults for each type of layout */ -#ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER static const H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; static const H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; static const H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; static const H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; -#else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ -static H5O_layout_t H5D_def_layout_compact_g = H5D_DEF_LAYOUT_COMPACT; -static H5O_layout_t H5D_def_layout_contig_g = H5D_DEF_LAYOUT_CONTIG; -static H5O_layout_t H5D_def_layout_chunk_g = H5D_DEF_LAYOUT_CHUNK; -static H5O_layout_t H5D_def_layout_virtual_g = H5D_DEF_LAYOUT_VIRTUAL; -static hbool_t H5P_dcrt_def_layout_init_g = FALSE; -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /*------------------------------------------------------------------------- * Function: H5P__dcrt_reg_prop @@ -1926,47 +1879,6 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__set_layout() */ -#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - -/*------------------------------------------------------------------------- - * Function: H5P__init_def_layout - * - * Purpose: Set the default layout information for the various types of - * dataset layouts - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, January 13, 2009 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5P__init_def_layout(void) -{ - const H5O_layout_chunk_t def_layout_chunk = H5D_DEF_LAYOUT_CHUNK_INIT; - const H5O_storage_compact_t def_store_compact = H5D_DEF_STORAGE_COMPACT_INIT; - const H5O_storage_chunk_t def_store_chunk = H5D_DEF_STORAGE_CHUNK_INIT; - const H5O_storage_virtual_t def_store_virtual = H5D_DEF_STORAGE_VIRTUAL_INIT; - - FUNC_ENTER_PACKAGE_NOERR - - /* Initialize the default layout info for non-contigous layouts */ - H5D_def_layout_compact_g.storage.type = H5D_COMPACT; - H5D_def_layout_compact_g.storage.u.compact = def_store_compact; - H5D_def_layout_chunk_g.u.chunk = def_layout_chunk; - H5D_def_layout_chunk_g.storage.type = H5D_CHUNKED; - H5D_def_layout_chunk_g.storage.u.chunk = def_store_chunk; - H5D_def_layout_virtual_g.storage.type = H5D_VIRTUAL; - H5D_def_layout_virtual_g.storage.u.virt = def_store_virtual; - - /* Note that we've initialized the default values */ - H5P_dcrt_def_layout_init_g = TRUE; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5P__init_def_layout() */ -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /*------------------------------------------------------------------------- * Function: H5Pset_layout * @@ -1997,15 +1909,6 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout_type) if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID") -#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - /* If the compiler doesn't support C99 designated initializers, check if - * the default layout structs have been initialized yet or not. *ick* -QAK - */ - if (!H5P_dcrt_def_layout_init_g) - if (H5P__init_def_layout() < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /* Get pointer to correct default layout */ switch (layout_type) { case H5D_COMPACT: @@ -2114,15 +2017,6 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) if (!dim) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no chunk dimensions specified") -#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - /* If the compiler doesn't support C99 designated initializers, check if - * the default layout structs have been initialized yet or not. *ick* -QAK - */ - if (!H5P_dcrt_def_layout_init_g) - if (H5P__init_def_layout() < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /* Verify & initialize property's chunk dims */ H5MM_memcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g)); HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim)); @@ -2254,15 +2148,6 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, const if (H5D_virtual_check_mapping_pre(vspace, src_space, H5O_VIRTUAL_STATUS_USER) < 0) HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "invalid mapping selections") -#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - /* If the compiler doesn't support C99 designated initializers, check if - * the default layout structs have been initialized yet or not. *ick* -QAK - */ - if (!H5P_dcrt_def_layout_init_g) - if (H5P__init_def_layout() < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /* Get the plist structure */ if (NULL == (plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID") @@ -2734,15 +2619,6 @@ H5Pset_chunk_opts(hid_t plist_id, unsigned options) if (options & ~(H5D_CHUNK_DONT_FILTER_PARTIAL_CHUNKS)) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "unknown chunk options") -#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - /* If the compiler doesn't support C99 designated initializers, check if - * the default layout structs have been initialized yet or not. *ick* -QAK - */ - if (!H5P_dcrt_def_layout_init_g) - if (H5P__init_def_layout() < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /* Get the plist structure */ if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID") @@ -2794,15 +2670,6 @@ H5Pget_chunk_opts(hid_t plist_id, unsigned *options /*out*/) FUNC_ENTER_API(FAIL) H5TRACE2("e", "ix", plist_id, options); -#ifndef H5_HAVE_C99_DESIGNATED_INITIALIZER - /* If the compiler doesn't support C99 designated initializers, check if - * the default layout structs have been initialized yet or not. *ick* -QAK - */ - if (!H5P_dcrt_def_layout_init_g) - if (H5P__init_def_layout() < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't initialize default layout info") -#endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ - /* Get the plist structure */ if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID") -- cgit v0.12