2020-07-11 10:18:03 +08:00
|
|
|
|
/******************************************************************************
|
|
|
|
|
* @brief ͨ<EFBFBD>ú궨<EFBFBD><EFBFBD>
|
|
|
|
|
*
|
2020-12-04 20:53:54 +08:00
|
|
|
|
* Copyright (c) 2018~2020, <morro_luo@163.com>
|
2020-07-11 10:18:03 +08:00
|
|
|
|
*
|
|
|
|
|
* 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
|