- return th->pid;
- cleanup:
- /* if(th && th->tls_cookie>=0) os_free_tls_pointer(th); */
- if(spaces) os_invalidate(spaces,
- THREAD_CONTROL_STACK_SIZE+BINDING_STACK_SIZE+
- ALIEN_STACK_SIZE+dynamic_values_bytes);
- return 0;
+void create_initial_thread(lispobj initial_function) {
+ struct thread *th=create_thread_struct(initial_function);
+ pid_t kid_pid=getpid();
+ if(th && kid_pid>0) {
+ link_thread(th,kid_pid);
+ initial_thread_trampoline(all_threads); /* no return */
+ } else lose("can't create initial thread");
+}
+
+#ifdef LISP_FEATURE_SB_THREAD
+pid_t create_thread(lispobj initial_function) {
+ struct thread *th=create_thread_struct(initial_function);
+ pid_t kid_pid=clone(new_thread_trampoline,
+ (((void*)th->control_stack_start)+
+ THREAD_CONTROL_STACK_SIZE-4),
+ CLONE_FILES|SIG_THREAD_EXIT|CLONE_VM,th);
+
+ if(th && kid_pid>0) {
+ link_thread(th,kid_pid);
+ return th->pid;
+ } else {
+ destroy_thread(th);
+ return 0;
+ }