Skip to content

Commit

Permalink
compiler: add HAVE_EXPRESSION_STATEMENT macro for gcc
Browse files Browse the repository at this point in the history
this will open fast version of div_const which defined in:
include/nuttx/lib/math32.h
when meet 64/32 when use gcc compiling

Signed-off-by: ligd <[email protected]>
  • Loading branch information
GUIDINGLI committed Nov 5, 2024
1 parent 3c4053a commit e17a99c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions arch/risc-v/src/esp32c3-legacy/esp32c3_ble_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
int ret;
struct bt_sem_s *bt_sem = (struct bt_sem_s *)semphr;
uint32_t tick = MSEC2TICK(block_time_ms);

if (block_time_ms == OSI_FUNCS_TIME_BLOCKING)
{
Expand All @@ -922,7 +923,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
if (block_time_ms > 0)
{
ret = nxsem_tickwait(&bt_sem->sem, MSEC2TICK(block_time_ms));
ret = nxsem_tickwait(&bt_sem->sem, tick);
}
else
{
Expand All @@ -932,8 +933,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)

if (ret)
{
wlerr("ERROR: Failed to wait sem in %lu ticks. Error=%d\n",
MSEC2TICK(block_time_ms), ret);
wlerr("ERROR: Failed to wait sem in %lu ticks. Error=%d\n", tick, ret);
}

return esp_errno_trans(ret);
Expand Down
6 changes: 3 additions & 3 deletions arch/risc-v/src/esp32c3/esp_ble_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
int ret;
struct bt_sem_s *bt_sem = (struct bt_sem_s *)semphr;
uint32_t tick = MSEC2TICK(block_time_ms);

if (block_time_ms == OSI_FUNCS_TIME_BLOCKING)
{
Expand All @@ -1061,7 +1062,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
if (block_time_ms > 0)
{
ret = nxsem_tickwait(&bt_sem->sem, MSEC2TICK(block_time_ms));
ret = nxsem_tickwait(&bt_sem->sem, tick);
}
else
{
Expand All @@ -1071,8 +1072,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)

if (ret)
{
wlerr("ERROR: Failed to wait sem in %lu ticks. Error=%d\n",
MSEC2TICK(block_time_ms), ret);
wlerr("ERROR: Failed to wait sem in %lu ticks. Error=%d\n", tick, ret);
}

return esp_errno_trans(ret);
Expand Down
6 changes: 3 additions & 3 deletions arch/xtensa/src/esp32/esp32_ble_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
int ret;
struct bt_sem_s *bt_sem = (struct bt_sem_s *)semphr;
uint32_t tick = MSEC2TICK(block_time_ms);

if (block_time_ms == OSI_FUNCS_TIME_BLOCKING)
{
Expand All @@ -1124,7 +1125,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
if (block_time_ms > 0)
{
ret = nxsem_tickwait(&bt_sem->sem, MSEC2TICK(block_time_ms));
ret = nxsem_tickwait(&bt_sem->sem, tick);
}
else
{
Expand All @@ -1134,8 +1135,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)

if (ret)
{
wlerr("ERROR: Failed to wait sem in %u ticks. Error=%d\n",
MSEC2TICK(block_time_ms), ret);
wlerr("ERROR: Failed to wait sem in %u ticks. Error=%d\n", tick, ret);
}

return esp_errno_trans(ret);
Expand Down
6 changes: 3 additions & 3 deletions arch/xtensa/src/esp32s3/esp32s3_ble_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
int ret;
struct bt_sem_s *bt_sem = (struct bt_sem_s *)semphr;
uint32_t tick = MSEC2TICK(block_time_ms);

if (block_time_ms == OSI_FUNCS_TIME_BLOCKING)
{
Expand All @@ -1052,7 +1053,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)
{
if (block_time_ms > 0)
{
ret = nxsem_tickwait(&bt_sem->sem, MSEC2TICK(block_time_ms));
ret = nxsem_tickwait(&bt_sem->sem, tick);
}
else
{
Expand All @@ -1062,8 +1063,7 @@ static int semphr_take_wrapper(void *semphr, uint32_t block_time_ms)

if (ret)
{
wlerr("ERROR: Failed to wait sem in %u ticks. Error=%d\n",
MSEC2TICK(block_time_ms), ret);
wlerr("ERROR: Failed to wait sem in %u ticks. Error=%d\n", tick, ret);
}

return esp_errno_trans(ret);
Expand Down
6 changes: 6 additions & 0 deletions include/nuttx/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@
# define tz_nonsecure_call __attribute__((cmse_nonsecure_call))
# endif

/* GCC support expression statement, a compound statement enclosed in
* parentheses may appear as an expression in GNU C.
*/

# define CONFIG_HAVE_EXPRESSION_STATEMENT 1

/* SDCC-specific definitions ************************************************/

#elif defined(SDCC) || defined(__SDCC)
Expand Down

0 comments on commit e17a99c

Please sign in to comment.