diff --git a/src/task.c b/src/task.c index 8e40fcd8d2a03c..fbad9ec93b4163 100644 --- a/src/task.c +++ b/src/task.c @@ -260,16 +260,15 @@ static void NOINLINE NORETURN start_task(void) } #ifdef COPY_STACKS -#ifndef ASM_COPY_STACKS void NOINLINE jl_set_base_ctx(char *__stk) { + jl_stackbase = (char*)(((uptrint_t)__stk + sizeof(*__stk))&-16); // also ensures stackbase is 16-byte aligned +#ifndef ASM_COPY_STACKS if (jl_setjmp(jl_base_ctx, 1)) { start_task(); } -} -#else -void jl_set_base_ctx(char *__stk) { } #endif +} #endif DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel) @@ -278,7 +277,6 @@ DLLEXPORT void julia_init(JL_IMAGE_SEARCH rel) _julia_init(rel); #ifdef COPY_STACKS char __stk; - jl_stackbase = (char*)(((uptrint_t)&__stk + sizeof(__stk))&-16); // also ensures stackbase is 16-byte aligned jl_set_base_ctx(&__stk); // separate function, to record the size of a stack frame #endif } diff --git a/src/threading.c b/src/threading.c index 47c8d7d1717bbd..e70c352e84b4f9 100644 --- a/src/threading.c +++ b/src/threading.c @@ -111,8 +111,9 @@ void ti_threadfun(void *arg) // set up tasking jl_init_root_task(0,0); - jl_set_stackbase((char*)&arg); +#ifdef COPY_STACKS jl_set_base_ctx((char*)&arg); +#endif // set the thread-local tid and wait for a thread group while (ta->state == TI_THREAD_INIT) @@ -165,7 +166,7 @@ void ti_threadfun(void *arg) } #if PROFILE_JL_THREADING -void ti_reset_timings(); +void ti_reset_timings(void); #endif // interface to Julia; sets up to make the runtime thread-safe @@ -184,9 +185,9 @@ void jl_init_threading(void) jl_n_threads = jl_max_threads; // set up space for per-thread heaps - jl_all_heaps = malloc(jl_n_threads * sizeof(void*)); - jl_all_pgcstacks = malloc(jl_n_threads * sizeof(void*)); - jl_all_task_states = malloc(jl_n_threads * sizeof(jl_thread_task_state_t)); + jl_all_heaps = (struct _jl_thread_heap_t **)malloc(jl_n_threads * sizeof(void*)); + jl_all_pgcstacks = (jl_gcframe_t ***)malloc(jl_n_threads * sizeof(void*)); + jl_all_task_states = (jl_thread_task_state_t *)malloc(jl_n_threads * sizeof(jl_thread_task_state_t)); #if PROFILE_JL_THREADING // estimate CPU speed @@ -229,7 +230,7 @@ void jl_start_threads(void) } // create threads - targs = malloc((jl_n_threads - 1) * sizeof (ti_threadarg_t *)); + targs = (ti_threadarg_t **)malloc((jl_n_threads - 1) * sizeof (ti_threadarg_t *)); for (i = 0; i < jl_n_threads - 1; ++i) { targs[i] = (ti_threadarg_t *)malloc(sizeof (ti_threadarg_t)); targs[i]->state = TI_THREAD_INIT; @@ -285,10 +286,10 @@ void jl_shutdown_threading(void) } // return thread's thread group -void *jl_threadgroup() { return (void *)tgworld; } +void *jl_threadgroup(void) { return (void *)tgworld; } // utility -void jl_cpu_pause() { cpu_pause(); } +void jl_cpu_pause(void) { cpu_pause(); } // interface to user code: specialize and compile the user thread function // and run it in all threads