diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:06:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:06:04 +0000 |
commit | 2f0649f6fe411d7e07c8d56cf8ea56db53536da8 (patch) | |
tree | 778611fb52176dce1ad06c68e87b2cb348ca0f7b /usr/include/stddef.h | |
parent | Initial commit. (diff) | |
download | klibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.tar.xz klibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.zip |
Adding upstream version 2.0.13.upstream/2.0.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'usr/include/stddef.h')
-rw-r--r-- | usr/include/stddef.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/usr/include/stddef.h b/usr/include/stddef.h new file mode 100644 index 0000000..6811451 --- /dev/null +++ b/usr/include/stddef.h @@ -0,0 +1,54 @@ +/* + * stddef.h + */ + +#ifndef _STDDEF_H +#define _STDDEF_H + +#ifndef __KLIBC__ +# error "__KLIBC__ not defined, compiler invocation error!" +#endif + +/* + * __SIZE_TYPE__ and __PTRDIFF_TYPE__ are defined by GCC and + * many other compilers to what types the ABI expects on the + * target platform for size_t and ptrdiff_t, so we use these + * for size_t, ssize_t, ptrdiff_t definitions, if available; + * fall back to unsigned long, which is correct on ILP32 and + * LP64 platforms (Linux does not have any others) otherwise. + * + * Note: the order "long unsigned int" precisely matches GCC. + */ +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ long unsigned int +#endif + +#ifndef __PTRDIFF_TYPE__ +#define __PTRDIFF_TYPE__ long int +#endif + +#define _SIZE_T +typedef __SIZE_TYPE__ size_t; + +#define _PTRDIFF_T +typedef __PTRDIFF_TYPE__ ptrdiff_t; + +#undef NULL +#ifdef __cplusplus +# define NULL 0 +#else +# define NULL ((void *)0) +#endif + +#undef offsetof +#define offsetof(t,m) ((size_t)&((t *)0)->m) + +/* + * The container_of construct: if p is a pointer to member m of + * container class c, then return a pointer to the container of which + * *p is a member. + */ +#undef container_of +#define container_of(p, c, m) ((c *)((char *)(p) - offsetof(c,m))) + +#endif /* _STDDEF_H */ |