#ifndef GEMMLOWP_INTERNAL_PLATFORM_H_
#define GEMMLOWP_INTERNAL_PLATFORM_H_
#ifdef _WIN32
#include <malloc.h>
#include <windows.h>
#else
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#endif
#ifdef __APPLE__
#include <sys/time.h>
#endif
#if defined ANDROID || defined __ANDROID__
#include <malloc.h>
#include <android/api-level.h>
#if __ANDROID_API__ < 18
#define GEMMLOWP_USE_MEMALIGN
#endif
#if __ANDROID_API__ == 18
#ifdef GEMMLOWP_X86_32
#define GEMMLOWP_USE_MEMALIGN
#endif
#endif
#endif
#ifndef _SC_NPROCESSORS_CONF
#define _SC_NPROCESSORS_CONF …
#endif
namespace gemmlowp {
#ifdef _WIN32
inline void *aligned_alloc(size_t alignment, size_t size) {
return _aligned_malloc(size, alignment);
}
inline void aligned_free(void *memptr) { _aligned_free(memptr); }
inline int GetHardwareConcurrency(int max_threads) {
if (max_threads == 0) {
SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo);
return sysinfo.dwNumberOfProcessors;
}
return max_threads;
}
inline double real_time_in_seconds() {
__int64 wintime;
GetSystemTimeAsFileTime((FILETIME *)&wintime);
wintime -= 116444736000000000LL;
return wintime / 10000000LL + wintime % 10000000LL * 100 * 1e-9;
}
#else
inline void *aligned_alloc(size_t alignment, size_t size) { … }
inline int GetHardwareConcurrency(int max_threads) { … }
inline void aligned_free(void *memptr) { … }
inline double real_time_in_seconds() { … }
#endif
}
#endif