mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-30 15:32:37 +08:00
Bring the H5detect removal change from develop (#3648)
* Bring the H5detect removal change from develop - Removed CMake cross-compiling variables * HDF5_USE_PREGEN * HDF5_BATCH_H5DETECT These were used to work around H5detect and H5make_libsettings and are no longer required. - Running H5make_libsettings is no longer required for cross-compiling The functionality of H5make_libsettings is now handled via template files, so H5make_libsettings has been removed. - Running H5detect is no longer required for cross-compiling The functionality of H5detect is now exercised at library startup, so H5detect has been removed. * Put H5T_CONV_ab macros in do..while loops (#3432) Ever since a recent round of macro cleanup, bin/trace and clang-format have been bickering over what H5Tconv.c should look like and neither produces readable code. This change puts the top-level H5T_CONV_ab macros in do..while loops, adds appropriate semicolons, and adds the missing H5_CLANG_DIAG_ON|OFF and H5_GCC_CLANG_DIAG_ON|OFF macros to the list of statement macros clang-format recognizes. H5Tconv.c is now readable and both bin/trace and clang-format are happy.
This commit is contained in:
parent
7b18845e9c
commit
0feda66ff0
@ -83,6 +83,10 @@ StatementMacros:
|
||||
- H5_END_TAG
|
||||
- H5_GCC_DIAG_OFF
|
||||
- H5_GCC_DIAG_ON
|
||||
- H5_CLANG_DIAG_OFF
|
||||
- H5_CLANG_DIAG_ON
|
||||
- H5_GCC_CLANG_DIAG_OFF
|
||||
- H5_GCC_CLANG_DIAG_ON
|
||||
- H5_LEAVE
|
||||
- HGOTO_DONE
|
||||
- HMPI_DONE_ERROR
|
||||
|
@ -1225,10 +1225,4 @@ endif ()
|
||||
#-----------------------------------------------------------------------------
|
||||
configure_file (${HDF_RESOURCES_DIR}/H5pubconf.h.in ${HDF5_SRC_BINARY_DIR}/H5pubconf.h @ONLY)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Options for use by cross compiling and toolchains
|
||||
#-----------------------------------------------------------------------------
|
||||
option (HDF5_USE_PREGEN "Use pre-generated Files" OFF)
|
||||
option (HDF5_BATCH_H5DETECT "Use a batch command for running h5detect" OFF)
|
||||
|
||||
include (CMakeInstallation.cmake)
|
||||
|
@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
#SBATCH -p knl -C quad
|
||||
#SBATCH --nodes=1
|
||||
#SBATCH -t 00:10:00
|
||||
#SBATCH --mail-type=BEGIN,END,FAIL
|
||||
#SBATCH --mail-user=<username>@sandia.gov
|
||||
#SBATCH --export=ALL
|
||||
#SBATCH --job-name=knl_h5detect
|
||||
|
||||
|
||||
# Inputs: Build directory, output file name, executable file name (username/email if available).
|
||||
PROGNAME=H5detect
|
||||
OUTPUT=H5Tinit.c
|
||||
|
||||
CMD="@HDF5_BINARY_DIR@/bin/${PROGNAME} @HDF5_GENERATED_SOURCE_DIR@/${OUTPUT}"
|
||||
echo "Run $CMD"
|
||||
srun -n 1 $CMD
|
||||
echo "Done running $CMD"
|
||||
|
@ -112,6 +112,10 @@ AC_CONFIG_COMMANDS([pubconf], [
|
||||
sed '/^#/d' < src/libhdf5.settings > libhdf5.settings.TMP
|
||||
cp libhdf5.settings.TMP src/libhdf5.settings
|
||||
rm -f libhdf5.settings.TMP
|
||||
echo "Post process src/H5build_settings.c"
|
||||
sed '/^# /d' < src/H5build_settings.c > H5build_settings.TMP
|
||||
cp H5build_settings.TMP src/H5build_settings.c
|
||||
rm -f H5build_settings.TMP
|
||||
])
|
||||
|
||||
## It's possible to configure for a host other than the one on which
|
||||
@ -3908,9 +3912,11 @@ AC_ARG_ENABLE([embedded-libinfo],
|
||||
|
||||
if test "${enable_embedded_libinfo}" = "yes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
BUILD_SETTINGS_FILE="src/H5build_settings.autotools.c.in"
|
||||
AC_DEFINE([HAVE_EMBEDDED_LIBINFO], [1],
|
||||
[Define if library information should be embedded in the executables])
|
||||
else
|
||||
BUILD_SETTINGS_FILE="src/H5build_settings.off.c.in"
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
|
||||
@ -4047,6 +4053,7 @@ AC_CONFIG_FILES([Makefile
|
||||
doxygen/Doxyfile
|
||||
src/Makefile
|
||||
src/libhdf5.settings
|
||||
src/H5build_settings.c:${BUILD_SETTINGS_FILE}
|
||||
test/Makefile
|
||||
test/H5srcdir_str.h
|
||||
test/test_abort_fail.sh
|
||||
|
@ -1030,15 +1030,6 @@ References:
|
||||
https://stackoverflow.com/questions/54539682/how-to-set-up-cmake-to-cross-compile-with-clang-for-arm-embedded-on-windows?rq=1
|
||||
https://developer.android.com/ndk/guides/cmake
|
||||
|
||||
Predefine H5Tinit.c file
|
||||
-------------------------------
|
||||
The one file that needs to be pre-generated is the H5Tinit.c file. The variables
|
||||
indicated in the error log (see above) are the variables that need to match the target system.
|
||||
|
||||
The HDF5 CMake variables;
|
||||
HDF5_USE_PREGEN: set this to true
|
||||
HDF5_USE_PREGEN_DIR: set this path to the preset H5Tinit.c file
|
||||
|
||||
|
||||
========================================================================
|
||||
X: Using CMakePresets.json for compiling
|
||||
|
@ -9,7 +9,6 @@ Section II: Obtain HDF5 source
|
||||
Section III: Using ctest command to build and test
|
||||
Section IV: Cross compiling
|
||||
Section V: Manual alternatives
|
||||
Section VI: Other cross compiling options
|
||||
|
||||
************************************************************************
|
||||
|
||||
@ -184,21 +183,3 @@ or
|
||||
for parallel builds.
|
||||
|
||||
Tests on machines using LSF will typically use "bsub ctestS.lsf", etc.
|
||||
|
||||
========================================================================
|
||||
VI. Other cross compiling options
|
||||
========================================================================
|
||||
Settings for two other cross-compiling options are also in the config/toolchain
|
||||
files which do not seem to be necessary with the Cray PrgEnv-* modules
|
||||
|
||||
1. HDF5_USE_PREGEN. This option, along with the HDF5_USE_PREGEN_DIR CMake
|
||||
variable would allow the use of an appropriate H5Tinit.c file with type
|
||||
information generated on a compute node to be used when cross compiling
|
||||
for those compute nodes. The use of the variables in lines 110 and 111
|
||||
of HDF5options.cmake file seem to preclude needing this option with the
|
||||
available Cray modules and CMake option.
|
||||
|
||||
2. HDF5_BATCH_H5DETECT and associated CMake variables. This option when
|
||||
properly configured will run H5detect in a batch job on a compute node
|
||||
at the beginning of the CMake build process. It was also found to be
|
||||
unnecessary with the available Cray modules and CMake options.
|
||||
|
@ -47,6 +47,24 @@ New Features
|
||||
|
||||
Configuration:
|
||||
-------------
|
||||
- Removed CMake cross-compiling variables
|
||||
|
||||
* HDF5_USE_PREGEN
|
||||
* HDF5_BATCH_H5DETECT
|
||||
|
||||
These were used to work around H5detect and H5make_libsettings and
|
||||
are no longer required.
|
||||
|
||||
- Running H5make_libsettings is no longer required for cross-compiling
|
||||
|
||||
The functionality of H5make_libsettings is now handled via template files,
|
||||
so H5make_libsettings has been removed.
|
||||
|
||||
- Running H5detect is no longer required for cross-compiling
|
||||
|
||||
The functionality of H5detect is now exercised at library startup,
|
||||
so H5detect has been removed.
|
||||
|
||||
- Thread-safety + static library disabled on Windows w/ CMake
|
||||
|
||||
The thread-safety feature requires hooks in DllMain(), which is only
|
||||
|
@ -6,6 +6,7 @@ project (HDF5_SRC C)
|
||||
#-----------------------------------------------------------------------------
|
||||
set (H5_SOURCES
|
||||
${HDF5_SRC_DIR}/H5.c
|
||||
${HDF5_SRC_BINARY_DIR}/H5build_settings.c
|
||||
${HDF5_SRC_DIR}/H5checksum.c
|
||||
${HDF5_SRC_DIR}/H5dbg.c
|
||||
${HDF5_SRC_DIR}/H5mpi.c
|
||||
@ -616,6 +617,7 @@ set (H5T_SOURCES
|
||||
${HDF5_SRC_DIR}/H5Tfields.c
|
||||
${HDF5_SRC_DIR}/H5Tfixed.c
|
||||
${HDF5_SRC_DIR}/H5Tfloat.c
|
||||
${HDF5_SRC_DIR}/H5Tinit_float.c
|
||||
${HDF5_SRC_DIR}/H5Tnative.c
|
||||
${HDF5_SRC_DIR}/H5Toffset.c
|
||||
${HDF5_SRC_DIR}/H5Toh.c
|
||||
@ -1013,14 +1015,9 @@ if (HDF5_GENERATE_HEADERS)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Setup the H5detect utility which generates H5Tinit with platform
|
||||
# specific type checks inside
|
||||
# Generate the H5build_settings.c file
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_USE_PREGEN)
|
||||
set (HDF5_GENERATED_SOURCE_DIR ${HDF5_USE_PREGEN_DIR})
|
||||
else ()
|
||||
set (HDF5_GENERATED_SOURCE_DIR ${HDF5_SRC_BINARY_DIR})
|
||||
endif ()
|
||||
configure_file (${HDF5_SOURCE_DIR}/src/H5build_settings.cmake.c.in ${HDF5_SRC_BINARY_DIR}/H5build_settings.c @ONLY)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
file (MAKE_DIRECTORY "${HDF5_SRC_BINARY_DIR}/shared")
|
||||
@ -1055,159 +1052,11 @@ if (LOCAL_BATCH_TEST)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#### make the H5detect program
|
||||
set (lib_prog_deps)
|
||||
add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
|
||||
target_include_directories (H5detect PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
||||
target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
|
||||
TARGET_C_PROPERTIES (H5detect STATIC)
|
||||
target_link_libraries (H5detect
|
||||
PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib>
|
||||
)
|
||||
target_compile_options(H5detect
|
||||
PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>"
|
||||
)
|
||||
set (lib_prog_deps ${lib_prog_deps} H5detect)
|
||||
|
||||
# check if a pregenerated H5Tinit.c file is present
|
||||
if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c")
|
||||
# execute the H5detect program
|
||||
if (HDF5_BATCH_H5DETECT)
|
||||
configure_file (
|
||||
${HDF5_SOURCE_DIR}/bin/batch/${HDF5_BATCH_H5DETECT_SCRIPT}.in.cmake
|
||||
${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} ESCAPE_QUOTES @ONLY
|
||||
)
|
||||
add_custom_command (
|
||||
OUTPUT gen_SRCS.stamp1
|
||||
BYPRODUCTS H5Tinit.c
|
||||
COMMAND ${HDF5_BATCH_CMD}
|
||||
ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E echo "Executed batch command to create H5Tinit.c"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E touch gen_SRCS.stamp1
|
||||
DEPENDS H5detect
|
||||
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
|
||||
)
|
||||
add_custom_target (gen_H5Tinit
|
||||
COMMAND ${CMAKE_COMMAND} -P ${HDF5_SOURCE_DIR}/config/cmake/wait_H5Tinit.cmake
|
||||
)
|
||||
else ()
|
||||
add_custom_command (
|
||||
OUTPUT gen_SRCS.stamp1
|
||||
BYPRODUCTS H5Tinit.c
|
||||
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5detect>
|
||||
ARGS H5Tinit.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E touch gen_SRCS.stamp1
|
||||
DEPENDS H5detect
|
||||
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
|
||||
COMMENT "Create H5Tinit.c"
|
||||
)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_custom_command (
|
||||
OUTPUT shared/shared_gen_SRCS.stamp1
|
||||
BYPRODUCTS shared/H5Tinit.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E touch shared/shared_gen_SRCS.stamp1
|
||||
DEPENDS H5detect gen_SRCS.stamp1
|
||||
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
|
||||
COMMENT "Copy H5Tinit.c to shared folder"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
add_custom_command (
|
||||
OUTPUT gen_SRCS.stamp1
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E touch gen_SRCS.stamp1
|
||||
DEPENDS H5Tinit.c
|
||||
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
|
||||
COMMENT "Touch existing H5Tinit.c"
|
||||
)
|
||||
set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_custom_command (
|
||||
OUTPUT shared/shared_gen_SRCS.stamp1
|
||||
BYPRODUCTS shared/H5Tinit.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different H5Tinit.c shared/H5Tinit.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E touch shared/shared_gen_SRCS.stamp1
|
||||
DEPENDS H5Tinit.c gen_SRCS.stamp1
|
||||
WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
|
||||
COMMENT "Copy existing H5Tinit.c to shared folder"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target to clang-format
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_FORMATTERS)
|
||||
clang_format (HDF5_SRC_DETECT_FORMAT ${HDF5_SRC_DIR}/H5detect.c)
|
||||
endif ()
|
||||
|
||||
# make the H5make_libsettings program
|
||||
add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c)
|
||||
target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
||||
target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
|
||||
TARGET_C_PROPERTIES (H5make_libsettings STATIC)
|
||||
target_link_libraries (H5make_libsettings
|
||||
PRIVATE "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>" $<$<OR:$<PLATFORM_ID:Windows>,$<PLATFORM_ID:MinGW>>:ws2_32.lib>
|
||||
)
|
||||
target_compile_options(H5make_libsettings
|
||||
PRIVATE "$<$<PLATFORM_ID:Emscripten>:-O0>"
|
||||
)
|
||||
set (lib_prog_deps ${lib_prog_deps} H5make_libsettings)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target to clang-format
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_FORMATTERS)
|
||||
clang_format (HDF5_SRC_LIBSETTINGS_FORMAT H5make_libsettings)
|
||||
endif ()
|
||||
|
||||
# execute the H5make_libsettings program
|
||||
add_custom_command (
|
||||
OUTPUT gen_SRCS.stamp2
|
||||
BYPRODUCTS H5lib_settings.c
|
||||
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5make_libsettings>
|
||||
ARGS H5lib_settings.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E touch gen_SRCS.stamp2
|
||||
DEPENDS H5make_libsettings
|
||||
WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR}
|
||||
COMMENT "Create H5lib_settings.c"
|
||||
)
|
||||
set_source_files_properties (${HDF5_SRC_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_custom_command (
|
||||
OUTPUT shared/shared_gen_SRCS.stamp2
|
||||
BYPRODUCTS shared/H5lib_settings.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy_if_different H5lib_settings.c shared/H5lib_settings.c
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E touch shared/shared_gen_SRCS.stamp2
|
||||
DEPENDS H5make_libsettings gen_SRCS.stamp2
|
||||
WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR}
|
||||
COMMENT "Copy H5lib_settings.c to shared folder"
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add H5Tinit source to build - generated by H5detect/CMake at configure time
|
||||
# Set up library builds
|
||||
#-----------------------------------------------------------------------------
|
||||
if (BUILD_STATIC_LIBS)
|
||||
set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c)
|
||||
add_custom_target (gen_${HDF5_LIB_TARGET} ALL
|
||||
DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2
|
||||
COMMENT "Generation target files"
|
||||
)
|
||||
|
||||
add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
|
||||
add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} H5build_settings.c ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
|
||||
target_include_directories (${HDF5_LIB_TARGET}
|
||||
PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
|
||||
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>;$<BUILD_INTERFACE:${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR}>"
|
||||
@ -1235,19 +1084,12 @@ if (BUILD_STATIC_LIBS)
|
||||
set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET})
|
||||
H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC 0)
|
||||
set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries)
|
||||
add_dependencies (${HDF5_LIB_TARGET} gen_${HDF5_LIB_TARGET})
|
||||
|
||||
set (install_targets ${HDF5_LIB_TARGET})
|
||||
endif ()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c)
|
||||
add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL
|
||||
DEPENDS ${lib_prog_deps} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2
|
||||
COMMENT "Shared generation target files"
|
||||
)
|
||||
|
||||
add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
|
||||
add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} H5build_settings.c ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS} ${H5_MODULE_HEADERS})
|
||||
target_include_directories (${HDF5_LIBSH_TARGET}
|
||||
PRIVATE "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
|
||||
PUBLIC "$<$<BOOL:${HDF5_ENABLE_HDFS}>:${HDFS_INCLUDE_DIR}>"
|
||||
@ -1274,7 +1116,6 @@ if (BUILD_SHARED_LIBS)
|
||||
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}")
|
||||
H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED "LIB")
|
||||
set_target_properties (${HDF5_LIBSH_TARGET} PROPERTIES FOLDER libraries)
|
||||
add_dependencies (${HDF5_LIBSH_TARGET} gen_${HDF5_LIBSH_TARGET})
|
||||
|
||||
set (install_targets ${install_targets} ${HDF5_LIBSH_TARGET})
|
||||
endif ()
|
||||
@ -1416,7 +1257,7 @@ if (DOXYGEN_FOUND)
|
||||
# Replace variables inside @@ with the current values
|
||||
add_custom_target (hdf5lib_doc ALL
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${HDF5_BINARY_DIR}/Doxyfile
|
||||
DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c
|
||||
DEPENDS ${HDF5_SRC_BINARY_DIR}/H5build_settings.c
|
||||
WORKING_DIRECTORY ${HDF5_SRC_DIR}
|
||||
COMMENT "Generating HDF5 library Source API documentation with Doxygen"
|
||||
VERBATIM )
|
||||
|
9
src/H5.c
9
src/H5.c
@ -904,8 +904,8 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
|
||||
/* Mention the versions we are referring to */
|
||||
fprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum,
|
||||
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
|
||||
/* Show library settings if available */
|
||||
fprintf(stderr, "%s", H5libhdf5_settings);
|
||||
/* Show library build settings if available */
|
||||
fprintf(stderr, "%s", H5build_settings);
|
||||
|
||||
/* Bail out now. */
|
||||
HDfputs("Bye...\n", stderr);
|
||||
@ -921,8 +921,9 @@ H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
|
||||
/* Mention the versions we are referring to */
|
||||
fprintf(stderr, "Headers are %u.%u.%u, library is %u.%u.%u\n", majnum, minnum, relnum,
|
||||
(unsigned)H5_VERS_MAJOR, (unsigned)H5_VERS_MINOR, (unsigned)H5_VERS_RELEASE);
|
||||
/* Show library settings if available */
|
||||
fprintf(stderr, "%s", H5libhdf5_settings);
|
||||
/* Show library build settings if available */
|
||||
fprintf(stderr, "%s", H5build_settings);
|
||||
|
||||
break;
|
||||
default:
|
||||
/* 2 or higher: continue silently */
|
||||
|
18
src/H5T.c
18
src/H5T.c
@ -368,8 +368,7 @@ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR;
|
||||
/*********************/
|
||||
|
||||
/*
|
||||
* Predefined data types. These are initialized at runtime in H5Tinit.c and
|
||||
* by H5T_init() in this source file.
|
||||
* Predefined data types. These are initialized at runtime by H5T_init().
|
||||
*
|
||||
* If more of these are added, the new ones must be added to the list of
|
||||
* types to reset in H5T_term_package().
|
||||
@ -501,11 +500,7 @@ size_t H5T_NATIVE_FLOAT_ALIGN_g = 0;
|
||||
size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0;
|
||||
size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0;
|
||||
|
||||
/*
|
||||
* Alignment constraints for C9x types. These are initialized at run time in
|
||||
* H5Tinit.c if the types are provided by the system. Otherwise we set their
|
||||
* values to 0 here (no alignment calculated).
|
||||
*/
|
||||
/* Alignment constraints for C99 types */
|
||||
size_t H5T_NATIVE_INT8_ALIGN_g = 0;
|
||||
size_t H5T_NATIVE_UINT8_ALIGN_g = 0;
|
||||
size_t H5T_NATIVE_INT_LEAST8_ALIGN_g = 0;
|
||||
@ -752,12 +747,9 @@ H5T_init(void)
|
||||
/* Only 16 (numbered 0-15) are supported in the current file format */
|
||||
HDcompile_assert(H5T_NCLASSES < 16);
|
||||
|
||||
/*
|
||||
* Initialize pre-defined native datatypes from code generated during
|
||||
* the library configuration by H5detect.
|
||||
*/
|
||||
if (H5T__init_native() < 0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize interface");
|
||||
/* Initialize native floating-point datatypes */
|
||||
if (H5T__init_native_float_types() < 0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize floating-point types");
|
||||
|
||||
/* Initialize all other native types */
|
||||
if (H5T__init_native_internal() < 0)
|
||||
|
1452
src/H5Tconv.c
1452
src/H5Tconv.c
File diff suppressed because it is too large
Load Diff
572
src/H5Tinit_float.c
Normal file
572
src/H5Tinit_float.c
Normal file
@ -0,0 +1,572 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the COPYING file, which can be found at the root of the source code *
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
||||
* If you do not have access to either file, you may request a copy from *
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*
|
||||
* Purpose: Initialize native floating-point datatypes
|
||||
*/
|
||||
|
||||
/****************/
|
||||
/* Module Setup */
|
||||
/****************/
|
||||
|
||||
#include "H5Tmodule.h" /* This source code file is part of the H5T module */
|
||||
|
||||
/***********/
|
||||
/* Headers */
|
||||
/***********/
|
||||
#include "H5private.h" /* Generic Functions */
|
||||
#include "H5Eprivate.h" /* Error handling */
|
||||
#include "H5FLprivate.h" /* Free Lists */
|
||||
#include "H5Iprivate.h" /* IDs */
|
||||
#include "H5Tpkg.h" /* Datatypes */
|
||||
|
||||
/****************/
|
||||
/* Local Macros */
|
||||
/****************/
|
||||
|
||||
/* This could also go in H5private.h, but this is the only place we
|
||||
* need to turn off the sanitizers and we don't want to encourage
|
||||
* this.
|
||||
*/
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(no_sanitize)
|
||||
#define H5_NO_UBSAN __attribute__((no_sanitize("undefined")))
|
||||
#else
|
||||
#define H5_NO_UBSAN
|
||||
#endif
|
||||
#else
|
||||
#define H5_NO_UBSAN
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: DETECT_F
|
||||
*
|
||||
* Purpose: This macro takes a floating point type like `double' and
|
||||
* a base name like `natd' and detects byte order, mantissa
|
||||
* location, exponent location, sign bit location, presence or
|
||||
* absence of implicit mantissa bit, and exponent bias and
|
||||
* initializes a detected_t structure with those properties.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#define DETECT_F(TYPE, VAR, INFO) \
|
||||
{ \
|
||||
TYPE _v1, _v2, _v3; \
|
||||
unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \
|
||||
unsigned char _pad_mask[sizeof(TYPE)]; \
|
||||
unsigned char _byte_mask; \
|
||||
int _i, _j, _last = (-1); \
|
||||
\
|
||||
memset(&INFO, 0, sizeof(INFO)); \
|
||||
INFO.size = sizeof(TYPE); \
|
||||
\
|
||||
/* Initialize padding mask */ \
|
||||
memset(_pad_mask, 0, sizeof(_pad_mask)); \
|
||||
\
|
||||
/* Padding bits. Set a variable to 4.0, then flip each bit and see if \
|
||||
* the modified variable is equal ("==") to the original. Build a \
|
||||
* padding bitmask to indicate which bits in the type are padding (i.e. \
|
||||
* have no effect on the value and should be ignored by subsequent \
|
||||
* steps). This is necessary because padding bits can change arbitrarily \
|
||||
* and interfere with detection of the various properties below unless we \
|
||||
* know to ignore them. */ \
|
||||
_v1 = (TYPE)4.0L; \
|
||||
memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
|
||||
for (_i = 0; _i < (int)sizeof(TYPE); _i++) \
|
||||
for (_byte_mask = (unsigned char)1; _byte_mask; _byte_mask = (unsigned char)(_byte_mask << 1)) { \
|
||||
_buf1[_i] ^= _byte_mask; \
|
||||
memcpy((void *)&_v2, (const void *)_buf1, sizeof(TYPE)); \
|
||||
H5_GCC_CLANG_DIAG_OFF("float-equal") \
|
||||
if (_v1 != _v2) \
|
||||
_pad_mask[_i] |= _byte_mask; \
|
||||
H5_GCC_CLANG_DIAG_ON("float-equal") \
|
||||
_buf1[_i] ^= _byte_mask; \
|
||||
} \
|
||||
\
|
||||
/* Byte Order */ \
|
||||
for (_i = 0, _v1 = (TYPE)0.0L, _v2 = (TYPE)1.0L; _i < (int)sizeof(TYPE); _i++) { \
|
||||
_v3 = _v1; \
|
||||
_v1 += _v2; \
|
||||
_v2 /= (TYPE)256.0L; \
|
||||
memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
|
||||
memcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \
|
||||
_j = H5T__byte_cmp(sizeof(TYPE), _buf3, _buf1, _pad_mask); \
|
||||
if (_j >= 0) { \
|
||||
INFO.perm[_i] = _j; \
|
||||
_last = _i; \
|
||||
} \
|
||||
} \
|
||||
if (H5T__fix_order(sizeof(TYPE), _last, INFO.perm, &INFO.order) < 0) \
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to detect byte order"); \
|
||||
\
|
||||
/* Implicit mantissa bit */ \
|
||||
_v1 = (TYPE)0.5L; \
|
||||
_v2 = (TYPE)1.0L; \
|
||||
if (H5T__imp_bit(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask, &(INFO.imp)) < 0) \
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to determine implicit bit"); \
|
||||
INFO.norm = INFO.imp ? H5T_NORM_IMPLIED : H5T_NORM_NONE; \
|
||||
\
|
||||
/* Sign bit */ \
|
||||
_v1 = (TYPE)1.0L; \
|
||||
_v2 = (TYPE)-1.0L; \
|
||||
if (H5T__bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask, &(INFO.sign)) < 0) \
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to detect byte order"); \
|
||||
\
|
||||
/* Mantissa */ \
|
||||
INFO.mpos = 0; \
|
||||
\
|
||||
_v1 = (TYPE)1.0L; \
|
||||
_v2 = (TYPE)1.5L; \
|
||||
if (H5T__bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask, &(INFO.msize)) < 0) \
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to detect byte order"); \
|
||||
INFO.msize += 1 + (unsigned)(INFO.imp ? 0 : 1) - INFO.mpos; \
|
||||
\
|
||||
/* Exponent */ \
|
||||
INFO.epos = INFO.mpos + INFO.msize; \
|
||||
\
|
||||
INFO.esize = INFO.sign - INFO.epos; \
|
||||
\
|
||||
_v1 = (TYPE)1.0L; \
|
||||
INFO.ebias = H5T__find_bias(INFO.epos, INFO.esize, INFO.perm, &_v1); \
|
||||
H5T__set_precision(&(INFO)); \
|
||||
COMP_ALIGNMENT(TYPE, INFO.comp_align); \
|
||||
}
|
||||
|
||||
/* Detect alignment for C structure */
|
||||
#define COMP_ALIGNMENT(TYPE, COMP_ALIGN) \
|
||||
{ \
|
||||
struct { \
|
||||
char c; \
|
||||
TYPE x; \
|
||||
} s; \
|
||||
\
|
||||
COMP_ALIGN = (unsigned)((char *)(&(s.x)) - (char *)(&s)); \
|
||||
}
|
||||
|
||||
/******************/
|
||||
/* Local Typedefs */
|
||||
/******************/
|
||||
|
||||
/* Holds detected information about a native floating-point type */
|
||||
typedef struct H5T_fpoint_det_t {
|
||||
unsigned size; /* Total byte size */
|
||||
unsigned prec; /* Meaningful bits */
|
||||
unsigned offset; /* Bit offset to meaningful bits */
|
||||
int perm[32]; /* For detection of byte order */
|
||||
H5T_order_t order; /* byte order */
|
||||
unsigned sign; /* Location of sign bit */
|
||||
unsigned mpos, msize, imp; /* Information about mantissa */
|
||||
H5T_norm_t norm; /* Information about mantissa */
|
||||
unsigned epos, esize; /* Information about exponent */
|
||||
unsigned long ebias; /* Exponent bias for floating point */
|
||||
unsigned comp_align; /* Alignment for structure */
|
||||
} H5T_fpoint_det_t;
|
||||
|
||||
/********************/
|
||||
/* Package Typedefs */
|
||||
/********************/
|
||||
|
||||
/********************/
|
||||
/* Local Prototypes */
|
||||
/********************/
|
||||
|
||||
/********************/
|
||||
/* Public Variables */
|
||||
/********************/
|
||||
|
||||
/*****************************/
|
||||
/* Library Private Variables */
|
||||
/*****************************/
|
||||
|
||||
/*********************/
|
||||
/* Package Variables */
|
||||
/*********************/
|
||||
|
||||
/*******************/
|
||||
/* Local Variables */
|
||||
/*******************/
|
||||
|
||||
/* Functions used in the DETECT_F() macro */
|
||||
static int H5T__byte_cmp(int, const void *, const void *, const unsigned char *);
|
||||
static herr_t H5T__bit_cmp(unsigned, int *, void *, void *, const unsigned char *, unsigned *);
|
||||
static herr_t H5T__fix_order(int, int, int *, H5T_order_t *);
|
||||
static herr_t H5T__imp_bit(unsigned, int *, void *, void *, const unsigned char *, unsigned *);
|
||||
static unsigned H5T__find_bias(unsigned, unsigned, int *, void *);
|
||||
static void H5T__set_precision(H5T_fpoint_det_t *);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T__byte_cmp
|
||||
*
|
||||
* Purpose: Compares two chunks of memory A and B and returns the
|
||||
* byte index into those arrays of the first byte that
|
||||
* differs between A and B. Ignores differences where the
|
||||
* corresponding bit in pad_mask is set to 0.
|
||||
*
|
||||
* Return: Success: Index of differing byte.
|
||||
* Failure: -1 if all bytes are the same.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
H5T__byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask)
|
||||
{
|
||||
const unsigned char *a = (const unsigned char *)_a;
|
||||
const unsigned char *b = (const unsigned char *)_b;
|
||||
int ret_value = -1;
|
||||
|
||||
FUNC_ENTER_PACKAGE_NOERR
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
if ((a[i] & pad_mask[i]) != (b[i] & pad_mask[i]))
|
||||
HGOTO_DONE(i);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T__bit_cmp
|
||||
*
|
||||
* Purpose: Compares two bit vectors and returns the index for the
|
||||
* first bit that differs between the two vectors. The
|
||||
* size of the vector is NBYTES. PERM is a mapping from
|
||||
* actual order to little endian. Ignores differences where
|
||||
* the corresponding bit in pad_mask is set to 0.
|
||||
*
|
||||
* Sets `first` to the index of the first differing bit
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5T__bit_cmp(unsigned nbytes, int *perm, void *_a, void *_b, const unsigned char *pad_mask, unsigned *first)
|
||||
{
|
||||
unsigned char *a = (unsigned char *)_a;
|
||||
unsigned char *b = (unsigned char *)_b;
|
||||
unsigned char aa, bb;
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_PACKAGE
|
||||
|
||||
*first = 0;
|
||||
|
||||
for (unsigned i = 0; i < nbytes; i++) {
|
||||
if (perm[i] >= (int)nbytes)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failure in bit comparison");
|
||||
if ((aa = (unsigned char)(a[perm[i]] & pad_mask[perm[i]])) !=
|
||||
(bb = (unsigned char)(b[perm[i]] & pad_mask[perm[i]]))) {
|
||||
|
||||
for (unsigned j = 0; j < 8; j++, aa >>= 1, bb >>= 1) {
|
||||
if ((aa & 1) != (bb & 1)) {
|
||||
*first = i * 8 + j;
|
||||
HGOTO_DONE(SUCCEED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we got here and didn't set a value, error out */
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "didn't find a value for `first`");
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T__fix_order
|
||||
*
|
||||
* Purpose: Given an array PERM with elements FIRST through LAST
|
||||
* initialized with zero origin byte numbers, this function
|
||||
* creates a permutation vector that maps the actual order
|
||||
* of a floating point number to little-endian.
|
||||
*
|
||||
* This function assumes that the mantissa byte ordering
|
||||
* implies the total ordering.
|
||||
*
|
||||
* Return: SUCCEED/FAIL
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5T__fix_order(int n, int last, int *perm, H5T_order_t *order)
|
||||
{
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_PACKAGE
|
||||
|
||||
if (last <= 0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to detect byte order");
|
||||
|
||||
/* We have at least three points to consider */
|
||||
if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) {
|
||||
/* Little endian */
|
||||
*order = H5T_ORDER_LE;
|
||||
for (int i = 0; i < n; i++)
|
||||
perm[i] = i;
|
||||
}
|
||||
else if (perm[last] > perm[last - 1] && perm[last - 1] > perm[last - 2]) {
|
||||
/* Big endian */
|
||||
*order = H5T_ORDER_BE;
|
||||
for (int i = 0; i < n; i++)
|
||||
perm[i] = (n - 1) - i;
|
||||
}
|
||||
else {
|
||||
/* Undetermined endianness - defaults to 'VAX' for historical
|
||||
* reasons, but there are other mixed-endian systems (like ARM
|
||||
* in rare cases)
|
||||
*/
|
||||
if (0 != n % 2)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "n is not a power of 2");
|
||||
|
||||
*order = H5T_ORDER_VAX;
|
||||
for (int i = 0; i < n; i += 2) {
|
||||
perm[i] = (n - 2) - i;
|
||||
perm[i + 1] = (n - 1) - i;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T__imp_bit
|
||||
*
|
||||
* Purpose: Looks for an implicit bit in the mantissa. The value
|
||||
* of _A should be 1.0 and the value of _B should be 0.5.
|
||||
* Some floating-point formats discard the most significant
|
||||
* bit of the mantissa after normalizing since it will always
|
||||
* be a one (except for 0.0). If this is true for the native
|
||||
* floating point values stored in _A and _B then the function
|
||||
* returns non-zero.
|
||||
*
|
||||
* This function assumes that the exponent occupies higher
|
||||
* order bits than the mantissa and that the most significant
|
||||
* bit of the mantissa is next to the least significant bit
|
||||
* of the exponent.
|
||||
*
|
||||
*
|
||||
* Return: imp_bit will be set to 1 if the most significant bit
|
||||
* of the mantissa is discarded (ie, the mantissa has an
|
||||
* implicit `one' as the most significant bit). Otherwise,
|
||||
* imp_bit will be set to zero zero.
|
||||
*
|
||||
* SUCCEED/FAIL
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5T__imp_bit(unsigned n, int *perm, void *_a, void *_b, const unsigned char *pad_mask, unsigned *imp_bit)
|
||||
{
|
||||
unsigned char *a = (unsigned char *)_a;
|
||||
unsigned char *b = (unsigned char *)_b;
|
||||
unsigned changed;
|
||||
unsigned major;
|
||||
unsigned minor;
|
||||
unsigned msmb; /* Most significant mantissa bit */
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_PACKAGE
|
||||
|
||||
/* Look for the least significant bit that has changed between
|
||||
* A and B. This is the least significant bit of the exponent.
|
||||
*/
|
||||
if (H5T__bit_cmp(n, perm, a, b, pad_mask, &changed) < 0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "couldn't find LSB");
|
||||
|
||||
/* The bit to the right (less significant) of the changed bit should
|
||||
* be the most significant bit of the mantissa. If it is non-zero
|
||||
* then the format does not remove the leading `1' of the mantissa.
|
||||
*/
|
||||
msmb = changed - 1;
|
||||
major = msmb / 8;
|
||||
minor = msmb % 8;
|
||||
|
||||
*imp_bit = (a[perm[major]] >> minor) & 0x01 ? 0 : 1;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: find_bias
|
||||
*
|
||||
* Purpose: Determines the bias of the exponent. This function should
|
||||
* be called with _A having a value of `1'.
|
||||
*
|
||||
* Return: The exponent bias
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5_ATTR_PURE static unsigned
|
||||
H5T__find_bias(unsigned epos, unsigned esize, int *perm, void *_a)
|
||||
{
|
||||
unsigned char *a = (unsigned char *)_a;
|
||||
unsigned char mask;
|
||||
unsigned b, shift = 0, nbits, bias = 0;
|
||||
|
||||
FUNC_ENTER_PACKAGE_NOERR
|
||||
|
||||
while (esize > 0) {
|
||||
nbits = MIN(esize, (8 - epos % 8));
|
||||
mask = (unsigned char)((1 << nbits) - 1);
|
||||
b = (unsigned)(a[perm[epos / 8]] >> (epos % 8)) & mask;
|
||||
bias |= b << shift;
|
||||
|
||||
shift += nbits;
|
||||
esize -= nbits;
|
||||
epos += nbits;
|
||||
}
|
||||
|
||||
FUNC_LEAVE_NOAPI(bias)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T__set_precision
|
||||
*
|
||||
* Purpose: Determine the precision and offset
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
H5T__set_precision(H5T_fpoint_det_t *d)
|
||||
{
|
||||
FUNC_ENTER_PACKAGE_NOERR
|
||||
|
||||
d->offset = MIN3(d->mpos, d->epos, d->sign);
|
||||
d->prec = d->msize + d->esize + 1;
|
||||
|
||||
FUNC_LEAVE_NOAPI_VOID
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T__init_native_float_types
|
||||
*
|
||||
* Purpose: Initialize native floating-point datatypes
|
||||
*
|
||||
* Return: Success: non-negative
|
||||
* Failure: negative
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
herr_t H5_NO_UBSAN
|
||||
H5T__init_native_float_types(void)
|
||||
{
|
||||
H5T_fpoint_det_t det;
|
||||
H5T_t *dt = NULL;
|
||||
herr_t ret_value = SUCCEED;
|
||||
|
||||
FUNC_ENTER_PACKAGE
|
||||
|
||||
/* H5T_NATIVE_FLOAT */
|
||||
|
||||
/* Get the type's characteristics */
|
||||
memset(&det, 0, sizeof(H5T_fpoint_det_t));
|
||||
DETECT_F(float, FLOAT, det);
|
||||
|
||||
/* Allocate and fill type structure */
|
||||
if (NULL == (dt = H5T__alloc()))
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "datatype allocation failed");
|
||||
dt->shared->state = H5T_STATE_IMMUTABLE;
|
||||
dt->shared->type = H5T_FLOAT;
|
||||
dt->shared->size = det.size;
|
||||
dt->shared->u.atomic.order = det.order;
|
||||
dt->shared->u.atomic.offset = det.offset;
|
||||
dt->shared->u.atomic.prec = det.prec;
|
||||
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;
|
||||
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;
|
||||
dt->shared->u.atomic.u.f.sign = det.sign;
|
||||
dt->shared->u.atomic.u.f.epos = det.epos;
|
||||
dt->shared->u.atomic.u.f.esize = det.esize;
|
||||
dt->shared->u.atomic.u.f.ebias = det.ebias;
|
||||
dt->shared->u.atomic.u.f.mpos = det.mpos;
|
||||
dt->shared->u.atomic.u.f.msize = det.msize;
|
||||
dt->shared->u.atomic.u.f.norm = det.norm;
|
||||
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;
|
||||
|
||||
/* Register the type and set global variables */
|
||||
if ((H5T_NATIVE_FLOAT_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register ID for built-in datatype");
|
||||
H5T_NATIVE_FLOAT_ALIGN_g = det.comp_align;
|
||||
|
||||
/* H5T_NATIVE_DOUBLE */
|
||||
|
||||
/* Get the type's characteristics */
|
||||
memset(&det, 0, sizeof(H5T_fpoint_det_t));
|
||||
DETECT_F(double, DOUBLE, det);
|
||||
|
||||
/* Allocate and fill type structure */
|
||||
if (NULL == (dt = H5T__alloc()))
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "datatype allocation failed");
|
||||
dt->shared->state = H5T_STATE_IMMUTABLE;
|
||||
dt->shared->type = H5T_FLOAT;
|
||||
dt->shared->size = det.size;
|
||||
dt->shared->u.atomic.order = det.order;
|
||||
dt->shared->u.atomic.offset = det.offset;
|
||||
dt->shared->u.atomic.prec = det.prec;
|
||||
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;
|
||||
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;
|
||||
dt->shared->u.atomic.u.f.sign = det.sign;
|
||||
dt->shared->u.atomic.u.f.epos = det.epos;
|
||||
dt->shared->u.atomic.u.f.esize = det.esize;
|
||||
dt->shared->u.atomic.u.f.ebias = det.ebias;
|
||||
dt->shared->u.atomic.u.f.mpos = det.mpos;
|
||||
dt->shared->u.atomic.u.f.msize = det.msize;
|
||||
dt->shared->u.atomic.u.f.norm = det.norm;
|
||||
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;
|
||||
|
||||
/* Register the type and set global variables */
|
||||
if ((H5T_NATIVE_DOUBLE_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register ID for built-in datatype");
|
||||
H5T_NATIVE_DOUBLE_ALIGN_g = det.comp_align;
|
||||
|
||||
/* H5T_NATIVE_LDOUBLE */
|
||||
|
||||
/* Get the type's characteristics */
|
||||
memset(&det, 0, sizeof(H5T_fpoint_det_t));
|
||||
DETECT_F(long double, LDOUBLE, det);
|
||||
|
||||
/* Allocate and fill type structure */
|
||||
if (NULL == (dt = H5T__alloc()))
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "datatype allocation failed");
|
||||
dt->shared->state = H5T_STATE_IMMUTABLE;
|
||||
dt->shared->type = H5T_FLOAT;
|
||||
dt->shared->size = det.size;
|
||||
dt->shared->u.atomic.order = det.order;
|
||||
dt->shared->u.atomic.offset = det.offset;
|
||||
dt->shared->u.atomic.prec = det.prec;
|
||||
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;
|
||||
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;
|
||||
dt->shared->u.atomic.u.f.sign = det.sign;
|
||||
dt->shared->u.atomic.u.f.epos = det.epos;
|
||||
dt->shared->u.atomic.u.f.esize = det.esize;
|
||||
dt->shared->u.atomic.u.f.ebias = det.ebias;
|
||||
dt->shared->u.atomic.u.f.mpos = det.mpos;
|
||||
dt->shared->u.atomic.u.f.msize = det.msize;
|
||||
dt->shared->u.atomic.u.f.norm = det.norm;
|
||||
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;
|
||||
|
||||
/* Register the type and set global variables */
|
||||
if ((H5T_NATIVE_LDOUBLE_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register ID for built-in datatype");
|
||||
H5T_NATIVE_LDOUBLE_ALIGN_g = det.comp_align;
|
||||
|
||||
/* Set the platform's alignment (assumes long double's order
|
||||
* is true for all types)
|
||||
*/
|
||||
H5T_native_order_g = det.order;
|
||||
|
||||
done:
|
||||
if (ret_value < 0) {
|
||||
if (dt != NULL) {
|
||||
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
|
||||
dt = H5FL_FREE(H5T_t, dt);
|
||||
}
|
||||
}
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5T__init_native_float_types() */
|
@ -464,7 +464,7 @@ H5FL_EXTERN(H5T_t);
|
||||
H5FL_EXTERN(H5T_shared_t);
|
||||
|
||||
/* Common functions */
|
||||
H5_DLL herr_t H5T__init_native(void);
|
||||
H5_DLL herr_t H5T__init_native_float_types(void);
|
||||
H5_DLL herr_t H5T__init_native_internal(void);
|
||||
H5_DLL H5T_t *H5T__create(H5T_class_t type, size_t size);
|
||||
H5_DLL H5T_t *H5T__alloc(void);
|
||||
|
119
src/H5build_settings.autotools.c.in
Normal file
119
src/H5build_settings.autotools.c.in
Normal file
@ -0,0 +1,119 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the COPYING file, which can be found at the root of the source code *
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
||||
* If you do not have access to either file, you may request a copy from *
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "H5private.h"
|
||||
|
||||
H5_GCC_DIAG_OFF("larger-than=")
|
||||
H5_CLANG_DIAG_OFF("overlength-strings")
|
||||
|
||||
/* clang-format off */
|
||||
const char H5build_settings[]=
|
||||
" SUMMARY OF THE HDF5 CONFIGURATION\n"
|
||||
" =================================\n"
|
||||
"\n"
|
||||
"General Information:\n"
|
||||
"-------------------\n"
|
||||
" HDF5 Version: @H5_VERSION@\n"
|
||||
" Configured on: @CONFIG_DATE@\n"
|
||||
" Configured by: @CONFIG_USER@\n"
|
||||
" Host system: @host_cpu@-@host_vendor@-@host_os@\n"
|
||||
" Uname information: @UNAME_INFO@\n"
|
||||
" Byte sex: @BYTESEX@\n"
|
||||
" Installation point: @prefix@\n"
|
||||
"\n"
|
||||
"Compiling Options:\n"
|
||||
"------------------\n"
|
||||
" Build Mode: @BUILD_MODE@\n"
|
||||
" Debugging Symbols: @SYMBOLS@\n"
|
||||
" Asserts: @ASSERTS@\n"
|
||||
" Profiling: @PROFILING@\n"
|
||||
" Optimization Level: @OPTIMIZATION@\n"
|
||||
"\n"
|
||||
"Linking Options:\n"
|
||||
"----------------\n"
|
||||
" Libraries: @STATIC_SHARED@\n"
|
||||
" Statically Linked Executables: @LT_STATIC_EXEC@\n"
|
||||
" LDFLAGS: @LDFLAGS@\n"
|
||||
" H5_LDFLAGS: @H5_LDFLAGS@\n"
|
||||
" AM_LDFLAGS: @AM_LDFLAGS@\n"
|
||||
" Extra libraries: @LIBS@\n"
|
||||
" Archiver: @AR@\n"
|
||||
" AR_FLAGS: @AR_FLAGS@\n"
|
||||
" Ranlib: @RANLIB@\n"
|
||||
"\n"
|
||||
"Languages:\n"
|
||||
"----------\n"
|
||||
" C: yes\n"
|
||||
" C Compiler: @CC_VERSION@\n"
|
||||
" CPPFLAGS: @CPPFLAGS@\n"
|
||||
" H5_CPPFLAGS: @H5_CPPFLAGS@\n"
|
||||
" AM_CPPFLAGS: @AM_CPPFLAGS@\n"
|
||||
" C Flags: @CFLAGS@\n"
|
||||
" H5 C Flags: @H5_CFLAGS@\n"
|
||||
" AM C Flags: @AM_CFLAGS@\n"
|
||||
" Shared C Library: @enable_shared@\n"
|
||||
" Static C Library: @enable_static@\n"
|
||||
"\n"
|
||||
"\n"
|
||||
" Fortran: @HDF_FORTRAN@\n"
|
||||
@BUILD_FORTRAN_CONDITIONAL_TRUE@ " Fortran Compiler: @FC_VERSION@\n"
|
||||
@BUILD_FORTRAN_CONDITIONAL_TRUE@ " Fortran Flags: @FCFLAGS@\n"
|
||||
@BUILD_FORTRAN_CONDITIONAL_TRUE@ " H5 Fortran Flags: @H5_FCFLAGS@\n"
|
||||
@BUILD_FORTRAN_CONDITIONAL_TRUE@ " AM Fortran Flags: @AM_FCFLAGS@\n"
|
||||
@BUILD_FORTRAN_CONDITIONAL_TRUE@ " Shared Fortran Library: @H5_FORTRAN_SHARED@\n"
|
||||
@BUILD_FORTRAN_CONDITIONAL_TRUE@ " Static Fortran Library: @enable_static@\n"
|
||||
@BUILD_FORTRAN_CONDITIONAL_TRUE@ " Module Directory: @fmoddir@\n"
|
||||
"\n"
|
||||
" C++: @HDF_CXX@\n"
|
||||
@BUILD_CXX_CONDITIONAL_TRUE@ " C++ Compiler: @CXX_VERSION@\n"
|
||||
@BUILD_CXX_CONDITIONAL_TRUE@ " C++ Flags: @CXXFLAGS@\n"
|
||||
@BUILD_CXX_CONDITIONAL_TRUE@ " H5 C++ Flags: @H5_CXXFLAGS@\n"
|
||||
@BUILD_CXX_CONDITIONAL_TRUE@ " AM C++ Flags: @AM_CXXFLAGS@\n"
|
||||
@BUILD_CXX_CONDITIONAL_TRUE@ " Shared C++ Library: @enable_shared@\n"
|
||||
@BUILD_CXX_CONDITIONAL_TRUE@ " Static C++ Library: @enable_static@\n"
|
||||
"\n"
|
||||
" Java: @HDF_JAVA@\n"
|
||||
@BUILD_JAVA_CONDITIONAL_TRUE@ " Java Compiler: @JAVA_VERSION@\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Features:\n"
|
||||
"---------\n"
|
||||
" Parallel HDF5: @PARALLEL@\n"
|
||||
" Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@\n"
|
||||
" Large Parallel I/O: @LARGE_PARALLEL_IO@\n"
|
||||
" High-level library: @HDF5_HL@\n"
|
||||
"Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@\n"
|
||||
" Build HDF5 Tests: @HDF5_TESTS@\n"
|
||||
" Build HDF5 Tools: @HDF5_TOOLS@\n"
|
||||
" Build GIF Tools: @HDF5_HL_GIF_TOOLS@\n"
|
||||
" Threadsafety: @THREADSAFE@\n"
|
||||
" Default API mapping: @DEFAULT_API_VERSION@\n"
|
||||
" With deprecated public symbols: @DEPRECATED_SYMBOLS@\n"
|
||||
" I/O filters (external): @EXTERNAL_FILTERS@\n"
|
||||
" Map (H5M) API: @MAP_API@\n"
|
||||
" Direct VFD: @DIRECT_VFD@\n"
|
||||
" Mirror VFD: @MIRROR_VFD@\n"
|
||||
" Subfiling VFD: @SUBFILING_VFD@\n"
|
||||
" (Read-Only) S3 VFD: @ROS3_VFD@\n"
|
||||
" (Read-Only) HDFS VFD: @HAVE_LIBHDFS@\n"
|
||||
" Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@\n"
|
||||
" API tracing: @TRACE_API@\n"
|
||||
" Using memory checker: @USINGMEMCHECKER@\n"
|
||||
" Function stack tracing: @CODESTACK@\n"
|
||||
" Use file locking: @DESIRED_FILE_LOCKING@\n"
|
||||
" Strict file format checks: @STRICT_FORMAT_CHECKS@\n"
|
||||
" Optimization instrumentation: @INSTRUMENT_LIBRARY@\n"
|
||||
;
|
||||
/* clang-format on */
|
||||
|
||||
H5_GCC_DIAG_ON("larger-than=")
|
||||
H5_CLANG_DIAG_OFF("overlength-strings")
|
117
src/H5build_settings.cmake.c.in
Normal file
117
src/H5build_settings.cmake.c.in
Normal file
@ -0,0 +1,117 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the COPYING file, which can be found at the root of the source code *
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
||||
* If you do not have access to either file, you may request a copy from *
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "H5private.h"
|
||||
|
||||
H5_GCC_DIAG_OFF("larger-than=")
|
||||
H5_CLANG_DIAG_OFF("overlength-strings")
|
||||
|
||||
const char H5build_settings[]=
|
||||
" SUMMARY OF THE HDF5 CONFIGURATION\n"
|
||||
" =================================\n"
|
||||
"\n"
|
||||
"General Information:\n"
|
||||
"-------------------\n"
|
||||
" HDF5 Version: @HDF5_PACKAGE_VERSION_STRING@\n"
|
||||
" Configured on: @CONFIG_DATE@\n"
|
||||
" Configured by: @CMAKE_GENERATOR@\n"
|
||||
" Host system: @CMAKE_HOST_SYSTEM@\n"
|
||||
" Uname information: @CMAKE_SYSTEM_NAME@\n"
|
||||
" Byte sex: @BYTESEX@\n"
|
||||
" Installation point: @CMAKE_INSTALL_PREFIX@\n"
|
||||
"\n"
|
||||
"Compiling Options:\n"
|
||||
"------------------\n"
|
||||
" Build Mode: @HDF_CFG_NAME@\n"
|
||||
" Debugging Symbols: @HDF5_ENABLE_SYMBOLS@\n"
|
||||
" Asserts: @HDF5_ENABLE_ASSERTS@\n"
|
||||
" Profiling: @HDF5_ENABLE_PROFILING@\n"
|
||||
" Optimization Level: @HDF5_ENABLE_OPTIMIZATION@\n"
|
||||
"\n"
|
||||
"Linking Options:\n"
|
||||
"----------------\n"
|
||||
" Libraries: @BUILD_NAME_EXT@\n"
|
||||
" Statically Linked Executables: @BUILD_STATIC_EXECS@\n"
|
||||
" LDFLAGS: @CMAKE_SHARED_LINKER_FLAGS@\n"
|
||||
" H5_LDFLAGS: @H5_LDFLAGS@\n"
|
||||
" AM_LDFLAGS: @AM_LDFLAGS@\n"
|
||||
" Extra libraries: @LINK_LIBS@\n"
|
||||
" Archiver: @CMAKE_AR@\n"
|
||||
" AR_FLAGS: \n"
|
||||
" Ranlib: @CMAKE_RANLIB@\n"
|
||||
"\n"
|
||||
"Languages:\n"
|
||||
"----------\n"
|
||||
" C: YES\n"
|
||||
" C Compiler: @CMAKE_C_COMPILER@ @CMAKE_C_COMPILER_VERSION@\n"
|
||||
" CPPFLAGS: @CPPFLAGS@\n"
|
||||
" H5_CPPFLAGS: @H5_CPPFLAGS@\n"
|
||||
" AM_CPPFLAGS: @AM_CPPFLAGS@\n"
|
||||
" C Flags: @CMAKE_C_FLAGS@\n"
|
||||
" H5 C Flags: @HDF5_CMAKE_C_FLAGS@\n"
|
||||
" AM C Flags: @AM_CFLAGS@\n"
|
||||
" Shared C Library: @H5_ENABLE_SHARED_LIB@\n"
|
||||
" Static C Library: @H5_ENABLE_STATIC_LIB@\n"
|
||||
"\n"
|
||||
"\n"
|
||||
" Fortran: @HDF5_BUILD_FORTRAN@\n"
|
||||
" Fortran Compiler: @CMAKE_Fortran_COMPILER@ @CMAKE_Fortran_COMPILER_VERSION@\n"
|
||||
" Fortran Flags: @CMAKE_Fortran_FLAGS@\n"
|
||||
" H5 Fortran Flags: @HDF5_CMAKE_Fortran_FLAGS@\n"
|
||||
" AM Fortran Flags: @AM_FCFLAGS@\n"
|
||||
" Shared Fortran Library: @H5_ENABLE_SHARED_LIB@\n"
|
||||
" Static Fortran Library: @H5_ENABLE_STATIC_LIB@\n"
|
||||
" Module Directory: @CMAKE_Fortran_MODULE_DIRECTORY@\n"
|
||||
"\n"
|
||||
" C++: @HDF5_BUILD_CPP_LIB@\n"
|
||||
" C++ Compiler: @CMAKE_CXX_COMPILER@ @CMAKE_CXX_COMPILER_VERSION@\n"
|
||||
" C++ Flags: @CMAKE_CXX_FLAGS@\n"
|
||||
" H5 C++ Flags: @HDF5_CMAKE_CXX_FLAGS@\n"
|
||||
" AM C++ Flags: @AM_CXXFLAGS@\n"
|
||||
" Shared C++ Library: @H5_ENABLE_SHARED_LIB@\n"
|
||||
" Static C++ Library: @H5_ENABLE_STATIC_LIB@\n"
|
||||
"\n"
|
||||
" Java: @HDF5_BUILD_JAVA@\n"
|
||||
" Java Compiler: @CMAKE_Java_COMPILER@ @Java_VERSION@\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"Features:\n"
|
||||
"---------\n"
|
||||
" Parallel HDF5: @HDF5_ENABLE_PARALLEL@\n"
|
||||
" Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@\n"
|
||||
" Large Parallel I/O: @LARGE_PARALLEL_IO@\n"
|
||||
" High-level library: @HDF5_BUILD_HL_LIB@\n"
|
||||
"Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@\n"
|
||||
" Build HDF5 Tests: @BUILD_TESTING@\n"
|
||||
" Build HDF5 Tools: @HDF5_BUILD_TOOLS@\n"
|
||||
" Build GIF Tools: @HDF5_BUILD_HL_GIF_TOOLS@\n"
|
||||
" Threadsafety: @HDF5_ENABLE_THREADSAFE@\n"
|
||||
" Default API mapping: @DEFAULT_API_VERSION@\n"
|
||||
" With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@\n"
|
||||
" I/O filters (external): @EXTERNAL_FILTERS@\n"
|
||||
" Map (H5M) API: @H5_HAVE_MAP_API@\n"
|
||||
" Direct VFD: @H5_HAVE_DIRECT@\n"
|
||||
" Mirror VFD: @H5_HAVE_MIRROR_VFD@\n"
|
||||
" Subfiling VFD: @H5_HAVE_SUBFILING_VFD@\n"
|
||||
" (Read-Only) S3 VFD: @H5_HAVE_ROS3_VFD@\n"
|
||||
" (Read-Only) HDFS VFD: @H5_HAVE_LIBHDFS@\n"
|
||||
" Packages w/ extra debug output: @INTERNAL_DEBUG_OUTPUT@\n"
|
||||
" API tracing: @HDF5_ENABLE_TRACE@\n"
|
||||
" Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@\n"
|
||||
" Function stack tracing: @HDF5_ENABLE_CODESTACK@\n"
|
||||
" Use file locking: @HDF5_FILE_LOCKING_SETTING@\n"
|
||||
" Strict file format checks: @HDF5_STRICT_FORMAT_CHECKS@\n"
|
||||
" Optimization instrumentation: @HDF5_Enable_Instrument@\n"
|
||||
;
|
||||
|
||||
H5_GCC_DIAG_ON("larger-than=")
|
||||
H5_CLANG_DIAG_OFF("overlength-strings")
|
13
src/H5build_settings.off.c.in
Normal file
13
src/H5build_settings.off.c.in
Normal file
@ -0,0 +1,13 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the COPYING file, which can be found at the root of the source code *
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
||||
* If you do not have access to either file, you may request a copy from *
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
const char H5build_settings[]="";
|
941
src/H5detect.c
941
src/H5detect.c
@ -1,941 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the COPYING file, which can be found at the root of the source code *
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
||||
* If you do not have access to either file, you may request a copy from *
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*keep this declaration near the top of this file -RPM*/
|
||||
static const char *FileHeader = "\n\
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\
|
||||
* Copyright by The HDF Group. *\n\
|
||||
* All rights reserved. *\n\
|
||||
* *\n\
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *\n\
|
||||
* terms governing use, modification, and redistribution, is contained in *\n\
|
||||
* the COPYING file, which can be found at the root of the source code *\n\
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *\n\
|
||||
* If you do not have access to either file, you may request a copy from *\n\
|
||||
* help@hdfgroup.org. *\n\
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
|
||||
/*
|
||||
* Purpose: This code was borrowed heavily from the `detect.c'
|
||||
* program in the AIO distribution from Lawrence
|
||||
* Livermore National Laboratory.
|
||||
*
|
||||
* Detects machine byte order and floating point
|
||||
* format and generates a C source file (H5Tinit.c)
|
||||
* to describe those parameters.
|
||||
*
|
||||
* Assumptions: We have an ANSI compiler. We're on a Unix like
|
||||
* system or configure has detected those Unix
|
||||
* features which aren't available. We're not
|
||||
* running on a Vax or other machine with mixed
|
||||
* endianness.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#undef NDEBUG
|
||||
#include "H5private.h"
|
||||
/* Do NOT use fprintf in this file as it is not linked with the library,
|
||||
* which contains the H5system.c file in which the function is defined.
|
||||
*/
|
||||
#include "H5Tpublic.h"
|
||||
#include "H5Rpublic.h"
|
||||
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(no_sanitize_address)
|
||||
#define HDF_NO_UBSAN __attribute__((no_sanitize_address))
|
||||
#else
|
||||
#define HDF_NO_UBSAN
|
||||
#endif
|
||||
#else
|
||||
#define HDF_NO_UBSAN
|
||||
#endif
|
||||
|
||||
#define MAXDETECT 64
|
||||
|
||||
/*
|
||||
* This structure holds information about a type that
|
||||
* was detected.
|
||||
*/
|
||||
typedef struct detected_t {
|
||||
const char *varname;
|
||||
unsigned int size; /* total byte size */
|
||||
unsigned int precision; /* meaningful bits */
|
||||
unsigned int offset; /* bit offset to meaningful bits */
|
||||
int perm[32]; /* for detection of byte order */
|
||||
hbool_t is_vax; /* for vax (float & double) only */
|
||||
unsigned int sign; /* location of sign bit */
|
||||
unsigned int mpos, msize, imp; /* information about mantissa */
|
||||
unsigned int epos, esize; /* information about exponent */
|
||||
unsigned long bias; /* exponent bias for floating pt */
|
||||
unsigned int comp_align; /* alignment for structure */
|
||||
} detected_t;
|
||||
|
||||
FILE *rawoutstream = NULL;
|
||||
|
||||
/* global variables types detection code */
|
||||
H5_GCC_DIAG_OFF("larger-than=")
|
||||
static detected_t d_g[MAXDETECT];
|
||||
H5_GCC_DIAG_ON("larger-than=")
|
||||
static volatile int nd_g = 0;
|
||||
|
||||
static void print_results(int nd, detected_t *d);
|
||||
static void iprint(detected_t *);
|
||||
static int byte_cmp(int, const void *, const void *, const unsigned char *);
|
||||
static unsigned int bit_cmp(unsigned int, int *, void *, void *, const unsigned char *);
|
||||
static void fix_order(int, int, int *, const char **);
|
||||
static unsigned int imp_bit(unsigned int, int *, void *, void *, const unsigned char *);
|
||||
static unsigned int find_bias(unsigned int, unsigned int, int *, void *);
|
||||
static void precision(detected_t *);
|
||||
static void print_header(void);
|
||||
static void detect_C89_floats(void);
|
||||
static void detect_C99_floats(void);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: precision
|
||||
*
|
||||
* Purpose: Determine the precision and offset.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
precision(detected_t *d)
|
||||
{
|
||||
/* A floating point */
|
||||
d->offset = MIN3(d->mpos, d->epos, d->sign);
|
||||
d->precision = d->msize + d->esize + 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: DETECT_F
|
||||
*
|
||||
* Purpose: This macro takes a floating point type like `double' and
|
||||
* a base name like `natd' and detects byte order, mantissa
|
||||
* location, exponent location, sign bit location, presence or
|
||||
* absence of implicit mantissa bit, and exponent bias and
|
||||
* initializes a detected_t structure with those properties.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#define DETECT_F(TYPE, VAR, INFO) \
|
||||
{ \
|
||||
TYPE _v1, _v2, _v3; \
|
||||
unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \
|
||||
unsigned char _pad_mask[sizeof(TYPE)]; \
|
||||
unsigned char _byte_mask; \
|
||||
int _i, _j, _last = (-1); \
|
||||
const char *_mesg; \
|
||||
\
|
||||
memset(&INFO, 0, sizeof(INFO)); \
|
||||
INFO.varname = #VAR; \
|
||||
INFO.size = sizeof(TYPE); \
|
||||
\
|
||||
/* Initialize padding mask */ \
|
||||
memset(_pad_mask, 0, sizeof(_pad_mask)); \
|
||||
\
|
||||
/* Padding bits. Set a variable to 4.0, then flip each bit and see if \
|
||||
* the modified variable is equal ("==") to the original. Build a \
|
||||
* padding bitmask to indicate which bits in the type are padding (i.e. \
|
||||
* have no effect on the value and should be ignored by subsequent \
|
||||
* steps). This is necessary because padding bits can change arbitrarily \
|
||||
* and interfere with detection of the various properties below unless we \
|
||||
* know to ignore them. */ \
|
||||
_v1 = (TYPE)4.0L; \
|
||||
memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
|
||||
for (_i = 0; _i < (int)sizeof(TYPE); _i++) \
|
||||
for (_byte_mask = (unsigned char)1; _byte_mask; _byte_mask = (unsigned char)(_byte_mask << 1)) { \
|
||||
_buf1[_i] ^= _byte_mask; \
|
||||
memcpy((void *)&_v2, (const void *)_buf1, sizeof(TYPE)); \
|
||||
H5_GCC_CLANG_DIAG_OFF("float-equal") \
|
||||
if (_v1 != _v2) \
|
||||
_pad_mask[_i] |= _byte_mask; \
|
||||
H5_GCC_CLANG_DIAG_ON("float-equal") \
|
||||
_buf1[_i] ^= _byte_mask; \
|
||||
} /* end for */ \
|
||||
\
|
||||
/* Byte Order */ \
|
||||
for (_i = 0, _v1 = (TYPE)0.0L, _v2 = (TYPE)1.0L; _i < (int)sizeof(TYPE); _i++) { \
|
||||
_v3 = _v1; \
|
||||
_v1 += _v2; \
|
||||
_v2 /= (TYPE)256.0L; \
|
||||
memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
|
||||
memcpy(_buf3, (const void *)&_v3, sizeof(TYPE)); \
|
||||
_j = byte_cmp(sizeof(TYPE), _buf3, _buf1, _pad_mask); \
|
||||
if (_j >= 0) { \
|
||||
INFO.perm[_i] = _j; \
|
||||
_last = _i; \
|
||||
} \
|
||||
} \
|
||||
fix_order(sizeof(TYPE), _last, INFO.perm, (const char **)&_mesg); \
|
||||
\
|
||||
if (!strcmp(_mesg, "VAX")) \
|
||||
INFO.is_vax = TRUE; \
|
||||
\
|
||||
/* Implicit mantissa bit */ \
|
||||
_v1 = (TYPE)0.5L; \
|
||||
_v2 = (TYPE)1.0L; \
|
||||
INFO.imp = imp_bit(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \
|
||||
\
|
||||
/* Sign bit */ \
|
||||
_v1 = (TYPE)1.0L; \
|
||||
_v2 = (TYPE)-1.0L; \
|
||||
INFO.sign = bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \
|
||||
\
|
||||
/* Mantissa */ \
|
||||
INFO.mpos = 0; \
|
||||
\
|
||||
_v1 = (TYPE)1.0L; \
|
||||
_v2 = (TYPE)1.5L; \
|
||||
INFO.msize = bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask); \
|
||||
INFO.msize += 1 + (unsigned int)(INFO.imp ? 0 : 1) - INFO.mpos; \
|
||||
\
|
||||
/* Exponent */ \
|
||||
INFO.epos = INFO.mpos + INFO.msize; \
|
||||
\
|
||||
INFO.esize = INFO.sign - INFO.epos; \
|
||||
\
|
||||
_v1 = (TYPE)1.0L; \
|
||||
INFO.bias = find_bias(INFO.epos, INFO.esize, INFO.perm, &_v1); \
|
||||
precision(&(INFO)); \
|
||||
if (!strcmp(INFO.varname, "FLOAT") || !strcmp(INFO.varname, "DOUBLE") || \
|
||||
!strcmp(INFO.varname, "LDOUBLE")) { \
|
||||
COMP_ALIGNMENT(TYPE, INFO.comp_align); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Detect alignment for C structure */
|
||||
#define COMP_ALIGNMENT(TYPE, COMP_ALIGN) \
|
||||
{ \
|
||||
struct { \
|
||||
char c; \
|
||||
TYPE x; \
|
||||
} s; \
|
||||
\
|
||||
COMP_ALIGN = (unsigned int)((char *)(&(s.x)) - (char *)(&s)); \
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: print_results
|
||||
*
|
||||
* Purpose: Prints information about the detected data types.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
print_results(int nd, detected_t *d)
|
||||
{
|
||||
int byte_order = 0; /*byte order of data types*/
|
||||
int i, j;
|
||||
|
||||
/* Include files */
|
||||
fprintf(rawoutstream, "\
|
||||
/****************/\n\
|
||||
/* Module Setup */\n\
|
||||
/****************/\n\
|
||||
\n\
|
||||
#include \"H5Tmodule.h\" /* This source code file is part of the H5T module */\n\
|
||||
\n\
|
||||
\n\
|
||||
/***********/\n\
|
||||
/* Headers */\n\
|
||||
/***********/\n\
|
||||
#include \"H5private.h\" /* Generic Functions */\n\
|
||||
#include \"H5Eprivate.h\" /* Error handling */\n\
|
||||
#include \"H5FLprivate.h\" /* Free Lists */\n\
|
||||
#include \"H5Iprivate.h\" /* IDs */\n\
|
||||
#include \"H5Tpkg.h\" /* Datatypes */\n\
|
||||
\n\
|
||||
\n\
|
||||
/****************/\n\
|
||||
/* Local Macros */\n\
|
||||
/****************/\n\
|
||||
\n\
|
||||
\n\
|
||||
/******************/\n\
|
||||
/* Local Typedefs */\n\
|
||||
/******************/\n\
|
||||
\n\
|
||||
\n\
|
||||
/********************/\n\
|
||||
/* Package Typedefs */\n\
|
||||
/********************/\n\
|
||||
\n\
|
||||
\n\
|
||||
/********************/\n\
|
||||
/* Local Prototypes */\n\
|
||||
/********************/\n\
|
||||
\n\
|
||||
\n\
|
||||
/********************/\n\
|
||||
/* Public Variables */\n\
|
||||
/********************/\n\
|
||||
\n\
|
||||
\n\
|
||||
/*****************************/\n\
|
||||
/* Library Private Variables */\n\
|
||||
/*****************************/\n\
|
||||
\n\
|
||||
\n\
|
||||
/*********************/\n\
|
||||
/* Package Variables */\n\
|
||||
/*********************/\n\
|
||||
\n\
|
||||
\n");
|
||||
fprintf(rawoutstream, "\n\
|
||||
/*******************/\n\
|
||||
/* Local Variables */\n\
|
||||
/*******************/\n\
|
||||
\n");
|
||||
|
||||
/* The interface initialization function */
|
||||
fprintf(rawoutstream, "\n\
|
||||
\n\
|
||||
/*-------------------------------------------------------------------------\n\
|
||||
* Function: H5T__init_native\n\
|
||||
*\n\
|
||||
* Purpose: Initialize pre-defined native datatypes from code generated\n\
|
||||
* during the library configuration by H5detect.\n\
|
||||
*\n\
|
||||
* Return: Success: non-negative\n\
|
||||
* Failure: negative\n\
|
||||
*\n\
|
||||
* Programmer: Robb Matzke\n\
|
||||
* Wednesday, December 16, 1998\n\
|
||||
*\n\
|
||||
*-------------------------------------------------------------------------\n\
|
||||
*/\n\
|
||||
herr_t\n\
|
||||
H5T__init_native(void)\n\
|
||||
{\n\
|
||||
H5T_t *dt = NULL;\n\
|
||||
herr_t ret_value = SUCCEED;\n\
|
||||
\n\
|
||||
FUNC_ENTER_PACKAGE\n");
|
||||
|
||||
for (i = 0; i < nd; i++) {
|
||||
/* The native endianness of this machine */
|
||||
/* The INFO.perm now contains `-1' for bytes that aren't used and
|
||||
* are always zero. This happens on the Cray for `short' where
|
||||
* sizeof(short) is 8, but only the low-order 4 bytes are ever used.
|
||||
*/
|
||||
if (d[i].is_vax) /* the type is a VAX floating number */
|
||||
byte_order = -1;
|
||||
else {
|
||||
for (j = 0; j < 32; j++) {
|
||||
/*Find the 1st containing valid data*/
|
||||
if (d[i].perm[j] > -1) {
|
||||
byte_order = d[i].perm[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Print a comment to describe this section of definitions. */
|
||||
fprintf(rawoutstream, "\n /*\n");
|
||||
iprint(d + i);
|
||||
fprintf(rawoutstream, " */\n");
|
||||
|
||||
/* The part common to fixed and floating types */
|
||||
fprintf(rawoutstream, "\
|
||||
if(NULL == (dt = H5T__alloc()))\n\
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\");\n\
|
||||
dt->shared->state = H5T_STATE_IMMUTABLE;\n\
|
||||
dt->shared->type = H5T_FLOAT;\n\
|
||||
dt->shared->size = %d;\n",
|
||||
d[i].size); /*size */
|
||||
|
||||
if (byte_order == -1)
|
||||
fprintf(rawoutstream, "\
|
||||
dt->shared->u.atomic.order = H5T_ORDER_VAX;\n");
|
||||
else if (byte_order == 0)
|
||||
fprintf(rawoutstream, "\
|
||||
dt->shared->u.atomic.order = H5T_ORDER_LE;\n");
|
||||
else
|
||||
fprintf(rawoutstream, "\
|
||||
dt->shared->u.atomic.order = H5T_ORDER_BE;\n");
|
||||
|
||||
fprintf(rawoutstream, "\
|
||||
dt->shared->u.atomic.offset = %d;\n\
|
||||
dt->shared->u.atomic.prec = %d;\n\
|
||||
dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\
|
||||
dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO;\n",
|
||||
d[i].offset, /*offset */
|
||||
d[i].precision); /*precision */
|
||||
/*assert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */
|
||||
|
||||
/* The part unique to floating point types */
|
||||
fprintf(rawoutstream, "\
|
||||
dt->shared->u.atomic.u.f.sign = %d;\n\
|
||||
dt->shared->u.atomic.u.f.epos = %d;\n\
|
||||
dt->shared->u.atomic.u.f.esize = %d;\n\
|
||||
dt->shared->u.atomic.u.f.ebias = 0x%08lx;\n\
|
||||
dt->shared->u.atomic.u.f.mpos = %d;\n\
|
||||
dt->shared->u.atomic.u.f.msize = %d;\n\
|
||||
dt->shared->u.atomic.u.f.norm = H5T_NORM_%s;\n\
|
||||
dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
|
||||
d[i].sign, /*sign location */
|
||||
d[i].epos, /*exponent loc */
|
||||
d[i].esize, /*exponent size */
|
||||
(unsigned long)(d[i].bias), /*exponent bias */
|
||||
d[i].mpos, /*mantissa loc */
|
||||
d[i].msize, /*mantissa size */
|
||||
d[i].imp ? "IMPLIED" : "NONE"); /*normalization */
|
||||
|
||||
/* Register the type */
|
||||
fprintf(rawoutstream, "\
|
||||
if((H5T_NATIVE_%s_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)\n\
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \"can't register ID for built-in datatype\");\n",
|
||||
d[i].varname);
|
||||
|
||||
/* Variables for alignment of compound datatype */
|
||||
if (!strcmp(d[i].varname, "SCHAR") || !strcmp(d[i].varname, "SHORT") ||
|
||||
!strcmp(d[i].varname, "INT") || !strcmp(d[i].varname, "LONG") || !strcmp(d[i].varname, "LLONG") ||
|
||||
!strcmp(d[i].varname, "FLOAT") || !strcmp(d[i].varname, "DOUBLE") ||
|
||||
!strcmp(d[i].varname, "LDOUBLE")) {
|
||||
fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname,
|
||||
(unsigned long)(d[i].comp_align));
|
||||
}
|
||||
}
|
||||
|
||||
/* Consider VAX a little-endian machine */
|
||||
if (byte_order == 0 || byte_order == -1) {
|
||||
fprintf(rawoutstream, "\n\
|
||||
/* Set the native order for this machine */\n\
|
||||
H5T_native_order_g = H5T_ORDER_%s;\n",
|
||||
"LE");
|
||||
}
|
||||
else {
|
||||
fprintf(rawoutstream, "\n\
|
||||
/* Set the native order for this machine */\n\
|
||||
H5T_native_order_g = H5T_ORDER_%s;\n",
|
||||
"BE");
|
||||
}
|
||||
|
||||
fprintf(rawoutstream, "\
|
||||
\n\
|
||||
done:\n\
|
||||
if(ret_value < 0) {\n\
|
||||
if(dt != NULL) {\n\
|
||||
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);\n\
|
||||
dt = H5FL_FREE(H5T_t, dt);\n\
|
||||
} /* end if */\n\
|
||||
} /* end if */\n\
|
||||
\n\
|
||||
FUNC_LEAVE_NOAPI(ret_value);\n} /* end H5T__init_native() */\n");
|
||||
|
||||
} /* end print_results() */
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: iprint
|
||||
*
|
||||
* Purpose: Prints information about the fields of a floating point format.
|
||||
*
|
||||
* Return: void
|
||||
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
iprint(detected_t *d)
|
||||
{
|
||||
unsigned int pass;
|
||||
|
||||
for (pass = (d->size - 1) / 4;; --pass) {
|
||||
unsigned int i, k;
|
||||
/*
|
||||
* Print the byte ordering above the bit fields.
|
||||
*/
|
||||
fprintf(rawoutstream, " * ");
|
||||
for (i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) {
|
||||
fprintf(rawoutstream, "%4d", d->perm[i]);
|
||||
if (i > pass * 4)
|
||||
fputs(" ", rawoutstream);
|
||||
if (!i)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print the bit fields
|
||||
*/
|
||||
fprintf(rawoutstream, "\n * ");
|
||||
for (i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31, 8 * d->size - 1); i >= pass * 4;
|
||||
--i) {
|
||||
unsigned int j;
|
||||
|
||||
for (j = 8; j > 0; --j) {
|
||||
if (k == d->sign) {
|
||||
fputc('S', rawoutstream);
|
||||
}
|
||||
else if (k >= d->epos && k < d->epos + d->esize) {
|
||||
fputc('E', rawoutstream);
|
||||
}
|
||||
else if (k >= d->mpos && k < d->mpos + d->msize) {
|
||||
fputc('M', rawoutstream);
|
||||
}
|
||||
else {
|
||||
fputc('?', rawoutstream); /*unknown floating point bit */
|
||||
}
|
||||
--k;
|
||||
}
|
||||
if (i > pass * 4)
|
||||
fputc(' ', rawoutstream);
|
||||
if (!i)
|
||||
break;
|
||||
}
|
||||
fputc('\n', rawoutstream);
|
||||
if (!pass)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is there an implicit bit in the mantissa.
|
||||
*/
|
||||
fprintf(rawoutstream, " * Implicit bit? %s\n", d->imp ? "yes" : "no");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: byte_cmp
|
||||
*
|
||||
* Purpose: Compares two chunks of memory A and B and returns the
|
||||
* byte index into those arrays of the first byte that
|
||||
* differs between A and B. Ignores differences where the
|
||||
* corresponding bit in pad_mask is set to 0.
|
||||
*
|
||||
* Return: Success: Index of differing byte.
|
||||
* Failure: -1 if all bytes are the same.
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int
|
||||
byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask)
|
||||
{
|
||||
int i;
|
||||
const unsigned char *a = (const unsigned char *)_a;
|
||||
const unsigned char *b = (const unsigned char *)_b;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
if ((a[i] & pad_mask[i]) != (b[i] & pad_mask[i]))
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: bit_cmp
|
||||
*
|
||||
* Purpose: Compares two bit vectors and returns the index for the
|
||||
* first bit that differs between the two vectors. The
|
||||
* size of the vector is NBYTES. PERM is a mapping from
|
||||
* actual order to little endian. Ignores differences where
|
||||
* the corresponding bit in pad_mask is set to 0.
|
||||
*
|
||||
* Return: Index of first differing bit.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static unsigned int
|
||||
bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, const unsigned char *pad_mask)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char *a = (unsigned char *)_a;
|
||||
unsigned char *b = (unsigned char *)_b;
|
||||
unsigned char aa, bb;
|
||||
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
assert(perm[i] < (int)nbytes);
|
||||
if ((aa = (unsigned char)(a[perm[i]] & pad_mask[perm[i]])) !=
|
||||
(bb = (unsigned char)(b[perm[i]] & pad_mask[perm[i]]))) {
|
||||
unsigned int j;
|
||||
|
||||
for (j = 0; j < 8; j++, aa >>= 1, bb >>= 1) {
|
||||
if ((aa & 1) != (bb & 1))
|
||||
return i * 8 + j;
|
||||
}
|
||||
fprintf(stderr, "INTERNAL ERROR");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "INTERNAL ERROR");
|
||||
abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: fix_order
|
||||
*
|
||||
* Purpose: Given an array PERM with elements FIRST through LAST
|
||||
* initialized with zero origin byte numbers, this function
|
||||
* creates a permutation vector that maps the actual order
|
||||
* of a floating point number to little-endian.
|
||||
*
|
||||
* This function assumes that the mantissa byte ordering
|
||||
* implies the total ordering.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
fix_order(int n, int last, int *perm, const char **mesg)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (last > 1) {
|
||||
/*
|
||||
* We have at least three points to consider.
|
||||
*/
|
||||
if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) {
|
||||
/*
|
||||
* Little endian.
|
||||
*/
|
||||
if (mesg)
|
||||
*mesg = "Little-endian";
|
||||
for (i = 0; i < n; i++)
|
||||
perm[i] = i;
|
||||
}
|
||||
else if (perm[last] > perm[last - 1] && perm[last - 1] > perm[last - 2]) {
|
||||
/*
|
||||
* Big endian.
|
||||
*/
|
||||
if (mesg)
|
||||
*mesg = "Big-endian";
|
||||
for (i = 0; i < n; i++)
|
||||
perm[i] = (n - 1) - i;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* Bi-endian machines like VAX.
|
||||
* (NOTE: This is not an actual determination of the VAX-endianness.
|
||||
* It could have some other endianness and fall into this
|
||||
* case - JKM & QAK)
|
||||
*/
|
||||
assert(0 == n % 2);
|
||||
if (mesg)
|
||||
*mesg = "VAX";
|
||||
for (i = 0; i < n; i += 2) {
|
||||
perm[i] = (n - 2) - i;
|
||||
perm[i + 1] = (n - 1) - i;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Failed to detect byte order of %d-byte floating point.\n", n);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: imp_bit
|
||||
*
|
||||
* Purpose: Looks for an implicit bit in the mantissa. The value
|
||||
* of _A should be 1.0 and the value of _B should be 0.5.
|
||||
* Some floating-point formats discard the most significant
|
||||
* bit of the mantissa after normalizing since it will always
|
||||
* be a one (except for 0.0). If this is true for the native
|
||||
* floating point values stored in _A and _B then the function
|
||||
* returns non-zero.
|
||||
*
|
||||
* This function assumes that the exponent occupies higher
|
||||
* order bits than the mantissa and that the most significant
|
||||
* bit of the mantissa is next to the least significant bit
|
||||
* of the exponent.
|
||||
*
|
||||
*
|
||||
* Return: Success: Non-zero if the most significant bit
|
||||
* of the mantissa is discarded (ie, the
|
||||
* mantissa has an implicit `one' as the
|
||||
* most significant bit). Otherwise,
|
||||
* returns zero.
|
||||
*
|
||||
* Failure: 1
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static unsigned int
|
||||
imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_mask)
|
||||
{
|
||||
unsigned char *a = (unsigned char *)_a;
|
||||
unsigned char *b = (unsigned char *)_b;
|
||||
unsigned int changed, major, minor;
|
||||
unsigned int msmb; /* most significant mantissa bit */
|
||||
|
||||
/*
|
||||
* Look for the least significant bit that has changed between
|
||||
* A and B. This is the least significant bit of the exponent.
|
||||
*/
|
||||
changed = bit_cmp(n, perm, a, b, pad_mask);
|
||||
|
||||
/*
|
||||
* The bit to the right (less significant) of the changed bit should
|
||||
* be the most significant bit of the mantissa. If it is non-zero
|
||||
* then the format does not remove the leading `1' of the mantissa.
|
||||
*/
|
||||
msmb = changed - 1;
|
||||
major = msmb / 8;
|
||||
minor = msmb % 8;
|
||||
|
||||
return (a[perm[major]] >> minor) & 0x01 ? 0 : 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: find_bias
|
||||
*
|
||||
* Purpose: Determines the bias of the exponent. This function should
|
||||
* be called with _A having a value of `1'.
|
||||
*
|
||||
* Return: The exponent bias.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
H5_ATTR_PURE static unsigned int
|
||||
find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a)
|
||||
{
|
||||
unsigned char *a = (unsigned char *)_a;
|
||||
unsigned char mask;
|
||||
unsigned int b, shift = 0, nbits, bias = 0;
|
||||
|
||||
while (esize > 0) {
|
||||
nbits = MIN(esize, (8 - epos % 8));
|
||||
mask = (unsigned char)((1 << nbits) - 1);
|
||||
b = (unsigned int)(a[perm[epos / 8]] >> (epos % 8)) & mask;
|
||||
bias |= b << shift;
|
||||
|
||||
shift += nbits;
|
||||
esize -= nbits;
|
||||
epos += nbits;
|
||||
}
|
||||
return bias;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: print_header
|
||||
*
|
||||
* Purpose: Prints the C file header for the generated file.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
print_header(void)
|
||||
{
|
||||
|
||||
time_t now = HDtime(NULL);
|
||||
struct tm *tm = HDlocaltime(&now);
|
||||
char real_name[30];
|
||||
char host_name[256];
|
||||
int i;
|
||||
const char *s;
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
struct passwd *pwd = NULL;
|
||||
#else
|
||||
int pwd = 1;
|
||||
#endif
|
||||
static const char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
static const char *purpose = "\
|
||||
This machine-generated source code contains\n\
|
||||
information about the various integer and\n\
|
||||
floating point numeric formats found on this\n\
|
||||
architecture. The parameters below should be\n\
|
||||
checked carefully and errors reported to the\n\
|
||||
HDF5 maintainer.\n\
|
||||
\n\
|
||||
Each of the numeric formats listed below are\n\
|
||||
printed from most significant bit to least\n\
|
||||
significant bit even though the actual bytes\n\
|
||||
might be stored in a different order in\n\
|
||||
memory. The integers above each binary byte\n\
|
||||
indicate the relative order of the bytes in\n\
|
||||
memory; little-endian machines have\n\
|
||||
decreasing numbers while big-endian machines\n\
|
||||
have increasing numbers.\n\
|
||||
\n\
|
||||
The fields of the numbers are printed as\n\
|
||||
letters with `S' for the mantissa sign bit,\n\
|
||||
`M' for the mantissa magnitude, and `E' for\n\
|
||||
the exponent. The exponent has an associated\n\
|
||||
bias which can be subtracted to find the\n\
|
||||
true exponent. The radix point is assumed\n\
|
||||
to be before the first `M' bit. Any bit\n\
|
||||
of a floating-point value not falling into one\n\
|
||||
of these categories is printed as a question\n\
|
||||
mark. Bits of integer types are printed as\n\
|
||||
`I' for 2's complement and `U' for magnitude.\n\
|
||||
\n\
|
||||
If the most significant bit of the normalized\n\
|
||||
mantissa (always a `1' except for `0.0') is\n\
|
||||
not stored then an `implicit=yes' appears\n\
|
||||
under the field description. In this case,\n\
|
||||
the radix point is still assumed to be\n\
|
||||
before the first `M' but after the implicit\n\
|
||||
bit.\n";
|
||||
|
||||
/*
|
||||
* The real name is the first item from the passwd gecos field.
|
||||
*/
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
{
|
||||
size_t n;
|
||||
char *comma;
|
||||
if ((pwd = getpwuid(getuid()))) {
|
||||
if ((comma = strchr(pwd->pw_gecos, ','))) {
|
||||
n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos));
|
||||
strncpy(real_name, pwd->pw_gecos, n);
|
||||
real_name[n] = '\0';
|
||||
}
|
||||
else {
|
||||
strncpy(real_name, pwd->pw_gecos, sizeof(real_name));
|
||||
real_name[sizeof(real_name) - 1] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
real_name[0] = '\0';
|
||||
}
|
||||
#else
|
||||
real_name[0] = '\0';
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The FQDM of this host or the empty string.
|
||||
*/
|
||||
#ifdef H5_HAVE_GETHOSTNAME
|
||||
if (gethostname(host_name, sizeof(host_name)) < 0) {
|
||||
host_name[0] = '\0';
|
||||
}
|
||||
#else
|
||||
host_name[0] = '\0';
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The file header: warning, copyright notice, build information.
|
||||
*/
|
||||
fprintf(rawoutstream, "/* Generated automatically by H5detect -- do not edit */\n\n\n");
|
||||
fputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */
|
||||
|
||||
fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday,
|
||||
1900 + tm->tm_year);
|
||||
if (pwd || real_name[0] || host_name[0]) {
|
||||
fprintf(rawoutstream, " *\t\t\t");
|
||||
if (real_name[0])
|
||||
fprintf(rawoutstream, "%s <", real_name);
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
if (pwd)
|
||||
fputs(pwd->pw_name, rawoutstream);
|
||||
#endif
|
||||
if (host_name[0])
|
||||
fprintf(rawoutstream, "@%s", host_name);
|
||||
if (real_name[0])
|
||||
fprintf(rawoutstream, ">");
|
||||
fputc('\n', rawoutstream);
|
||||
}
|
||||
fprintf(rawoutstream, " *\n * Purpose:\t\t");
|
||||
for (s = purpose; *s; s++) {
|
||||
fputc(*s, rawoutstream);
|
||||
if ('\n' == *s && s[1])
|
||||
fprintf(rawoutstream, " *\t\t\t");
|
||||
}
|
||||
|
||||
fprintf(rawoutstream, " *\n");
|
||||
fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
|
||||
fprintf(rawoutstream, " *\tIt was generated by code in `H5detect.c'.\n");
|
||||
|
||||
fprintf(rawoutstream, " *\n *");
|
||||
for (i = 0; i < 73; i++)
|
||||
fputc('-', rawoutstream);
|
||||
fprintf(rawoutstream, "\n */\n\n");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: detect_C89_floats
|
||||
*
|
||||
* Purpose: Detect C89 floating point types
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void HDF_NO_UBSAN
|
||||
detect_C89_floats(void)
|
||||
{
|
||||
DETECT_F(float, FLOAT, d_g[nd_g]);
|
||||
nd_g++;
|
||||
DETECT_F(double, DOUBLE, d_g[nd_g]);
|
||||
nd_g++;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: detect_C99_floats
|
||||
*
|
||||
* Purpose: Detect C99 floating point types
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void HDF_NO_UBSAN
|
||||
detect_C99_floats(void)
|
||||
{
|
||||
#if H5_SIZEOF_DOUBLE == H5_SIZEOF_LONG_DOUBLE
|
||||
/*
|
||||
* If sizeof(double)==sizeof(long double) then assume that `long double'
|
||||
* isn't supported and use `double' instead. This suppresses warnings on
|
||||
* some systems and `long double' is probably the same as `double' here
|
||||
* anyway.
|
||||
*/
|
||||
DETECT_F(double, LDOUBLE, d_g[nd_g]);
|
||||
nd_g++;
|
||||
#else
|
||||
DETECT_F(long double, LDOUBLE, d_g[nd_g]);
|
||||
nd_g++;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: main
|
||||
*
|
||||
* Purpose: Main entry point.
|
||||
*
|
||||
* Return: Success: EXIT_SUCCESS
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int HDF_NO_UBSAN
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *fname = NULL;
|
||||
FILE *f; /* temporary holding place for the stream pointer
|
||||
* so that rawoutstream is changed only when succeeded */
|
||||
|
||||
if (argc > 1)
|
||||
fname = argv[1];
|
||||
|
||||
/* First check if filename is string "NULL" */
|
||||
if (fname != NULL) {
|
||||
/* binary output */
|
||||
if ((f = fopen(fname, "w")) != NULL)
|
||||
rawoutstream = f;
|
||||
}
|
||||
if (!rawoutstream)
|
||||
rawoutstream = stdout;
|
||||
|
||||
print_header();
|
||||
|
||||
/* C89 floating point types */
|
||||
detect_C89_floats();
|
||||
|
||||
/* C99 floating point types */
|
||||
detect_C99_floats();
|
||||
|
||||
print_results(nd_g, d_g);
|
||||
|
||||
if (rawoutstream && rawoutstream != stdout) {
|
||||
if (fclose(rawoutstream))
|
||||
fprintf(stderr, "closing rawoutstream");
|
||||
else
|
||||
rawoutstream = NULL;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -1,300 +0,0 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the COPYING file, which can be found at the root of the source code *
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *
|
||||
* If you do not have access to either file, you may request a copy from *
|
||||
* help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* Keep this declaration near the top of this file */
|
||||
static const char *FileHeader = "\n\
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\
|
||||
* Copyright by The HDF Group. *\n\
|
||||
* All rights reserved. *\n\
|
||||
* *\n\
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *\n\
|
||||
* terms governing use, modification, and redistribution, is contained in *\n\
|
||||
* the COPYING file, which can be found at the root of the source code *\n\
|
||||
* distribution tree, or in https://www.hdfgroup.org/licenses. *\n\
|
||||
* If you do not have access to either file, you may request a copy from *\n\
|
||||
* help@hdfgroup.org. *\n\
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
|
||||
/*
|
||||
* Purpose: Generate the H5libsettings.c file from the
|
||||
* libhdf5.settings file.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "H5private.h"
|
||||
|
||||
/* Do NOT use fprintf in this file as it is not linked with the library,
|
||||
* which contains the H5system.c file in which the function is defined.
|
||||
*/
|
||||
|
||||
#define LIBSETTINGSFNAME "libhdf5.settings"
|
||||
|
||||
FILE *rawoutstream = NULL;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: insert_libhdf5_settings
|
||||
*
|
||||
* Purpose: insert the contents of libhdf5.settings into a file
|
||||
* represented by flibinfo.
|
||||
* Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not
|
||||
* defined, i.e., not enabled.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
insert_libhdf5_settings(FILE *flibinfo)
|
||||
{
|
||||
#ifdef H5_HAVE_EMBEDDED_LIBINFO
|
||||
FILE *fsettings; /* for files libhdf5.settings */
|
||||
int inchar;
|
||||
int bol = 0; /* indicates the beginning of a new line */
|
||||
|
||||
if (NULL == (fsettings = fopen(LIBSETTINGSFNAME, "r"))) {
|
||||
perror(LIBSETTINGSFNAME);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Turn off warnings for large arrays. If the library info string is
|
||||
* a problem, people can build without the embedded library info.
|
||||
*/
|
||||
fprintf(flibinfo, "#include \"H5private.h\"\n");
|
||||
fprintf(flibinfo, "H5_GCC_DIAG_OFF(\"larger-than=\")\n\n");
|
||||
fprintf(flibinfo, "H5_CLANG_DIAG_OFF(\"overlength-strings\")\n\n");
|
||||
|
||||
/* Print variable definition and the string. Do not use const or some
|
||||
* platforms (AIX?) will have issues.
|
||||
*/
|
||||
fprintf(flibinfo, "const char H5libhdf5_settings[]=\n");
|
||||
bol++;
|
||||
while (EOF != (inchar = getc(fsettings))) {
|
||||
if (bol) {
|
||||
/* Start a new line */
|
||||
fprintf(flibinfo, "\t\"");
|
||||
bol = 0;
|
||||
}
|
||||
if (inchar == '\n') {
|
||||
/* end of a line */
|
||||
fprintf(flibinfo, "\\n\"\n");
|
||||
bol++;
|
||||
}
|
||||
else
|
||||
putc(inchar, flibinfo);
|
||||
}
|
||||
|
||||
if (feof(fsettings)) {
|
||||
/* wrap up */
|
||||
if (!bol)
|
||||
/* EOF found without a new line */
|
||||
fprintf(flibinfo, "\\n\"\n");
|
||||
fprintf(flibinfo, ";\n\n");
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (0 != fclose(fsettings)) {
|
||||
perror(LIBSETTINGSFNAME);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Re-enable warnings for large arrays */
|
||||
fprintf(rawoutstream, "H5_GCC_DIAG_ON(\"larger-than=\")\n");
|
||||
fprintf(rawoutstream, "H5_CLANG_DIAG_OFF(\"overlength-strings\")\n");
|
||||
#else
|
||||
/* Print variable definition and an empty string. Do not use const or some
|
||||
* platforms (AIX?) will have issues.
|
||||
*/
|
||||
fprintf(flibinfo, "const char H5libhdf5_settings[]=\"\";\n");
|
||||
#endif
|
||||
} /* insert_libhdf5_settings() */
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: make_libinfo
|
||||
*
|
||||
* Purpose: Create the embedded library information definition.
|
||||
* This sets up for a potential extension that the declaration
|
||||
* is printed to a file different from stdout.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
make_libinfo(void)
|
||||
{
|
||||
/* Print variable definition and then the string as a macro */
|
||||
insert_libhdf5_settings(rawoutstream);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: print_header
|
||||
*
|
||||
* Purpose: Prints the header for the generated file.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
print_header(void)
|
||||
{
|
||||
time_t now = HDtime(NULL);
|
||||
struct tm *tm = HDlocaltime(&now);
|
||||
char real_name[30];
|
||||
char host_name[256];
|
||||
int i;
|
||||
const char *s;
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
struct passwd *pwd = NULL;
|
||||
#else
|
||||
int pwd = 1;
|
||||
#endif
|
||||
static const char *month_name[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
static const char *purpose = "\
|
||||
This machine-generated source code contains\n\
|
||||
information about the library build configuration\n";
|
||||
|
||||
/*
|
||||
* The real name is the first item from the passwd gecos field.
|
||||
*/
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
{
|
||||
size_t n;
|
||||
char *comma;
|
||||
|
||||
if ((pwd = getpwuid(getuid()))) {
|
||||
if ((comma = strchr(pwd->pw_gecos, ','))) {
|
||||
n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos));
|
||||
strncpy(real_name, pwd->pw_gecos, n);
|
||||
real_name[n] = '\0';
|
||||
}
|
||||
else {
|
||||
strncpy(real_name, pwd->pw_gecos, sizeof(real_name));
|
||||
real_name[sizeof(real_name) - 1] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
real_name[0] = '\0';
|
||||
}
|
||||
#else
|
||||
real_name[0] = '\0';
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The FQDM of this host or the empty string.
|
||||
*/
|
||||
#ifdef H5_HAVE_GETHOSTNAME
|
||||
if (gethostname(host_name, sizeof(host_name)) < 0)
|
||||
host_name[0] = '\0';
|
||||
#else
|
||||
host_name[0] = '\0';
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The file header: warning, copyright notice, build information.
|
||||
*/
|
||||
fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n");
|
||||
fputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */
|
||||
|
||||
fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday,
|
||||
1900 + tm->tm_year);
|
||||
if (pwd || real_name[0] || host_name[0]) {
|
||||
fprintf(rawoutstream, " *\t\t\t");
|
||||
if (real_name[0])
|
||||
fprintf(rawoutstream, "%s <", real_name);
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
if (pwd)
|
||||
fputs(pwd->pw_name, rawoutstream);
|
||||
#endif
|
||||
if (host_name[0])
|
||||
fprintf(rawoutstream, "@%s", host_name);
|
||||
if (real_name[0])
|
||||
fprintf(rawoutstream, ">");
|
||||
fputc('\n', rawoutstream);
|
||||
}
|
||||
|
||||
fprintf(rawoutstream, " *\n * Purpose:\t\t");
|
||||
|
||||
for (s = purpose; *s; s++) {
|
||||
fputc(*s, rawoutstream);
|
||||
if ('\n' == *s && s[1])
|
||||
fprintf(rawoutstream, " *\t\t\t");
|
||||
}
|
||||
|
||||
fprintf(rawoutstream, " *\n");
|
||||
fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
|
||||
fprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n");
|
||||
|
||||
fprintf(rawoutstream, " *\n *");
|
||||
for (i = 0; i < 73; i++)
|
||||
fputc('-', rawoutstream);
|
||||
fprintf(rawoutstream, "\n */\n\n");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: print_footer
|
||||
*
|
||||
* Purpose: Prints the file footer for the generated file.
|
||||
*
|
||||
* Return: void
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
print_footer(void)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: main
|
||||
*
|
||||
* Purpose: Main entry point.
|
||||
*
|
||||
* Return: Success: EXIT_SUCCESS
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *fname = NULL;
|
||||
FILE *f; /* temporary holding place for the stream pointer
|
||||
* so that rawoutstream is changed only when succeeded
|
||||
*/
|
||||
|
||||
if (argc > 1)
|
||||
fname = argv[1];
|
||||
|
||||
/* First check if filename is string "NULL" */
|
||||
if (fname != NULL) {
|
||||
/* binary output */
|
||||
if ((f = fopen(fname, "w")) != NULL)
|
||||
rawoutstream = f;
|
||||
}
|
||||
if (!rawoutstream)
|
||||
rawoutstream = stdout;
|
||||
|
||||
print_header();
|
||||
|
||||
/* Generate embedded library information variable definition */
|
||||
make_libinfo();
|
||||
|
||||
print_footer();
|
||||
|
||||
if (rawoutstream && rawoutstream != stdout) {
|
||||
if (fclose(rawoutstream))
|
||||
fprintf(stderr, "closing rawoutstream");
|
||||
else
|
||||
rawoutstream = NULL;
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
@ -1262,7 +1262,7 @@ extern H5_debug_t H5_debug_g;
|
||||
#define H5DEBUG(X) (H5_debug_g.pkg[H5_PKG_##X].stream)
|
||||
|
||||
/* Embedded build information */
|
||||
extern const char H5libhdf5_settings[];
|
||||
extern const char H5build_settings[];
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Purpose: These macros are inserted automatically just after the
|
||||
|
@ -18,25 +18,17 @@
|
||||
include $(top_srcdir)/config/commence.am
|
||||
include $(top_srcdir)/config/lt_vers.am
|
||||
|
||||
# How to build H5detect for number format detection.
|
||||
# Use -g to force no optimization since many compilers (e.g., Intel) takes
|
||||
# a long time to compile it with any optimization on. H5detect is used
|
||||
# to generate H5Tinit.c once. So, optimization is not critical.
|
||||
noinst_PROGRAMS = H5detect H5make_libsettings
|
||||
|
||||
# Our main target, the HDF5 library
|
||||
lib_LTLIBRARIES=libhdf5.la
|
||||
|
||||
# Add libtool numbers to the HDF5 library (from config/lt_vers.am)
|
||||
libhdf5_la_LDFLAGS= -version-info $(LT_VERS_INTERFACE):$(LT_VERS_REVISION):$(LT_VERS_AGE) $(AM_LDFLAGS)
|
||||
|
||||
# H5Tinit.c and H5lib_settings.c are generated files and should be cleaned.
|
||||
MOSTLYCLEANFILES=H5Tinit.c H5lib_settings.c $(DX_CLEANFILES)
|
||||
# H5pubconf.h is generated by configure, and should be cleaned.
|
||||
DISTCLEANFILES=H5pubconf.h
|
||||
# These files are generated by configure, and should be cleaned
|
||||
DISTCLEANFILES=H5pubconf.h H5build_settings.c
|
||||
|
||||
# library sources
|
||||
libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \
|
||||
libhdf5_la_SOURCES= H5.c H5build_settings.c H5checksum.c H5dbg.c H5system.c \
|
||||
H5timer.c H5trace.c \
|
||||
H5A.c H5Abtree2.c H5Adense.c H5Adeprec.c H5Aint.c H5Atest.c \
|
||||
H5AC.c H5ACdbg.c H5ACproxy_entry.c \
|
||||
@ -101,7 +93,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5lib_settings.c H5system.c \
|
||||
H5SM.c H5SMbtree2.c H5SMcache.c H5SMmessage.c H5SMtest.c \
|
||||
H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \
|
||||
H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c H5Tfixed.c \
|
||||
H5Tfloat.c H5Tinit.c H5Tnative.c H5Toffset.c H5Toh.c H5Topaque.c \
|
||||
H5Tfloat.c H5Tinit_float.c H5Tnative.c H5Toffset.c H5Toh.c H5Topaque.c \
|
||||
H5Torder.c H5Tref.c H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c \
|
||||
H5Tvlen.c \
|
||||
H5TS.c \
|
||||
@ -187,32 +179,6 @@ endif
|
||||
settingsdir=$(libdir)
|
||||
settings_DATA=libhdf5.settings
|
||||
|
||||
# Number format detection
|
||||
# The LD_LIBRARY_PATH setting is a kludge.
|
||||
# Things should have been all set during H5detect making.
|
||||
# Remove the generated .c file if errors occur unless HDF5_Make_Ignore
|
||||
# is set to ignore the error.
|
||||
H5Tinit.c: H5detect$(EXEEXT)
|
||||
@if $(AM_V_P); then set -x; else echo " GEN H5Tinit.c"; fi; \
|
||||
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
|
||||
sed -e 's/-L/:/g' -e 's/ //g'`" \
|
||||
$(RUNSERIAL) ./H5detect$(EXEEXT) $@ || \
|
||||
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
|
||||
($(RM) $@ ; exit 1)
|
||||
|
||||
# Build configuration header file generation
|
||||
# The LD_LIBRARY_PATH setting is a kludge.
|
||||
# Things should have been all set during H5make_libsettings making.
|
||||
# Remove the generated .c file if errors occur unless HDF5_Make_Ignore
|
||||
# is set to ignore the error.
|
||||
H5lib_settings.c: H5make_libsettings$(EXEEXT) libhdf5.settings
|
||||
@if $(AM_V_P); then set -x; else echo " GEN H5lib_settings.c"; fi; \
|
||||
LD_LIBRARY_PATH="$$LD_LIBRARY_PATH`echo $(LDFLAGS) | \
|
||||
sed -e 's/-L/:/g' -e 's/ //g'`" \
|
||||
$(RUNSERIAL) ./H5make_libsettings$(EXEEXT) $@ || \
|
||||
(test $$HDF5_Make_Ignore && echo "*** Error ignored") || \
|
||||
($(RM) $@ ; exit 1)
|
||||
|
||||
# Error header generation
|
||||
#
|
||||
# Actually, H5Einit.h, H5Eterm.h, H5Edefin.h and H5Epubgen.h all
|
||||
|
Loading…
Reference in New Issue
Block a user