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