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 /kern | |
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.
Diffstat (limited to 'kern')
-rw-r--r-- | kern/bitmap.c | 3 | ||||
-rw-r--r-- | kern/bitmap.h | 3 | ||||
-rw-r--r-- | kern/condition.c | 3 | ||||
-rw-r--r-- | kern/condition.h | 3 | ||||
-rw-r--r-- | kern/cpumap.c | 3 | ||||
-rw-r--r-- | kern/evcnt.c | 3 | ||||
-rw-r--r-- | kern/kmem.c | 6 | ||||
-rw-r--r-- | kern/kmem.h | 2 | ||||
-rw-r--r-- | kern/kmem_i.h | 3 | ||||
-rw-r--r-- | kern/list.h | 2 | ||||
-rw-r--r-- | kern/llsync.c | 2 | ||||
-rw-r--r-- | kern/macros.h | 6 | ||||
-rw-r--r-- | kern/percpu.c | 7 | ||||
-rw-r--r-- | kern/percpu.h | 3 | ||||
-rw-r--r-- | kern/rbtree.c | 5 | ||||
-rw-r--r-- | kern/rbtree.h | 5 | ||||
-rw-r--r-- | kern/rbtree_i.h | 5 | ||||
-rw-r--r-- | kern/rdxtree.c | 6 | ||||
-rw-r--r-- | kern/rdxtree.h | 4 | ||||
-rw-r--r-- | kern/sprintf.c | 5 | ||||
-rw-r--r-- | kern/sref.c | 2 | ||||
-rw-r--r-- | kern/sref_i.h | 3 | ||||
-rw-r--r-- | kern/stdint.h | 33 | ||||
-rw-r--r-- | kern/string.c | 5 | ||||
-rw-r--r-- | kern/string.h | 2 | ||||
-rw-r--r-- | kern/task.c | 5 | ||||
-rw-r--r-- | kern/thread.c | 5 | ||||
-rw-r--r-- | kern/types.h (renamed from kern/stddef.h) | 23 | ||||
-rw-r--r-- | kern/work.c | 3 | ||||
-rw-r--r-- | kern/xcall.c | 3 |
30 files changed, 72 insertions, 91 deletions
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/stdint.h b/kern/stdint.h deleted file mode 100644 index 9c6cab0e..00000000 --- a/kern/stdint.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2010-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 - * the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef _KERN_STDINT_H -#define _KERN_STDINT_H - -typedef long intptr_t; -typedef unsigned long uintptr_t; - -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 */ 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> |