mirror of
https://github.com/hashcat/hashcat
synced 2024-11-13 17:28:58 +01:00
4b79ccd416
* https://github.com/hashcat/hashcat/pull/485 * https://github.com/hashcat/hashcat/pull/486
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
/**
|
|
* Authors.....: Jens Steube <jens.steube@gmail.com>
|
|
* License.....: MIT
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#ifdef _POSIX
|
|
#include <pthread.h>
|
|
#include <semaphore.h>
|
|
#endif // _POSIX
|
|
#ifdef _WIN
|
|
#include <windows.h>
|
|
#endif // _WIN
|
|
|
|
#ifdef _WIN
|
|
typedef HANDLE hc_thread_t;
|
|
typedef CRITICAL_SECTION hc_thread_mutex_t;
|
|
#elif _POSIX
|
|
typedef pthread_t hc_thread_t;
|
|
typedef pthread_mutex_t hc_thread_mutex_t;
|
|
#endif
|
|
|
|
#ifdef _WIN
|
|
|
|
#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)
|
|
|
|
#elif _POSIX
|
|
|
|
#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
|