6 #define va_list __builtin_va_list
8 #define va_rounded_size(type) \
9 (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
11 #define va_start(v,l) __builtin_va_start(v,l)
12 #define va_end(v) __builtin_va_end(v)
13 #define va_arg(v,l) __builtin_va_arg(v,l)
15 #define NULL ((void *) 0)
17 typedef unsigned char uint8_t;
18 typedef unsigned short uint16_t;
19 typedef unsigned int uint32_t;
20 typedef unsigned short wchar_t;
21 typedef unsigned long size_t;
23 // these are defined in libc-asm.asm
24 void *memcpy(void *dest
, void *src
, size_t count
);
25 void *memmove(void *dest
, void *src
, size_t count
);
26 void *memset(void *dest
, int val
, size_t count
);
27 int memcmp(const void *src1
, const void *src2
, size_t count
);
28 wchar_t *wmemset(wchar_t *dest
, wchar_t val
, size_t count
);
29 size_t strlen(const char *str
);
31 // these are defined in general.c
32 int strcmp(const char *str1
, const char *str2
);
33 void panic_internal(const char *file
, int line
, const char *fmt
, ...);
34 #define panic(...) panic_internal(__FILE__, __LINE__, __VA_ARGS__)
36 // these are defined in sprintf.c
37 int vsnprintf(char *buffer
, size_t n
, const char *fmt
, va_list ap
);
38 int snprintf(char *str
, size_t n
, const char *fmt
, ...);
39 int vsprintf(char *str
, const char *fmt
, va_list ap
);
40 int sprintf(char *str
, const char *fmt
, ...);
42 // these are defined in math.c
46 // these are defined in mp_tables.c
47 void parse_mp_tables(void);
49 static inline void outb(int port
, uint8_t value
)
51 asm volatile ("outb %%al,%%dx" :: "a" (value
), "d" (port
));
54 static inline void outw(int port
, uint16_t value
)
56 asm volatile ("outw %%ax,%%dx" :: "a" (value
), "d" (port
));
59 static inline void outl(int port
, uint32_t value
)
61 asm volatile ("outl %%eax,%%dx" :: "a" (value
), "d" (port
));
64 static inline uint8_t inb(int port
)
67 asm volatile ("inb %%dx,%%al" : "=a" (value
) : "d" (port
));
71 static inline uint16_t inw(int port
)
74 asm volatile ("inw %%dx,%%ax" : "=a" (value
) : "d" (port
));
78 static inline uint32_t inl(int port
)
81 asm volatile ("inl %%dx,%%eax" : "=a" (value
) : "d" (port
));
85 static inline void cli(void)
90 static inline void sti(void)
95 static inline void hlt(void)