Apollo 10.0
自动驾驶开放平台
macros.h 文件参考
#include <cstdlib>
#include <new>
macros.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

宏定义

#define eprosima   eprosima_wrap
 
#define cyber_likely(x)   (x)
 
#define cyber_unlikely(x)   (x)
 
#define CACHELINE_SIZE   64
 
#define DEFINE_TYPE_TRAIT(name, func)
 

函数

void cpu_relax ()
 
void * CheckedMalloc (size_t size)
 
void * CheckedCalloc (size_t num, size_t size)
 

宏定义说明

◆ CACHELINE_SIZE

#define CACHELINE_SIZE   64

在文件 macros.h33 行定义.

◆ cyber_likely

#define cyber_likely (   x)    (x)

在文件 macros.h29 行定义.

◆ cyber_unlikely

#define cyber_unlikely (   x)    (x)

在文件 macros.h30 行定义.

◆ DEFINE_TYPE_TRAIT

#define DEFINE_TYPE_TRAIT (   name,
  func 
)
值:
template <typename T> \
struct name { \
template <typename Class> \
static constexpr bool Test(decltype(&Class::func)*) { \
return true; \
} \
template <typename> \
static constexpr bool Test(...) { \
return false; \
} \
\
static constexpr bool value = Test<T>(nullptr); \
}; \
\
template <typename T> \
constexpr bool name<T>::value;

在文件 macros.h35 行定义.

37 { \
38 template <typename Class> \
39 static constexpr bool Test(decltype(&Class::func)*) { \
40 return true; \
41 } \
42 template <typename> \
43 static constexpr bool Test(...) { \
44 return false; \
45 } \
46 \
47 static constexpr bool value = Test<T>(nullptr); \
48 }; \
49 \
50 template <typename T> \
51 constexpr bool name<T>::value;

◆ eprosima

#define eprosima   eprosima_wrap

在文件 macros.h23 行定义.

函数说明

◆ CheckedCalloc()

void * CheckedCalloc ( size_t  num,
size_t  size 
)
inline

在文件 macros.h69 行定义.

69 {
70 void* ptr = std::calloc(num, size);
71 if (!ptr) {
72 throw std::bad_alloc();
73 }
74 return ptr;
75}

◆ CheckedMalloc()

void * CheckedMalloc ( size_t  size)
inline

在文件 macros.h61 行定义.

61 {
62 void* ptr = std::malloc(size);
63 if (!ptr) {
64 throw std::bad_alloc();
65 }
66 return ptr;
67}

◆ cpu_relax()

void cpu_relax ( )
inline

在文件 macros.h53 行定义.

53 {
54#if defined(__aarch64__)
55 asm volatile("yield" ::: "memory");
56#else
57 asm volatile("rep; nop" ::: "memory");
58#endif
59}