summaryrefslogtreecommitdiffstats
path: root/config/cmake
diff options
context:
space:
mode:
authorSean <sean@rogue-research.com>2021-02-15 21:23:43 (GMT)
committerGitHub <noreply@github.com>2021-02-15 21:23:43 (GMT)
commitca6a26225db56108a40472a1d4d7af090668cfb9 (patch)
treee277b6221085e60be473af699fc0015ec2ad13a6 /config/cmake
parent52ac74689a869b4ae40801e6096a1f037aad0081 (diff)
downloadhdf5-ca6a26225db56108a40472a1d4d7af090668cfb9.zip
hdf5-ca6a26225db56108a40472a1d4d7af090668cfb9.tar.gz
hdf5-ca6a26225db56108a40472a1d4d7af090668cfb9.tar.bz2
Detect correct long double size with universal binaires (#335)
On macOS on x86_64, long double is 16 bytes; on macOS on arm64, it's 8 bytes. Use the same existing technique used to properly detect other sizes to now also properly detect the size of long double. For bug #311.
Diffstat (limited to 'config/cmake')
-rw-r--r--config/cmake/H5pubconf.h.in23
1 files changed, 19 insertions, 4 deletions
diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in
index 1256cf8..5ebf629 100644
--- a/config/cmake/H5pubconf.h.in
+++ b/config/cmake/H5pubconf.h.in
@@ -605,6 +605,7 @@
#cmakedefine H5_SIZEOF_INT_LEAST8_T @H5_SIZEOF_INT_LEAST8_T@
#if !defined(__APPLE__)
+
/* The size of `size_t', as computed by sizeof. */
#cmakedefine H5_SIZEOF_SIZE_T @H5_SIZEOF_SIZE_T@
@@ -614,8 +615,17 @@
/* The size of `long', as computed by sizeof. */
#cmakedefine H5_SIZEOF_LONG @H5_SIZEOF_LONG@
+/* The size of `long double', as computed by sizeof. */
+#cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@
+
#else
- # if defined(__LP64__) && __LP64__
+
+ /* On Apple, to support Universal Binaries (where multiple CPU
+ architectures exist in one library/executable), we can't assume
+ the machine doing the compiling has the same endianness or type
+ sizes as all the various architectures (PowerPC, Intel, ARM). */
+
+ # if defined(__LP64__) && __LP64__
#define H5_SIZEOF_LONG 8
#define H5_SIZEOF_SIZE_T 8
#define H5_SIZEOF_SSIZE_T 8
@@ -625,10 +635,15 @@
#define H5_SIZEOF_SSIZE_T 4
# endif
-#endif
+ # if defined(__i386__) || defined(__x86_64__)
+ #define H5_SIZEOF_LONG_DOUBLE 16
+ # elif defined(__aarch64__)
+ #define H5_SIZEOF_LONG_DOUBLE 8
+ # else
+ #cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@
+ # endif
-/* The size of `long double', as computed by sizeof. */
-#cmakedefine H5_SIZEOF_LONG_DOUBLE @H5_SIZEOF_LONG_DOUBLE@
+#endif
/* Define size of long long and/or __int64 bit integer type only if the type
exists. */