diff options
author | Richard Braun <rbraun@sceen.net> | 2017-02-04 16:21:10 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-02-04 16:21:10 +0100 |
commit | 7a00044da882d30b1dea8757c7f6a1ccaa9ee08d (patch) | |
tree | 9e342eca8a673ac9b0982c3e4bda22ff5158690e /kern | |
parent | d09b913612712c7d58e5ee3ee20703cce63ad0b0 (diff) |
kern/types: split into module-specific type headers
Using a single header for all types causing inclusion circular
dependencies isn't very elegant and doesn't scale.
Diffstat (limited to 'kern')
-rw-r--r-- | kern/condition.c | 1 | ||||
-rw-r--r-- | kern/condition.h | 5 | ||||
-rw-r--r-- | kern/condition_types.h (renamed from kern/types.h) | 34 | ||||
-rw-r--r-- | kern/mutex.c | 1 | ||||
-rw-r--r-- | kern/mutex.h | 2 | ||||
-rw-r--r-- | kern/mutex_i.h | 2 | ||||
-rw-r--r-- | kern/mutex_types.h | 33 | ||||
-rw-r--r-- | kern/spinlock.h | 2 | ||||
-rw-r--r-- | kern/spinlock_i.h | 2 | ||||
-rw-r--r-- | kern/spinlock_types.h | 28 | ||||
-rw-r--r-- | kern/thread.h | 6 | ||||
-rw-r--r-- | kern/thread_i.h | 3 |
12 files changed, 82 insertions, 37 deletions
diff --git a/kern/condition.c b/kern/condition.c index 2c233df0..7d83f47d 100644 --- a/kern/condition.c +++ b/kern/condition.c @@ -30,7 +30,6 @@ #include <kern/spinlock.h> #include <kern/stddef.h> #include <kern/thread.h> -#include <kern/types.h> void condition_wait(struct condition *condition, struct mutex *mutex) diff --git a/kern/condition.h b/kern/condition.h index 3de39be2..4e7f7f0f 100644 --- a/kern/condition.h +++ b/kern/condition.h @@ -21,13 +21,10 @@ #ifndef _KERN_CONDITION_H #define _KERN_CONDITION_H +#include <kern/condition_types.h> #include <kern/list.h> -#include <kern/mutex.h> #include <kern/spinlock.h> #include <kern/stddef.h> -#include <kern/types.h> - -struct condition; static inline void condition_init(struct condition *condition) diff --git a/kern/types.h b/kern/condition_types.h index fa13ef7a..9f68bf44 100644 --- a/kern/types.h +++ b/kern/condition_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2014 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,33 +13,17 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * + * Isolated type definition used to avoid inclusion circular dependencies. */ -#ifndef _KERN_TYPES_H -#define _KERN_TYPES_H - -#include <machine/types.h> - -/* - * Forward declarations. - */ -struct task; - -/* - * Types defined here to avoid inclusion loops. - */ +#ifndef _KERN_CONDITION_TYPES_H +#define _KERN_CONDITION_TYPES_H #include <kern/list.h> - -struct spinlock { - unsigned int locked; -}; - -struct mutex { - unsigned int state; - struct spinlock lock; - struct list waiters; -}; +#include <kern/mutex_types.h> +#include <kern/spinlock_types.h> struct condition { struct spinlock lock; @@ -47,4 +31,4 @@ struct condition { struct list waiters; }; -#endif /* _KERN_TYPES_H */ +#endif /* _KERN_CONDITION_TYPES_H */ diff --git a/kern/mutex.c b/kern/mutex.c index 3c76f50c..58e24513 100644 --- a/kern/mutex.c +++ b/kern/mutex.c @@ -19,7 +19,6 @@ #include <kern/mutex_i.h> #include <kern/spinlock.h> #include <kern/thread.h> -#include <kern/types.h> void mutex_lock_slow(struct mutex *mutex) diff --git a/kern/mutex.h b/kern/mutex.h index a36ed17e..5ea8061e 100644 --- a/kern/mutex.h +++ b/kern/mutex.h @@ -26,8 +26,8 @@ #include <kern/assert.h> #include <kern/list.h> #include <kern/mutex_i.h> +#include <kern/mutex_types.h> #include <kern/spinlock.h> -#include <kern/types.h> struct mutex; diff --git a/kern/mutex_i.h b/kern/mutex_i.h index b09f8cdd..aaaf7cad 100644 --- a/kern/mutex_i.h +++ b/kern/mutex_i.h @@ -20,8 +20,8 @@ #include <kern/assert.h> #include <kern/list.h> +#include <kern/mutex_types.h> #include <kern/thread.h> -#include <kern/types.h> #include <machine/atomic.h> #define MUTEX_UNLOCKED 0 diff --git a/kern/mutex_types.h b/kern/mutex_types.h new file mode 100644 index 00000000..4f99b400 --- /dev/null +++ b/kern/mutex_types.h @@ -0,0 +1,33 @@ +/* + * 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 + * 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/>. + * + * + * Isolated type definition used to avoid inclusion circular dependencies. + */ + +#ifndef _KERN_MUTEX_TYPES_H +#define _KERN_MUTEX_TYPES_H + +#include <kern/list.h> +#include <kern/spinlock_types.h> + +struct mutex { + unsigned int state; + struct spinlock lock; + struct list waiters; +}; + +#endif /* _KERN_MUTEX_TYPES_H */ diff --git a/kern/spinlock.h b/kern/spinlock.h index f63c4e0b..a9e82bc7 100644 --- a/kern/spinlock.h +++ b/kern/spinlock.h @@ -26,8 +26,8 @@ #include <kern/assert.h> #include <kern/macros.h> #include <kern/spinlock_i.h> +#include <kern/spinlock_types.h> #include <kern/thread.h> -#include <kern/types.h> #include <machine/cpu.h> struct spinlock; diff --git a/kern/spinlock_i.h b/kern/spinlock_i.h index ed851099..6f7f4a6c 100644 --- a/kern/spinlock_i.h +++ b/kern/spinlock_i.h @@ -19,7 +19,7 @@ #define _KERN_SPINLOCK_I_H #include <kern/assert.h> -#include <kern/types.h> +#include <kern/spinlock_types.h> #include <machine/atomic.h> #include <machine/cpu.h> diff --git a/kern/spinlock_types.h b/kern/spinlock_types.h new file mode 100644 index 00000000..f5a03866 --- /dev/null +++ b/kern/spinlock_types.h @@ -0,0 +1,28 @@ +/* + * 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 + * 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/>. + * + * + * Isolated type definition used to avoid inclusion circular dependencies. + */ + +#ifndef _KERN_SPINLOCK_TYPES_H +#define _KERN_SPINLOCK_TYPES_H + +struct spinlock { + unsigned int locked; +}; + +#endif /* _KERN_SPINLOCK_TYPES_H */ diff --git a/kern/thread.h b/kern/thread.h index 14fd8669..074963de 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -36,10 +36,14 @@ #include <kern/assert.h> #include <kern/cpumap.h> #include <kern/macros.h> -#include <kern/types.h> #include <machine/tcb.h> /* + * Forward declaration + */ +struct spinlock; + +/* * Thread structure. */ struct thread; diff --git a/kern/thread_i.h b/kern/thread_i.h index 752eb944..6d9bc501 100644 --- a/kern/thread_i.h +++ b/kern/thread_i.h @@ -18,11 +18,12 @@ #ifndef _KERN_THREAD_I_H #define _KERN_THREAD_I_H +#include <kern/condition_types.h> #include <kern/cpumap.h> #include <kern/list.h> #include <kern/macros.h> +#include <kern/mutex_types.h> #include <kern/param.h> -#include <kern/types.h> #include <machine/atomic.h> #include <machine/tcb.h> |