From 436fe6cb9711401fcc1f1d8fc29025f1aec5b774 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Tue, 30 May 2017 22:16:59 +0200 Subject: Move assert.h to the include directory This turns assert.h into a standard header. --- Makefrag.am | 2 +- arch/x86/machine/acpimp.c | 2 +- arch/x86/machine/biosmem.c | 2 +- arch/x86/machine/cpu.c | 2 +- arch/x86/machine/ioapic.c | 2 +- arch/x86/machine/lapic.c | 2 +- arch/x86/machine/pic.c | 2 +- arch/x86/machine/pit.c | 3 ++- arch/x86/machine/pmap.c | 2 +- arch/x86/machine/tcb.h | 3 ++- arch/x86/machine/trap.c | 2 +- arch/x86/machine/uart.c | 2 +- include/assert.h | 43 +++++++++++++++++++++++++++++++++++++++++++ kern/arg.c | 2 +- kern/assert.h | 43 ------------------------------------------- kern/cbuf.c | 3 ++- kern/condition.c | 2 +- kern/console.c | 2 +- kern/hash.h | 3 +-- kern/kmem.c | 2 +- kern/llsync.c | 2 +- kern/llsync_i.h | 3 ++- kern/log2.h | 3 ++- kern/mutex.h | 3 ++- kern/mutex_i.h | 3 ++- kern/percpu.c | 2 +- kern/percpu.h | 2 +- kern/rbtree.c | 2 +- kern/rbtree.h | 2 +- kern/rbtree_i.h | 2 +- kern/rdxtree.c | 2 +- kern/rtmutex.c | 2 +- kern/rtmutex.h | 2 +- kern/rtmutex_i.h | 2 +- kern/semaphore.h | 3 ++- kern/semaphore_i.h | 3 ++- kern/sleepq.c | 2 +- kern/spinlock.c | 2 +- kern/spinlock_i.h | 2 +- kern/sref.c | 2 +- kern/thread.c | 2 +- kern/thread.h | 2 +- kern/turnstile.c | 2 +- kern/work.c | 2 +- kern/xcall.c | 2 +- vm/vm_kmem.c | 2 +- vm/vm_map.c | 2 +- vm/vm_page.c | 2 +- vm/vm_page.h | 2 +- 49 files changed, 99 insertions(+), 91 deletions(-) create mode 100644 include/assert.h delete mode 100644 kern/assert.h diff --git a/Makefrag.am b/Makefrag.am index e9d4e63e..0fabdc2d 100644 --- a/Makefrag.am +++ b/Makefrag.am @@ -4,13 +4,13 @@ include doc/Makefrag.am EXTRA_DIST += tools/qemu.sh x15_SOURCES += \ + include/assert.h \ include/stdio.h \ include/string.h x15_SOURCES += \ kern/arg.c \ kern/arg.h \ - kern/assert.h \ kern/atomic.h \ kern/bitmap.c \ kern/bitmap.h \ diff --git a/arch/x86/machine/acpimp.c b/arch/x86/machine/acpimp.c index bba2b8ca..0af1ae76 100644 --- a/arch/x86/machine/acpimp.c +++ b/arch/x86/machine/acpimp.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ +#include #include #include #include #include -#include #include #include #include diff --git a/arch/x86/machine/biosmem.c b/arch/x86/machine/biosmem.c index 65329a06..bfa22afd 100644 --- a/arch/x86/machine/biosmem.c +++ b/arch/x86/machine/biosmem.c @@ -15,13 +15,13 @@ * along with this program. If not, see . */ +#include #include #include #include #include #include -#include #include #include #include diff --git a/arch/x86/machine/cpu.c b/arch/x86/machine/cpu.c index eaa43ae7..7c608499 100644 --- a/arch/x86/machine/cpu.c +++ b/arch/x86/machine/cpu.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ +#include #include #include #include #include -#include #include #include #include diff --git a/arch/x86/machine/ioapic.c b/arch/x86/machine/ioapic.c index 66178b3a..d48cc307 100644 --- a/arch/x86/machine/ioapic.c +++ b/arch/x86/machine/ioapic.c @@ -15,11 +15,11 @@ * along with this program. If not, see . */ +#include #include #include #include -#include #include #include #include diff --git a/arch/x86/machine/lapic.c b/arch/x86/machine/lapic.c index 6bd1d723..148a2a93 100644 --- a/arch/x86/machine/lapic.c +++ b/arch/x86/machine/lapic.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ +#include #include #include #include #include -#include #include #include #include diff --git a/arch/x86/machine/pic.c b/arch/x86/machine/pic.c index 9084abce..52f9461a 100644 --- a/arch/x86/machine/pic.c +++ b/arch/x86/machine/pic.c @@ -15,9 +15,9 @@ * along with this program. If not, see . */ +#include #include -#include #include #include #include diff --git a/arch/x86/machine/pit.c b/arch/x86/machine/pit.c index bf53ee11..c31c7e0b 100644 --- a/arch/x86/machine/pit.c +++ b/arch/x86/machine/pit.c @@ -15,7 +15,8 @@ * along with this program. If not, see . */ -#include +#include + #include #include #include diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c index 1de9b093..1aab9cc8 100644 --- a/arch/x86/machine/pmap.c +++ b/arch/x86/machine/pmap.c @@ -18,11 +18,11 @@ * TODO Review locking. */ +#include #include #include #include -#include #include #include #include diff --git a/arch/x86/machine/tcb.h b/arch/x86/machine/tcb.h index 5f455850..914ec9d7 100644 --- a/arch/x86/machine/tcb.h +++ b/arch/x86/machine/tcb.h @@ -21,7 +21,8 @@ #ifndef _X86_TCB_H #define _X86_TCB_H -#include +#include + #include #include diff --git a/arch/x86/machine/trap.c b/arch/x86/machine/trap.c index 3de4fd26..e033b352 100644 --- a/arch/x86/machine/trap.c +++ b/arch/x86/machine/trap.c @@ -19,10 +19,10 @@ * additional configuration and resources to be properly handled. */ +#include #include #include -#include #include #include #include diff --git a/arch/x86/machine/uart.c b/arch/x86/machine/uart.c index 82b6c83b..24fcace4 100644 --- a/arch/x86/machine/uart.c +++ b/arch/x86/machine/uart.c @@ -18,10 +18,10 @@ * TODO Make serial line parameters configurable. */ +#include #include #include -#include #include #include #include diff --git a/include/assert.h b/include/assert.h new file mode 100644 index 00000000..8fdc2fe2 --- /dev/null +++ b/include/assert.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2010 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 . + */ + +#ifndef _ASSERT_H +#define _ASSERT_H + +#define static_assert _Static_assert + +#ifdef NDEBUG +#define assert(expression) ((void)(expression)) +#else /* NDEBUG */ + +#include +#include + +/* + * Panic if the given expression is false. + */ +#define assert(expression) \ +MACRO_BEGIN \ + if (unlikely(!(expression))) { \ + panic("assertion (%s) failed in %s:%d, function %s()", \ + __QUOTE(expression), __FILE__, __LINE__, __func__); \ + } \ +MACRO_END + +#endif /* NDEBUG */ + +#endif /* _ASSERT_H */ diff --git a/kern/arg.c b/kern/arg.c index 02ed4b7b..1278812c 100644 --- a/kern/arg.c +++ b/kern/arg.c @@ -15,13 +15,13 @@ * along with this program. If not, see . */ +#include #include #include #include #include #include -#include #include #include #include diff --git a/kern/assert.h b/kern/assert.h deleted file mode 100644 index cc8b80ea..00000000 --- a/kern/assert.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2010 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 . - */ - -#ifndef _KERN_ASSERT_H -#define _KERN_ASSERT_H - -#define static_assert _Static_assert - -#ifdef NDEBUG -#define assert(expression) ((void)(expression)) -#else /* NDEBUG */ - -#include -#include - -/* - * Panic if the given expression is false. - */ -#define assert(expression) \ -MACRO_BEGIN \ - if (unlikely(!(expression))) { \ - panic("assertion (%s) failed in %s:%d, function %s()", \ - __QUOTE(expression), __FILE__, __LINE__, __func__); \ - } \ -MACRO_END - -#endif /* NDEBUG */ - -#endif /* _KERN_ASSERT_H */ diff --git a/kern/cbuf.c b/kern/cbuf.c index 17369afe..5c636e56 100644 --- a/kern/cbuf.c +++ b/kern/cbuf.c @@ -15,7 +15,8 @@ * along with this program. If not, see . */ -#include +#include + #include #include #include diff --git a/kern/condition.c b/kern/condition.c index 4a837f4e..c8ea5f39 100644 --- a/kern/condition.c +++ b/kern/condition.c @@ -18,10 +18,10 @@ * Locking order : mutex -> sleep queue */ +#include #include #include -#include #include #include #include diff --git a/kern/console.c b/kern/console.c index c82e7dc9..e8c0c28a 100644 --- a/kern/console.c +++ b/kern/console.c @@ -15,13 +15,13 @@ * along with this program. If not, see . */ +#include #include #include #include #include #include -#include #include #include #include diff --git a/kern/hash.h b/kern/hash.h index 108d4b46..db399960 100644 --- a/kern/hash.h +++ b/kern/hash.h @@ -39,11 +39,10 @@ #ifndef _KERN_HASH_H #define _KERN_HASH_H +#include #include #include -#include - #ifdef __LP64__ #define HASH_ALLBITS 64 #define hash_long(n, bits) hash_int64(n, bits) diff --git a/kern/kmem.c b/kern/kmem.c index 5cce5589..1f822b8a 100644 --- a/kern/kmem.c +++ b/kern/kmem.c @@ -41,13 +41,13 @@ * TODO Rework the CPU pool layer to use the SLQB algorithm by Nick Piggin. */ +#include #include #include #include #include #include -#include #include #include #include diff --git a/kern/llsync.c b/kern/llsync.c index 1942576d..1c5086f3 100644 --- a/kern/llsync.c +++ b/kern/llsync.c @@ -32,11 +32,11 @@ * TODO Gracefully handle large amounts of deferred works. */ +#include #include #include #include -#include #include #include #include diff --git a/kern/llsync_i.h b/kern/llsync_i.h index 6bc1bf1d..12e2861c 100644 --- a/kern/llsync_i.h +++ b/kern/llsync_i.h @@ -18,7 +18,8 @@ #ifndef _KERN_LLSYNC_I_H #define _KERN_LLSYNC_I_H -#include +#include + #include #include #include diff --git a/kern/log2.h b/kern/log2.h index 0a3768a7..ebcf2f38 100644 --- a/kern/log2.h +++ b/kern/log2.h @@ -21,7 +21,8 @@ #ifndef _KERN_LOG2_H #define _KERN_LOG2_H -#include +#include + #include static inline unsigned int diff --git a/kern/mutex.h b/kern/mutex.h index 1100b77d..d09a7bbe 100644 --- a/kern/mutex.h +++ b/kern/mutex.h @@ -68,7 +68,8 @@ mutex_unlock(struct mutex *mutex) #else /* X15_MUTEX_PI */ -#include +#include + #include #include #include diff --git a/kern/mutex_i.h b/kern/mutex_i.h index a4a40eb5..3b36dcde 100644 --- a/kern/mutex_i.h +++ b/kern/mutex_i.h @@ -20,7 +20,8 @@ #ifndef X15_MUTEX_PI -#include +#include + #include #include diff --git a/kern/percpu.c b/kern/percpu.c index 5e4ff827..a1f7df15 100644 --- a/kern/percpu.c +++ b/kern/percpu.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ +#include #include #include #include #include -#include #include #include #include diff --git a/kern/percpu.h b/kern/percpu.h index 59959518..d6a8d1ab 100644 --- a/kern/percpu.h +++ b/kern/percpu.h @@ -53,9 +53,9 @@ #ifndef _KERN_PERCPU_H #define _KERN_PERCPU_H +#include #include -#include #include #define PERCPU_SECTION .percpu diff --git a/kern/rbtree.c b/kern/rbtree.c index e2ea54ad..adce033a 100644 --- a/kern/rbtree.c +++ b/kern/rbtree.c @@ -15,10 +15,10 @@ * along with this program. If not, see . */ +#include #include #include -#include #include #include #include diff --git a/kern/rbtree.h b/kern/rbtree.h index 38083427..4ae8353f 100644 --- a/kern/rbtree.h +++ b/kern/rbtree.h @@ -21,10 +21,10 @@ #ifndef _KERN_RBTREE_H #define _KERN_RBTREE_H +#include #include #include -#include #include /* diff --git a/kern/rbtree_i.h b/kern/rbtree_i.h index 99722977..944148e0 100644 --- a/kern/rbtree_i.h +++ b/kern/rbtree_i.h @@ -18,10 +18,10 @@ #ifndef _KERN_RBTREE_I_H #define _KERN_RBTREE_I_H +#include #include #include -#include #include /* diff --git a/kern/rdxtree.c b/kern/rdxtree.c index 788f3ba8..b518c7f6 100644 --- a/kern/rdxtree.c +++ b/kern/rdxtree.c @@ -15,12 +15,12 @@ * along with this program. If not, see . */ +#include #include #include #include #include -#include #include #include #include diff --git a/kern/rtmutex.c b/kern/rtmutex.c index 6f639ddf..09f011c4 100644 --- a/kern/rtmutex.c +++ b/kern/rtmutex.c @@ -15,10 +15,10 @@ * along with this program. If not, see . */ +#include #include #include -#include #include #include #include diff --git a/kern/rtmutex.h b/kern/rtmutex.h index f64274d7..ec79afa9 100644 --- a/kern/rtmutex.h +++ b/kern/rtmutex.h @@ -24,9 +24,9 @@ #ifndef _KERN_RTMUTEX_H #define _KERN_RTMUTEX_H +#include #include -#include #include #include #include diff --git a/kern/rtmutex_i.h b/kern/rtmutex_i.h index 2f2cc17f..984cfd16 100644 --- a/kern/rtmutex_i.h +++ b/kern/rtmutex_i.h @@ -18,10 +18,10 @@ #ifndef _KERN_RTMUTEX_I_H #define _KERN_RTMUTEX_I_H +#include #include #include -#include #include #include #include diff --git a/kern/semaphore.h b/kern/semaphore.h index d7219b4f..e08927ec 100644 --- a/kern/semaphore.h +++ b/kern/semaphore.h @@ -32,7 +32,8 @@ #ifndef _KERN_SEMAPHORE_H #define _KERN_SEMAPHORE_H -#include +#include + #include #include #include diff --git a/kern/semaphore_i.h b/kern/semaphore_i.h index 54985062..acd7cd48 100644 --- a/kern/semaphore_i.h +++ b/kern/semaphore_i.h @@ -18,7 +18,8 @@ #ifndef _KERN_SEMAPHORE_I_H #define _KERN_SEMAPHORE_I_H -#include +#include + #include struct semaphore { diff --git a/kern/sleepq.c b/kern/sleepq.c index 09548db6..f5fa6729 100644 --- a/kern/sleepq.c +++ b/kern/sleepq.c @@ -18,11 +18,11 @@ * TODO Analyse hash parameters. */ +#include #include #include #include -#include #include #include #include diff --git a/kern/spinlock.c b/kern/spinlock.c index 3ec36b36..6b9f2788 100644 --- a/kern/spinlock.c +++ b/kern/spinlock.c @@ -53,9 +53,9 @@ * more contention, an operation called downgrading. */ +#include #include -#include #include #include #include diff --git a/kern/spinlock_i.h b/kern/spinlock_i.h index 45018033..c9dcdd10 100644 --- a/kern/spinlock_i.h +++ b/kern/spinlock_i.h @@ -18,10 +18,10 @@ #ifndef _KERN_SPINLOCK_I_H #define _KERN_SPINLOCK_I_H +#include #include #include -#include #include #include #include diff --git a/kern/sref.c b/kern/sref.c index 3f399a30..95e697a4 100644 --- a/kern/sref.c +++ b/kern/sref.c @@ -41,11 +41,11 @@ * TODO Reconsider whether it's possible to bring back local review queues. */ +#include #include #include #include -#include #include #include #include diff --git a/kern/thread.c b/kern/thread.c index e6875586..68aa7285 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -81,13 +81,13 @@ * weights in a smoother way than a raw scaling). */ +#include #include #include #include #include #include -#include #include #include #include diff --git a/kern/thread.h b/kern/thread.h index 62708268..e348fe39 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -33,10 +33,10 @@ #ifndef _KERN_THREAD_H #define _KERN_THREAD_H +#include #include #include -#include #include #include #include diff --git a/kern/turnstile.c b/kern/turnstile.c index 7b27d841..78532fb5 100644 --- a/kern/turnstile.c +++ b/kern/turnstile.c @@ -43,11 +43,11 @@ * TODO Analyse hash parameters. */ +#include #include #include #include -#include #include #include #include diff --git a/kern/work.c b/kern/work.c index 714af35c..738ab8b6 100644 --- a/kern/work.c +++ b/kern/work.c @@ -15,10 +15,10 @@ * along with this program. If not, see . */ +#include #include #include -#include #include #include #include diff --git a/kern/xcall.c b/kern/xcall.c index 364ad0be..ce22aa0f 100644 --- a/kern/xcall.c +++ b/kern/xcall.c @@ -15,9 +15,9 @@ * along with this program. If not, see . */ +#include #include -#include #include #include #include diff --git a/vm/vm_kmem.c b/vm/vm_kmem.c index 8a7272cb..a9ba842d 100644 --- a/vm/vm_kmem.c +++ b/vm/vm_kmem.c @@ -18,10 +18,10 @@ * TODO Rework so that pmap update errors can be handled. */ +#include #include #include -#include #include #include #include diff --git a/vm/vm_map.c b/vm/vm_map.c index 657f4b59..f506d3ba 100644 --- a/vm/vm_map.c +++ b/vm/vm_map.c @@ -19,11 +19,11 @@ * needed for kernel allocation. */ +#include #include #include #include -#include #include #include #include diff --git a/vm/vm_page.c b/vm/vm_page.c index 284964a4..edf213ef 100644 --- a/vm/vm_page.c +++ b/vm/vm_page.c @@ -29,13 +29,13 @@ * The symmetric case is handled likewise. */ +#include #include #include #include #include #include -#include #include #include #include diff --git a/vm/vm_page.h b/vm/vm_page.h index 139f1bff..fa018a05 100644 --- a/vm/vm_page.h +++ b/vm/vm_page.h @@ -21,10 +21,10 @@ #ifndef _VM_VM_PAGE_H #define _VM_VM_PAGE_H +#include #include #include -#include #include #include #include -- cgit v1.2.3