parlib: Add a helper for multi-threaded-ness
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 6 Mar 2017 21:21:12 +0000 (16:21 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 3 May 2017 16:13:02 +0000 (12:13 -0400)
GCC needs to know at runtime if we have multiple threads or not.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
user/parlib/include/parlib/uthread.h
user/parlib/uthread.c

index ed651bf..e12f4ea 100644 (file)
@@ -182,4 +182,7 @@ void uth_cond_var_wait(uth_cond_var_t cv, uth_mutex_t m);
 void uth_cond_var_signal(uth_cond_var_t cv);
 void uth_cond_var_broadcast(uth_cond_var_t cv);
 
+/* Called by gcc to see if we are multithreaded. */
+bool uth_2ls_is_multithreaded(void);
+
 __END_DECLS
index b86a7ea..39f9b65 100644 (file)
@@ -1193,3 +1193,10 @@ static void __uthread_free_tls(struct uthread *uthread)
        free_tls(uthread->tls_desc);
        uthread->tls_desc = NULL;
 }
+
+bool uth_2ls_is_multithreaded(void)
+{
+       /* thread 0 is single threaded.  For the foreseeable future, every other 2LS
+        * will be multithreaded. */
+       return sched_ops != &thread0_2ls_ops;
+}