From dea22ca51a27843cf98b859d71ee9cebb85f923c Mon Sep 17 00:00:00 2001 From: jzlv Date: Wed, 25 Aug 2021 16:56:00 +0800 Subject: [PATCH] [fix][common] fix some macro redefinitions --- common/device/drv_device.c | 6 +++--- common/device/drv_device.h | 4 ++-- common/memheap/drv_mmheap.h | 2 +- common/misc/gcc.h | 9 --------- common/misc/misc.h | 29 ++++++++++++++++++----------- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/common/device/drv_device.c b/common/device/drv_device.c index 1a71cfc8..75975d57 100644 --- a/common/device/drv_device.c +++ b/common/device/drv_device.c @@ -53,7 +53,7 @@ int device_register(struct device *dev, const char *name) } } - strncpy(dev->name, name, NAME_MAX); + strncpy(dev->name, name, DEVICE_NAME_MAX); dlist_insert_after(&device_head, &(dev->list)); dev->status = DEVICE_REGISTERED; @@ -86,7 +86,7 @@ int device_unregister(const char *name) if (!dev) { return -DEVICE_ENODEV; } - + dev->status = DEVICE_UNREGISTER; /* remove from old list */ dlist_remove(&(dev->list)); return DEVICE_EOK; @@ -108,7 +108,7 @@ struct device *device_find(const char *name) { dev = dlist_entry(node, struct device, list); - if (strncmp(dev->name, name, NAME_MAX) == 0) { + if (strncmp(dev->name, name, DEVICE_NAME_MAX) == 0) { return dev; } } diff --git a/common/device/drv_device.h b/common/device/drv_device.h index faa11ac5..101d1cfa 100644 --- a/common/device/drv_device.h +++ b/common/device/drv_device.h @@ -26,7 +26,7 @@ #include "drv_list.h" #include "bflb_platform.h" -#define NAME_MAX 20 /* max device name*/ +#define DEVICE_NAME_MAX 20 /* max device name*/ #define DEVICE_OFLAG_DEFAULT 0x000 /* open with default */ #define DEVICE_OFLAG_STREAM_TX 0x001 /* open with poll tx */ @@ -107,7 +107,7 @@ enum device_status_type { }; struct device { - char name[NAME_MAX]; /*name of device */ + char name[DEVICE_NAME_MAX]; /*name of device */ dlist_t list; /*list node of device */ enum device_status_type status; /*status of device */ enum device_class_type type; /*type of device */ diff --git a/common/memheap/drv_mmheap.h b/common/memheap/drv_mmheap.h index d75e19bf..df76969f 100644 --- a/common/memheap/drv_mmheap.h +++ b/common/memheap/drv_mmheap.h @@ -48,7 +48,7 @@ * We support allocations of sizes up to (1 << MMHEAP_FL_INDEX_MAX) bits. * However, because we linearly subdivide the second-level lists, and * our minimum size granularity is 4 bytes, it doesn't make sense to - * create first-level lists for sizes smaller than K_MMHEAP_SL_INDEX_COUNT * 4, + * create first-level lists for sizes smaller than MMHEAP_SL_INDEX_COUNT * 4, * or (1 << (K_MMHEAP_SL_INDEX_COUNT_LOG2 + 2)) bytes, as there we will be * trying to split size ranges into more slots than we have available. * Instead, we calculate the minimum threshold size, and place all diff --git a/common/misc/gcc.h b/common/misc/gcc.h index c89e30a6..9b492416 100644 --- a/common/misc/gcc.h +++ b/common/misc/gcc.h @@ -66,15 +66,6 @@ #endif #define NORETURN __attribute__((noreturn)) -/* alignment value should be a power of 2 */ -#define ALIGN(num, align) MASK(num, (typeof(num))align - 1) - -#define ALIGN_2(num) ALIGN(num, 2) -#define ALIGN_4(num) ALIGN(num, 4) -#define ALIGN_8(num) ALIGN(num, 8) -#define ALIGN_16(num) ALIGN(num, 16) -#define ALIGN_32(num) ALIGN(num, 32) - #else /* __GNUC__ */ #define WARN_UNUSED_RET diff --git a/common/misc/misc.h b/common/misc/misc.h index fff66c29..c4d4dd88 100644 --- a/common/misc/misc.h +++ b/common/misc/misc.h @@ -77,18 +77,25 @@ } /* Std driver attribute macro*/ -#define ATTR_CLOCK_SECTION __attribute__((section(".sclock_rlt_code"))) -#define ATTR_CLOCK_CONST_SECTION __attribute__((section(".sclock_rlt_const"))) -#define ATTR_TCM_SECTION __attribute__((section(".tcm_code"))) -#define ATTR_TCM_CONST_SECTION __attribute__((section(".tcm_const"))) -#define ATTR_DTCM_SECTION __attribute__((section(".tcm_data"))) -#define ATTR_HSRAM_SECTION __attribute__((section(".hsram_code"))) -#define ATTR_DMA_RAM_SECTION __attribute__((section(".system_ram"))) -#define ATTR_EALIGN(x) __attribute((aligned(x))) -#define ATTR_FALLTHROUGH() __attribute__((fallthrough)) -#define ATTR_USED __attribute__((__used__)) +#define ATTR_CLOCK_SECTION __attribute__((section(".sclock_rlt_code"))) +#define ATTR_CLOCK_CONST_SECTION __attribute__((section(".sclock_rlt_const"))) +#define ATTR_TCM_SECTION __attribute__((section(".tcm_code"))) +#define ATTR_TCM_CONST_SECTION __attribute__((section(".tcm_const"))) +#define ATTR_DTCM_SECTION __attribute__((section(".tcm_data"))) +#define ATTR_HSRAM_SECTION __attribute__((section(".hsram_code"))) +#define ATTR_DMA_RAM_SECTION __attribute__((section(".system_ram"))) +#define ATTR_HBN_RAM_SECTION __attribute__((section(".hbn_ram_code"))) +#define ATTR_HBN_RAM_CONST_SECTION __attribute__((section(".hbn_ram_data"))) +#define ATTR_EALIGN(x) __attribute((aligned(x))) +#define ATTR_FALLTHROUGH() __attribute__((fallthrough)) +#define ATTR_USED __attribute__((__used__)) -#define BIT(x) (1 << (x)) +#ifdef BIT +#undef BIT +#define BIT(n) (1UL << (n)) +#else +#define BIT(n) (1UL << (n)) +#endif /** * @brief Error type definition