Skip to content

Commit

Permalink
time: cleanup sleep() and msleep() API
Browse files Browse the repository at this point in the history
The sleep() expected miliseconds parameter, hence it should become the
msleep(), and sleep() should just use the msleep() directly.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Sep 8, 2023
1 parent de99b45 commit 940cd5f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion arch/x86/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void init_apic_timer(void) {
apic_write(APIC_LVT_TIMER, timer.reg);

/* Sleep for 20ms to calibrate, count the ticks */
sleep(CAL_SLEEP_TIME);
msleep(CAL_SLEEP_TIME);

/* Calibrate */
uint32_t elapsed_ticks = (_U32(-1) - apic_read(APIC_TMR_CCR)) / CAL_SLEEP_TIME;
Expand Down
6 changes: 3 additions & 3 deletions include/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@

typedef uint64_t time_t;

extern void sleep(time_t ms);
extern void msleep(time_t ms);
extern time_t get_timer_ticks(void);

/* Static declarations */

static inline void msleep(time_t ms) {
sleep(ms);
static inline void sleep(time_t s) {
msleep(s * 1000);
}

#endif
2 changes: 1 addition & 1 deletion lib/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void timer_interrupt_handler(void) {
apic_EOI();
}

void sleep(time_t ms) {
void msleep(time_t ms) {
time_t end = ticks + ms;
while (ticks < end) {
cpu_relax();
Expand Down

0 comments on commit 940cd5f

Please sign in to comment.