Redo SIZEOF_VOID_P like SIZEOF_POINTER

This commit is contained in:
Boris Kolpackov 2022-09-04 09:33:24 +02:00
parent 6e0ee89374
commit a64598861f
2 changed files with 18 additions and 6 deletions

View File

@ -1,6 +1,6 @@
// SIZEOF_POINTER // SIZEOF_POINTER
/* See also SIZEOF_SIZE_T (the two may not be the same). */ /* See also SIZEOF_SIZE_T (the two may not be the same), SIZEOF_VOID_P. */
#undef SIZEOF_POINTER #undef SIZEOF_POINTER

View File

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