Use compiler builtins for NK_OFFSETOF when possible
This commit is contained in:
parent
6322f53cb5
commit
ebdb341750
21
nuklear.h
21
nuklear.h
@ -5697,12 +5697,10 @@ struct nk_context {
|
|||||||
#define NK_ALIGN_PTR_BACK(x, mask)\
|
#define NK_ALIGN_PTR_BACK(x, mask)\
|
||||||
(NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
|
(NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
|
||||||
|
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
|
||||||
|
#else
|
||||||
#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
|
#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
|
||||||
#define NK_CONTAINER_OF(ptr,type,member)\
|
|
||||||
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -5712,12 +5710,18 @@ template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};}
|
|||||||
template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
|
template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
|
||||||
diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
|
diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
|
||||||
#define NK_ALIGNOF(t) (nk_alignof<t>::value)
|
#define NK_ALIGNOF(t) (nk_alignof<t>::value)
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define NK_ALIGNOF(t) (__alignof(t))
|
|
||||||
#else
|
#else
|
||||||
#define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
|
#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NK_CONTAINER_OF(ptr,type,member)\
|
||||||
|
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* NK_NUKLEAR_H_ */
|
#endif /* NK_NUKLEAR_H_ */
|
||||||
|
|
||||||
#ifdef NK_IMPLEMENTATION
|
#ifdef NK_IMPLEMENTATION
|
||||||
@ -29525,6 +29529,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|||||||
/// - [yy]: Minor version with non-breaking API and library changes
|
/// - [yy]: Minor version with non-breaking API and library changes
|
||||||
/// - [zz]: Bug fix version with no direct changes to API
|
/// - [zz]: Bug fix version with no direct changes to API
|
||||||
///
|
///
|
||||||
|
/// - 2021/09/08 (4.08.1) - Use compiler builtins for NK_OFFSETOF when possible
|
||||||
/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
|
/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
|
||||||
/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
|
/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
|
||||||
/// - 2021/08/15 (4.07.4) - Fix conversion and sign conversion warnings
|
/// - 2021/08/15 (4.07.4) - Fix conversion and sign conversion warnings
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nuklear",
|
"name": "nuklear",
|
||||||
"version": "4.08.0",
|
"version": "4.08.1",
|
||||||
"repo": "Immediate-Mode-UI/Nuklear",
|
"repo": "Immediate-Mode-UI/Nuklear",
|
||||||
"description": "A small ANSI C gui toolkit",
|
"description": "A small ANSI C gui toolkit",
|
||||||
"keywords": ["gl", "ui", "toolkit"],
|
"keywords": ["gl", "ui", "toolkit"],
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
/// - [yy]: Minor version with non-breaking API and library changes
|
/// - [yy]: Minor version with non-breaking API and library changes
|
||||||
/// - [zz]: Bug fix version with no direct changes to API
|
/// - [zz]: Bug fix version with no direct changes to API
|
||||||
///
|
///
|
||||||
|
/// - 2021/09/08 (4.08.1) - Use compiler builtins for NK_OFFSETOF when possible
|
||||||
/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
|
/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
|
||||||
/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
|
/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
|
||||||
/// - 2021/08/15 (4.07.4) - Fix conversion and sign conversion warnings
|
/// - 2021/08/15 (4.07.4) - Fix conversion and sign conversion warnings
|
||||||
|
@ -5476,12 +5476,10 @@ struct nk_context {
|
|||||||
#define NK_ALIGN_PTR_BACK(x, mask)\
|
#define NK_ALIGN_PTR_BACK(x, mask)\
|
||||||
(NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
|
(NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
|
||||||
|
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
|
||||||
|
#else
|
||||||
#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
|
#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
|
||||||
#define NK_CONTAINER_OF(ptr,type,member)\
|
|
||||||
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -5491,10 +5489,16 @@ template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};}
|
|||||||
template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
|
template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
|
||||||
diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
|
diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
|
||||||
#define NK_ALIGNOF(t) (nk_alignof<t>::value)
|
#define NK_ALIGNOF(t) (nk_alignof<t>::value)
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define NK_ALIGNOF(t) (__alignof(t))
|
|
||||||
#else
|
#else
|
||||||
#define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
|
#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define NK_CONTAINER_OF(ptr,type,member)\
|
||||||
|
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* NK_NUKLEAR_H_ */
|
#endif /* NK_NUKLEAR_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user