This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new cb2d839a3 interpreters/bas: Convert clock() with CLOCKS_PER_SEC in
TIME.
cb2d839a3 is described below
commit cb2d839a3d50ba15705f3f67efda16b07b525ccc
Author: Marco Casaroli <[email protected]>
AuthorDate: Fri Oct 23 10:51:03 2026 +0200
interpreters/bas: Convert clock() with CLOCKS_PER_SEC in TIME.
The TIME function (fn_timei()) divided clock() by CLK_TCK, the system
tick rate. clock() counts in CLOCKS_PER_SEC units, which is the tick
rate in NuttX today.
Divide by CLOCKS_PER_SEC. The result does not change today, and stays
correct if CLOCKS_PER_SEC changes.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
interpreters/bas/bas_global.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/interpreters/bas/bas_global.c b/interpreters/bas/bas_global.c
index 480ac47db..795945897 100644
--- a/interpreters/bas/bas_global.c
+++ b/interpreters/bas/bas_global.c
@@ -1899,7 +1899,8 @@ static struct Value *fn_tan(struct Value *v, struct Auto
*stack)
static struct Value *fn_timei(struct Value *v, struct Auto *stack)
{
- return Value_new_INTEGER(v, (unsigned long)(clock() / (CLK_TCK / 100.0)));
+ return Value_new_INTEGER(v, (unsigned long)(clock() /
+ (CLOCKS_PER_SEC / 100.0)));
}
static struct Value *fn_times(struct Value *v, struct Auto *stack)