mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
Use SSIZE_T for ssize_t on Windows (#5811)
The PR adds a compile assert to ensure that size_t and ssize_t have the same size, just to be sure. * Use SSIZE_T for ssize_t on Windows * Use SSIZE_T and SSIZE_T_MAX * Add missing header * Exclude MinGW from ssize_t ifdefs
This commit is contained in:
@@ -154,6 +154,9 @@ H5_init_library(void)
|
||||
*/
|
||||
H5_INIT_GLOBAL = true;
|
||||
|
||||
/* Make sure we picked a good type for ssize_t if it wasn't present */
|
||||
HDcompile_assert(sizeof(size_t) == sizeof(ssize_t));
|
||||
|
||||
#ifdef H5_HAVE_PARALLEL
|
||||
{
|
||||
int mpi_initialized;
|
||||
|
||||
+1
-1
@@ -371,7 +371,7 @@
|
||||
* Only needed where ssize_t isn't a thing (e.g., Windows)
|
||||
*/
|
||||
#ifndef SSIZE_MAX
|
||||
#define SSIZE_MAX ((ssize_t)(((size_t)1 << (8 * sizeof(ssize_t) - 1)) - 1))
|
||||
#define SSIZE_MAX SSIZE_T_MAX
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
+5
-15
@@ -289,21 +289,11 @@ typedef int htri_t;
|
||||
*
|
||||
* Use of ssize_t should be discouraged in new code.
|
||||
*/
|
||||
#if H5_SIZEOF_SSIZE_T == 0
|
||||
/* Undefine this size, we will re-define it in one of the sections below */
|
||||
#undef H5_SIZEOF_SSIZE_T
|
||||
#if H5_SIZEOF_SIZE_T == H5_SIZEOF_INT
|
||||
typedef int ssize_t;
|
||||
#define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT
|
||||
#elif H5_SIZEOF_SIZE_T == H5_SIZEOF_LONG
|
||||
typedef long ssize_t;
|
||||
#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG
|
||||
#elif H5_SIZEOF_SIZE_T == H5_SIZEOF_LONG_LONG
|
||||
typedef long long ssize_t;
|
||||
#define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG
|
||||
#else /* Can't find matching type for ssize_t */
|
||||
#error "nothing appropriate for ssize_t"
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
/* This will have been defined to 0 in configure */
|
||||
#define H5_SIZEOF_SSIZE_T H5_SIZEOF_SIZE_T
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user