Commit 3a992f84 authored by clang-format's avatar clang-format Committed by Yaowu Xu

vpx_util/: apply clang-format

Change-Id: I831214d16a5bbfdb86e24dbff8afe4ff4aeebdde
parent 1214cee2
......@@ -17,17 +17,16 @@
#include "vpx/vpx_integer.h"
#if defined(__GNUC__)
# define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__)
# define LOCAL_GCC_PREREQ(maj, min) \
(LOCAL_GCC_VERSION >= (((maj) << 8) | (min)))
#define LOCAL_GCC_VERSION ((__GNUC__ << 8) | __GNUC_MINOR__)
#define LOCAL_GCC_PREREQ(maj, min) (LOCAL_GCC_VERSION >= (((maj) << 8) | (min)))
#else
# define LOCAL_GCC_VERSION 0
# define LOCAL_GCC_PREREQ(maj, min) 0
#define LOCAL_GCC_VERSION 0
#define LOCAL_GCC_PREREQ(maj, min) 0
#endif
// handle clang compatibility
#ifndef __has_builtin
# define __has_builtin(x) 0
#define __has_builtin(x) 0
#endif
// some endian fix (e.g.: mips-gcc doesn't define __BIG_ENDIAN__)
......@@ -80,12 +79,11 @@ static INLINE uint16_t BSwap16(uint16_t x) {
static INLINE uint32_t BSwap32(uint32_t x) {
#if defined(VPX_USE_MIPS32_R2)
uint32_t ret;
__asm__ volatile (
__asm__ volatile(
"wsbh %[ret], %[x] \n\t"
"rotr %[ret], %[ret], 16 \n\t"
: [ret]"=r"(ret)
: [x]"r"(x)
);
: [ret] "=r"(ret)
: [x] "r"(x));
return ret;
#elif defined(HAVE_BUILTIN_BSWAP32)
return __builtin_bswap32(x);
......
......@@ -30,7 +30,7 @@ struct VPxWorkerImpl {
static void execute(VPxWorker *const worker); // Forward declaration.
static THREADFN thread_loop(void *ptr) {
VPxWorker *const worker = (VPxWorker*)ptr;
VPxWorker *const worker = (VPxWorker *)ptr;
int done = 0;
while (!done) {
pthread_mutex_lock(&worker->impl_->mutex_);
......@@ -51,8 +51,7 @@ static THREADFN thread_loop(void *ptr) {
}
// main thread state control
static void change_state(VPxWorker *const worker,
VPxWorkerStatus new_status) {
static void change_state(VPxWorker *const worker, VPxWorkerStatus new_status) {
// No-op when attempting to change state on a thread that didn't come up.
// Checking status_ without acquiring the lock first would result in a data
// race.
......@@ -95,7 +94,7 @@ static int reset(VPxWorker *const worker) {
worker->had_error = 0;
if (worker->status_ < OK) {
#if CONFIG_MULTITHREAD
worker->impl_ = (VPxWorkerImpl*)vpx_calloc(1, sizeof(*worker->impl_));
worker->impl_ = (VPxWorkerImpl *)vpx_calloc(1, sizeof(*worker->impl_));
if (worker->impl_ == NULL) {
return 0;
}
......@@ -161,15 +160,14 @@ static void end(VPxWorker *const worker) {
//------------------------------------------------------------------------------
static VPxWorkerInterface g_worker_interface = {
init, reset, sync, launch, execute, end
};
static VPxWorkerInterface g_worker_interface = { init, reset, sync,
launch, execute, end };
int vpx_set_worker_interface(const VPxWorkerInterface* const winterface) {
if (winterface == NULL ||
winterface->init == NULL || winterface->reset == NULL ||
winterface->sync == NULL || winterface->launch == NULL ||
winterface->execute == NULL || winterface->end == NULL) {
int vpx_set_worker_interface(const VPxWorkerInterface *const winterface) {
if (winterface == NULL || winterface->init == NULL ||
winterface->reset == NULL || winterface->sync == NULL ||
winterface->launch == NULL || winterface->execute == NULL ||
winterface->end == NULL) {
return 0;
}
g_worker_interface = *winterface;
......
......@@ -66,23 +66,19 @@ typedef struct {
WaitForSingleObjectEx(obj, timeout, FALSE /*bAlertable*/)
#endif
static INLINE int pthread_create(pthread_t* const thread, const void* attr,
unsigned int (__stdcall *start)(void*),
void* arg) {
static INLINE int pthread_create(pthread_t *const thread, const void *attr,
unsigned int(__stdcall *start)(void *),
void *arg) {
(void)attr;
#ifdef USE_CREATE_THREAD
*thread = CreateThread(NULL, /* lpThreadAttributes */
0, /* dwStackSize */
start,
arg,
0, /* dwStackSize */
start, arg, 0, /* dwStackSize */
NULL); /* lpThreadId */
#else
*thread = (pthread_t)_beginthreadex(NULL, /* void *security */
0, /* unsigned stack_size */
start,
arg,
0, /* unsigned initflag */
start, arg, 0, /* unsigned initflag */
NULL); /* unsigned *thrdaddr */
#endif
if (*thread == NULL) return 1;
......@@ -90,7 +86,7 @@ static INLINE int pthread_create(pthread_t* const thread, const void* attr,
return 0;
}
static INLINE int pthread_join(pthread_t thread, void** value_ptr) {
static INLINE int pthread_join(pthread_t thread, void **value_ptr) {
(void)value_ptr;
return (WaitForSingleObject(thread, INFINITE) != WAIT_OBJECT_0 ||
CloseHandle(thread) == 0);
......@@ -98,7 +94,7 @@ static INLINE int pthread_join(pthread_t thread, void** value_ptr) {
// Mutex
static INLINE int pthread_mutex_init(pthread_mutex_t *const mutex,
void* mutexattr) {
void *mutexattr) {
(void)mutexattr;
#if _WIN32_WINNT >= 0x0600 // Windows Vista / Server 2008 or greater
InitializeCriticalSectionEx(mutex, 0 /*dwSpinCount*/, 0 /*Flags*/);
......@@ -141,7 +137,7 @@ static INLINE int pthread_cond_destroy(pthread_cond_t *const condition) {
}
static INLINE int pthread_cond_init(pthread_cond_t *const condition,
void* cond_attr) {
void *cond_attr) {
(void)cond_attr;
#ifdef USE_WINDOWS_CONDITION_VARIABLE
InitializeConditionVariable(condition);
......@@ -149,8 +145,7 @@ static INLINE int pthread_cond_init(pthread_cond_t *const condition,
condition->waiting_sem_ = CreateSemaphore(NULL, 0, MAX_DECODE_THREADS, NULL);
condition->received_sem_ = CreateSemaphore(NULL, 0, MAX_DECODE_THREADS, NULL);
condition->signal_event_ = CreateEvent(NULL, FALSE, FALSE, NULL);
if (condition->waiting_sem_ == NULL ||
condition->received_sem_ == NULL ||
if (condition->waiting_sem_ == NULL || condition->received_sem_ == NULL ||
condition->signal_event_ == NULL) {
pthread_cond_destroy(condition);
return 1;
......@@ -184,8 +179,7 @@ static INLINE int pthread_cond_wait(pthread_cond_t *const condition,
#else
// note that there is a consumer available so the signal isn't dropped in
// pthread_cond_signal
if (!ReleaseSemaphore(condition->waiting_sem_, 1, NULL))
return 1;
if (!ReleaseSemaphore(condition->waiting_sem_, 1, NULL)) return 1;
// now unlock the mutex so pthread_cond_signal may be issued
pthread_mutex_unlock(mutex);
ok = (WaitForSingleObject(condition->signal_event_, INFINITE) ==
......@@ -219,20 +213,19 @@ typedef struct {
#define THREAD_RETURN(val) (val)
typedef struct {
void* (*start_)(void*);
void* arg_;
void *(*start_)(void *);
void *arg_;
} thread_arg;
static void thread_start(void* arg) {
static void thread_start(void *arg) {
thread_arg targ = *(thread_arg *)arg;
free(arg);
targ.start_(targ.arg_);
}
static INLINE int pthread_create(pthread_t* const thread, const void* attr,
void* (*start)(void*),
void* arg) {
static INLINE int pthread_create(pthread_t *const thread, const void *attr,
void *(*start)(void *), void *arg) {
int tid;
thread_arg *targ = (thread_arg *)malloc(sizeof(*targ));
if (targ == NULL) return 1;
......@@ -251,14 +244,14 @@ static INLINE int pthread_create(pthread_t* const thread, const void* attr,
return 0;
}
static INLINE int pthread_join(pthread_t thread, void** value_ptr) {
static INLINE int pthread_join(pthread_t thread, void **value_ptr) {
(void)value_ptr;
return DosWaitThread(&thread, DCWW_WAIT) != 0;
}
// Mutex
static INLINE int pthread_mutex_init(pthread_mutex_t *const mutex,
void* mutexattr) {
void *mutexattr) {
(void)mutexattr;
return DosCreateMutexSem(NULL, mutex, 0, FALSE) != 0;
}
......@@ -288,12 +281,12 @@ static INLINE int pthread_cond_destroy(pthread_cond_t *const condition) {
}
static INLINE int pthread_cond_init(pthread_cond_t *const condition,
void* cond_attr) {
void *cond_attr) {
int ok = 1;
(void)cond_attr;
ok &= DosCreateEventSem(NULL, &condition->event_sem_, DCE_POSTONE, FALSE)
== 0;
ok &=
DosCreateEventSem(NULL, &condition->event_sem_, DCE_POSTONE, FALSE) == 0;
ok &= DosCreateEventSem(NULL, &condition->ack_sem_, DCE_POSTONE, FALSE) == 0;
if (!ok) {
pthread_cond_destroy(condition);
......@@ -343,8 +336,8 @@ static INLINE int pthread_cond_wait(pthread_cond_t *const condition,
}
#else // _WIN32
#include <pthread.h> // NOLINT
# define THREADFN void*
# define THREAD_RETURN(val) val
#define THREADFN void *
#define THREAD_RETURN(val) val
#endif
#endif // CONFIG_MULTITHREAD
......@@ -358,7 +351,7 @@ typedef enum {
// Function to be called by the worker thread. Takes two opaque pointers as
// arguments (data1 and data2), and should return false in case of error.
typedef int (*VPxWorkerHook)(void*, void*);
typedef int (*VPxWorkerHook)(void *, void *);
// Platform-dependent implementation details for the worker.
typedef struct VPxWorkerImpl VPxWorkerImpl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment