Style. Use ANSI definition, wrap long lines, no initialization in

declaration for locals.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2015-09-08 08:48:53 +00:00
parent 3e7e67c08d
commit b684727b07
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287557

View File

@ -50,9 +50,11 @@ __weak_reference(_pthread_once, pthread_once);
static void
once_cancel_handler(void *arg)
{
pthread_once_t *once_control = arg;
pthread_once_t *once_control;
if (atomic_cmpset_rel_int(&once_control->state, ONCE_IN_PROGRESS, ONCE_NEVER_DONE))
once_control = arg;
if (atomic_cmpset_rel_int(&once_control->state, ONCE_IN_PROGRESS,
ONCE_NEVER_DONE))
return;
atomic_store_rel_int(&once_control->state, ONCE_NEVER_DONE);
_thr_umtx_wake(&once_control->state, INT_MAX, 0);
@ -73,13 +75,17 @@ _pthread_once(pthread_once_t *once_control, void (*init_routine) (void))
return (0);
}
if (state == ONCE_NEVER_DONE) {
if (atomic_cmpset_int(&once_control->state, state, ONCE_IN_PROGRESS))
if (atomic_cmpset_int(&once_control->state, state,
ONCE_IN_PROGRESS))
break;
} else if (state == ONCE_IN_PROGRESS) {
if (atomic_cmpset_int(&once_control->state, state, ONCE_WAIT))
_thr_umtx_wait_uint(&once_control->state, ONCE_WAIT, NULL, 0);
if (atomic_cmpset_int(&once_control->state, state,
ONCE_WAIT))
_thr_umtx_wait_uint(&once_control->state,
ONCE_WAIT, NULL, 0);
} else if (state == ONCE_WAIT) {
_thr_umtx_wait_uint(&once_control->state, state, NULL, 0);
_thr_umtx_wait_uint(&once_control->state, state,
NULL, 0);
} else
return (EINVAL);
}
@ -88,7 +94,8 @@ _pthread_once(pthread_once_t *once_control, void (*init_routine) (void))
THR_CLEANUP_PUSH(curthread, once_cancel_handler, once_control);
init_routine();
THR_CLEANUP_POP(curthread, 0);
if (atomic_cmpset_rel_int(&once_control->state, ONCE_IN_PROGRESS, ONCE_DONE))
if (atomic_cmpset_rel_int(&once_control->state, ONCE_IN_PROGRESS,
ONCE_DONE))
return (0);
atomic_store_rel_int(&once_control->state, ONCE_DONE);
_thr_umtx_wake(&once_control->state, INT_MAX, 0);
@ -96,6 +103,6 @@ _pthread_once(pthread_once_t *once_control, void (*init_routine) (void))
}
void
_thr_once_init()
_thr_once_init(void)
{
}