Update brace style.

Add braces around single-line blocks, and remove line breaks before
function-opening braces.

This resolves #537.
This commit is contained in:
Jason Evans
2017-01-15 16:56:30 -08:00
parent 5154ff32ee
commit c4c2592c83
119 changed files with 2971 additions and 3572 deletions

View File

@@ -1,7 +1,6 @@
#include "test/jemalloc_test.h"
void *
btalloc(size_t size, unsigned bits)
{
btalloc(size_t size, unsigned bits) {
return (btalloc_0(size, bits));
}

View File

@@ -5,8 +5,7 @@
* time is guaranteed.
*/
void
mq_nanosleep(unsigned ns)
{
mq_nanosleep(unsigned ns) {
assert(ns <= 1000*1000*1000);
#ifdef _WIN32

View File

@@ -5,11 +5,12 @@
#endif
bool
mtx_init(mtx_t *mtx)
{
mtx_init(mtx_t *mtx) {
#ifdef _WIN32
if (!InitializeCriticalSectionAndSpinCount(&mtx->lock, _CRT_SPINCOUNT))
if (!InitializeCriticalSectionAndSpinCount(&mtx->lock,
_CRT_SPINCOUNT)) {
return (true);
}
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
mtx->lock = OS_UNFAIR_LOCK_INIT;
#elif (defined(JEMALLOC_OSSPIN))
@@ -17,8 +18,9 @@ mtx_init(mtx_t *mtx)
#else
pthread_mutexattr_t attr;
if (pthread_mutexattr_init(&attr) != 0)
if (pthread_mutexattr_init(&attr) != 0) {
return (true);
}
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT);
if (pthread_mutex_init(&mtx->lock, &attr) != 0) {
pthread_mutexattr_destroy(&attr);
@@ -30,8 +32,7 @@ mtx_init(mtx_t *mtx)
}
void
mtx_fini(mtx_t *mtx)
{
mtx_fini(mtx_t *mtx) {
#ifdef _WIN32
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
#elif (defined(JEMALLOC_OSSPIN))
@@ -41,8 +42,7 @@ mtx_fini(mtx_t *mtx)
}
void
mtx_lock(mtx_t *mtx)
{
mtx_lock(mtx_t *mtx) {
#ifdef _WIN32
EnterCriticalSection(&mtx->lock);
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
@@ -55,8 +55,7 @@ mtx_lock(mtx_t *mtx)
}
void
mtx_unlock(mtx_t *mtx)
{
mtx_unlock(mtx_t *mtx) {
#ifdef _WIN32
LeaveCriticalSection(&mtx->lock);
#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))

View File

@@ -7,8 +7,7 @@ static const char * test_name = "";
JEMALLOC_FORMAT_PRINTF(1, 2)
void
test_skip(const char *format, ...)
{
test_skip(const char *format, ...) {
va_list ap;
va_start(ap, format);
@@ -20,8 +19,7 @@ test_skip(const char *format, ...)
JEMALLOC_FORMAT_PRINTF(1, 2)
void
test_fail(const char *format, ...)
{
test_fail(const char *format, ...) {
va_list ap;
va_start(ap, format);
@@ -32,8 +30,7 @@ test_fail(const char *format, ...)
}
static const char *
test_status_string(test_status_t test_status)
{
test_status_string(test_status_t test_status) {
switch (test_status) {
case test_status_pass: return "pass";
case test_status_skip: return "skip";
@@ -43,23 +40,20 @@ test_status_string(test_status_t test_status)
}
void
p_test_init(const char *name)
{
p_test_init(const char *name) {
test_count++;
test_status = test_status_pass;
test_name = name;
}
void
p_test_fini(void)
{
p_test_fini(void) {
test_counts[test_status]++;
malloc_printf("%s: %s\n", test_name, test_status_string(test_status));
}
static test_status_t
p_test_impl(bool do_malloc_init, test_t *t, va_list ap)
{
p_test_impl(bool do_malloc_init, test_t *t, va_list ap) {
test_status_t ret;
if (do_malloc_init) {
@@ -78,8 +72,9 @@ p_test_impl(bool do_malloc_init, test_t *t, va_list ap)
ret = test_status_pass;
for (; t != NULL; t = va_arg(ap, test_t *)) {
t();
if (test_status > ret)
if (test_status > ret) {
ret = test_status;
}
}
malloc_printf("--- %s: %u/%u, %s: %u/%u, %s: %u/%u ---\n",
@@ -94,8 +89,7 @@ p_test_impl(bool do_malloc_init, test_t *t, va_list ap)
}
test_status_t
p_test(test_t *t, ...)
{
p_test(test_t *t, ...) {
test_status_t ret;
va_list ap;
@@ -108,8 +102,7 @@ p_test(test_t *t, ...)
}
test_status_t
p_test_no_malloc_init(test_t *t, ...)
{
p_test_no_malloc_init(test_t *t, ...) {
test_status_t ret;
va_list ap;
@@ -122,8 +115,7 @@ p_test_no_malloc_init(test_t *t, ...)
}
void
p_test_fail(const char *prefix, const char *message)
{
p_test_fail(const char *prefix, const char *message) {
malloc_cprintf(NULL, NULL, "%s%s\n", prefix, message);
test_status = test_status_fail;
}

View File

@@ -2,17 +2,16 @@
#ifdef _WIN32
void
thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
{
thd_create(thd_t *thd, void *(*proc)(void *), void *arg) {
LPTHREAD_START_ROUTINE routine = (LPTHREAD_START_ROUTINE)proc;
*thd = CreateThread(NULL, 0, routine, arg, 0, NULL);
if (*thd == NULL)
if (*thd == NULL) {
test_fail("Error in CreateThread()\n");
}
}
void
thd_join(thd_t thd, void **ret)
{
thd_join(thd_t thd, void **ret) {
if (WaitForSingleObject(thd, INFINITE) == WAIT_OBJECT_0 && ret) {
DWORD exit_code;
GetExitCodeThread(thd, (LPDWORD) &exit_code);
@@ -22,15 +21,14 @@ thd_join(thd_t thd, void **ret)
#else
void
thd_create(thd_t *thd, void *(*proc)(void *), void *arg)
{
if (pthread_create(thd, NULL, proc, arg) != 0)
thd_create(thd_t *thd, void *(*proc)(void *), void *arg) {
if (pthread_create(thd, NULL, proc, arg) != 0) {
test_fail("Error in pthread_create()\n");
}
}
void
thd_join(thd_t thd, void **ret)
{
thd_join(thd_t thd, void **ret) {
pthread_join(thd, ret);
}
#endif

View File

@@ -1,22 +1,19 @@
#include "test/jemalloc_test.h"
void
timer_start(timedelta_t *timer)
{
timer_start(timedelta_t *timer) {
nstime_init(&timer->t0, 0);
nstime_update(&timer->t0);
}
void
timer_stop(timedelta_t *timer)
{
timer_stop(timedelta_t *timer) {
nstime_copy(&timer->t1, &timer->t0);
nstime_update(&timer->t1);
}
uint64_t
timer_usec(const timedelta_t *timer)
{
timer_usec(const timedelta_t *timer) {
nstime_t delta;
nstime_copy(&delta, &timer->t1);
@@ -25,8 +22,7 @@ timer_usec(const timedelta_t *timer)
}
void
timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen)
{
timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen) {
uint64_t t0 = timer_usec(a);
uint64_t t1 = timer_usec(b);
uint64_t mult;
@@ -36,11 +32,13 @@ timer_ratio(timedelta_t *a, timedelta_t *b, char *buf, size_t buflen)
/* Whole. */
n = malloc_snprintf(&buf[i], buflen-i, "%"FMTu64, t0 / t1);
i += n;
if (i >= buflen)
if (i >= buflen) {
return;
}
mult = 1;
for (j = 0; j < n; j++)
for (j = 0; j < n; j++) {
mult *= 10;
}
/* Decimal. */
n = malloc_snprintf(&buf[i], buflen-i, ".");