Deleted Added
full compact
thr_once.c (179417) thr_once.c (220888)
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_once.c 179417 2008-05-30 00:02:59Z davidxu $
26 * $FreeBSD: head/lib/libthr/thread/thr_once.c 220888 2011-04-20 14:19:34Z rstone $
27 *
28 */
29
30#include "namespace.h"
31#include <pthread.h>
32#include "un-namespace.h"
33
34#include "thr_private.h"

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

59}
60
61int
62_pthread_once(pthread_once_t *once_control, void (*init_routine) (void))
63{
64 struct pthread *curthread;
65 int state;
66
27 *
28 */
29
30#include "namespace.h"
31#include <pthread.h>
32#include "un-namespace.h"
33
34#include "thr_private.h"

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

59}
60
61int
62_pthread_once(pthread_once_t *once_control, void (*init_routine) (void))
63{
64 struct pthread *curthread;
65 int state;
66
67 _thr_check_init();
68
67 for (;;) {
68 state = once_control->state;
69 if (state == ONCE_DONE)
70 return (0);
71 if (state == ONCE_NEVER_DONE) {
72 if (atomic_cmpset_acq_int(&once_control->state, state, ONCE_IN_PROGRESS))
73 break;
74 } else if (state == ONCE_IN_PROGRESS) {

--- 23 unchanged lines hidden ---
69 for (;;) {
70 state = once_control->state;
71 if (state == ONCE_DONE)
72 return (0);
73 if (state == ONCE_NEVER_DONE) {
74 if (atomic_cmpset_acq_int(&once_control->state, state, ONCE_IN_PROGRESS))
75 break;
76 } else if (state == ONCE_IN_PROGRESS) {

--- 23 unchanged lines hidden ---