]> xenbits.xensource.com Git - people/aperard/xtf.git/commitdiff
Drop dependency on gcc-multilib
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 15 Apr 2021 15:55:09 +0000 (16:55 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 16 Apr 2021 22:41:56 +0000 (23:41 +0100)
inttypes.h in particular isn't a freestanding header, and certain distros have
problems providing suitable freestanding headers anyway.  This also gets more
complicated as we start supporting other architectures.

Take the plunge and switch to entirely local headers only.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CODING_STYLE
build/common.mk
docs/mainpage.dox
include/inttypes.h [new file with mode: 0644]
include/limits.h [new file with mode: 0644]
include/stdarg.h [new file with mode: 0644]
include/stdbool.h [new file with mode: 0644]
include/stddef.h [new file with mode: 0644]
include/stdint.h [new file with mode: 0644]

index 761de468674098a5d2d46e238c47b7ab7ba9e404..866da965a76a82e25c35bb705f93b952dcc0bb71 100644 (file)
@@ -112,15 +112,4 @@ Header files
 ------------
 
 A microkernel will not make use of system libraries, and provide local
-implementations of all required functionality.  C99 however provides
-standard headers which are explicitly safe for embedded use.  These
-should be used instead of reimplementing equivalent functionality
-locally.
-
-An incomplete list includes:
-
- * inttypes.h  (PRIx64, ...)
- * limits.h    (INT_MAX, ...)
- * stdarg.h    (va_list, ...)
- * stdbool.h   (bool, true, false)
- * stdint.h    (uint??_t ...)
+implementations of all required functionality.
index 6480a5476121e0a00eac7e8b802b74bbfb91c2f7..2a146c6ac218ff9fa1e2a729fcc2051c8c723d41 100644 (file)
@@ -25,7 +25,7 @@ COMMON_AFLAGS := $(COMMON_FLAGS) -D__ASSEMBLY__
 COMMON_CFLAGS := $(COMMON_FLAGS) $(COMMON_CFLAGS-y)
 COMMON_CFLAGS += -Wall -Wextra -Werror -std=gnu99 -Wstrict-prototypes -O3 -g
 COMMON_CFLAGS += -fno-common -fno-asynchronous-unwind-tables -fno-strict-aliasing
-COMMON_CFLAGS += -fno-stack-protector -fno-pic -ffreestanding
+COMMON_CFLAGS += -fno-stack-protector -fno-pic -ffreestanding -nostdinc
 COMMON_CFLAGS += -mno-red-zone -mno-sse
 COMMON_CFLAGS += -Wno-unused-parameter -Winline
 
index 4b09ce15005c3ac163c3d5a7a85d1c63ba585504..d9558d621e8721109b2216c73f81e2c6ab180213 100644 (file)
@@ -34,20 +34,17 @@ Environment | Guest | Width | Paging
 
 Requirements:
 - GNU Make >= 3.81
-- GNU compatible 32 and 64-bit toolchain, capable of `-std=gnu99`, `-m64`, and
-  `-m32`
-    - For Debian-based systems, the `build-essential` package is
-      sufficient. For RHEL-based systems, the `glibc-devel.i686` package is
-      generally needed beyond the default toolchain packages.
-    - Clang may be used, via `CC="clang"`
 - Python 2.6 or later
 
-Optionally:
-- A toolchain with x32 support.
-    - `hvm64` tests would prefer to use the `elf32-x86-64` format, so they
-      both load and disassemble correctly.  In the absence of x32 support,
-      `elf32-i386` will be used which will load correctly, but disassemble
-      incorrectly.
+For x86:
+    - GNU compatible 32 and 64-bit toolchain, capable of `-std=gnu99`, `-m64`,
+      and `-m32`.
+        - Clang may be used, via `CC="clang"`.
+    - Optionally, a toolchain with x32 support.
+        - `hvm64` tests would prefer to use the `elf32-x86-64` format, so they
+          both load and disassemble correctly.  In the absence of x32 support,
+          `elf32-i386` will be used which will load correctly, but disassemble
+          incorrectly.
 
 To obtain and build:
 
diff --git a/include/inttypes.h b/include/inttypes.h
new file mode 100644 (file)
index 0000000..565fe9e
--- /dev/null
@@ -0,0 +1,37 @@
+/**
+ * @file include/inttypes.h
+ *
+ * Local subset of C's inttypes.h
+ */
+#ifndef INTTYPES_H
+#define INTTYPES_H
+
+#if __SIZEOF_LONG__ == 8
+# define __PRI64  "l"
+# define __PRIPTR "l"
+#else
+# define __PRI64  "ll"
+# define __PRIPTR
+#endif
+
+#define PRId64     __PRI64  "d"
+#define PRIx64     __PRI64  "x"
+#define PRIo64     __PRI64  "o"
+#define PRIu64     __PRI64  "u"
+
+#define PRIdPTR    __PRIPTR "d"
+#define PRIoPTR    __PRIPTR "o"
+#define PRIuPTR    __PRIPTR "u"
+#define PRIxPTR    __PRIPTR "x"
+
+#endif /* INTTYPES_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/limits.h b/include/limits.h
new file mode 100644 (file)
index 0000000..ae8b2d5
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * @file include/limits.h
+ *
+ * Local subset of C's limits.h
+ */
+#ifndef LIMITS_H
+#define LIMITS_H
+
+#define CHAR_BIT __CHAR_BIT__
+
+#endif /* LIMITS_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/stdarg.h b/include/stdarg.h
new file mode 100644 (file)
index 0000000..819ea55
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * @file include/stdarg.h
+ *
+ * Local subset of C's stdarg.h
+ */
+#ifndef STDARG_H
+#define STDARG_H
+
+typedef __builtin_va_list va_list;
+#define va_start(v, l)  __builtin_va_start(v, l)
+#define va_end(v)       __builtin_va_end(v)
+#define va_arg(v, l)    __builtin_va_arg(v, l)
+#define va_copy(d, s)   __builtin_va_copy(d, s)
+
+#endif /* STDARG_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/stdbool.h b/include/stdbool.h
new file mode 100644 (file)
index 0000000..d4000b6
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * @file include/stdbool.h
+ *
+ * Local subset of C's stdbool.h
+ */
+#ifndef STDBOOL_H
+#define STDBOOL_H
+
+typedef _Bool bool;
+#define true   1
+#define false  0
+
+#endif /* STDBOOL_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/stddef.h b/include/stddef.h
new file mode 100644 (file)
index 0000000..7bd0722
--- /dev/null
@@ -0,0 +1,26 @@
+/**
+ * @file include/stddef.h
+ *
+ * Local subset of C's stddef.h
+ */
+#ifndef STDDEF_H
+#define STDDEF_H
+
+typedef __SIZE_TYPE__       size_t;
+typedef __PTRDIFF_TYPE__    ptrdiff_t;
+
+#define NULL ((void *)0)
+
+#define offsetof(t, m) __builtin_offsetof(t, m)
+
+#endif /* STDDEF_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/stdint.h b/include/stdint.h
new file mode 100644 (file)
index 0000000..8fcb1b3
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+ * @file include/stdint.h
+ *
+ * Local subset of C's stdint.h
+ */
+#ifndef STDINT_H
+#define STDINT_H
+
+typedef __INT8_TYPE__      int8_t;
+typedef __INT16_TYPE__     int16_t;
+typedef __INT32_TYPE__     int32_t;
+typedef __INT64_TYPE__     int64_t;
+
+typedef __UINT8_TYPE__     uint8_t;
+typedef __UINT16_TYPE__    uint16_t;
+typedef __UINT32_TYPE__    uint32_t;
+typedef __UINT64_TYPE__    uint64_t;
+
+typedef __INTPTR_TYPE__    intptr_t;
+typedef __UINTPTR_TYPE__   uintptr_t;
+
+#endif /* STDINT_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */