summaryrefslogtreecommitdiff
path: root/thread-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread-utils.c')
-rw-r--r--thread-utils.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/thread-utils.c b/thread-utils.c
index a2135e0..5329845 100644
--- a/thread-utils.c
+++ b/thread-utils.c
@@ -20,6 +20,9 @@
int online_cpus(void)
{
+#ifdef NO_PTHREADS
+ return 1;
+#else
#ifdef _SC_NPROCESSORS_ONLN
long ncpus;
#endif
@@ -59,10 +62,12 @@ int online_cpus(void)
#endif
return 1;
+#endif
}
int init_recursive_mutex(pthread_mutex_t *m)
{
+#ifndef NO_PTHREADS
pthread_mutexattr_t a;
int ret;
@@ -74,4 +79,47 @@ int init_recursive_mutex(pthread_mutex_t *m)
pthread_mutexattr_destroy(&a);
}
return ret;
+#else
+ return 0;
+#endif
+}
+
+#ifdef NO_PTHREADS
+int dummy_pthread_create(pthread_t *pthread, const void *attr,
+ void *(*fn)(void *), void *data)
+{
+ /*
+ * Do nothing.
+ *
+ * The main purpose of this function is to break compiler's
+ * flow analysis and avoid -Wunused-variable false warnings.
+ */
+ return ENOSYS;
+}
+
+int dummy_pthread_init(void *data)
+{
+ /*
+ * Do nothing.
+ *
+ * The main purpose of this function is to break compiler's
+ * flow analysis or it may realize that functions like
+ * pthread_mutex_init() is no-op, which means the (static)
+ * variable is not used/initialized at all and trigger
+ * -Wunused-variable
+ */
+ return ENOSYS;
}
+
+int dummy_pthread_join(pthread_t pthread, void **retval)
+{
+ /*
+ * Do nothing.
+ *
+ * The main purpose of this function is to break compiler's
+ * flow analysis and avoid -Wunused-variable false warnings.
+ */
+ return ENOSYS;
+}
+
+#endif