diff --git a/arch/x86/gdt.c b/arch/x86/gdt.c index 769eae1..25b8512 100644 --- a/arch/x86/gdt.c +++ b/arch/x86/gdt.c @@ -19,6 +19,8 @@ */ #include "segment.h" #include "gdt.h" +#include "stddef.h" +#include "stdint.h" /** * The sructure of a segment descriptor. diff --git a/arch/x86/idt.c b/arch/x86/idt.c index 063611d..7b35900 100644 --- a/arch/x86/idt.c +++ b/arch/x86/idt.c @@ -1,4 +1,6 @@ #include "idt.h" +#include "stddef.h" + static struct idtEntry idt[IDT_NUM]; int idtSetup() diff --git a/arch/x86/idt.h b/arch/x86/idt.h index 79730c3..51510f6 100644 --- a/arch/x86/idt.h +++ b/arch/x86/idt.h @@ -1,5 +1,5 @@ #pragma once -#include "stdarg.h" +#include "stdint.h" #define IDT_NUM 256 diff --git a/core/alloc.h b/core/alloc.h index d64b528..174a325 100644 --- a/core/alloc.h +++ b/core/alloc.h @@ -1,6 +1,7 @@ #pragma once #include "paging.h" -#include "stdarg.h" +#include "stddef.h" +#include "types.h" /* * Initialize malloc system diff --git a/core/allocArea.h b/core/allocArea.h index 1b21709..4ceda6e 100644 --- a/core/allocArea.h +++ b/core/allocArea.h @@ -1,6 +1,7 @@ #pragma once #include "paging.h" #include "stdarg.h" +#include "stdint.h" /* Pure Virtual Memory Allocation */ diff --git a/core/cpu_context.h b/core/cpu_context.h index 936eaa9..945b87d 100644 --- a/core/cpu_context.h +++ b/core/cpu_context.h @@ -27,7 +27,8 @@ */ #include "errno.h" -#include "stdarg.h" +#include "stddef.h" +#include "stdint.h" #include "types.h" /** diff --git a/core/io.h b/core/io.h index f153d3b..7993719 100644 --- a/core/io.h +++ b/core/io.h @@ -1,5 +1,5 @@ #pragma once -#include "stdarg.h" +#include "stdint.h" // NIH http://wiki.osdev.org/Inline_Assembly/Examples#I.2FO_access static inline void outb(uint16_t port, uint8_t val) diff --git a/core/klibc.h b/core/klibc.h index f5129c6..8b59f20 100644 --- a/core/klibc.h +++ b/core/klibc.h @@ -1,6 +1,7 @@ #pragma once #include "assert.h" #include "stdarg.h" +#include "stddef.h" #include "minmax.h" #define islower(c) (('a' <= (c)) && ((c) <= 'z')) diff --git a/core/math.h b/core/math.h index db179ce..35ad040 100644 --- a/core/math.h +++ b/core/math.h @@ -1,5 +1,5 @@ #pragma once -#include "stdarg.h" +#include "stdint.h" #include "types.h" uint32_t log2(uint32_t x); diff --git a/core/mem.h b/core/mem.h index 216fbb8..bead0d8 100644 --- a/core/mem.h +++ b/core/mem.h @@ -1,5 +1,5 @@ #pragma once -#include "stdarg.h" +#include "stdint.h" #include "types.h" /** Physical Page related function diff --git a/core/mmuContext.h b/core/mmuContext.h index 8bb73a0..337884f 100644 --- a/core/mmuContext.h +++ b/core/mmuContext.h @@ -1,5 +1,5 @@ #pragma once -#include "stdarg.h" +#include "stddef.h" struct mmu_context; diff --git a/core/stdarg.h b/core/stdarg.h index 7c40c3c..004bf26 100644 --- a/core/stdarg.h +++ b/core/stdarg.h @@ -1,55 +1,5 @@ #pragma once -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#ifdef __GNUC__ -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#else -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif - -/* sysv */ -typedef unsigned char unchar; -typedef unsigned short ushort; -typedef unsigned int uint; -typedef unsigned long ulong; - -typedef __s8 int8_t; -typedef __s16 int16_t; -typedef __s32 int32_t; - -typedef __u8 uint8_t; -typedef __u16 uint16_t; -typedef __u32 uint32_t; - -typedef __u64 uint64_t; -typedef __u64 u_int64_t; -typedef __s64 int64_t; - -typedef enum { FALSE = 0, TRUE } bool_t; -#define NULL ((void *)0) - -#if __x86_64__ -typedef unsigned long size_t; -typedef long ssize_t; -typedef unsigned long int uintptr_t; -typedef long int intptr_t; -#else -typedef unsigned int size_t; -typedef int ssize_t; -typedef unsigned int uintptr_t; -typedef int intptr_t; -#endif - //__builtin_va_list could be used instead typedef char *va_list; #define va_start(v, l) ((v) = (va_list) & (l) + sizeof(l)) diff --git a/core/stddef.h b/core/stddef.h new file mode 100644 index 0000000..d14c15a --- /dev/null +++ b/core/stddef.h @@ -0,0 +1,29 @@ +#pragma once + +typedef enum { FALSE = 0, TRUE } bool_t; +#define NULL ((void *)0) + +#if __x86_64__ +typedef unsigned long size_t; +typedef long ssize_t; +typedef unsigned long int uintptr_t; +typedef long int intptr_t; +#else +typedef unsigned int size_t; +typedef int ssize_t; +typedef unsigned int uintptr_t; +typedef int intptr_t; +#endif +#if __x86_64__ +typedef unsigned long size_t; +typedef long ssize_t; +typedef unsigned long int uintptr_t; +typedef long int intptr_t; +#else +typedef unsigned int size_t; +typedef int ssize_t; +typedef unsigned int uintptr_t; +typedef int intptr_t; +#endif + +typedef int wchar_t; diff --git a/core/stdint.h b/core/stdint.h new file mode 100644 index 0000000..70be36a --- /dev/null +++ b/core/stdint.h @@ -0,0 +1,64 @@ +#pragma once + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +#ifdef __GNUC__ +__extension__ typedef __signed__ long long __s64; +__extension__ typedef unsigned long long __u64; +#else +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +/* sysv */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +typedef __s8 int8_t; +typedef __s16 int16_t; +typedef __s32 int32_t; + +typedef __u8 uint8_t; +typedef __u16 uint16_t; +typedef __u32 uint32_t; + +typedef __u64 uint64_t; +typedef __u64 u_int64_t; +typedef __s64 int64_t; + +#define USHRT_MAX ((u16)(~0U)) +#define SHRT_MAX ((s16)(USHRT_MAX >> 1)) +#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) +#define INT_MAX ((int)(~0U >> 1)) +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (~0U) +#define LONG_MAX ((long)(~0UL >> 1)) +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX (~0UL) +#define LLONG_MAX ((long long)(~0ULL >> 1)) +#define LLONG_MIN (-LLONG_MAX - 1) +#define ULLONG_MAX (~0ULL) +#define SIZE_MAX (~(size_t)0) +#define PHYS_ADDR_MAX (~(phys_addr_t)0) + +#define U8_MAX ((u8)~0U) +#define S8_MAX ((s8)(U8_MAX >> 1)) +#define S8_MIN ((s8)(-S8_MAX - 1)) +#define U16_MAX ((u16)~0U) +#define S16_MAX ((s16)(U16_MAX >> 1)) +#define S16_MIN ((s16)(-S16_MAX - 1)) +#define U32_MAX ((u32)~0U) +#define S32_MAX ((s32)(U32_MAX >> 1)) +#define S32_MIN ((s32)(-S32_MAX - 1)) +#define U64_MAX ((u64)~0ULL) +#define S64_MAX ((s64)(U64_MAX >> 1)) +#define S64_MIN ((s64)(-S64_MAX - 1)) diff --git a/core/time.c b/core/time.c index b08b77d..dd5cec3 100644 --- a/core/time.c +++ b/core/time.c @@ -1,4 +1,6 @@ #include "time.h" +#include "stddef.h" +#include unsigned long volatile jiffies = INITIAL_JIFFIES; diff --git a/core/time.h b/core/time.h index a5a4bdd..cb5c3c6 100644 --- a/core/time.h +++ b/core/time.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "stdint.h" #define HZ 100 /* diff --git a/core/types.h b/core/types.h index 45f0fd0..36eaf27 100644 --- a/core/types.h +++ b/core/types.h @@ -1,32 +1,5 @@ #pragma once -#define USHRT_MAX ((u16)(~0U)) -#define SHRT_MAX ((s16)(USHRT_MAX >> 1)) -#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) -#define INT_MAX ((int)(~0U >> 1)) -#define INT_MIN (-INT_MAX - 1) -#define UINT_MAX (~0U) -#define LONG_MAX ((long)(~0UL >> 1)) -#define LONG_MIN (-LONG_MAX - 1) -#define ULONG_MAX (~0UL) -#define LLONG_MAX ((long long)(~0ULL >> 1)) -#define LLONG_MIN (-LLONG_MAX - 1) -#define ULLONG_MAX (~0ULL) -#define SIZE_MAX (~(size_t)0) -#define PHYS_ADDR_MAX (~(phys_addr_t)0) - -#define U8_MAX ((u8)~0U) -#define S8_MAX ((s8)(U8_MAX >> 1)) -#define S8_MIN ((s8)(-S8_MAX - 1)) -#define U16_MAX ((u16)~0U) -#define S16_MAX ((s16)(U16_MAX >> 1)) -#define S16_MIN ((s16)(-S16_MAX - 1)) -#define U32_MAX ((u32)~0U) -#define S32_MAX ((s32)(U32_MAX >> 1)) -#define S32_MIN ((s32)(-S32_MAX - 1)) -#define U64_MAX ((u64)~0ULL) -#define S64_MAX ((s64)(U64_MAX >> 1)) -#define S64_MIN ((s64)(-S64_MAX - 1)) // Virtual address typedef unsigned long vaddr_t; diff --git a/drivers/vga.h b/drivers/vga.h index 17d37f5..a01e966 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -1,5 +1,5 @@ #pragma once -#include "stdarg.h" +#include "stdint.h" #include "types.h" // https://wiki.osdev.org/Text_UI diff --git a/userspace/libc.h b/userspace/libc.h index 409855c..4e2a4a5 100644 --- a/userspace/libc.h +++ b/userspace/libc.h @@ -1,6 +1,8 @@ #pragma once #include "assert.h" #include "stdarg.h" +#include "stdint.h" +#include "stddef.h" #include "minmax.h" #define islower(c) (('a' <= (c)) && ((c) <= 'z')) diff --git a/userspace/list.h b/userspace/list.h new file mode 100644 index 0000000..5a77f76 --- /dev/null +++ b/userspace/list.h @@ -0,0 +1,189 @@ +/* Copyright (C) 2001 David Decotigny + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. +*/ +#ifndef _SOS_LIST_H_ +#define _SOS_LIST_H_ + +/** + * @file list.h + * + * Circular doubly-linked lists implementation entirely based on C + * macros + */ + +/* *_named are used when next and prev links are not exactly next + and prev. For instance when we have next_in_team, prev_in_team, + prev_global and next_global */ + +#define list_init_named(list, prev, next) ((list) = NULL) + +#define list_singleton_named(list, item, prev, next) \ + ({ \ + (item)->next = (item)->prev = (item); \ + (list) = (item); \ + }) + +#define list_is_empty_named(list, prev, next) ((list) == NULL) + +#define list_is_singleton_named(list, prev, next) \ + (((list) != NULL) && ((list)->prev == (list)->next) && ((list) == (list)->next)) + +#define list_get_head_named(list, prev, next) (list) + +#define list_get_tail_named(list, prev, next) ((list) ? ((list)->prev) : NULL) + +/* Internal macro : insert before the head == insert at tail */ +#define __list_insert_atleft_named(before_this, item, prev, next) \ + ({ \ + (before_this)->prev->next = (item); \ + (item)->prev = (before_this)->prev; \ + (before_this)->prev = (item); \ + (item)->next = (before_this); \ + }) + +/* @note Before_this and item are expected to be valid ! */ +#define list_insert_before_named(list, before_this, item, prev, next) \ + ({ \ + __list_insert_atleft_named(before_this, item, prev, next); \ + if ((list) == (before_this)) \ + (list) = (item); \ + }) + +/** @note After_this and item are expected to be valid ! */ +#define list_insert_after_named(list, after_this, item, prev, next) \ + ({ \ + (after_this)->next->prev = (item); \ + (item)->next = (after_this)->next; \ + (after_this)->next = (item); \ + (item)->prev = (after_this); \ + }) + +#define list_add_head_named(list, item, prev, next) \ + ({ \ + if (list) \ + __list_insert_atleft_named(list, item, prev, next); \ + else \ + list_singleton_named(list, item, prev, next); \ + (list) = (item); \ + }) + +#define list_add_tail_named(list, item, prev, next) \ + ({ \ + if (list) \ + __list_insert_atleft_named(list, item, prev, next); \ + else \ + list_singleton_named(list, item, prev, next); \ + }) + +/** @note NO check whether item really is in list ! */ +#define list_delete_named(list, item, prev, next) \ + ({ \ + if (((item)->next == (item)) && ((item)->prev == (item))) \ + (item)->next = (item)->prev = (list) = NULL; \ + else { \ + (item)->prev->next = (item)->next; \ + (item)->next->prev = (item)->prev; \ + if ((item) == (list)) \ + (list) = (item)->next; \ + (item)->prev = (item)->next = NULL; \ + } \ + }) + +#define list_pop_head_named(list, prev, next) \ + ({ \ + typeof(list) __ret_elt = (list); \ + list_delete_named(list, __ret_elt, prev, next); \ + __ret_elt; \ + }) + +/** Loop statement that iterates through all of its elements, from + head to tail */ +#define list_foreach_forward_named(list, iterator, nb_elements, prev, next) \ + for (nb_elements = 0, (iterator) = (list); \ + (iterator) && (!nb_elements || ((iterator) != (list))); \ + nb_elements++, (iterator) = (iterator)->next) + +/** Loop statement that iterates through all of its elements, from + tail back to head */ +#define list_foreach_backward_named(list, iterator, nb_elements, prev, next) \ + for (nb_elements = 0, (iterator) = list_get_tail_named(list, prev, next); \ + (iterator) && \ + (!nb_elements || ((iterator) != list_get_tail_named(list, prev, next))); \ + nb_elements++, (iterator) = (iterator)->prev) + +#define list_foreach_named list_foreach_forward_named + +/** True when we exitted early from the foreach loop (ie break) */ +#define list_foreach_early_break(list, iterator, nb_elements) \ + ((list) && (((list) != (iterator)) || (((list) == (iterator)) && (nb_elements == 0)))) + +/** Loop statement that also removes the item at each iteration. The + body of the loop is allowed to delete the iterator element from + memory. */ +#define list_collapse_named(list, iterator, prev, next) \ + for (; ({ \ + ((iterator) = (list)); \ + if (list) \ + list_delete_named(list, iterator, prev, next); \ + (iterator); \ + });) + +/* + * the same macros : assume that the prev and next fields are really + * named "prev" and "next" + */ + +#define list_init(list) list_init_named(list, prev, next) + +#define list_singleton(list, item) list_singleton_named(list, item, prev, next) + +#define list_is_empty(list) list_is_empty_named(list, prev, next) + +#define list_is_singleton(list) list_is_singleton_named(list, prev, next) + +#define list_get_head(list) list_get_head_named(list, prev, next) + +#define list_get_tail(list) list_get_tail_named(list, prev, next) + +/* @note Before_this and item are expected to be valid ! */ +#define list_insert_after(list, after_this, item) \ + list_insert_after_named(list, after_this, item, prev, next) + +/* @note After_this and item are expected to be valid ! */ +#define list_insert_before(list, before_this, item) \ + list_insert_before_named(list, before_this, item, prev, next) + +#define list_add_head(list, item) list_add_head_named(list, item, prev, next) + +#define list_add_tail(list, item) list_add_tail_named(list, item, prev, next) + +/* @note NO check whether item really is in list ! */ +#define list_delete(list, item) list_delete_named(list, item, prev, next) + +#define list_pop_head(list) list_pop_head_named(list, prev, next) + +#define list_foreach_forward(list, iterator, nb_elements) \ + list_foreach_forward_named(list, iterator, nb_elements, prev, next) + +#define list_foreach_backward(list, iterator, nb_elements) \ + list_foreach_backward_named(list, iterator, nb_elements, prev, next) + +#define list_foreach list_foreach_forward + +#define list_collapse(list, iterator) list_collapse_named(list, iterator, prev, next) + +#endif /* _SOS_LIST_H_ */ diff --git a/userspace/math.h b/userspace/math.h index db179ce..35ad040 100644 --- a/userspace/math.h +++ b/userspace/math.h @@ -1,5 +1,5 @@ #pragma once -#include "stdarg.h" +#include "stdint.h" #include "types.h" uint32_t log2(uint32_t x); diff --git a/userspace/stdarg.h b/userspace/stdarg.h index 5760def..004bf26 100644 --- a/userspace/stdarg.h +++ b/userspace/stdarg.h @@ -1,55 +1,6 @@ #pragma once -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#ifdef __GNUC__ -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#else -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif - -/* sysv */ -typedef unsigned char unchar; -typedef unsigned short ushort; -typedef unsigned int uint; -typedef unsigned long ulong; - -typedef __s8 int8_t; -typedef __s16 int16_t; -typedef __s32 int32_t; - -typedef __u8 uint8_t; -typedef __u16 uint16_t; -typedef __u32 uint32_t; - -typedef __u64 uint64_t; -typedef __u64 u_int64_t; -typedef __s64 int64_t; - -typedef enum { FALSE = 0, TRUE } bool_t; -#define NULL ((void *)0) - -#if __x86_64__ -typedef unsigned long size_t; -typedef long ssize_t; -typedef unsigned long int uintptr_t; -typedef long int intptr_t; -#else -typedef unsigned int size_t; -typedef int ssize_t; -typedef unsigned int uintptr_t; -typedef int intptr_t; -#endif - +//__builtin_va_list could be used instead typedef char *va_list; #define va_start(v, l) ((v) = (va_list) & (l) + sizeof(l)) #define va_end(v) ((v) = NULL) diff --git a/userspace/stddef.h b/userspace/stddef.h new file mode 100644 index 0000000..d14c15a --- /dev/null +++ b/userspace/stddef.h @@ -0,0 +1,29 @@ +#pragma once + +typedef enum { FALSE = 0, TRUE } bool_t; +#define NULL ((void *)0) + +#if __x86_64__ +typedef unsigned long size_t; +typedef long ssize_t; +typedef unsigned long int uintptr_t; +typedef long int intptr_t; +#else +typedef unsigned int size_t; +typedef int ssize_t; +typedef unsigned int uintptr_t; +typedef int intptr_t; +#endif +#if __x86_64__ +typedef unsigned long size_t; +typedef long ssize_t; +typedef unsigned long int uintptr_t; +typedef long int intptr_t; +#else +typedef unsigned int size_t; +typedef int ssize_t; +typedef unsigned int uintptr_t; +typedef int intptr_t; +#endif + +typedef int wchar_t; diff --git a/userspace/stdint.h b/userspace/stdint.h new file mode 100644 index 0000000..70be36a --- /dev/null +++ b/userspace/stdint.h @@ -0,0 +1,64 @@ +#pragma once + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +#ifdef __GNUC__ +__extension__ typedef __signed__ long long __s64; +__extension__ typedef unsigned long long __u64; +#else +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +/* sysv */ +typedef unsigned char unchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +typedef __s8 int8_t; +typedef __s16 int16_t; +typedef __s32 int32_t; + +typedef __u8 uint8_t; +typedef __u16 uint16_t; +typedef __u32 uint32_t; + +typedef __u64 uint64_t; +typedef __u64 u_int64_t; +typedef __s64 int64_t; + +#define USHRT_MAX ((u16)(~0U)) +#define SHRT_MAX ((s16)(USHRT_MAX >> 1)) +#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) +#define INT_MAX ((int)(~0U >> 1)) +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (~0U) +#define LONG_MAX ((long)(~0UL >> 1)) +#define LONG_MIN (-LONG_MAX - 1) +#define ULONG_MAX (~0UL) +#define LLONG_MAX ((long long)(~0ULL >> 1)) +#define LLONG_MIN (-LLONG_MAX - 1) +#define ULLONG_MAX (~0ULL) +#define SIZE_MAX (~(size_t)0) +#define PHYS_ADDR_MAX (~(phys_addr_t)0) + +#define U8_MAX ((u8)~0U) +#define S8_MAX ((s8)(U8_MAX >> 1)) +#define S8_MIN ((s8)(-S8_MAX - 1)) +#define U16_MAX ((u16)~0U) +#define S16_MAX ((s16)(U16_MAX >> 1)) +#define S16_MIN ((s16)(-S16_MAX - 1)) +#define U32_MAX ((u32)~0U) +#define S32_MAX ((s32)(U32_MAX >> 1)) +#define S32_MIN ((s32)(-S32_MAX - 1)) +#define U64_MAX ((u64)~0ULL) +#define S64_MAX ((s64)(U64_MAX >> 1)) +#define S64_MIN ((s64)(-S64_MAX - 1)) diff --git a/userspace/types.h b/userspace/types.h index 45f0fd0..36eaf27 100644 --- a/userspace/types.h +++ b/userspace/types.h @@ -1,32 +1,5 @@ #pragma once -#define USHRT_MAX ((u16)(~0U)) -#define SHRT_MAX ((s16)(USHRT_MAX >> 1)) -#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) -#define INT_MAX ((int)(~0U >> 1)) -#define INT_MIN (-INT_MAX - 1) -#define UINT_MAX (~0U) -#define LONG_MAX ((long)(~0UL >> 1)) -#define LONG_MIN (-LONG_MAX - 1) -#define ULONG_MAX (~0UL) -#define LLONG_MAX ((long long)(~0ULL >> 1)) -#define LLONG_MIN (-LLONG_MAX - 1) -#define ULLONG_MAX (~0ULL) -#define SIZE_MAX (~(size_t)0) -#define PHYS_ADDR_MAX (~(phys_addr_t)0) - -#define U8_MAX ((u8)~0U) -#define S8_MAX ((s8)(U8_MAX >> 1)) -#define S8_MIN ((s8)(-S8_MAX - 1)) -#define U16_MAX ((u16)~0U) -#define S16_MAX ((s16)(U16_MAX >> 1)) -#define S16_MIN ((s16)(-S16_MAX - 1)) -#define U32_MAX ((u32)~0U) -#define S32_MAX ((s32)(U32_MAX >> 1)) -#define S32_MIN ((s32)(-S32_MAX - 1)) -#define U64_MAX ((u64)~0ULL) -#define S64_MAX ((s64)(U64_MAX >> 1)) -#define S64_MIN ((s64)(-S64_MAX - 1)) // Virtual address typedef unsigned long vaddr_t;