parlib: Move init_once_racy() to parlib (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 3 Apr 2017 20:05:56 +0000 (16:05 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 3 May 2017 16:13:02 +0000 (12:13 -0400)
Reinstall your kernel headers.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/ros/common.h
user/parlib/include/parlib/parlib.h
user/parlib/uthread.c
user/parlib/vcore.c
user/pthread/pthread.c
user/vmm/sched.c

index f130e9b..78ec9e2 100644 (file)
@@ -155,16 +155,4 @@ do {                                                                           \
        }                                                                          \
 } while (0)
 
-/* Aborts with 'retcmd' if this function has already been called.  Compared to
- * run_once, this is put at the top of a function that can be called from
- * multiple sources but should only execute once. */
-#define init_once_racy(retcmd)                                                 \
-do {                                                                           \
-       static bool initialized = FALSE;                                           \
-       if (initialized) {                                                         \
-               retcmd;                                                                \
-       }                                                                          \
-       initialized = TRUE;                                                        \
-} while (0)
-
 #endif /* __ASSEMBLER__ */
index 3581e5c..8bcd54d 100644 (file)
@@ -73,6 +73,18 @@ pid_t create_child(const char *exe, int argc, char *const argv[],
 pid_t create_child_with_stdfds(const char *exe, int argc, char *const argv[],
                                char *const envp[]);
 
+/* Aborts with 'retcmd' if this function has already been called.  Compared to
+ * run_once, this is put at the top of a function that can be called from
+ * multiple sources but should only execute once. */
+#define parlib_init_once_racy(retcmd)                                          \
+do {                                                                           \
+       static bool initialized = FALSE;                                           \
+       if (initialized) {                                                         \
+               retcmd;                                                                \
+       }                                                                          \
+       initialized = TRUE;                                                        \
+} while (0)
+
 __END_DECLS
 
 #endif // !ASSEMBLER
index 39f9b65..ff685f1 100644 (file)
@@ -91,7 +91,7 @@ static void uthread_track_thread0(struct uthread *uthread)
 void uthread_mcp_init()
 {
        /* Prevent this from happening more than once. */
-       init_once_racy(return);
+       parlib_init_once_racy(return);
 
        /* Doing this after the init_once check, since we don't want to let the
         * process/2LS change their mind about being an MCP or not once they have
@@ -239,7 +239,7 @@ void __attribute__((constructor)) uthread_lib_init(void)
        if (__in_fake_parlib())
                return;
        /* Only run once, but make sure that vcore_lib_init() has run already. */
-       init_once_racy(return);
+       parlib_init_once_racy(return);
        vcore_lib_init();
 
        ret = posix_memalign((void**)&thread0_uth, __alignof__(struct uthread),
index 0bc444a..2773640 100644 (file)
@@ -184,7 +184,7 @@ void __attribute__((constructor)) vcore_lib_init(void)
         * Also, this is the "lowest" level constructor for now, so we don't need
         * to call any other init functions after our run_once() call. This may
         * change in the future. */
-       init_once_racy(return);
+       parlib_init_once_racy(return);
        /* Need to alloc vcore0's transition stuff here (technically, just the TLS)
         * so that schedulers can use vcore0's transition TLS before it comes up in
         * vcore_entry() */
index 4d699d6..b2cb8d4 100644 (file)
@@ -436,7 +436,7 @@ void __attribute__((constructor)) pthread_lib_init(void)
        int ret;
 
        /* Only run once, but make sure that uthread_lib_init() has run already. */
-       init_once_racy(return);
+       parlib_init_once_racy(return);
        uthread_lib_init();
 
        mcs_pdr_init(&queue_lock);
@@ -521,7 +521,7 @@ void __attribute__((constructor)) pthread_lib_init(void)
 void pthread_mcp_init()
 {
        /* Prevent this from happening more than once. */
-       init_once_racy(return);
+       parlib_init_once_racy(return);
 
        uthread_mcp_init();
        /* From here forward we are an MCP running on vcore 0. Could consider doing
index ad28499..5be751f 100644 (file)
@@ -109,7 +109,7 @@ static void __attribute__((constructor)) vmm_lib_init(void)
 {
        struct task_thread *thread0;
 
-       init_once_racy(return);
+       parlib_init_once_racy(return);
        uthread_lib_init();
 
        /* Note that thread0 doesn't belong to a VM.  We can set this during