summaryrefslogtreecommitdiff
path: root/kern
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-29 00:52:40 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-29 01:12:05 +0100
commitbc6e853d4b27055056eebfd871aaf0fc60405b0f (patch)
tree9860d545d88a627fcea3309efea89cb27779aaf9 /kern
parent3ec2193d8538beec5d961d11d67f568d8d3f6cd8 (diff)
Fix undefined behavior in conditional macro replacement
See C11 6.10.3 ยง11 : If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives, the behavior is undefined.
Diffstat (limited to 'kern')
-rw-r--r--kern/mutex/mutex_adaptive.c9
-rw-r--r--kern/mutex/mutex_plain.c10
-rw-r--r--kern/rtmutex.c9
-rw-r--r--kern/thread.c17
4 files changed, 33 insertions, 12 deletions
diff --git a/kern/mutex/mutex_adaptive.c b/kern/mutex/mutex_adaptive.c
index bda54532..db92f9d5 100644
--- a/kern/mutex/mutex_adaptive.c
+++ b/kern/mutex/mutex_adaptive.c
@@ -333,9 +333,14 @@ mutex_adaptive_setup(void)
return 0;
}
-INIT_OP_DEFINE(mutex_adaptive_setup,
- INIT_OP_DEP(mutex_adaptive_bootstrap, true),
#ifdef CONFIG_MUTEX_DEBUG
+#define MUTEX_ADAPTIVE_DEBUG_INIT_OP_DEPS \
INIT_OP_DEP(syscnt_setup, true),
+#else /* CONFIG_MUTEX_DEBUG */
+#define MUTEX_ADAPTIVE_DEBUG_INIT_OP_DEPS
#endif /* CONFIG_MUTEX_DEBUG */
+
+INIT_OP_DEFINE(mutex_adaptive_setup,
+ INIT_OP_DEP(mutex_adaptive_bootstrap, true),
+ MUTEX_ADAPTIVE_DEBUG_INIT_OP_DEPS
);
diff --git a/kern/mutex/mutex_plain.c b/kern/mutex/mutex_plain.c
index 266bd70b..f12f13fd 100644
--- a/kern/mutex/mutex_plain.c
+++ b/kern/mutex/mutex_plain.c
@@ -173,9 +173,15 @@ mutex_plain_setup(void)
return 0;
}
-INIT_OP_DEFINE(mutex_plain_setup,
- INIT_OP_DEP(mutex_plain_bootstrap, true),
#ifdef CONFIG_MUTEX_DEBUG
+#define MUTEX_PLAIN_DEBUG_INIT_OP_DEPS \
INIT_OP_DEP(syscnt_setup, true),
+#else /* CONFIG_MUTEX_DEBUG */
+#define MUTEX_PLAIN_DEBUG_INIT_OP_DEPS
#endif /* CONFIG_MUTEX_DEBUG */
+
+
+INIT_OP_DEFINE(mutex_plain_setup,
+ INIT_OP_DEP(mutex_plain_bootstrap, true),
+ MUTEX_PLAIN_DEBUG_INIT_OP_DEPS
);
diff --git a/kern/rtmutex.c b/kern/rtmutex.c
index 7457196d..55d17cdc 100644
--- a/kern/rtmutex.c
+++ b/kern/rtmutex.c
@@ -240,9 +240,14 @@ rtmutex_setup(void)
return 0;
}
-INIT_OP_DEFINE(rtmutex_setup,
- INIT_OP_DEP(rtmutex_bootstrap, true),
#ifdef CONFIG_MUTEX_DEBUG
+#define RTMUTEX_DEBUG_INIT_OPS \
INIT_OP_DEP(syscnt_setup, true),
+#else /* CONFIG_MUTEX_DEBUG */
+#define RTMUTEX_DEBUG_INIT_OPS
#endif /* CONFIG_MUTEX_DEBUG */
+
+INIT_OP_DEFINE(rtmutex_setup,
+ INIT_OP_DEP(rtmutex_bootstrap, true),
+ RTMUTEX_DEBUG_INIT_OPS
);
diff --git a/kern/thread.c b/kern/thread.c
index 601cc3fe..330b5375 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -2310,6 +2310,15 @@ thread_setup(void)
return 0;
}
+#ifdef CONFIG_THREAD_STACK_GUARD
+#define THREAD_STACK_GUARD_INIT_OP_DEPS \
+ INIT_OP_DEP(vm_kmem_setup, true), \
+ INIT_OP_DEP(vm_map_setup, true), \
+ INIT_OP_DEP(vm_page_setup, true),
+#else /* CONFIG_THREAD_STACK_GUARD */
+#define THREAD_STACK_GUARD_INIT_OP_DEPS
+#endif /* CONFIG_THREAD_STACK_GUARD */
+
INIT_OP_DEFINE(thread_setup,
INIT_OP_DEP(cpumap_setup, true),
INIT_OP_DEP(kmem_setup, true),
@@ -2318,12 +2327,8 @@ INIT_OP_DEFINE(thread_setup,
INIT_OP_DEP(task_setup, true),
INIT_OP_DEP(thread_bootstrap, true),
INIT_OP_DEP(turnstile_setup, true),
-#ifdef CONFIG_THREAD_STACK_GUARD
- INIT_OP_DEP(vm_kmem_setup, true),
- INIT_OP_DEP(vm_map_setup, true),
- INIT_OP_DEP(vm_page_setup, true),
-#endif
- );
+ THREAD_STACK_GUARD_INIT_OP_DEPS
+);
void __init
thread_ap_setup(void)