SayoriOS 0.3.3

portability.h
1 #pragma once
2
3 #include "mem/vmm.h"
4 #include "lib/stdlib.h"
5
6 #define malloc(a) kmalloc(a)
7 #define calloc(a, b) kcalloc(a, b)
8 #define realloc(a, b) krealloc(a, b)
9 #define free(a) kfree(a)
10 #define printf(a, ...) qemu_printf(a, ##__VA_ARGS__)
11
12
13 #define passert(expression) \
14 if (!(expression)) { \
15 qemu_warn("Assertion failed: file %s, line %d\n", __FILE__, __LINE__); \
16 }
17
18 // stdint.h
19
20 #define INT_FAST16_MIN (-2147483647-1)
21 #define INT_FAST32_MIN (-2147483647-1)
22 #define INT_FAST16_MAX (2147483647)
23 #define INT_FAST32_MAX (2147483647)
24 #define UINT_FAST16_MAX (4294967295U)
25 #define UINT_FAST32_MAX (4294967295U)
26 #define SIZE_MAX (4294967295U)
27
28 #define INT32_MIN (-INT32_MAX-1)
29 #define INT32_MAX 2147483647
30
31 #define INT_MIN (-INT_MAX - 1)
32 #define INT_MAX 2147483647
33
34 #define UINT_MAX 4294967295U
35
36 #define UINT32_MAX (4294967295U)
37
38
39 // bits/types.h
40
41 typedef signed char __int8_t;
42 typedef unsigned char __uint8_t;
43 typedef signed short int __int16_t;
44 typedef unsigned short int __uint16_t;
45 typedef signed int __int32_t;
46 typedef unsigned int __uint32_t;
47 typedef unsigned long long __uint64_t;
48 typedef long long __int64_t;
49
50 typedef __int8_t __int_least8_t;
51 typedef __uint8_t __uint_least8_t;
52 typedef __int16_t __int_least16_t;
53 typedef __uint16_t __uint_least16_t;
54 typedef __int32_t __int_least32_t;
55 typedef __uint32_t __uint_least32_t;
56 typedef __int64_t __int_least64_t;
57 typedef __uint64_t __uint_least64_t;
58
59 // stdint.h
60 typedef __int_least8_t int_least8_t;
61 typedef __int_least16_t int_least16_t;
62 typedef __int_least32_t int_least32_t;
63 typedef __int_least64_t int_least64_t;
64
65
66 typedef __uint_least8_t uint_least8_t;
67 typedef __uint_least16_t uint_least16_t;
68 typedef __uint_least32_t uint_least32_t;
69 typedef __uint_least64_t uint_least64_t;
70
71 typedef signed char int_fast8_t;
72 typedef int int_fast16_t;
73 typedef int int_fast32_t;
74
75 typedef uint8_t uint_fast8_t;
76 typedef uint32_t uint_fast16_t;
77 typedef uint32_t uint_fast32_t;
78
79 typedef int intptr_t;
80 typedef unsigned int uintptr_t;
81
82 __extension__ typedef long long int __intmax_t;
83 __extension__ typedef unsigned long long int __uintmax_t;
84
85 typedef __intmax_t intmax_t;
86 typedef __uintmax_t uintmax_t;
87
88
89 typedef __uint_least64_t uint_least64_t;
90 typedef __int_least64_t int_least64_t;
91
92 typedef long long int int_fast64_t;
93 typedef unsigned long long int uint_fast64_t;
94
95 // bits/types/struct_tm.h
96
97 struct tm {
98 int tm_sec; /* Seconds. [0-60] (1 leap second) */
99 int tm_min; /* Minutes. [0-59] */
100 int tm_hour; /* Hours. [0-23] */
101 int tm_mday; /* Day. [1-31] */
102 int tm_mon; /* Month. [0-11] */
103 int tm_year; /* Year - 1900. */
104 int tm_wday; /* Day of week. [0-6] */
105 int tm_yday; /* Days in year.[0-365] */
106 int tm_isdst; /* DST. [-1/0/1]*/
107
108 long int __tm_gmtoff; /* Seconds east of UTC. */
109 const char *__tm_zone; /* Timezone abbreviation. */
110 };
111
112 typedef int32_t time_t;
tm
Definition: portability.h:97