mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-11 23:43:35 +08:00
UAVCAN_IMPLEMENT_PLACEMENT_NEW
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <new>
|
||||
#include <uavcan/stdint.hpp>
|
||||
#include <uavcan/util/templates.hpp>
|
||||
#include <uavcan/util/placement_new.hpp>
|
||||
#include <uavcan/impl_constants.hpp>
|
||||
|
||||
namespace uavcan
|
||||
|
||||
@@ -82,6 +82,16 @@
|
||||
# include <cstdio>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Some C++ implementations are half-broken and do not implement the placement new operator.
|
||||
* Setting this preprocessor symbol to 1 makes libuavcan implement its own operator new (std::size_t, void*),
|
||||
* and its delete counterpart.
|
||||
* This option may be removed in future.
|
||||
*/
|
||||
#ifndef UAVCAN_IMPLEMENT_PLACEMENT_NEW
|
||||
# define UAVCAN_IMPLEMENT_PLACEMENT_NEW 0
|
||||
#endif
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
#include <uavcan/error.hpp>
|
||||
#include <uavcan/impl_constants.hpp>
|
||||
#include <uavcan/util/templates.hpp>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <uavcan/impl_constants.hpp>
|
||||
|
||||
#ifndef UAVCAN_IMPLEMENT_PLACEMENT_NEW
|
||||
# error UAVCAN_IMPLEMENT_PLACEMENT_NEW
|
||||
#endif
|
||||
|
||||
#if UAVCAN_IMPLEMENT_PLACEMENT_NEW
|
||||
|
||||
inline void* operator new (std::size_t, void* ptr) throw()
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
inline void* operator new[](std::size_t, void* ptr) throw()
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline void operator delete (void*, void*) throw() { }
|
||||
inline void operator delete[](void*, void*) throw() { }
|
||||
|
||||
#else
|
||||
# include <new>
|
||||
#endif
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <uavcan/transport/transfer_buffer.hpp>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
|
||||
namespace uavcan
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user