Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions nob.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@
# include <shellapi.h>
#else
# ifdef __APPLE__
# define _DARWIN_C_SOURCE 1
# include <mach-o/dyld.h>
# include <sys/sysctl.h>
# endif
# ifdef __FreeBSD__
# include <sys/sysctl.h>
Expand Down Expand Up @@ -1226,6 +1228,11 @@ NOBDEF int nob_nprocs(void)
SYSTEM_INFO siSysInfo;
GetSystemInfo(&siSysInfo);
return siSysInfo.dwNumberOfProcessors;
#elif __APPLE__
int nprocs = 0;
size_t len = sizeof(nprocs);
sysctlbyname("hw.logicalcpu", &nprocs, &len, NULL, 0);
return nprocs;
#else
return sysconf(_SC_NPROCESSORS_ONLN);
#endif
Expand Down
2 changes: 1 addition & 1 deletion shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#elif defined(__APPLE__) || defined(__MACH__)
// TODO: "-std=c99", "-D_POSIX_C_SOURCE=200112L" didn't work for MacOS, don't know why, don't really care that much at the moment.
// Anybody who does feel free to investigate.
#define nob_cc_flags(cmd) cmd_append(cmd, "-Wall", "-Wextra", "-Wswitch-enum", "-I.")
#define nob_cc_flags(cmd) cmd_append(cmd, "-Wall", "-Wextra", "-Wswitch-enum", "-std=c99", "-D_POSIX_C_SOURCE=200112L", "-I.")
#elif defined(__FreeBSD__)
// "-D_POSIX_C_SOURCE=200112L" hides required symbols on FreeBSD
#define nob_cc_flags(cmd) cmd_append(cmd, "-Wall", "-Wextra", "-Wswitch-enum", "-std=c99", "-ggdb", "-I.");
Expand Down