2016-09-05 19:47:26 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-05 19:47:26 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2016-09-06 16:44:05 +00:00
|
|
|
#ifndef _THREAD_H
|
|
|
|
#define _THREAD_H
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2016-09-12 10:59:40 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (_POSIX)
|
2016-09-05 19:47:26 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
#include <semaphore.h>
|
|
|
|
#endif // _POSIX
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (_WIN)
|
2016-09-05 19:47:26 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#endif // _WIN
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (_WIN)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
|
|
|
#define hc_thread_create(t,f,a) t = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) &f, a, 0, NULL)
|
|
|
|
#define hc_thread_wait(n,a) for (uint i = 0; i < n; i++) WaitForSingleObject ((a)[i], INFINITE)
|
|
|
|
#define hc_thread_exit(t) ExitThread (t)
|
|
|
|
|
|
|
|
#define hc_thread_mutex_lock(m) EnterCriticalSection (&m)
|
|
|
|
#define hc_thread_mutex_unlock(m) LeaveCriticalSection (&m)
|
|
|
|
#define hc_thread_mutex_init(m) InitializeCriticalSection (&m)
|
|
|
|
#define hc_thread_mutex_delete(m) DeleteCriticalSection (&m)
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#elif defined (_POSIX)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
|
|
|
#define hc_thread_create(t,f,a) pthread_create (&t, NULL, f, a)
|
|
|
|
#define hc_thread_wait(n,a) for (uint i = 0; i < n; i++) pthread_join ((a)[i], NULL)
|
|
|
|
#define hc_thread_exit(t) pthread_exit (&t)
|
|
|
|
|
|
|
|
#define hc_thread_mutex_lock(m) pthread_mutex_lock (&m)
|
|
|
|
#define hc_thread_mutex_unlock(m) pthread_mutex_unlock (&m)
|
|
|
|
#define hc_thread_mutex_init(m) pthread_mutex_init (&m, NULL)
|
|
|
|
#define hc_thread_mutex_delete(m) pthread_mutex_destroy (&m)
|
|
|
|
|
|
|
|
#endif
|
2016-09-06 16:44:05 +00:00
|
|
|
|
2016-09-12 10:59:40 +00:00
|
|
|
#if defined (_WIN)
|
|
|
|
|
|
|
|
BOOL WINAPI sigHandler_default (DWORD sig);
|
|
|
|
BOOL WINAPI sigHandler_benchmark (DWORD sig);
|
|
|
|
void hc_signal (BOOL WINAPI (callback) (DWORD));
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void sigHandler_default (int sig);
|
|
|
|
void sigHandler_benchmark (int sig);
|
|
|
|
void hc_signal (void (callback) (int));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-09-19 13:52:01 +00:00
|
|
|
void mycracked (opencl_ctx_t *opencl_ctx);
|
2016-09-15 14:02:52 +00:00
|
|
|
void myabort (opencl_ctx_t *opencl_ctx);
|
|
|
|
void myquit (opencl_ctx_t *opencl_ctx);
|
2016-09-19 13:52:01 +00:00
|
|
|
void bypass (opencl_ctx_t *opencl_ctx);
|
2016-09-12 10:59:40 +00:00
|
|
|
|
2016-09-15 14:02:52 +00:00
|
|
|
void SuspendThreads (opencl_ctx_t *opencl_ctx);
|
|
|
|
void ResumeThreads (opencl_ctx_t *opencl_ctx);
|
2016-09-14 18:22:38 +00:00
|
|
|
|
2016-09-06 16:44:05 +00:00
|
|
|
#endif // _THREAD_H
|