thr_cancel.c (164583) | thr_cancel.c (164877) |
---|---|
1/* 2 * Copyright (c) 2005, David Xu <davidxu@freebsd.org> 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 --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 2005, David Xu <davidxu@freebsd.org> 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 --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/lib/libthr/thread/thr_cancel.c 164583 2006-11-24 09:57:38Z davidxu $ | 26 * $FreeBSD: head/lib/libthr/thread/thr_cancel.c 164877 2006-12-04 14:20:41Z davidxu $ |
27 * 28 */ 29 30#include "namespace.h" 31#include <pthread.h> 32#include "un-namespace.h" 33 34#include "thr_private.h" 35 36__weak_reference(_pthread_cancel, pthread_cancel); 37__weak_reference(_pthread_setcancelstate, pthread_setcancelstate); 38__weak_reference(_pthread_setcanceltype, pthread_setcanceltype); 39__weak_reference(_pthread_testcancel, pthread_testcancel); 40 41static inline void 42testcancel(struct pthread *curthread) 43{ 44 if (__predict_false(SHOULD_CANCEL(curthread) && | 27 * 28 */ 29 30#include "namespace.h" 31#include <pthread.h> 32#include "un-namespace.h" 33 34#include "thr_private.h" 35 36__weak_reference(_pthread_cancel, pthread_cancel); 37__weak_reference(_pthread_setcancelstate, pthread_setcancelstate); 38__weak_reference(_pthread_setcanceltype, pthread_setcanceltype); 39__weak_reference(_pthread_testcancel, pthread_testcancel); 40 41static inline void 42testcancel(struct pthread *curthread) 43{ 44 if (__predict_false(SHOULD_CANCEL(curthread) && |
45 !THR_IN_CRITICAL(curthread))) | 45 !THR_IN_CRITICAL(curthread) && curthread->cancel_defer == 0)) |
46 _pthread_exit(PTHREAD_CANCELED); 47} 48 49void 50_thr_testcancel(struct pthread *curthread) 51{ 52 testcancel(curthread); 53} --- 96 unchanged lines hidden (view full) --- 150} 151 152void 153_thr_cancel_leave(struct pthread *curthread) 154{ 155 if (curthread->cancel_enable) 156 curthread->cancel_point--; 157} | 46 _pthread_exit(PTHREAD_CANCELED); 47} 48 49void 50_thr_testcancel(struct pthread *curthread) 51{ 52 testcancel(curthread); 53} --- 96 unchanged lines hidden (view full) --- 150} 151 152void 153_thr_cancel_leave(struct pthread *curthread) 154{ 155 if (curthread->cancel_enable) 156 curthread->cancel_point--; 157} |
158 159void 160_thr_cancel_enter_defer(struct pthread *curthread) 161{ 162 if (curthread->cancel_enable) { 163 curthread->cancel_point++; 164 testcancel(curthread); 165 curthread->cancel_defer++; 166 } 167} 168 169void 170_thr_cancel_leave_defer(struct pthread *curthread, int check) 171{ 172 if (curthread->cancel_enable) { 173 curthread->cancel_defer--; 174 if (check) 175 testcancel(curthread); 176 curthread->cancel_point--; 177 } 178} |
|