rtio: Use CONCAT in place of ## in macros

Found issues when using ## to concatenate tokens in macros where the
resulting symbolic names were including the ## tokens themselves. Using
CONCAT everywhere fixes the issue.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This commit is contained in:
Tom Burdick 2024-03-15 12:07:44 -05:00 committed by Alberto Escolar
parent 300de90ab6
commit c2c95e18ed
2 changed files with 20 additions and 19 deletions

View file

@ -36,10 +36,10 @@ struct i2c_rtio {
* @param _sq_sz Submission queue entry pool size
* @param _cq_sz Completeion queue entry pool size
*/
#define I2C_RTIO_DEFINE(_name, _sq_sz, _cq_sz) \
RTIO_DEFINE(_name##_r, _sq_sz, _cq_sz); \
static struct i2c_rtio _name = { \
.r = &_name##_r, \
#define I2C_RTIO_DEFINE(_name, _sq_sz, _cq_sz) \
RTIO_DEFINE(CONCAT(_name, _r), _sq_sz, _cq_sz); \
static struct i2c_rtio _name = { \
.r = &CONCAT(_name, _r), \
};
/**

View file

@ -737,22 +737,22 @@ static inline void rtio_block_pool_free(struct rtio *r, void *buf, uint32_t buf_
}
#define Z_RTIO_SQE_POOL_DEFINE(name, sz) \
static struct rtio_iodev_sqe _sqe_pool_##name[sz]; \
static struct rtio_iodev_sqe CONCAT(_sqe_pool_, name)[sz]; \
STRUCT_SECTION_ITERABLE(rtio_sqe_pool, name) = { \
.free_q = RTIO_MPSC_INIT((name.free_q)), \
.pool_size = sz, \
.pool_free = sz, \
.pool = _sqe_pool_##name, \
.pool = CONCAT(_sqe_pool_, name), \
}
#define Z_RTIO_CQE_POOL_DEFINE(name, sz) \
static struct rtio_cqe _cqe_pool_##name[sz]; \
static struct rtio_cqe CONCAT(_cqe_pool_, name)[sz]; \
STRUCT_SECTION_ITERABLE(rtio_cqe_pool, name) = { \
.free_q = RTIO_MPSC_INIT((name.free_q)), \
.pool_size = sz, \
.pool_free = sz, \
.pool = _cqe_pool_##name, \
.pool = CONCAT(_cqe_pool_, name), \
}
/**
@ -779,19 +779,19 @@ static inline void rtio_block_pool_free(struct rtio *r, void *buf, uint32_t buf_
#define Z_RTIO_BLOCK_POOL_DEFINE(name, blk_sz, blk_cnt, blk_align) \
RTIO_BMEM uint8_t __aligned(WB_UP(blk_align)) \
_block_pool_##name[blk_cnt*WB_UP(blk_sz)]; \
_SYS_MEM_BLOCKS_DEFINE_WITH_EXT_BUF(name, WB_UP(blk_sz), blk_cnt, _block_pool_##name, \
RTIO_DMEM)
CONCAT(_block_pool_, name)[blk_cnt*WB_UP(blk_sz)]; \
_SYS_MEM_BLOCKS_DEFINE_WITH_EXT_BUF(name, WB_UP(blk_sz), blk_cnt, \
CONCAT(_block_pool_, name), RTIO_DMEM)
#define Z_RTIO_DEFINE(name, _sqe_pool, _cqe_pool, _block_pool) \
IF_ENABLED(CONFIG_RTIO_SUBMIT_SEM, \
(static K_SEM_DEFINE(_submit_sem_##name, 0, K_SEM_MAX_LIMIT))) \
(static K_SEM_DEFINE(CONCAT(_submit_sem_, name), 0, K_SEM_MAX_LIMIT))) \
IF_ENABLED(CONFIG_RTIO_CONSUME_SEM, \
(static K_SEM_DEFINE(_consume_sem_##name, 0, K_SEM_MAX_LIMIT))) \
(static K_SEM_DEFINE(CONCAT(_consume_sem_, name), 0, K_SEM_MAX_LIMIT))) \
STRUCT_SECTION_ITERABLE(rtio, name) = { \
IF_ENABLED(CONFIG_RTIO_SUBMIT_SEM, (.submit_sem = &_submit_sem_##name,)) \
IF_ENABLED(CONFIG_RTIO_SUBMIT_SEM, (.submit_sem = &CONCAT(_submit_sem_, name),)) \
IF_ENABLED(CONFIG_RTIO_SUBMIT_SEM, (.submit_count = 0,)) \
IF_ENABLED(CONFIG_RTIO_CONSUME_SEM, (.consume_sem = &_consume_sem_##name,)) \
IF_ENABLED(CONFIG_RTIO_CONSUME_SEM, (.consume_sem = &CONCAT(_consume_sem_, name),))\
.cq_count = ATOMIC_INIT(0), \
.xcqcnt = ATOMIC_INIT(0), \
.sqe_pool = _sqe_pool, \
@ -808,10 +808,11 @@ static inline void rtio_block_pool_free(struct rtio *r, void *buf, uint32_t buf_
* @param sq_sz Size of the submission queue entry pool
* @param cq_sz Size of the completion queue entry pool
*/
#define RTIO_DEFINE(name, sq_sz, cq_sz) \
Z_RTIO_SQE_POOL_DEFINE(name##_sqe_pool, sq_sz); \
Z_RTIO_CQE_POOL_DEFINE(name##_cqe_pool, cq_sz); \
Z_RTIO_DEFINE(name, &name##_sqe_pool, &name##_cqe_pool, NULL) \
#define RTIO_DEFINE(name, sq_sz, cq_sz) \
Z_RTIO_SQE_POOL_DEFINE(CONCAT(name, _sqe_pool), sq_sz); \
Z_RTIO_CQE_POOL_DEFINE(CONCAT(name, _cqe_pool), cq_sz); \
Z_RTIO_DEFINE(name, &CONCAT(name, _sqe_pool), \
&CONCAT(name, _cqe_pool), NULL)
/* clang-format on */