Use the appropriate version of alignof

This commit is contained in:
Valeri
2023-12-01 04:19:47 +03:00
committed by GitHub
parent c6e58bd44a
commit 45cf4710c4

View File

@@ -8,6 +8,10 @@
#ifndef cglm_types_h #ifndef cglm_types_h
#define cglm_types_h #define cglm_types_h
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
# include <stdalign.h>
#endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
/* do not use alignment for older visual studio versions */ /* do not use alignment for older visual studio versions */
# if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */ # if _MSC_VER < 1913 /* Visual Studio 2017 version 15.6 */
@@ -57,8 +61,16 @@
# define CGLM_ASSUME_ALIGNED(expr, alignment) (expr) # define CGLM_ASSUME_ALIGNED(expr, alignment) (expr)
#endif #endif
#define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type))) # define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), alignof(type)))
#elif defined(_MSC_VER)
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof(type)))
#else
# define CGLM_CASTPTR_ASSUME_ALIGNED(expr, type) \
((type*)CGLM_ASSUME_ALIGNED((expr), __alignof__(type)))
#endif
typedef int ivec2[2]; typedef int ivec2[2];
typedef int ivec3[3]; typedef int ivec3[3];