1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-01-21 16:43:49 +00:00
parent 6b6411229f
commit 04752ec546
1376 changed files with 393460 additions and 412662 deletions

View File

@@ -29,128 +29,113 @@ typedef HANDLE pthread_cond_t;
struct timespec
{
unsigned long tv_sec;
unsigned long tv_nsec;
unsigned long tv_sec;
unsigned long tv_nsec;
};
static inline int pthread_create(pthread_t* thread, void* dummy1,
LPTHREAD_START_ROUTINE start_routine,
static inline int pthread_create(pthread_t* thread, void* dummy1, LPTHREAD_START_ROUTINE start_routine,
void* arg)
{
/* Start thread ...
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
*/
*thread = CreateThread(NULL, /* lpThreadAttributes */
0, /* dwStackSize */
start_routine,
arg, /* lpParameter */
0, /* dwCreationFlags */
NULL /* lpThreadId */);
return *thread != NULL ? 0 : -1;
/* Start thread ...
* see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createthread.asp
*/
*thread = CreateThread(NULL, /* lpThreadAttributes */
0, /* dwStackSize */
start_routine, arg, /* lpParameter */
0, /* dwCreationFlags */
NULL /* lpThreadId */);
return *thread != NULL ? 0 : -1;
}
static inline int pthread_join(pthread_t th, void** thread_return)
{
return WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
return WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
}
static inline int pthread_mutex_init(pthread_mutex_t* mutex, void* dummy)
static inline int pthread_mutex_init(pthread_mutex_t* mutex, void* dummy)
{
InitializeCriticalSection(mutex);
InitializeCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_lock(pthread_mutex_t* mutex)
{
EnterCriticalSection(mutex);
return 0;
}
static inline int pthread_mutex_unlock(pthread_mutex_t* mutex)
{
LeaveCriticalSection(mutex);
return 0;
}
static inline int pthread_cond_init(pthread_cond_t* cond, void* dummy)
{
*cond = CreateEvent(NULL, TRUE, TRUE, NULL);
if (*cond == NULL)
return -1;
else
return 0;
}
static inline int pthread_mutex_lock(pthread_mutex_t* mutex)
static inline int pthread_cond_signal(pthread_cond_t* cond)
{
EnterCriticalSection(mutex);
return 0;
return SetEvent(*cond) ? 0 : -1;
}
static inline int pthread_mutex_unlock(pthread_mutex_t* mutex)
static inline int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex)
{
LeaveCriticalSection(mutex);
return 0;
}
static inline int pthread_cond_init(pthread_cond_t* cond, void* dummy)
{
*cond = CreateEvent(NULL, TRUE, TRUE, NULL);
if (*cond == NULL)
return -1;
else
return 0;
}
static inline int pthread_cond_signal(pthread_cond_t* cond)
{
return SetEvent(*cond) ? 0 : -1;
}
static inline int pthread_cond_wait(pthread_cond_t* cond,
pthread_mutex_t* mutex)
{
int r;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
r = WaitForSingleObject(*cond, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
EnterCriticalSection(mutex);
return r;
int r;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
r = WaitForSingleObject(*cond, INFINITE) == WAIT_OBJECT_0 ? 0 : -1;
EnterCriticalSection(mutex);
return r;
}
static inline void pthread_cancel(pthread_t* thread)
{
TerminateThread(thread, 0);
TerminateThread(thread, 0);
}
#define ETIMEDOUT -2
#define MILLION 1000000
#define MILLION 1000000
#define BILLION 1000000000
static inline int pthread_cond_timedwait(pthread_cond_t* cond,
pthread_mutex_t* mutex,
struct timespec* ts)
static inline int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, struct timespec* ts)
{
int r;
struct timeval tv;
long delta;
int r;
struct timeval tv;
long delta;
gettimeofday(&tv, NULL);
gettimeofday(&tv, NULL);
delta = (ts->tv_sec - tv.tv_sec) * 1000 +
(ts->tv_nsec / BILLION - tv.tv_usec / MILLION);
delta = (ts->tv_sec - tv.tv_sec) * 1000 + (ts->tv_nsec / BILLION - tv.tv_usec / MILLION);
if (delta < 0)
delta = 0;
if (delta < 0)
delta = 0;
ResetEvent(*cond);
LeaveCriticalSection(mutex);
ResetEvent(*cond);
LeaveCriticalSection(mutex);
switch (WaitForSingleObject(*cond, delta ))
{
case WAIT_OBJECT_0:
r = 0;
break;
switch (WaitForSingleObject(*cond, delta))
{
case WAIT_OBJECT_0: r = 0; break;
case WAIT_TIMEOUT:
r = ETIMEDOUT;
break;
case WAIT_TIMEOUT: r = ETIMEDOUT; break;
default:
r = -1;
break;
}
default: r = -1; break;
}
EnterCriticalSection(mutex);
return r;
EnterCriticalSection(mutex);
return r;
}
#define THREAD_RETURN DWORD WINAPI
#else /* __MINGW32__ */
#include <pthread.h>
#define THREAD_RETURN void *
#define THREAD_RETURN void*
#endif /* __MINGW32__ */