SyterKit
0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
include
arch
riscv
stddef.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0+ */
2
3
#ifndef __STDDEF_H__
4
#define __STDDEF_H__
5
6
#ifdef __cplusplus
7
extern
"C"
{
8
#endif
9
27
#if defined(__cplusplus)
28
#define NULL (0)
29
#else
30
#define NULL ((void *) 0)
31
#endif
32
44
#if (defined(__GNUC__) && (__GNUC__ >= 4))
45
#define offsetof(type, member) __builtin_offsetof(type, member)
46
#else
47
#define offsetof(type, field) ((size_t) (&((type *) 0)->field))
48
#endif
49
63
#define container_of(ptr, type, member) \
64
({ \
65
const typeof(((type *) 0)->member) *__mptr = (ptr); \
66
(type *) ((char *) __mptr - offsetof(type, member)); \
67
})
68
79
#if (defined(__GNUC__) && (__GNUC__ >= 3))
80
#define likely(expr) (__builtin_expect(!!(expr), 1))
81
#define unlikely(expr) (__builtin_expect(!!(expr), 0))
82
#else
83
#define likely(expr) (!!(expr))
84
#define unlikely(expr) (!!(expr))
85
#endif
86
97
#define min(a, b) (((a) < (b)) ? (a) : (b))
98
109
#define max(a, b) (((a) > (b)) ? (a) : (b))
110
123
#define clamp(v, a, b) min(max(a, v), b)
124
135
#define ifloor(x) ((x) > 0 ? (int) (x) : (int) ((x) -0.9999999999))
136
147
#define iround(x) ((x) > 0 ? (int) ((x) + 0.5) : (int) ((x) -0.5))
148
158
#define iceil(x) ((x) > 0 ? (int) ((x) + 0.9999999999) : (int) (x))
159
170
#define idiv255(x) ((((int) (x) + 1) * 257) >> 16)
171
172
#ifdef __cplusplus
173
}
174
#endif
175
176
#endif
/* __STDDEF_H__ */
Generated by
1.9.8