Skip to content

Commit

Permalink
[Runtime] Make runtime compatible with android ndk api 15 (#2446)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlu1 authored and tqchen committed Jan 17, 2019
1 parent 6783d37 commit 52e3bd3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/runtime/cpu_device_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include <cstring>
#include "workspace_pool.h"

#ifdef __ANDROID__
#include <android/api-level.h>
#endif

namespace tvm {
namespace runtime {
class CPUDeviceAPI final : public DeviceAPI {
Expand All @@ -28,10 +32,11 @@ class CPUDeviceAPI final : public DeviceAPI {
#if _MSC_VER
ptr = _aligned_malloc(nbytes, alignment);
if (ptr == nullptr) throw std::bad_alloc();
#elif defined(_LIBCPP_SGX_CONFIG)
#elif defined(_LIBCPP_SGX_CONFIG) || (defined(__ANDROID__) && __ANDROID_API__ < 16)
ptr = memalign(alignment, nbytes);
if (ptr == nullptr) throw std::bad_alloc();
#else
// posix_memalign is available in android ndk since __ANDROID_API__ >= 16
int ret = posix_memalign(&ptr, alignment, nbytes);
if (ret != 0) throw std::bad_alloc();
#endif
Expand Down

0 comments on commit 52e3bd3

Please sign in to comment.