Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions vanitygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
#include "pattern.h"
#include "util.h"


#if defined(__APPLE__)

#include <sys/types.h>
#include <sys/sysctl.h>

#endif


const char *version = VANITYGEN_VERSION;


Expand Down Expand Up @@ -241,6 +250,28 @@ vg_thread_loop(void *arg)


#if !defined(_WIN32)
// define count_processors only on non Windows systems

#if defined(__APPLE__)
// possibly *BSD goes here as well

int
count_processors(void)
{
int error = 0;
int value = 0;
size_t length = sizeof(value);

error = sysctlbyname("hw.ncpu", &value, &length, NULL, 0);
if (error == 0)
return value;

return 0;
}

#else

// default case is Linux
int
count_processors(void)
{
Expand All @@ -261,6 +292,8 @@ count_processors(void)
}
#endif

#endif

int
start_threads(vg_context_t *vcp, int nthreads)
{
Expand Down