SayoriOS 0.3.3

common.h
См. документацию.
1
9 #pragma once
10
11 #define FALSE 0
12 #define TRUE 1
13
14 #ifndef __cplusplus
15
16 typedef enum {
17 false = 0,
18 true = 1
19 } bool;
20
21 #define nullptr ((void*)0)
22 #define NULL (0)
23
24 #endif
25
26 #define SAYORI_INLINE static inline __attribute__((always_inline))
27
28 #define KB (1 << 10)
29 #define MB (1 << 20)
30 #define GB (1 << 30)
31
32 #define ALIGN(value, align) ((value) + ((-(value)) & ((align) - 1)))
33 #define IS_ALIGNED(value, align) ((value) % (align) == 0)
34
35 /* 64-bit types */
36 typedef unsigned long long uint64_t;
37 typedef long long int64_t;
38 /* 32-bit types */
39 typedef unsigned int uint32_t;
40 typedef int int32_t;
41 /* 16-bit types */
42 typedef unsigned short uint16_t;
43 typedef short int16_t;
44 /* 8-bit types */
45 typedef unsigned char uint8_t;
46 typedef char int8_t;
47
48 #ifdef SAYORI64
49 typedef uint64_t size_t;
50 typedef int64_t ssize_t;
51 #else
52 typedef uint32_t size_t;
53 typedef int32_t ssize_t;
54 #endif
55
56
57
58
59 struct registers {
60 uint32_t ds;
61 uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
62 uint32_t int_num, err_code;
63 uint32_t eip, cs, eflags, useresp, ss;
64 } __attribute__((packed));
65
66 typedef struct registers registers_t;
67
68 // Use ON_NULLPTR macro to tell a user (developer) that he passed a nullptr
69 #ifndef RELEASE
70 #define ON_NULLPTR(ptr, code) \
71 do { \
72 if((ptr) == 0) { \
73 qemu_err("You have an illusion that you see an object but you can't touch it because it's not exist..."); \
74 code \
75 } \
76 } while(0)
77 #else
78 #define ON_NULLPTR(ptr, code)
79 #endif
__attribute__
struct registers __attribute__((packed))
Структура данных пакета от мыши
Definition: psf.h:19
registers
Definition: common.h:59