thr_fork.c (54138) | thr_fork.c (55194) |
---|---|
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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * | 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 --- 15 unchanged lines hidden (view full) --- 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/lib/libkse/thread/thr_fork.c 54138 1999-12-04 22:55:59Z deischen $ | 32 * $FreeBSD: head/lib/libkse/thread/thr_fork.c 55194 1999-12-28 18:13:04Z deischen $ |
33 */ 34#include <errno.h> 35#include <string.h> | 33 */ 34#include <errno.h> 35#include <string.h> |
36#include <stdlib.h> |
|
36#include <unistd.h> 37#include <fcntl.h> 38#ifdef _THREAD_SAFE 39#include <pthread.h> 40#include "pthread_private.h" 41 42pid_t 43fork(void) --- 81 unchanged lines hidden (view full) --- 125 126 /* Make sure this isn't the running thread: */ 127 if (pthread_save != _thread_run) { 128 /* Remove this thread from the list: */ 129 TAILQ_REMOVE(&_thread_list, 130 pthread_save, tle); 131 132 if (pthread_save->attr.stackaddr_attr == | 37#include <unistd.h> 38#include <fcntl.h> 39#ifdef _THREAD_SAFE 40#include <pthread.h> 41#include "pthread_private.h" 42 43pid_t 44fork(void) --- 81 unchanged lines hidden (view full) --- 126 127 /* Make sure this isn't the running thread: */ 128 if (pthread_save != _thread_run) { 129 /* Remove this thread from the list: */ 130 TAILQ_REMOVE(&_thread_list, 131 pthread_save, tle); 132 133 if (pthread_save->attr.stackaddr_attr == |
133 NULL && pthread_save->stack != NULL) | 134 NULL && pthread_save->stack != NULL) { |
134 if (pthread_save->attr.stacksize_attr 135 == PTHREAD_STACK_DEFAULT) { 136 /* | 135 if (pthread_save->attr.stacksize_attr 136 == PTHREAD_STACK_DEFAULT) { 137 /* |
137 * Default-size stack. Cache 138 * it: | 138 * Default-size stack. 139 * Cache it: |
139 */ 140 struct stack *spare_stack; 141 142 spare_stack 143 = (pthread_save->stack | 140 */ 141 struct stack *spare_stack; 142 143 spare_stack 144 = (pthread_save->stack |
144 + PTHREAD_STACK_DEFAULT 145 - sizeof(struct stack)); 146 SLIST_INSERT_HEAD( 147 &_stackq, 148 spare_stack, 149 qe); | 145 + PTHREAD_STACK_DEFAULT 146 - sizeof(struct stack)); 147 SLIST_INSERT_HEAD(&_stackq, 148 spare_stack, qe); |
150 } else 151 /* 152 * Free the stack of 153 * the dead thread: 154 */ 155 free(pthread_save->stack); | 149 } else 150 /* 151 * Free the stack of 152 * the dead thread: 153 */ 154 free(pthread_save->stack); |
155 } |
|
156 157 if (pthread_save->specific_data != NULL) 158 free(pthread_save->specific_data); 159 160 if (pthread_save->poll_data.fds != NULL) 161 free(pthread_save->poll_data.fds); 162 163 free(pthread_save); --- 60 unchanged lines hidden --- | 156 157 if (pthread_save->specific_data != NULL) 158 free(pthread_save->specific_data); 159 160 if (pthread_save->poll_data.fds != NULL) 161 free(pthread_save->poll_data.fds); 162 163 free(pthread_save); --- 60 unchanged lines hidden --- |