apache / apache/nuttx

clock() and CLOCKS_PER_SEC is not POSIX compliant

Open
#3,516 8 comments 0 reactions 0 assignees View on GitHub
Area: Standards
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

NuttX defines `CLOCKS_PER_SEC` as:

```
#ifdef CONFIG_USEC_PER_TICK
# define CLK_TCK (1000000/CONFIG_USEC_PER_TICK)
# define CLOCKS_PER_SEC (1000000/CONFIG_USEC_PER_TICK)
#else
# define CLK_TCK (100)
# define CLOCKS_PER_SEC (100)
#endif
```
But the POSIX standard defines it as always one million.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html

Contributor guide

Open the contributing guide

Research direction

Start by locating the clock() implementation and the definitions of CLOCKS_PER_SEC and CLK_TCK, then read the linked POSIX specification to compare their required meanings. Done means the exposed clock timing interface follows the specified CLOCKS_PER_SEC behavior across the relevant configuration paths, with existing clock-related tests or checks updated as needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.