summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-28 00:50:04 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-03-28 00:50:04 +0200
commit05cefb83e22c08aedf5d3b893ad387eb6424faba (patch)
tree20bdecf3032d11716c94afa3a7bb085f5b70493a
parent85b62d7aaedb24b6ad07d437e5b8560f62d07529 (diff)
Fix coding style
-rw-r--r--pthread/alloca_cutoff.c2
-rw-r--r--pthread/pt-alloc.c14
-rw-r--r--pthread/pt-cancel.c2
-rw-r--r--pthread/pt-create.c39
-rw-r--r--pthread/pt-dealloc.c2
-rw-r--r--pthread/pt-detach.c8
-rw-r--r--pthread/pt-exit.c2
-rw-r--r--pthread/pt-getattr.c8
-rw-r--r--pthread/pt-initialize.c93
-rw-r--r--pthread/pt-internal.h26
-rw-r--r--pthread/pt-sigmask.c3
-rw-r--r--pthread/pt-spin-inlines.c2
-rw-r--r--pthread/pt-yield.c3
13 files changed, 101 insertions, 103 deletions
diff --git a/pthread/alloca_cutoff.c b/pthread/alloca_cutoff.c
index ecbba35..4c183bd 100644
--- a/pthread/alloca_cutoff.c
+++ b/pthread/alloca_cutoff.c
@@ -21,6 +21,6 @@
int
__libc_alloca_cutoff (size_t size)
{
- return size <= 65536;
+ return size <= 65536;
}
libc_hidden_def (__libc_alloca_cutoff)
diff --git a/pthread/pt-alloc.c b/pthread/pt-alloc.c
index 22a3000..adab790 100644
--- a/pthread/pt-alloc.c
+++ b/pthread/pt-alloc.c
@@ -95,10 +95,10 @@ __pthread_alloc (struct __pthread **pthread)
for (new = __pthread_free_threads; new; new = new->next)
{
/* There is no need to take NEW->STATE_LOCK: if NEW is on this
- list, then it is protected by __PTHREAD_FREE_THREADS_LOCK
- except in __pthread_dealloc where after it is added to the
- list (with the lock held), it drops the lock and then sets
- NEW->STATE and immediately stops using NEW. */
+ list, then it is protected by __PTHREAD_FREE_THREADS_LOCK
+ except in __pthread_dealloc where after it is added to the
+ list (with the lock held), it drops the lock and then sets
+ NEW->STATE and immediately stops using NEW. */
if (new->state == PTHREAD_TERMINATED)
{
__pthread_dequeue (new);
@@ -116,7 +116,7 @@ __pthread_alloc (struct __pthread **pthread)
}
err = initialize_pthread (new);
- if (! err)
+ if (!err)
*pthread = new;
return err;
}
@@ -133,7 +133,7 @@ __pthread_alloc (struct __pthread **pthread)
return err;
}
- retry:
+retry:
__pthread_rwlock_wrlock (&__pthread_threads_lock);
if (__pthread_num_threads < __pthread_max_threads)
@@ -168,7 +168,7 @@ __pthread_alloc (struct __pthread **pthread)
/* Allocate a new lookup table that's twice as large. */
new_max_threads
- = max_threads > 0 ? max_threads * 2 : _POSIX_THREAD_THREADS_MAX;
+ = max_threads > 0 ? max_threads * 2 : _POSIX_THREAD_THREADS_MAX;
threads = malloc (new_max_threads * sizeof (struct __pthread *));
if (threads == NULL)
{
diff --git a/pthread/pt-cancel.c b/pthread/pt-cancel.c
index b7e9a93..9f87724 100644
--- a/pthread/pt-cancel.c
+++ b/pthread/pt-cancel.c
@@ -27,7 +27,7 @@ pthread_cancel (pthread_t t)
struct __pthread *p;
p = __pthread_getid (t);
- if (! p)
+ if (p == NULL)
return ESRCH;
__pthread_mutex_lock (&p->cancel_lock);
diff --git a/pthread/pt-create.c b/pthread/pt-create.c
index 41e8507..0b70f77 100644
--- a/pthread/pt-create.c
+++ b/pthread/pt-create.c
@@ -38,11 +38,11 @@
here since it would be really stupid to have a threads-using
program that doesn't call `pthread_create'. */
unsigned int __pthread_total;
-
+
/* The entry-point for new threads. */
static void
-entry_point (struct __pthread *self, void *(*start_routine)(void *), void *arg)
+entry_point (struct __pthread *self, void *(*start_routine) (void *), void *arg)
{
___pthread_self = self;
__resp = &self->res_state;
@@ -64,14 +64,14 @@ entry_point (struct __pthread *self, void *(*start_routine)(void *), void *arg)
/* Create a thread with attributes given by ATTR, executing
START_ROUTINE with argument ARG. */
int
-pthread_create (pthread_t *thread, const pthread_attr_t *attr,
- void *(*start_routine)(void *), void *arg)
+pthread_create (pthread_t * thread, const pthread_attr_t * attr,
+ void *(*start_routine) (void *), void *arg)
{
int err;
struct __pthread *pthread;
err = __pthread_create_internal (&pthread, attr, start_routine, arg);
- if (! err)
+ if (!err)
*thread = pthread->thread;
else if (err == ENOMEM)
err = EAGAIN;
@@ -83,8 +83,8 @@ pthread_create (pthread_t *thread, const pthread_attr_t *attr,
pt-internal.h. */
int
__pthread_create_internal (struct __pthread **thread,
- const pthread_attr_t *attr,
- void *(*start_routine)(void *), void *arg)
+ const pthread_attr_t * attr,
+ void *(*start_routine) (void *), void *arg)
{
int err;
struct __pthread *pthread;
@@ -104,7 +104,7 @@ __pthread_create_internal (struct __pthread **thread,
if (!stacksize)
{
struct rlimit rlim;
- __getrlimit(RLIMIT_STACK, &rlim);
+ __getrlimit (RLIMIT_STACK, &rlim);
if (rlim.rlim_cur != RLIM_INFINITY)
stacksize = rlim.rlim_cur;
if (!stacksize)
@@ -120,7 +120,7 @@ __pthread_create_internal (struct __pthread **thread,
pthread->stackaddr = setup->__stackaddr;
/* If the user supplied a stack, it is not our responsibility to
- setup a stack guard. */
+ setup a stack guard. */
pthread->guardsize = 0;
pthread->stack = 0;
}
@@ -128,7 +128,7 @@ __pthread_create_internal (struct __pthread **thread,
{
/* Allocate a stack. */
err = __pthread_stack_alloc (&pthread->stackaddr,
- ((setup->__guardsize + __vm_page_size-1)
+ ((setup->__guardsize + __vm_page_size - 1)
/ __vm_page_size) * __vm_page_size
+ stacksize);
if (err)
@@ -216,32 +216,31 @@ __pthread_create_internal (struct __pthread **thread,
return 0;
- failed_starting:
+failed_starting:
/* If joinable, a reference was added for the caller. */
if (pthread->state == PTHREAD_JOINABLE)
__pthread_dealloc (pthread);
__pthread_setid (pthread->thread, NULL);
atomic_decrement (&__pthread_total);
- failed_sigstate:
+failed_sigstate:
__pthread_sigstate_destroy (pthread);
- failed_setup:
+failed_setup:
_dl_deallocate_tls (pthread->tcb, 1);
pthread->tcb = NULL;
- failed_thread_tls_alloc:
+failed_thread_tls_alloc:
__pthread_thread_terminate (pthread);
/* __pthread_thread_terminate has taken care of deallocating the stack and
the thread structure. */
goto failed;
- failed_thread_alloc:
+failed_thread_alloc:
if (pthread->stack)
__pthread_stack_dealloc (pthread->stackaddr,
- ((setup->__guardsize + __vm_page_size-1)
- / __vm_page_size) * __vm_page_size
- + stacksize);
- failed_stack_alloc:
+ ((setup->__guardsize + __vm_page_size - 1)
+ / __vm_page_size) * __vm_page_size + stacksize);
+failed_stack_alloc:
__pthread_dealloc (pthread);
- failed:
+failed:
return err;
}
diff --git a/pthread/pt-dealloc.c b/pthread/pt-dealloc.c
index 1807a1d..15e251e 100644
--- a/pthread/pt-dealloc.c
+++ b/pthread/pt-dealloc.c
@@ -35,7 +35,7 @@ __pthread_dealloc (struct __pthread *pthread)
{
assert (pthread->state != PTHREAD_TERMINATED);
- if (! atomic_decrement_and_test (&pthread->nr_refs))
+ if (!atomic_decrement_and_test (&pthread->nr_refs))
return;
/* Withdraw this thread from the thread ID lookup table. */
diff --git a/pthread/pt-detach.c b/pthread/pt-detach.c
index f22c1a0..773ed10 100644
--- a/pthread/pt-detach.c
+++ b/pthread/pt-detach.c
@@ -45,8 +45,8 @@ pthread_detach (pthread_t thread)
pthread->state = PTHREAD_DETACHED;
/* Broadcast the condition. This will make threads that are
- waiting to join THREAD continue with hopefully disastrous
- consequences instead of blocking indefinitely. */
+ waiting to join THREAD continue with hopefully disastrous
+ consequences instead of blocking indefinitely. */
pthread_cond_broadcast (&pthread->state_cond);
__pthread_mutex_unlock (&pthread->state_lock);
@@ -57,8 +57,8 @@ pthread_detach (pthread_t thread)
__pthread_mutex_unlock (&pthread->state_lock);
/* THREAD has already exited. PTHREAD remained after the thread
- exited in order to provide the exit status, but it turns out
- it won't be needed. */
+ exited in order to provide the exit status, but it turns out
+ it won't be needed. */
__pthread_dealloc (pthread);
break;
diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c
index 14e560e..314bfd4 100644
--- a/pthread/pt-exit.c
+++ b/pthread/pt-exit.c
@@ -65,7 +65,7 @@ __pthread_exit (void *status)
switch (self->state)
{
default:
- assert (! "Consistency error: unexpected self->state");
+ assert (!"Consistency error: unexpected self->state");
abort ();
break;
diff --git a/pthread/pt-getattr.c b/pthread/pt-getattr.c
index f76ad57..b1ec5e0 100644
--- a/pthread/pt-getattr.c
+++ b/pthread/pt-getattr.c
@@ -30,7 +30,7 @@ __pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
{
struct __pthread *pthread;
- pthread = __pthread_getid(thread);
+ pthread = __pthread_getid (thread);
if (pthread == NULL)
return ESRCH;
@@ -39,12 +39,12 @@ __pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
*attr = __pthread_default_attr;
attr->__stackaddr = pthread->stackaddr +
- ((pthread->guardsize + __vm_page_size-1)
- / __vm_page_size * __vm_page_size);
+ ((pthread->guardsize + __vm_page_size - 1)
+ / __vm_page_size * __vm_page_size);
attr->__stacksize = pthread->stacksize;
attr->__guardsize = pthread->guardsize;
attr->__detachstate = (pthread->state == PTHREAD_DETACHED
- ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
+ ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE);
return 0;
}
diff --git a/pthread/pt-initialize.c b/pthread/pt-initialize.c
index 094c596..201810f 100644
--- a/pthread/pt-initialize.c
+++ b/pthread/pt-initialize.c
@@ -26,52 +26,51 @@
#include <pthread-functions.h>
#if IS_IN (libpthread)
-static const struct pthread_functions pthread_functions =
- {
- .ptr_pthread_attr_destroy = __pthread_attr_destroy,
- .ptr_pthread_attr_init = __pthread_attr_init,
- .ptr_pthread_attr_getdetachstate = __pthread_attr_getdetachstate,
- .ptr_pthread_attr_setdetachstate = __pthread_attr_setdetachstate,
- .ptr_pthread_attr_getinheritsched = __pthread_attr_getinheritsched,
- .ptr_pthread_attr_setinheritsched = __pthread_attr_setinheritsched,
- .ptr_pthread_attr_getschedparam = __pthread_attr_getschedparam,
- .ptr_pthread_attr_setschedparam = __pthread_attr_setschedparam,
- .ptr_pthread_attr_getschedpolicy = __pthread_attr_getschedpolicy,
- .ptr_pthread_attr_setschedpolicy = __pthread_attr_setschedpolicy,
- .ptr_pthread_attr_getscope = __pthread_attr_getscope,
- .ptr_pthread_attr_setscope = __pthread_attr_setscope,
- .ptr_pthread_condattr_destroy = __pthread_condattr_destroy,
- .ptr_pthread_condattr_init = __pthread_condattr_init,
- .ptr_pthread_cond_broadcast = __pthread_cond_broadcast,
- .ptr_pthread_cond_destroy = __pthread_cond_destroy,
- .ptr_pthread_cond_init = __pthread_cond_init,
- .ptr_pthread_cond_signal = __pthread_cond_signal,
- .ptr_pthread_cond_wait = __pthread_cond_wait,
- .ptr_pthread_cond_timedwait = __pthread_cond_timedwait,
- .ptr_pthread_equal = __pthread_equal,
- .ptr___pthread_exit = __pthread_exit,
- .ptr_pthread_getschedparam = __pthread_getschedparam,
- .ptr_pthread_setschedparam = __pthread_setschedparam,
- .ptr_pthread_mutex_destroy = _pthread_mutex_destroy,
- .ptr_pthread_mutex_init = _pthread_mutex_init,
- .ptr_pthread_mutex_lock = __pthread_mutex_lock,
- .ptr_pthread_mutex_trylock = __pthread_mutex_trylock,
- .ptr_pthread_mutex_unlock = __pthread_mutex_unlock,
- .ptr_pthread_self = __pthread_self,
- .ptr___pthread_setcancelstate = __pthread_setcancelstate,
- .ptr_pthread_setcanceltype = __pthread_setcanceltype,
- .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack,
- .ptr_pthread_once = __pthread_once,
- .ptr_pthread_rwlock_rdlock = __pthread_rwlock_rdlock,
- .ptr_pthread_rwlock_wrlock = __pthread_rwlock_wrlock,
- .ptr_pthread_rwlock_unlock = __pthread_rwlock_unlock,
- .ptr___pthread_key_create = __pthread_key_create,
- .ptr___pthread_getspecific = __pthread_getspecific,
- .ptr___pthread_setspecific = __pthread_setspecific,
- .ptr__IO_flockfile = _cthreads_flockfile,
- .ptr__IO_funlockfile = _cthreads_funlockfile,
- .ptr__IO_ftrylockfile = _cthreads_ftrylockfile,
- };
+static const struct pthread_functions pthread_functions = {
+ .ptr_pthread_attr_destroy = __pthread_attr_destroy,
+ .ptr_pthread_attr_init = __pthread_attr_init,
+ .ptr_pthread_attr_getdetachstate = __pthread_attr_getdetachstate,
+ .ptr_pthread_attr_setdetachstate = __pthread_attr_setdetachstate,
+ .ptr_pthread_attr_getinheritsched = __pthread_attr_getinheritsched,
+ .ptr_pthread_attr_setinheritsched = __pthread_attr_setinheritsched,
+ .ptr_pthread_attr_getschedparam = __pthread_attr_getschedparam,
+ .ptr_pthread_attr_setschedparam = __pthread_attr_setschedparam,
+ .ptr_pthread_attr_getschedpolicy = __pthread_attr_getschedpolicy,
+ .ptr_pthread_attr_setschedpolicy = __pthread_attr_setschedpolicy,
+ .ptr_pthread_attr_getscope = __pthread_attr_getscope,
+ .ptr_pthread_attr_setscope = __pthread_attr_setscope,
+ .ptr_pthread_condattr_destroy = __pthread_condattr_destroy,
+ .ptr_pthread_condattr_init = __pthread_condattr_init,
+ .ptr_pthread_cond_broadcast = __pthread_cond_broadcast,
+ .ptr_pthread_cond_destroy = __pthread_cond_destroy,
+ .ptr_pthread_cond_init = __pthread_cond_init,
+ .ptr_pthread_cond_signal = __pthread_cond_signal,
+ .ptr_pthread_cond_wait = __pthread_cond_wait,
+ .ptr_pthread_cond_timedwait = __pthread_cond_timedwait,
+ .ptr_pthread_equal = __pthread_equal,
+ .ptr___pthread_exit = __pthread_exit,
+ .ptr_pthread_getschedparam = __pthread_getschedparam,
+ .ptr_pthread_setschedparam = __pthread_setschedparam,
+ .ptr_pthread_mutex_destroy = _pthread_mutex_destroy,
+ .ptr_pthread_mutex_init = _pthread_mutex_init,
+ .ptr_pthread_mutex_lock = __pthread_mutex_lock,
+ .ptr_pthread_mutex_trylock = __pthread_mutex_trylock,
+ .ptr_pthread_mutex_unlock = __pthread_mutex_unlock,
+ .ptr_pthread_self = __pthread_self,
+ .ptr___pthread_setcancelstate = __pthread_setcancelstate,
+ .ptr_pthread_setcanceltype = __pthread_setcanceltype,
+ .ptr___pthread_get_cleanup_stack = __pthread_get_cleanup_stack,
+ .ptr_pthread_once = __pthread_once,
+ .ptr_pthread_rwlock_rdlock = __pthread_rwlock_rdlock,
+ .ptr_pthread_rwlock_wrlock = __pthread_rwlock_wrlock,
+ .ptr_pthread_rwlock_unlock = __pthread_rwlock_unlock,
+ .ptr___pthread_key_create = __pthread_key_create,
+ .ptr___pthread_getspecific = __pthread_getspecific,
+ .ptr___pthread_setspecific = __pthread_setspecific,
+ .ptr__IO_flockfile = _cthreads_flockfile,
+ .ptr__IO_funlockfile = _cthreads_funlockfile,
+ .ptr__IO_ftrylockfile = _cthreads_ftrylockfile,
+};
#endif /* IS_IN (libpthread) */
/* Initialize the pthreads library. */
@@ -79,6 +78,6 @@ void
___pthread_init (void)
{
#if IS_IN (libpthread)
- __libc_pthread_init(&pthread_functions);
+ __libc_pthread_init (&pthread_functions);
#endif
}
diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h
index 1f17f25..22afc1f 100644
--- a/pthread/pt-internal.h
+++ b/pthread/pt-internal.h
@@ -74,15 +74,15 @@ struct __pthread
/* Thread ID. */
pthread_t thread;
- unsigned int nr_refs; /* Detached threads have a self reference only,
- while joinable threads have two references.
- These are used to keep the structure valid at
- thread destruction. Detaching/joining a thread
- drops a reference. */
+ unsigned int nr_refs; /* Detached threads have a self reference only,
+ while joinable threads have two references.
+ These are used to keep the structure valid at
+ thread destruction. Detaching/joining a thread
+ drops a reference. */
/* Cancellation. */
- pthread_mutex_t cancel_lock; /* Protect cancel_xxx members. */
- void (*cancel_hook)(void *); /* Called to unblock a thread blocking
+ pthread_mutex_t cancel_lock; /* Protect cancel_xxx members. */
+ void (*cancel_hook) (void *); /* Called to unblock a thread blocking
in a cancellation point (namely,
__pthread_cond_timedwait_internal). */
void *cancel_hook_arg;
@@ -209,7 +209,7 @@ extern void ___pthread_init (void);
tid, we return the whole __pthread structure in *PTHREAD. */
extern int __pthread_create_internal (struct __pthread **__restrict pthread,
const pthread_attr_t *__restrict attr,
- void *(*start_routine)(void *),
+ void *(*start_routine) (void *),
void *__restrict arg);
/* Allocate a new thread structure and a pthread thread ID (but not a
@@ -233,11 +233,11 @@ extern void __pthread_stack_dealloc (void *stackaddr, size_t stacksize);
/* Setup thread THREAD's context. */
extern int __pthread_setup (struct __pthread *__restrict thread,
- void (*entry_point)(struct __pthread *,
- void *(*)(void *),
- void *),
- void *(*start_routine)(void *),
- void *__restrict arg);
+ void (*entry_point) (struct __pthread *,
+ void *(*)(void *),
+ void *),
+ void *(*start_routine) (void *),
+ void *__restrict arg);
/* Allocate a kernel thread (and any miscellaneous system dependent
diff --git a/pthread/pt-sigmask.c b/pthread/pt-sigmask.c
index 7402d87..f55c508 100644
--- a/pthread/pt-sigmask.c
+++ b/pthread/pt-sigmask.c
@@ -22,8 +22,7 @@
#include <pt-internal.h>
int
-pthread_sigmask (int how, const sigset_t *set,
- sigset_t *oset)
+pthread_sigmask (int how, const sigset_t *set, sigset_t *oset)
{
struct __pthread *self = _pthread_self ();
diff --git a/pthread/pt-spin-inlines.c b/pthread/pt-spin-inlines.c
index 40a692b..af453e1 100644
--- a/pthread/pt-spin-inlines.c
+++ b/pthread/pt-spin-inlines.c
@@ -20,7 +20,7 @@
not possible. */
#define _FORCE_INLINES
-#define __PT_SPIN_INLINE /* empty */
+#define __PT_SPIN_INLINE /* empty */
#include <pthread.h>
diff --git a/pthread/pt-yield.c b/pthread/pt-yield.c
index 5cf6c8b..0dee959 100644
--- a/pthread/pt-yield.c
+++ b/pthread/pt-yield.c
@@ -19,7 +19,8 @@
#include <pthread.h>
#include <sched.h>
-int pthread_yield(void)
+int
+pthread_yield (void)
{
return sched_yield ();
}