thr_init.c (0465e53d8c067a68cd1f9d49ac1b02d1ff7ef688) thr_init.c (4cd18a22d554e7205ddf0408badbda02411ed51e)
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

162void
163init_td_common(struct pthread *td, struct pthread_attr *attrp, int reinit)
164{
165 /*
166 * Some parts of a pthread are initialized only once.
167 */
168 if (!reinit) {
169 memset(td, 0, sizeof(struct pthread));
1/*
2 * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

162void
163init_td_common(struct pthread *td, struct pthread_attr *attrp, int reinit)
164{
165 /*
166 * Some parts of a pthread are initialized only once.
167 */
168 if (!reinit) {
169 memset(td, 0, sizeof(struct pthread));
170 td->cancelflags = PTHREAD_CANCEL_ENABLE |
171 PTHREAD_CANCEL_DEFERRED;
170 td->cancelmode = M_DEFERRED;
171 td->cancelstate = M_DEFERRED;
172 td->cancellation = CS_NULL;
172 memcpy(&td->attr, attrp, sizeof(struct pthread_attr));
173 td->magic = PTHREAD_MAGIC;
174 TAILQ_INIT(&td->mutexq);
175 td->base_priority = PTHREAD_DEFAULT_PRIORITY;
176 td->active_priority = PTHREAD_DEFAULT_PRIORITY;
177 td->inherited_priority = PTHREAD_MIN_PRIORITY;
178 } else {
179 memset(&td->join_status, 0, sizeof(struct join_status));

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

236/*
237 * Threaded process initialization
238 */
239void
240_thread_init(void)
241{
242 struct pthread *pthread;
243 int fd;
173 memcpy(&td->attr, attrp, sizeof(struct pthread_attr));
174 td->magic = PTHREAD_MAGIC;
175 TAILQ_INIT(&td->mutexq);
176 td->base_priority = PTHREAD_DEFAULT_PRIORITY;
177 td->active_priority = PTHREAD_DEFAULT_PRIORITY;
178 td->inherited_priority = PTHREAD_MIN_PRIORITY;
179 } else {
180 memset(&td->join_status, 0, sizeof(struct join_status));

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

237/*
238 * Threaded process initialization
239 */
240void
241_thread_init(void)
242{
243 struct pthread *pthread;
244 int fd;
244 int i;
245 size_t len;
246 int mib[2];
247 int error;
248
249 /* Check if this function has already been called: */
250 if (_thread_initial)
251 /* Only initialise the threaded application once. */
252 return;

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

329 /* Set the stack attributes. */
330 pthread->attr.stackaddr_attr = pthread->stack;
331 pthread->attr.stacksize_attr = PTHREAD_STACK_INITIAL;
332
333 /* Setup the context for initial thread. */
334 getcontext(&pthread->ctx);
335 pthread->ctx.uc_stack.ss_sp = pthread->stack;
336 pthread->ctx.uc_stack.ss_size = PTHREAD_STACK_INITIAL;
245 size_t len;
246 int mib[2];
247 int error;
248
249 /* Check if this function has already been called: */
250 if (_thread_initial)
251 /* Only initialise the threaded application once. */
252 return;

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

329 /* Set the stack attributes. */
330 pthread->attr.stackaddr_attr = pthread->stack;
331 pthread->attr.stacksize_attr = PTHREAD_STACK_INITIAL;
332
333 /* Setup the context for initial thread. */
334 getcontext(&pthread->ctx);
335 pthread->ctx.uc_stack.ss_sp = pthread->stack;
336 pthread->ctx.uc_stack.ss_size = PTHREAD_STACK_INITIAL;
337
338 /* Initialise the state of the initial thread: */
339 pthread->state = PS_RUNNING;
340
341 /* Enter a loop to get the existing signal status: */
342 for (i = 1; i < NSIG; i++) {
343 /* Check for signals which cannot be trapped. */
344 if (i == SIGKILL || i == SIGSTOP)
345 continue;
346
347 /* Get the signal handler details. */
348 if (__sys_sigaction(i, NULL,
349 &_thread_sigact[i - 1]) != 0)
350 PANIC("Cannot read signal handler info");
351 }
352}
353
354/*
355 * Special start up code for NetBSD/Alpha
356 */
357#if defined(__NetBSD__) && defined(__alpha__)
358int
359main(int argc, char *argv[], char *env);
360
361int
362_thread_main(int argc, char *argv[], char *env)
363{
364 _thread_init();
365 return (main(argc, argv, env));
366}
367#endif
337}
338
339/*
340 * Special start up code for NetBSD/Alpha
341 */
342#if defined(__NetBSD__) && defined(__alpha__)
343int
344main(int argc, char *argv[], char *env);
345
346int
347_thread_main(int argc, char *argv[], char *env)
348{
349 _thread_init();
350 return (main(argc, argv, env));
351}
352#endif