yamt commented on code in PR #15455:
URL: https://github.com/apache/nuttx/pull/15455#discussion_r1906481741
##########
libs/libbuiltin/libgcc/profile.c:
##########
@@ -288,13 +284,13 @@ void moncontrol(int mode)
if (mode)
{
- uintptr_t lowpc = ROUNDDOWN((uintptr_t)&_stext,
+ uintptr_t lowpc = ALIGN_DOWN((uintptr_t)&_stext,
HISTFRACTION * sizeof(HISTCOUNTER));
- uintptr_t highpc = ROUNDUP((uintptr_t)&_etext,
- HISTFRACTION * sizeof(HISTCOUNTER));
+ uintptr_t highpc = ALIGN_UP((uintptr_t)&_etext,
+ HISTFRACTION * sizeof(HISTCOUNTER));
Review Comment:
it isn't obvious `HISTFRACTION * sizeof(HISTCOUNTER)` is a power of two.
is it possible to have a power-of-two assertion in ALIGN_UP itself?
this PR as it is seems a bit fragile to me.
does ALIGN_UP actually produce a better code than ROUNDUP with a power of
two `y` with modern compilers? otherwise, maybe it's safer to drop the
power-of-two assumption from ALIGN_UP.
##########
binfmt/binfmt_copyactions.c:
##########
@@ -98,8 +93,8 @@ int binfmt_copyactions(FAR const posix_spawn_file_actions_t
**copy,
case SPAWN_FILE_ACTION_OPEN:
open = (FAR struct spawn_open_file_action_s *)entry;
- size += ROUNDUP(SIZEOF_OPEN_FILE_ACTION_S(strlen(open->path)),
- sizeof(FAR void *));
+ size += ALIGN_UP(SIZEOF_OPEN_FILE_ACTION_S(strlen(open->path)),
+ sizeof(FAR void *));
Review Comment:
i feel a bit uneasy to assume sizeof(FAR void *) is a power of two.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]