1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/**
* slibc — Yet another C library
* Copyright © 2015 Mattias Andrée (maandree@member.fsf.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _STDDEF_H
#define _STDDEF_H
#include <slibc/version.h>
/**
* `NULL` is a zero-values constant, conventionally
* a `void`-pointer (it is specified this way in
* POSIX, it does not really matter and ISO C does
* not specify it this way), use to indicate that
* a pointer does not point to anything.
*/
#define NULL ((void*)0)
/**
* Get the offset of a member in a `struct`, in bytes.
*
* For example. Consider the structure
* ```
* struct example
* {
* char offset_is_0[16];
* char offset_is_16[16];
* }
* ```
* `offsetof(struct example, offset_is_0)` evaluates to
* 0 because it is at the top of the structure.
* `offsetof(struct example, offset_is_16)` evaluates to
* 16 because the member above it in the structure
* has offset 0 and size 16. 0 + 16 = 16.
*
* @param type:identifier The identifier for a structure.
* @param member:identifier The identifier for a member, direct or indirect,
* of the structure.
* @return :size_t The offset of the member.
*/
#define offsetof(type, member) \
((size_t)((char*)&(((type*)NULL)->member) - (char*)NULL))
#define __NEED_ptrdiff_t
#define __NEED_wchar_t
#define __NEED_size_t
#if __STDC_VERSION__ >= 201112L
# define __NEED_max_align_t
#endif
#include <bits/types.h>
#endif
|