mirror of
https://gitee.com/moluo-tech/CodeBrick.git
synced 2025-01-16 04:32:51 +08:00
56 lines
1.8 KiB
C
56 lines
1.8 KiB
C
/******************************************************************************
|
||
* @brief ͨ<>ú궨<C3BA><EAB6A8>
|
||
*
|
||
* Copyright (c) 2018~2020, <morro_luo@163.com>
|
||
*
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*
|
||
* Change Logs:
|
||
* Date Author Notes
|
||
* 2018-02-01 Morro Initial version.
|
||
******************************************************************************/
|
||
|
||
#ifndef _COM_DEF_H_
|
||
#define _COM_DEF_H_
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD> -----------------------------------------------------------*/
|
||
#define ANONY_CONN(type, var, line) type var##line
|
||
#define ANONY_DEF(type,prefix,line) ANONY_CONN(type, prefix, line)
|
||
#define ANONY_TYPE(type,prefix) ANONY_DEF(type, prefix, __LINE__)
|
||
|
||
/**
|
||
* container_of - cast a member of a structure out to the containing structure
|
||
* @ptr: the pointer to the member.
|
||
* @type: the type of the container struct this is embedded in.
|
||
* @member: the name of the member within the struct.
|
||
*
|
||
*/
|
||
#define container_of(ptr, type, member) ( \
|
||
(type *)( (char *)(ptr) - offsetof(type,member) ))
|
||
|
||
|
||
#if defined(__CC_ARM) || defined(__GNUC__) /* ARM,GCC*/
|
||
#define SECTION(x) __attribute__((section(x)))
|
||
#define UNUSED __attribute__((unused))
|
||
#define USED __attribute__((used))
|
||
#define ALIGN(n) __attribute__((aligned(n)))
|
||
#define WEAK __attribute__((weak))
|
||
#elif defined (__ICCARM__) /*IAR */
|
||
#define SECTION(x) @ x
|
||
#define UNUSED
|
||
#define USED __root
|
||
#define WEAK __weak
|
||
#else
|
||
#error "Current tool chain haven't supported yet!"
|
||
#endif
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif
|