basic user, group and capability housekeeping.
[lunaix-os.git] / lunaix-os / includes / lunaix / types.h
1 #ifndef __LUNAIX_TYPES_H
2 #define __LUNAIX_TYPES_H
3
4 #include <lunaix/compiler.h>
5 #include <lunaix/limits.h>
6 #include <stdarg.h>
7 #include <usr/lunaix/types.h>
8
9 // TODO: WTERMSIG
10
11 // TODO: replace the integer type with these. To make thing more portable.
12
13 typedef unsigned char u8_t;
14 typedef unsigned short u16_t;
15 typedef unsigned int u32_t;
16 typedef unsigned long ptr_t;
17 typedef unsigned long reg_t;
18
19 typedef unsigned int uid_t;
20 typedef unsigned int gid_t;
21
22 #ifndef CONFIG_ARCH_BITS_64
23 typedef unsigned long long u64_t;
24 #else
25 typedef unsigned long u64_t;
26 #endif
27
28 typedef int pid_t;
29 typedef signed long ssize_t;
30
31 typedef unsigned int cpu_t;
32
33 typedef u64_t lba_t;
34
35 #define true 1
36 #define false 0
37 typedef int bool;
38
39 /**
40  * container_of - cast a member of a structure out to the containing structure
41  *
42  * @ptr:        the pointer to the member.
43  * @type:       the type of the container struct this is embedded in.
44  * @member:     the name of the member within the struct.
45  *
46  */
47 #define container_of(ptr, type, member)                                        \
48     ({                                                                         \
49         const typeof(((type*)0)->member)* __mptr = (ptr);                      \
50         ((ptr_t)ptr != 0UL) ? (type*)((char*)__mptr - offsetof(type, member)) : 0;           \
51     })
52
53 #define offset(data, off)   \
54             ((typeof(data))(__ptr(data) + (off)))
55
56 #define offset_t(data, type, off)   \
57             ((type*)(__ptr(data) + (off)))
58
59 #define __ptr(val)      ((ptr_t)(val))
60
61 typedef va_list* sc_va_list;
62
63 #endif /* __LUNAIX_TYPES_H */