Add minimal stdint This adds a minimal subset of stdint and stddef that is required by the runtime. Signed-off-by: Curtis Millar <curtis@curtism.me>
diff --git a/include/sel4runtime/stddef.h b/include/sel4runtime/stddef.h new file mode 100644 index 0000000..b001c16 --- /dev/null +++ b/include/sel4runtime/stddef.h
@@ -0,0 +1,25 @@ +/* + * Copyright 2020, Data61 + * Commonwealth Scientific and Industrial Research Organisation (CSIRO) + * ABN 41 687 119 230. + * + * This software may be distributed and modified according to the terms of + * the BSD 2-Clause license. Note that NO WARRANTY is provided. + * See "LICENSE_BSD2.txt" for details. + * + * @TAG(DATA61_BSD) + */ + +#include <sel4runtime/stdint.h> + +#pragma once + +/* + * This is a very naive implementation of stddef that should work for + * most major platforms. This is the minimal subset needed for the + * runtime. + */ + +typedef sel4runtime_uintptr_t sel4runtime_size_t; + +#define SEL4RUNTIME_NULL ((void *)0)
diff --git a/include/sel4runtime/stdint.h b/include/sel4runtime/stdint.h new file mode 100644 index 0000000..0f21e29 --- /dev/null +++ b/include/sel4runtime/stdint.h
@@ -0,0 +1,40 @@ +/* + * Copyright 2020, Data61 + * Commonwealth Scientific and Industrial Research Organisation (CSIRO) + * ABN 41 687 119 230. + * + * This software may be distributed and modified according to the terms of + * the BSD 2-Clause license. Note that NO WARRANTY is provided. + * See "LICENSE_BSD2.txt" for details. + * + * @TAG(DATA61_BSD) + */ + +#pragma once + +/* + * This is a very naive implementation of stdint that should work for + * most major platforms. This is the minimal subset needed for the + * runtime. + */ + +_Static_assert(sizeof(char) == 1, "char is 8 bits"); +_Static_assert(sizeof(short) == 2, "short is 16 bits"); +_Static_assert(sizeof(int) == 4, "int is 32 bits"); +_Static_assert(sizeof(long long) == 8, "long long is 64 bits"); +_Static_assert(sizeof(long) == sizeof(void *), "long is word size"); + +/* Fixed size integer types */ +typedef signed char sel4runtime_int8_t; +typedef signed short sel4runtime_int16_t; +typedef signed int sel4runtime_int32_t; +typedef signed long long sel4runtime_int64_t; + +typedef unsigned char sel4runtime_uint8_t; +typedef unsigned short sel4runtime_uint16_t; +typedef unsigned int sel4runtime_uint32_t; +typedef unsigned long long sel4runtime_uint64_t; + +/* Word-sized integer types */ +typedef signed long sel4runtime_intptr_t; +typedef unsigned long sel4runtime_uintptr_t;