Add SIZEOF_{LONG,POINTER,SIZE_T} checks

This commit is contained in:
Boris Kolpackov 2022-04-24 11:12:35 +02:00
parent 8e969c04e2
commit fba5138c0d
3 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// SIZEOF_LONG
#undef SIZEOF_LONG
#ifdef _MSC_VER
# define SIZEOF_LONG 4
#else
/* Both GCC and Clang (and maybe others) define __SIZEOF_LONG__. */
# ifdef __SIZEOF_LONG__
# define SIZEOF_LONG __SIZEOF_LONG__
# endif
#endif
#ifndef SIZEOF_LONG
# error unable to determine size of long int
#endif

View File

@ -0,0 +1,23 @@
// SIZEOF_POINTER
/* See also SIZEOF_SIZE_T (the two may not be the same). */
#undef SIZEOF_POINTER
#ifdef _MSC_VER
/* _WIN64 is defined for both x64 (x86_64) and ARM64 (aarch64). */
# ifdef _WIN64
# define SIZEOF_POINTER 8
# else
# define SIZEOF_POINTER 4
# endif
#else
/* Both GCC and Clang (and maybe others) define __SIZEOF_POINTER__. */
# ifdef __SIZEOF_POINTER__
# define SIZEOF_POINTER __SIZEOF_POINTER__
# endif
#endif
#ifndef SIZEOF_POINTER
# error unable to determine size of pointer
#endif

View File

@ -0,0 +1,23 @@
// SIZEOF_SIZE_T
/* See also SIZEOF_POINTER (the two may not be the same). */
#undef SIZEOF_SIZE_T
#ifdef _MSC_VER
/* _WIN64 is defined for both x64 (x86_64) and ARM64 (aarch64). */
# ifdef _WIN64
# define SIZEOF_SIZE_T 8
# else
# define SIZEOF_SIZE_T 4
# endif
#else
/* Both GCC and Clang (and maybe others) define __SIZEOF_SIZE_T__. */
# ifdef __SIZEOF_SIZE_T__
# define SIZEOF_SIZE_T __SIZEOF_SIZE_T__
# endif
#endif
#ifndef SIZEOF_SIZE_T
# error unable to determine size of size_t
#endif