diff options
author | Richard Braun <rbraun@sceen.net> | 2017-02-04 17:45:17 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-02-04 17:45:17 +0100 |
commit | fd035c0a3d361e513fe7916b67e14ff702983153 (patch) | |
tree | 81d24cf88a68144bfd6113a8e148a0dd9528affe | |
parent | d479903845975a480be4201aa892e4434c4f6c54 (diff) |
Clean up compilation
Instead of mixing standard headers and internal redefinitions of standard
types, completely rely on the compiler for what is guaranteed for a free
standing environment. This results in the removal of kern/stddef.h and
kern/stdint.h. The kern/types.h header is reintroduced for the different
(and saner) purpose of defining types not specified in standard C,
namely ssize_t for now.
62 files changed, 183 insertions, 135 deletions
diff --git a/Makefile.am b/Makefile.am index 33529765..649bc51d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,23 +1,41 @@ EXTRA_DIST = MOSTLYCLEANFILES = +AM_CPPFLAGS = +AM_CFLAGS = -AM_CPPFLAGS = \ - -pipe \ - -std=gnu99 \ - -imacros config.h \ +AM_CPPFLAGS += -pipe +AM_CPPFLAGS += -imacros config.h + +# Do not include headers from the hosted environment, but +# do include headers from the compiler. +AM_CPPFLAGS += -nostdinc +AM_CPPFLAGS += -isystem $(shell $(CC) -print-file-name=include) + +AM_CPPFLAGS += \ -I$(top_srcdir) \ + -I$(top_srcdir)/include \ -I$(top_srcdir)/arch/$(arch) -AM_CFLAGS = \ +AM_CFLAGS += -ffreestanding + +# TODO Adopt C11 +AM_CFLAGS += -std=gnu99 + +AM_CFLAGS += \ -Wall \ -Wextra \ -Wshadow \ -Wmissing-prototypes \ - -Wstrict-prototypes \ + -Wstrict-prototypes + +AM_CFLAGS += \ -fsigned-char \ - -ffreestanding \ - -fno-common \ - -fno-stack-protector + -fno-common + +# TODO Add stack protector support +AM_CFLAGS += -fno-stack-protector + +AM_CFLAGS += -nostdlib SUFFIXES = .lds .lds.S diff --git a/Makefrag.am b/Makefrag.am index fca8820a..01e7f5b0 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -1,5 +1,8 @@ include arch/x86/Makefrag.am +x15_SOURCES += \ + include/string.h + x15_SOURCES += \ kern/assert.h \ kern/bitmap.c \ @@ -54,8 +57,6 @@ x15_SOURCES += \ kern/sref.c \ kern/sref.h \ kern/sref_i.h \ - kern/stddef.h \ - kern/stdint.h \ kern/string.c \ kern/string.h \ kern/task.c \ @@ -63,6 +64,7 @@ x15_SOURCES += \ kern/thread.c \ kern/thread.h \ kern/thread_i.h \ + kern/types.h \ kern/work.c \ kern/work.h \ kern/xcall.c \ diff --git a/arch/x86/machine/acpimp.c b/arch/x86/machine/acpimp.c index ef93bc43..2c3dc6c2 100644 --- a/arch/x86/machine/acpimp.c +++ b/arch/x86/machine/acpimp.c @@ -15,15 +15,16 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <stdint.h> +#include <string.h> + #include <kern/assert.h> #include <kern/init.h> #include <kern/kmem.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <machine/acpimp.h> #include <machine/biosmem.h> #include <machine/cpu.h> diff --git a/arch/x86/machine/atomic.h b/arch/x86/machine/atomic.h index c990526c..b56da522 100644 --- a/arch/x86/machine/atomic.h +++ b/arch/x86/machine/atomic.h @@ -23,7 +23,7 @@ #ifndef _X86_ATOMIC_H #define _X86_ATOMIC_H -#include <kern/stdint.h> +#include <stdint.h> #define ATOMIC_ADD(ptr, delta) \ asm volatile("lock add %1, %0" \ diff --git a/arch/x86/machine/biosmem.c b/arch/x86/machine/biosmem.c index 6e6410cf..4208b72b 100644 --- a/arch/x86/machine/biosmem.c +++ b/arch/x86/machine/biosmem.c @@ -16,6 +16,9 @@ */ #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> #include <kern/assert.h> #include <kern/init.h> @@ -23,9 +26,6 @@ #include <kern/panic.h> #include <kern/param.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <machine/biosmem.h> #include <machine/boot.h> #include <machine/cpu.h> diff --git a/arch/x86/machine/boot.c b/arch/x86/machine/boot.c index a3fd3146..2ab1c6d5 100644 --- a/arch/x86/machine/boot.c +++ b/arch/x86/machine/boot.c @@ -43,6 +43,9 @@ */ #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> #include <kern/evcnt.h> #include <kern/init.h> @@ -54,9 +57,6 @@ #include <kern/percpu.h> #include <kern/printk.h> #include <kern/sref.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <kern/thread.h> #include <machine/biosmem.h> #include <machine/boot.h> diff --git a/arch/x86/machine/cga.c b/arch/x86/machine/cga.c index 1ab23582..c926ec3d 100644 --- a/arch/x86/machine/cga.c +++ b/arch/x86/machine/cga.c @@ -15,11 +15,12 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stdint.h> +#include <string.h> + #include <kern/init.h> #include <kern/macros.h> #include <kern/param.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <machine/io.h> #include <machine/cga.h> #include <vm/vm_page.h> diff --git a/arch/x86/machine/cga.h b/arch/x86/machine/cga.h index 0486fd96..2dc12cf4 100644 --- a/arch/x86/machine/cga.h +++ b/arch/x86/machine/cga.h @@ -21,7 +21,7 @@ #ifndef _X86_CGA_H #define _X86_CGA_H -#include <kern/stdint.h> +#include <stdint.h> /* * Initialize the cga module. diff --git a/arch/x86/machine/cpu.c b/arch/x86/machine/cpu.c index 5fc21315..19282121 100644 --- a/arch/x86/machine/cpu.c +++ b/arch/x86/machine/cpu.c @@ -15,6 +15,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <stdint.h> +#include <string.h> + #include <kern/assert.h> #include <kern/init.h> #include <kern/macros.h> @@ -22,9 +26,6 @@ #include <kern/param.h> #include <kern/percpu.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <kern/thread.h> #include <kern/xcall.h> #include <machine/acpimp.h> diff --git a/arch/x86/machine/cpu.h b/arch/x86/machine/cpu.h index a18712c8..862799e8 100644 --- a/arch/x86/machine/cpu.h +++ b/arch/x86/machine/cpu.h @@ -95,9 +95,10 @@ #ifndef __ASSEMBLER__ +#include <stdint.h> + #include <kern/macros.h> #include <kern/percpu.h> -#include <kern/stdint.h> #include <machine/lapic.h> #include <machine/pit.h> diff --git a/arch/x86/machine/io.h b/arch/x86/machine/io.h index 6b10f0eb..fb566b95 100644 --- a/arch/x86/machine/io.h +++ b/arch/x86/machine/io.h @@ -18,7 +18,7 @@ #ifndef _X86_IO_H #define _X86_IO_H -#include <kern/stdint.h> +#include <stdint.h> /* * Read a byte from an I/O port. diff --git a/arch/x86/machine/lapic.c b/arch/x86/machine/lapic.c index 26b0dd50..c0d10e5c 100644 --- a/arch/x86/machine/lapic.c +++ b/arch/x86/machine/lapic.c @@ -15,13 +15,14 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <stdint.h> + #include <kern/init.h> #include <kern/macros.h> #include <kern/panic.h> #include <kern/param.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/stdint.h> #include <kern/thread.h> #include <machine/cpu.h> #include <machine/lapic.h> diff --git a/arch/x86/machine/lapic.h b/arch/x86/machine/lapic.h index 8c87adc6..802d1251 100644 --- a/arch/x86/machine/lapic.h +++ b/arch/x86/machine/lapic.h @@ -18,7 +18,8 @@ #ifndef _X86_LAPIC_H #define _X86_LAPIC_H -#include <kern/stdint.h> +#include <stdint.h> + #include <machine/trap.h> /* diff --git a/arch/x86/machine/multiboot.h b/arch/x86/machine/multiboot.h index 4a0502c8..02c8a330 100644 --- a/arch/x86/machine/multiboot.h +++ b/arch/x86/machine/multiboot.h @@ -46,8 +46,9 @@ #ifndef __ASSEMBLER__ +#include <stdint.h> + #include <kern/macros.h> -#include <kern/stdint.h> /* * A multiboot module. diff --git a/arch/x86/machine/pic.c b/arch/x86/machine/pic.c index 440ca3a7..db26a166 100644 --- a/arch/x86/machine/pic.c +++ b/arch/x86/machine/pic.c @@ -15,10 +15,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stdint.h> + #include <kern/assert.h> #include <kern/init.h> #include <kern/panic.h> -#include <kern/stdint.h> #include <machine/io.h> #include <machine/cpu.h> #include <machine/pic.h> diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c index ea49856e..7cf50866 100644 --- a/arch/x86/machine/pmap.c +++ b/arch/x86/machine/pmap.c @@ -18,6 +18,9 @@ * TODO Review locking. */ +#include <stddef.h> +#include <string.h> + #include <kern/assert.h> #include <kern/condition.h> #include <kern/cpumap.h> @@ -33,8 +36,6 @@ #include <kern/percpu.h> #include <kern/spinlock.h> #include <kern/sprintf.h> -#include <kern/stddef.h> -#include <kern/string.h> #include <kern/thread.h> #include <machine/biosmem.h> #include <machine/boot.h> diff --git a/arch/x86/machine/pmap.h b/arch/x86/machine/pmap.h index 1806a6fb..4fdda23f 100644 --- a/arch/x86/machine/pmap.h +++ b/arch/x86/machine/pmap.h @@ -96,10 +96,11 @@ #ifndef __ASSEMBLER__ +#include <stdint.h> + #include <kern/cpumap.h> #include <kern/list.h> #include <kern/mutex.h> -#include <kern/stdint.h> #include <kern/thread.h> #include <machine/cpu.h> #include <machine/trap.h> diff --git a/arch/x86/machine/strace.c b/arch/x86/machine/strace.c index e65efb08..e40b3645 100644 --- a/arch/x86/machine/strace.c +++ b/arch/x86/machine/strace.c @@ -15,12 +15,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <string.h> + #include <kern/init.h> #include <kern/kmem.h> #include <kern/param.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/string.h> #include <machine/elf.h> #include <machine/multiboot.h> #include <machine/pmap.h> diff --git a/arch/x86/machine/string.c b/arch/x86/machine/string.c index 26ce941b..cdf00e3f 100644 --- a/arch/x86/machine/string.c +++ b/arch/x86/machine/string.c @@ -15,9 +15,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <string.h> + #include <kern/param.h> -#include <kern/stddef.h> -#include <kern/string.h> #ifdef ARCH_STRING_MEMCPY void * diff --git a/kern/stdint.h b/include/string.h index 9c6cab0e..0eee8969 100644 --- a/kern/stdint.h +++ b/include/string.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Richard Braun. + * Copyright (c) 2017 Richard Braun. * * 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 @@ -15,19 +15,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _KERN_STDINT_H -#define _KERN_STDINT_H +#ifndef _STRING_H +#define _STRING_H -typedef long intptr_t; -typedef unsigned long uintptr_t; +#include <kern/string.h> -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; - -#endif /* _KERN_STDINT_H */ +#endif /* _STRING_H */ diff --git a/kern/bitmap.c b/kern/bitmap.c index b3117dfb..d270b9f5 100644 --- a/kern/bitmap.c +++ b/kern/bitmap.c @@ -15,10 +15,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <string.h> + #include <kern/bitmap.h> #include <kern/bitmap_i.h> #include <kern/limits.h> -#include <kern/string.h> int bitmap_cmp(const unsigned long *a, const unsigned long *b, int nr_bits) diff --git a/kern/bitmap.h b/kern/bitmap.h index 6489b486..77dfac1b 100644 --- a/kern/bitmap.h +++ b/kern/bitmap.h @@ -24,9 +24,10 @@ #ifndef _KERN_BITMAP_H #define _KERN_BITMAP_H +#include <string.h> + #include <kern/bitmap_i.h> #include <kern/limits.h> -#include <kern/string.h> #include <machine/atomic.h> #define BITMAP_DECLARE(name, nr_bits) unsigned long name[BITMAP_LONGS(nr_bits)] diff --git a/kern/condition.c b/kern/condition.c index 7d83f47d..467cb85a 100644 --- a/kern/condition.c +++ b/kern/condition.c @@ -22,13 +22,14 @@ * locked, the current owner does the same when unlocking. */ +#include <stddef.h> + #include <kern/assert.h> #include <kern/condition.h> #include <kern/list.h> #include <kern/mutex.h> #include <kern/mutex_i.h> #include <kern/spinlock.h> -#include <kern/stddef.h> #include <kern/thread.h> void diff --git a/kern/condition.h b/kern/condition.h index 4e7f7f0f..a61c2a9d 100644 --- a/kern/condition.h +++ b/kern/condition.h @@ -21,10 +21,11 @@ #ifndef _KERN_CONDITION_H #define _KERN_CONDITION_H +#include <stddef.h> + #include <kern/condition_types.h> #include <kern/list.h> #include <kern/spinlock.h> -#include <kern/stddef.h> static inline void condition_init(struct condition *condition) diff --git a/kern/cpumap.c b/kern/cpumap.c index 2cc3511c..5582e681 100644 --- a/kern/cpumap.c +++ b/kern/cpumap.c @@ -15,12 +15,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> + #include <kern/bitmap.h> #include <kern/cpumap.h> #include <kern/error.h> #include <kern/kmem.h> #include <kern/param.h> -#include <kern/stddef.h> #include <machine/cpu.h> static struct cpumap cpumap_active_cpus __read_mostly = { { 1 } }; diff --git a/kern/evcnt.c b/kern/evcnt.c index 803516d0..e993edd9 100644 --- a/kern/evcnt.c +++ b/kern/evcnt.c @@ -15,12 +15,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <string.h> + #include <kern/evcnt.h> #include <kern/init.h> #include <kern/list.h> #include <kern/mutex.h> #include <kern/printk.h> -#include <kern/string.h> /* * Global list of all registered counters. diff --git a/kern/kmem.c b/kern/kmem.c index 49ec177b..e406115b 100644 --- a/kern/kmem.c +++ b/kern/kmem.c @@ -42,6 +42,9 @@ */ #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> #include <kern/assert.h> #include <kern/init.h> @@ -56,9 +59,6 @@ #include <kern/param.h> #include <kern/printk.h> #include <kern/sprintf.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <kern/thread.h> #include <machine/cpu.h> #include <machine/pmap.h> diff --git a/kern/kmem.h b/kern/kmem.h index b1861557..8f6c773c 100644 --- a/kern/kmem.h +++ b/kern/kmem.h @@ -21,7 +21,7 @@ #ifndef _KERN_KMEM_H #define _KERN_KMEM_H -#include <kern/stddef.h> +#include <stddef.h> /* * Object cache. diff --git a/kern/kmem_i.h b/kern/kmem_i.h index 08b11c54..b9972d78 100644 --- a/kern/kmem_i.h +++ b/kern/kmem_i.h @@ -18,10 +18,11 @@ #ifndef _KERN_KMEM_I_H #define _KERN_KMEM_I_H +#include <stddef.h> + #include <kern/list.h> #include <kern/mutex.h> #include <kern/param.h> -#include <kern/stddef.h> /* * Per-processor cache of pre-constructed objects. diff --git a/kern/list.h b/kern/list.h index 8cd5a2d7..c31b71a7 100644 --- a/kern/list.h +++ b/kern/list.h @@ -22,11 +22,11 @@ #define _KERN_LIST_H #include <stdbool.h> +#include <stddef.h> #include <kern/list_types.h> #include <kern/llsync.h> #include <kern/macros.h> -#include <kern/stddef.h> /* * Structure used as both head and node. diff --git a/kern/llsync.c b/kern/llsync.c index 6859f59e..059773f4 100644 --- a/kern/llsync.c +++ b/kern/llsync.c @@ -33,6 +33,7 @@ */ #include <stdbool.h> +#include <stddef.h> #include <kern/assert.h> #include <kern/condition.h> @@ -49,7 +50,6 @@ #include <kern/printk.h> #include <kern/spinlock.h> #include <kern/sprintf.h> -#include <kern/stddef.h> #include <kern/work.h> #include <machine/cpu.h> diff --git a/kern/macros.h b/kern/macros.h index 068bb035..a5b7b032 100644 --- a/kern/macros.h +++ b/kern/macros.h @@ -22,7 +22,7 @@ #define _KERN_MACROS_H #ifndef __ASSEMBLER__ -#include <kern/stddef.h> +#include <stddef.h> #endif /* __ASSEMBLER__ */ #define MACRO_BEGIN ({ @@ -64,7 +64,11 @@ #define __noreturn __attribute__((noreturn)) #define __aligned(x) __attribute__((aligned(x))) + +#ifndef __always_inline #define __always_inline inline __attribute__((always_inline)) +#endif /* __attribute__ */ + #define __section(x) __attribute__((section(x))) #define __packed __attribute__((packed)) #define __alias(x) __attribute__((alias(x))) diff --git a/kern/percpu.c b/kern/percpu.c index ab7b4fb6..b57788ed 100644 --- a/kern/percpu.c +++ b/kern/percpu.c @@ -15,6 +15,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <stdint.h> +#include <string.h> + #include <kern/assert.h> #include <kern/error.h> #include <kern/init.h> @@ -23,9 +27,6 @@ #include <kern/param.h> #include <kern/percpu.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <machine/cpu.h> #include <vm/vm_kmem.h> #include <vm/vm_page.h> diff --git a/kern/percpu.h b/kern/percpu.h index a9d1eb3b..456131a0 100644 --- a/kern/percpu.h +++ b/kern/percpu.h @@ -53,9 +53,10 @@ #ifndef _KERN_PERCPU_H #define _KERN_PERCPU_H +#include <stdint.h> + #include <kern/assert.h> #include <kern/macros.h> -#include <kern/stdint.h> #define PERCPU_SECTION .percpu #define __percpu __section(QUOTE(PERCPU_SECTION)) diff --git a/kern/rbtree.c b/kern/rbtree.c index 0d0a844c..e2ea54ad 100644 --- a/kern/rbtree.c +++ b/kern/rbtree.c @@ -15,12 +15,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <stdint.h> + #include <kern/assert.h> #include <kern/macros.h> #include <kern/rbtree.h> #include <kern/rbtree_i.h> -#include <kern/stddef.h> -#include <kern/stdint.h> /* * Return the index of a node in the children array of its parent. diff --git a/kern/rbtree.h b/kern/rbtree.h index dd17e956..02a657c1 100644 --- a/kern/rbtree.h +++ b/kern/rbtree.h @@ -21,10 +21,11 @@ #ifndef _KERN_RBTREE_H #define _KERN_RBTREE_H +#include <stddef.h> +#include <stdint.h> + #include <kern/assert.h> #include <kern/macros.h> -#include <kern/stddef.h> -#include <kern/stdint.h> /* * Indexes of the left and right nodes in the children array of a node. diff --git a/kern/rbtree_i.h b/kern/rbtree_i.h index f788e830..99722977 100644 --- a/kern/rbtree_i.h +++ b/kern/rbtree_i.h @@ -18,10 +18,11 @@ #ifndef _KERN_RBTREE_I_H #define _KERN_RBTREE_I_H +#include <stddef.h> +#include <stdint.h> + #include <kern/assert.h> #include <kern/macros.h> -#include <kern/stddef.h> -#include <kern/stdint.h> /* * Red-black node structure. diff --git a/kern/rdxtree.c b/kern/rdxtree.c index 90676e04..788f3ba8 100644 --- a/kern/rdxtree.c +++ b/kern/rdxtree.c @@ -16,6 +16,9 @@ */ #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> #include <kern/assert.h> #include <kern/error.h> @@ -25,9 +28,6 @@ #include <kern/macros.h> #include <kern/rdxtree.h> #include <kern/rdxtree_i.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <kern/work.h> /* diff --git a/kern/rdxtree.h b/kern/rdxtree.h index a0d19b55..e3a2ba06 100644 --- a/kern/rdxtree.h +++ b/kern/rdxtree.h @@ -26,8 +26,8 @@ #ifndef _KERN_RDXTREE_H #define _KERN_RDXTREE_H -#include <kern/stddef.h> -#include <kern/stdint.h> +#include <stddef.h> +#include <stdint.h> typedef uint32_t rdxtree_key_t; diff --git a/kern/sprintf.c b/kern/sprintf.c index 386d9d3c..3d2bf2df 100644 --- a/kern/sprintf.c +++ b/kern/sprintf.c @@ -16,11 +16,12 @@ */ #include <stdarg.h> +#include <stddef.h> +#include <stdint.h> #include <kern/limits.h> #include <kern/sprintf.h> -#include <kern/stddef.h> -#include <kern/stdint.h> +#include <kern/types.h> /* * Formatting flags. diff --git a/kern/sref.c b/kern/sref.c index dc5f446e..e1368c30 100644 --- a/kern/sref.c +++ b/kern/sref.c @@ -42,6 +42,7 @@ */ #include <stdbool.h> +#include <stddef.h> #include <kern/assert.h> #include <kern/condition.h> @@ -58,7 +59,6 @@ #include <kern/sprintf.h> #include <kern/sref.h> #include <kern/sref_i.h> -#include <kern/stddef.h> #include <kern/thread.h> #include <machine/cpu.h> diff --git a/kern/sref_i.h b/kern/sref_i.h index 1452bbc9..5b63857f 100644 --- a/kern/sref_i.h +++ b/kern/sref_i.h @@ -18,8 +18,9 @@ #ifndef _KERN_SREF_I_H #define _KERN_SREF_I_H +#include <stdint.h> + #include <kern/spinlock.h> -#include <kern/stdint.h> #include <kern/work.h> #define SREF_WEAKREF_DYING ((uintptr_t)1) diff --git a/kern/string.c b/kern/string.c index 88d251f8..05218e01 100644 --- a/kern/string.c +++ b/kern/string.c @@ -18,8 +18,9 @@ * Trivial, portable implementations. */ -#include <kern/stddef.h> -#include <kern/string.h> +#include <stddef.h> +#include <string.h> + #include <kern/param.h> #ifndef ARCH_STRING_MEMCPY diff --git a/kern/string.h b/kern/string.h index 238d0e73..7ce4ab8f 100644 --- a/kern/string.h +++ b/kern/string.h @@ -18,7 +18,7 @@ #ifndef _KERN_STRING_H #define _KERN_STRING_H -#include <kern/stddef.h> +#include <stddef.h> void * memcpy(void *dest, const void *src, size_t n); void * memmove(void *dest, const void *src, size_t n); diff --git a/kern/task.c b/kern/task.c index e5b34d16..e415cb65 100644 --- a/kern/task.c +++ b/kern/task.c @@ -15,14 +15,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> +#include <string.h> + #include <kern/error.h> #include <kern/init.h> #include <kern/kmem.h> #include <kern/list.h> #include <kern/param.h> #include <kern/spinlock.h> -#include <kern/stddef.h> -#include <kern/string.h> #include <kern/task.h> #include <kern/thread.h> #include <vm/vm_kmem.h> diff --git a/kern/thread.c b/kern/thread.c index 0cb5008b..180f780d 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -81,6 +81,9 @@ * weights in a smoother way than a raw scaling). */ +#include <stddef.h> +#include <string.h> + #include <kern/assert.h> #include <kern/condition.h> #include <kern/cpumap.h> @@ -98,8 +101,6 @@ #include <kern/spinlock.h> #include <kern/sprintf.h> #include <kern/sref.h> -#include <kern/stddef.h> -#include <kern/string.h> #include <kern/task.h> #include <kern/thread.h> #include <kern/work.h> diff --git a/kern/stddef.h b/kern/types.h index b07c9924..2eb1064d 100644 --- a/kern/stddef.h +++ b/kern/types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011 Richard Braun. + * Copyright (c) 2017 Richard Braun. * * 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 @@ -13,23 +13,14 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * + * Machine-independent definitions for non-standard C types. */ -#ifndef _KERN_STDDEF_H -#define _KERN_STDDEF_H - -#define NULL ((void *)0) - -#define offsetof(type, member) __builtin_offsetof(type, member) +#ifndef _KERN_TYPES_H +#define _KERN_TYPES_H -#ifdef __LP64__ -typedef unsigned long size_t; typedef long ssize_t; -typedef long ptrdiff_t; -#else /* __LP64__ */ -typedef unsigned int size_t; -typedef int ssize_t; -typedef int ptrdiff_t; -#endif /* __LP64__ */ -#endif /* _KERN_STDDEF_H */ +#endif /* _KERN_TYPES_H */ diff --git a/kern/work.c b/kern/work.c index d7a221fa..6c798fbb 100644 --- a/kern/work.c +++ b/kern/work.c @@ -15,6 +15,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> + #include <kern/assert.h> #include <kern/bitmap.h> #include <kern/error.h> @@ -28,7 +30,6 @@ #include <kern/printk.h> #include <kern/spinlock.h> #include <kern/sprintf.h> -#include <kern/stddef.h> #include <kern/thread.h> #include <kern/work.h> #include <machine/cpu.h> diff --git a/kern/xcall.c b/kern/xcall.c index 398001d1..565cd20a 100644 --- a/kern/xcall.c +++ b/kern/xcall.c @@ -15,12 +15,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stddef.h> + #include <kern/assert.h> #include <kern/macros.h> #include <kern/param.h> #include <kern/percpu.h> #include <kern/spinlock.h> -#include <kern/stddef.h> #include <kern/thread.h> #include <kern/xcall.h> #include <machine/mb.h> diff --git a/test/test_llsync_defer.c b/test/test_llsync_defer.c index e4cca214..954ea390 100644 --- a/test/test_llsync_defer.c +++ b/test/test_llsync_defer.c @@ -28,6 +28,9 @@ * Each thread regularly prints a string to report that it's making progress. */ +#include <stddef.h> +#include <string.h> + #include <kern/condition.h> #include <kern/error.h> #include <kern/kmem.h> @@ -37,8 +40,6 @@ #include <kern/panic.h> #include <kern/param.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/string.h> #include <kern/thread.h> #include <kern/work.h> #include <test/test.h> diff --git a/test/test_pmap_update_mp.c b/test/test_pmap_update_mp.c index 21882bf2..5f40c8ce 100644 --- a/test/test_pmap_update_mp.c +++ b/test/test_pmap_update_mp.c @@ -24,6 +24,9 @@ * tables of the current processor have been updated. */ +#include <stddef.h> +#include <string.h> + #include <kern/condition.h> #include <kern/cpumap.h> #include <kern/error.h> @@ -31,8 +34,6 @@ #include <kern/panic.h> #include <kern/param.h> #include <kern/printk.h> -#include <kern/stddef.h> -#include <kern/string.h> #include <kern/thread.h> #include <test/test.h> #include <vm/vm_kmem.h> diff --git a/test/test_sref_dirty_zeroes.c b/test/test_sref_dirty_zeroes.c index 042fb681..7f17ceea 100644 --- a/test/test_sref_dirty_zeroes.c +++ b/test/test_sref_dirty_zeroes.c @@ -26,6 +26,8 @@ * and panics if it is. */ +#include <stddef.h> + #include <kern/condition.h> #include <kern/error.h> #include <kern/evcnt.h> @@ -35,7 +37,6 @@ #include <kern/panic.h> #include <kern/sprintf.h> #include <kern/sref.h> -#include <kern/stddef.h> #include <kern/thread.h> #include <test/test.h> #include <vm/vm_kmem.h> diff --git a/test/test_sref_noref.c b/test/test_sref_noref.c index d9fe63b8..b74338dc 100644 --- a/test/test_sref_noref.c +++ b/test/test_sref_noref.c @@ -32,6 +32,8 @@ * to occur. */ +#include <stddef.h> + #include <kern/condition.h> #include <kern/error.h> #include <kern/evcnt.h> @@ -41,7 +43,6 @@ #include <kern/panic.h> #include <kern/sprintf.h> #include <kern/sref.h> -#include <kern/stddef.h> #include <kern/thread.h> #include <test/test.h> #include <vm/vm_kmem.h> diff --git a/test/test_sref_weakref.c b/test/test_sref_weakref.c index f618a483..20e8e155 100644 --- a/test/test_sref_weakref.c +++ b/test/test_sref_weakref.c @@ -32,11 +32,12 @@ * first thread reinitializes the weak reference. */ +#include <stddef.h> + #include <kern/error.h> #include <kern/evcnt.h> #include <kern/macros.h> #include <kern/sref.h> -#include <kern/stddef.h> #include <kern/thread.h> #include <test/test.h> #include <vm/vm_kmem.h> diff --git a/test/test_vm_page_fill.c b/test/test_vm_page_fill.c index 55a328b2..c334407d 100644 --- a/test/test_vm_page_fill.c +++ b/test/test_vm_page_fill.c @@ -22,11 +22,12 @@ * in which case this test will catch the error. */ +#include <stddef.h> +#include <stdint.h> + #include <kern/cpumap.h> #include <kern/error.h> #include <kern/list.h> -#include <kern/stddef.h> -#include <kern/stdint.h> #include <kern/thread.h> #include <machine/pmap.h> #include <test/test.h> diff --git a/test/test_xcall.c b/test/test_xcall.c index 2d496de1..ab4fa113 100644 --- a/test/test_xcall.c +++ b/test/test_xcall.c @@ -20,11 +20,12 @@ * processor, and another on a remote processor. */ +#include <stddef.h> + #include <kern/error.h> #include <kern/cpumap.h> #include <kern/panic.h> #include <kern/printk.h> -#include <kern/stddef.h> #include <kern/thread.h> #include <kern/xcall.h> #include <test/test.h> diff --git a/vm/vm_kmem.c b/vm/vm_kmem.c index 9a767e08..8a7272cb 100644 --- a/vm/vm_kmem.c +++ b/vm/vm_kmem.c @@ -18,13 +18,14 @@ * TODO Rework so that pmap update errors can be handled. */ +#include <stddef.h> +#include <stdint.h> + #include <kern/assert.h> #include <kern/cpumap.h> #include <kern/init.h> #include <kern/panic.h> #include <kern/param.h> -#include <kern/stddef.h> -#include <kern/stdint.h> #include <machine/pmap.h> #include <machine/types.h> #include <vm/vm_adv.h> diff --git a/vm/vm_kmem.h b/vm/vm_kmem.h index eafb4183..c4b5295c 100644 --- a/vm/vm_kmem.h +++ b/vm/vm_kmem.h @@ -18,7 +18,8 @@ #ifndef _VM_VM_KMEM_H #define _VM_VM_KMEM_H -#include <kern/stdint.h> +#include <stdint.h> + #include <machine/types.h> /* diff --git a/vm/vm_map.c b/vm/vm_map.c index 883936c5..9fcc4f0a 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -19,6 +19,9 @@ * needed for kernel allocation. */ +#include <stddef.h> +#include <stdint.h> + #include <kern/assert.h> #include <kern/error.h> #include <kern/init.h> @@ -30,8 +33,6 @@ #include <kern/param.h> #include <kern/printk.h> #include <kern/rbtree.h> -#include <kern/stddef.h> -#include <kern/stdint.h> #include <machine/pmap.h> #include <vm/vm_adv.h> #include <vm/vm_inherit.h> diff --git a/vm/vm_map.h b/vm/vm_map.h index e4d47301..1e17bbb4 100644 --- a/vm/vm_map.h +++ b/vm/vm_map.h @@ -21,10 +21,11 @@ #ifndef _VM_VM_MAP_H #define _VM_VM_MAP_H +#include <stdint.h> + #include <kern/list.h> #include <kern/mutex.h> #include <kern/rbtree.h> -#include <kern/stdint.h> #include <machine/pmap.h> #include <vm/vm_adv.h> #include <vm/vm_inherit.h> diff --git a/vm/vm_page.c b/vm/vm_page.c index 487e4624..df20790c 100644 --- a/vm/vm_page.c +++ b/vm/vm_page.c @@ -30,6 +30,9 @@ */ #include <stdbool.h> +#include <stddef.h> +#include <stdint.h> +#include <string.h> #include <kern/assert.h> #include <kern/init.h> @@ -40,9 +43,6 @@ #include <kern/param.h> #include <kern/printk.h> #include <kern/sprintf.h> -#include <kern/stddef.h> -#include <kern/stdint.h> -#include <kern/string.h> #include <kern/thread.h> #include <machine/cpu.h> #include <machine/pmap.h> diff --git a/vm/vm_page.h b/vm/vm_page.h index cd4dab10..139f1bff 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -21,13 +21,14 @@ #ifndef _VM_VM_PAGE_H #define _VM_VM_PAGE_H +#include <stddef.h> +#include <stdint.h> + #include <kern/assert.h> #include <kern/list.h> #include <kern/log2.h> #include <kern/macros.h> #include <kern/param.h> -#include <kern/stddef.h> -#include <kern/stdint.h> #include <machine/pmap.h> #include <machine/types.h> |