-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: John Sanpe <[email protected]>
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
/* | ||
* Copyright(c) 2024 John Sanpe <[email protected]> | ||
*/ | ||
|
||
#include <bfdev.h> | ||
#include <xdbd.h> | ||
#include <time.h> | ||
#include <sys/time.h> | ||
|
||
volatile xdbd_msec_t xdbd_current_msec; | ||
|
||
static xdbd_msec_t | ||
xdbd_monotonic_time(void) | ||
{ | ||
struct timespec ts; | ||
time_t sec; | ||
long msec; | ||
|
||
clock_gettime(CLOCK_MONOTONIC, &ts); | ||
sec = ts.tv_sec; | ||
msec = ts.tv_nsec / 1000000; | ||
|
||
return (xdbd_msec_t) sec * 1000 + msec; | ||
} | ||
|
||
void | ||
xdbd_time_update(void) | ||
{ | ||
xdbd_current_msec = xdbd_monotonic_time(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
/* | ||
* Copyright(c) 2024 John Sanpe <[email protected]> | ||
*/ | ||
|
||
#ifndef __xdbd_times__H__ | ||
#define __xdbd_times__H__ | ||
|
||
#include <xdbd.h> | ||
|
||
extern volatile xdbd_msec_t xdbd_current_msec; | ||
|
||
void | ||
xdbd_time_update(void); | ||
|
||
#endif /* __xdbd_times__H__ */ |