mirror of
https://gitcode.com/gh_mirrors/es/esp32-opencv.git
synced 2025-08-06 18:24:38 +08:00
initial commit
This commit is contained in:
46
esp32/scripts/resources/alloc_fix.cpp
Normal file
46
esp32/scripts/resources/alloc_fix.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2018 Intel Corporation
|
||||
//
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ade/memory/alloc.hpp"
|
||||
|
||||
#if defined(_WIN32) || defined(__ANDROID__) || defined(ANDROID) || defined(ESP32)
|
||||
#include <malloc.h>
|
||||
#else
|
||||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "ade/util/math.hpp"
|
||||
#include "ade/util/assert.hpp"
|
||||
|
||||
namespace ade
|
||||
{
|
||||
|
||||
void* aligned_alloc(std::size_t size, std::size_t alignment)
|
||||
{
|
||||
ADE_ASSERT(util::is_pow2(alignment));
|
||||
#if defined(_WIN32)
|
||||
return _aligned_malloc(size, alignment);
|
||||
#elif defined(__ANDROID__) || defined(ANDROID) || defined(ESP32)
|
||||
return memalign(alignment, size);
|
||||
#else
|
||||
void* ret = nullptr;
|
||||
auto res = posix_memalign(&ret, std::max(sizeof(void*), alignment), size);
|
||||
(void)res;
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
void aligned_free(void* ptr)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return _aligned_free(ptr);
|
||||
#else
|
||||
return free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
13
esp32/scripts/resources/toolchain-esp32.cmake
Normal file
13
esp32/scripts/resources/toolchain-esp32.cmake
Normal file
@ -0,0 +1,13 @@
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set( ESP32 True )
|
||||
|
||||
set(CMAKE_C_COMPILER xtensa-esp32-elf-gcc)
|
||||
set(CMAKE_CXX_COMPILER xtensa-esp32-elf-g++)
|
||||
set(CMAKE_ASM_COMPILER xtensa-esp32-elf-gcc)
|
||||
|
||||
set(CMAKE_C_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C Compiler Base Flags")
|
||||
set(CMAKE_CXX_FLAGS "-mlongcalls -Wno-frame-address" CACHE STRING "C++ Compiler Base Flags")
|
||||
|
||||
# Can be removed after gcc 5.2.0 support is removed (ref GCC_NOT_5_2_0)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib" CACHE STRING "Linker Base Flags")
|
Reference in New Issue
Block a user