fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / includes / lunaix / types.h
1 #ifndef __LUNAIX_TYPES_H
2 #define __LUNAIX_TYPES_H
3
4 #include <stdarg.h>
5 #include <lunaix/compiler.h>
6 #include <lunaix/limits.h>
7 #include <usr/lunaix/types.h>
8
9 #undef  NULL
10 #define NULL                (void*)0
11
12 typedef unsigned char       u8_t;
13 typedef unsigned short      u16_t;
14 typedef unsigned int        u32_t;
15
16 #ifndef CONFIG_ARCH_BITS_64
17 typedef unsigned long long  u64_t;
18 #else
19 typedef unsigned long       u64_t;
20 #endif
21
22 typedef __lunaix_pid_t      pid_t;
23 typedef __lunaix_tid_t      tid_t;
24 typedef __lunaix_uid_t      uid_t;
25 typedef __lunaix_gid_t      gid_t;
26 typedef __lunaix_size_t     size_t;
27 typedef __lunaix_ssize_t    ssize_t;
28 typedef __lunaix_size_t     off_t;
29 typedef __lunaix_ino_t      ino_t;
30
31 typedef unsigned long       ptr_t;
32 typedef unsigned long       reg_t;
33 typedef unsigned int        cpu_t;
34 typedef u64_t               lba_t;
35
36 typedef __lunaix_dev_t      dev_t;
37
38 #define true 1
39 #define false 0
40 typedef int bool;
41
42 /**
43  * container_of - cast a member of a structure out to the containing structure
44  *
45  * @ptr:        the pointer to the member.
46  * @type:       the type of the container struct this is embedded in.
47  * @member:     the name of the member within the struct.
48  *
49  */
50 #define container_of(ptr, type, member)                                        \
51     ({                                                                         \
52         const typeof(((type*)0)->member)* __mptr = (ptr);                      \
53         ((ptr_t)ptr != 0UL) ? (type*)((char*)__mptr - offsetof(type, member)) : 0;           \
54     })
55
56 #define offset(data, off)   \
57             ((typeof(data))(__ptr(data) + (off)))
58
59 #define offset_t(data, type, off)   \
60             ((type*)(__ptr(data) + (off)))
61
62 #define __ptr(val)      ((ptr_t)(val))
63
64 typedef va_list* sc_va_list;
65
66 #endif /* __LUNAIX_TYPES_H */