mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-03 13:22:37 +00:00
implement thread affinity for FreeBSD
This commit is contained in:
parent
883bc202db
commit
c2bcdbebcb
13
src/shared.c
13
src/shared.c
@ -6,10 +6,15 @@
|
|||||||
* License.....: MIT
|
* License.....: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
#ifdef DARWIN
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <shared.h>
|
#include <shared.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
@ -4537,6 +4542,9 @@ void set_cpu_affinity (char *cpu_affinity)
|
|||||||
{
|
{
|
||||||
#ifdef _WIN
|
#ifdef _WIN
|
||||||
DWORD_PTR aff_mask = 0;
|
DWORD_PTR aff_mask = 0;
|
||||||
|
#elif __FreeBSD__
|
||||||
|
cpuset_t cpuset;
|
||||||
|
CPU_ZERO (&cpuset);
|
||||||
#elif _POSIX
|
#elif _POSIX
|
||||||
cpu_set_t cpuset;
|
cpu_set_t cpuset;
|
||||||
CPU_ZERO (&cpuset);
|
CPU_ZERO (&cpuset);
|
||||||
@ -4584,6 +4592,9 @@ void set_cpu_affinity (char *cpu_affinity)
|
|||||||
#ifdef _WIN
|
#ifdef _WIN
|
||||||
SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
|
SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
|
||||||
SetThreadAffinityMask (GetCurrentThread (), aff_mask);
|
SetThreadAffinityMask (GetCurrentThread (), aff_mask);
|
||||||
|
#elif __FreeBSD__
|
||||||
|
pthread_t thread = pthread_self ();
|
||||||
|
pthread_setaffinity_np (thread, sizeof (cpuset_t), &cpuset);
|
||||||
#elif _POSIX
|
#elif _POSIX
|
||||||
pthread_t thread = pthread_self ();
|
pthread_t thread = pthread_self ();
|
||||||
pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset);
|
pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset);
|
||||||
|
Loading…
Reference in New Issue
Block a user