Merge branch 'master' of github.com:Minep/lunaix-os
[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 <stdarg.h>
6 #include <usr/lunaix/types.h>
7
8 #define PACKED __attribute__((packed))
9
10 // TODO: WTERMSIG
11
12 // TODO: replace the integer type with these. To make thing more portable.
13
14 typedef unsigned char u8_t;
15 typedef unsigned short u16_t;
16 typedef unsigned int u32_t;
17 typedef unsigned long long u64_t;
18 typedef unsigned long ptr_t;
19
20 typedef int pid_t;
21 typedef signed long ssize_t;
22 // typedef unsigned long size_t;
23 // typedef unsigned long off_t;
24
25 typedef unsigned int cpu_t;
26
27 typedef u64_t lba_t;
28
29 #define true 1
30 #define false 0
31 typedef int bool;
32
33 /**
34  * container_of - cast a member of a structure out to the containing structure
35  *
36  * @ptr:        the pointer to the member.
37  * @type:       the type of the container struct this is embedded in.
38  * @member:     the name of the member within the struct.
39  *
40  */
41 #define container_of(ptr, type, member)                                        \
42     ({                                                                         \
43         const typeof(((type*)0)->member)* __mptr = (ptr);                      \
44         (ptr) ? (type*)((char*)__mptr - offsetof(type, member)) : 0;           \
45     })
46
47 #endif /* __LUNAIX_TYPES_H */