Fix compilation on macOS

This commit is contained in:
Sean Purcell 2017-04-13 12:33:45 -07:00
parent afa48518e2
commit f876f1200c
4 changed files with 15 additions and 5 deletions

View File

@ -146,8 +146,13 @@ typedef struct {
} blockParam_t;
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define MAX(a,b) ((a)>(b) ? (a) : (b))
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
static int BMK_benchMem(const void* srcBuffer, size_t srcSize,
const char* displayName, int cLevel,

View File

@ -89,7 +89,9 @@ unsigned DiB_isError(size_t errorCode) { return ERR_isError(errorCode); }
const char* DiB_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
#define MIN(a,b) ( (a) < (b) ? (a) : (b) )
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/* ********************************************************

View File

@ -96,7 +96,9 @@ void FIO_setNotificationLevel(unsigned level) { g_displayLevel=level; }
static const clock_t refreshRate = CLOCKS_PER_SEC * 15 / 100;
static clock_t g_time = 0;
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#ifndef MIN
# define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/* ************************************************************
* Avoid fseek()'s 2GiB barrier with MSVC, MacOS, *BSD, MinGW

View File

@ -569,7 +569,8 @@ UTIL_STATIC int UTIL_countPhysicalCores(void)
static S32 numPhysicalCores; /* apple specifies int32_t */
if (numPhysicalCores != 0) return numPhysicalCores;
{ int const ret = sysctlbyname("hw.physicalcpu", &numPhysicalCores, sizeof(int), NULL, 0);
{ size_t size = sizeof(S32);
int const ret = sysctlbyname("hw.physicalcpu", &numPhysicalCores, &size, NULL, 0);
if (ret != 0) {
if (errno == ENOENT) {
/* entry not present, fall back on 1 */