kern_thr.c (685dc743dc3b5645e34836464128e1c0558b404b) kern_thr.c (7b68fb5ab2a276ccd081cc1a43cebf0fb315e952)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2003, Jeffrey Roberson <jeff@freebsd.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 132 unchanged lines hidden (view full) ---

141 return (kern_thr_new(td, &param));
142}
143
144static int
145thr_new_initthr(struct thread *td, void *thunk)
146{
147 stack_t stack;
148 struct thr_param *param;
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2003, Jeffrey Roberson <jeff@freebsd.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 132 unchanged lines hidden (view full) ---

141 return (kern_thr_new(td, &param));
142}
143
144static int
145thr_new_initthr(struct thread *td, void *thunk)
146{
147 stack_t stack;
148 struct thr_param *param;
149 int error;
149
150 /*
151 * Here we copy out tid to two places, one for child and one
152 * for parent, because pthread can create a detached thread,
153 * if parent wants to safely access child tid, it has to provide
154 * its storage, because child thread may exit quickly and
155 * memory is freed before parent thread can access it.
156 */
157 param = thunk;
158 if ((param->child_tid != NULL &&
159 suword_lwpid(param->child_tid, td->td_tid)) ||
160 (param->parent_tid != NULL &&
161 suword_lwpid(param->parent_tid, td->td_tid)))
162 return (EFAULT);
163
164 /* Set up our machine context. */
165 stack.ss_sp = param->stack_base;
166 stack.ss_size = param->stack_size;
167 /* Set upcall address to user thread entry function. */
150
151 /*
152 * Here we copy out tid to two places, one for child and one
153 * for parent, because pthread can create a detached thread,
154 * if parent wants to safely access child tid, it has to provide
155 * its storage, because child thread may exit quickly and
156 * memory is freed before parent thread can access it.
157 */
158 param = thunk;
159 if ((param->child_tid != NULL &&
160 suword_lwpid(param->child_tid, td->td_tid)) ||
161 (param->parent_tid != NULL &&
162 suword_lwpid(param->parent_tid, td->td_tid)))
163 return (EFAULT);
164
165 /* Set up our machine context. */
166 stack.ss_sp = param->stack_base;
167 stack.ss_size = param->stack_size;
168 /* Set upcall address to user thread entry function. */
168 cpu_set_upcall(td, param->start_func, param->arg, &stack);
169 error = cpu_set_upcall(td, param->start_func, param->arg, &stack);
170 if (error != 0)
171 return (error);
169 /* Setup user TLS address and TLS pointer register. */
170 return (cpu_set_user_tls(td, param->tls_base));
171}
172
173int
174kern_thr_new(struct thread *td, struct thr_param *param)
175{
176 struct rtprio rtp, *rtpp;

--- 449 unchanged lines hidden ---
172 /* Setup user TLS address and TLS pointer register. */
173 return (cpu_set_user_tls(td, param->tls_base));
174}
175
176int
177kern_thr_new(struct thread *td, struct thr_param *param)
178{
179 struct rtprio rtp, *rtpp;

--- 449 unchanged lines hidden ---