commit f1cac449f1fb07c9f386e5be8903b61520fde283 parent b63d9f5515e037e4638a1c8b7e1d31b3da28f15a Author: Evgeny Grin (Karlson2k) <k2k@drgrin.dev> Date: Sun, 19 Jul 2026 11:37:28 +0200 mhd_sys_options.h: added new portability macro Diffstat:
| M | src/incl_priv/mhd_sys_options.h | | | 18 | ++++++++++++++++++ |
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/incl_priv/mhd_sys_options.h b/src/incl_priv/mhd_sys_options.h @@ -463,6 +463,24 @@ # define mhd_UINT_TO_PTR(i) ((void *) (i)) #endif +/** + * Cast a pointer to an integer + * + * The result type is platform-dependent and may be signed. + */ +#if defined(HAVE_UINTPTR_T) +# define mhd_PTR_TO_INT(p) ((uintptr_t) ((const void*)(p))) +#elif defined(HAVE_INTPTR_T) +# define mhd_PTR_TO_INT(p) ((intptr_t) ((const void*)(p))) +#elif (0 != SIZEOF_VOIDP) && (SIZEOF_VOIDP == SIZEOF_UNSIGNED_LONG) +# define mhd_PTR_TO_INT(p) ((unsigned long)((const void*)(p))) +#elif (0 != SIZEOF_VOIDP) && (SIZEOF_VOIDP == SIZEOF_UNSIGNED_INT) +# define mhd_PTR_TO_INT(p) ((unsigned int) ((const void*)(p))) +#else +# define mhd_PTR_TO_INT(p) ((unsigned long long)((const void*)(p))) +#endif + + /* *************************************************************** * * Macros to enable various features in the system headers * * *************************************************************** */