-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from damus-io/master
Update
- Loading branch information
Showing
12 changed files
with
1,152 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
#if defined(_WIN32) || defined(_WIN64) | ||
#include <windows.h> | ||
#elif defined(__linux__) | ||
#include <unistd.h> | ||
#elif defined(__APPLE__) | ||
#include <sys/types.h> | ||
#include <sys/sysctl.h> | ||
#else | ||
#error "Unsupported platform" | ||
#endif | ||
|
||
static inline int get_cpu_cores() { | ||
int num_cores = 0; | ||
|
||
// Windows | ||
#if defined(_WIN32) || defined(_WIN64) | ||
SYSTEM_INFO sysinfo; | ||
GetSystemInfo(&sysinfo); | ||
num_cores = sysinfo.dwNumberOfProcessors; // This returns logical processors | ||
// Further use GetLogicalProcessorInformation for physical cores... | ||
// Linux | ||
#elif defined(__linux__) | ||
num_cores = sysconf(_SC_NPROCESSORS_ONLN); // This returns logical processors | ||
// macOS | ||
#elif defined(__APPLE__) | ||
size_t size = sizeof(num_cores); | ||
sysctlbyname("hw.physicalcpu", &num_cores, &size, NULL, 0); | ||
#else | ||
num_cores = -1; // Unsupported platform | ||
#endif | ||
|
||
return num_cores; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.