]> git.ipfire.org Git - thirdparty/git.git/blobdiff - thread-utils.c
submodule: defend against submodule.update = !command in .gitmodules
[thirdparty/git.git] / thread-utils.c
index a2135e0743ac60d8d4512210a81bac2102948fa1..532984569132de11f6f05b561f817817523a3468 100644 (file)
@@ -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