mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
sys: add the possibility to fuzz what sys_now() returns
This commit is contained in:
parent
9b5a6fe1dc
commit
fc85b055d7
@ -670,9 +670,14 @@ u32_t
|
|||||||
sys_now(void)
|
sys_now(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
u32_t now;
|
||||||
|
|
||||||
get_monotonic_time(&ts);
|
get_monotonic_time(&ts);
|
||||||
return (u32_t)(ts.tv_sec * 1000L + ts.tv_nsec / 1000000L);
|
now = (u32_t)(ts.tv_sec * 1000L + ts.tv_nsec / 1000000L);
|
||||||
|
#ifdef LWIP_FUZZ_SYS_NOW
|
||||||
|
now += sys_now_offset;
|
||||||
|
#endif
|
||||||
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32_t
|
u32_t
|
||||||
|
@ -142,7 +142,11 @@ sys_jiffies(void)
|
|||||||
u32_t
|
u32_t
|
||||||
sys_now(void)
|
sys_now(void)
|
||||||
{
|
{
|
||||||
return (u32_t)sys_get_ms_longlong();
|
u32_t now = (u32_t)sys_get_ms_longlong();
|
||||||
|
#ifdef LWIP_FUZZ_SYS_NOW
|
||||||
|
now += sys_now_offset;
|
||||||
|
#endif
|
||||||
|
return now;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRITICAL_SECTION critSec;
|
CRITICAL_SECTION critSec;
|
||||||
|
@ -445,6 +445,11 @@ void sys_init(void);
|
|||||||
u32_t sys_jiffies(void);
|
u32_t sys_jiffies(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LWIP_FUZZ_SYS_NOW
|
||||||
|
/* This offset should be added to the time 'sys_now()' returns */
|
||||||
|
extern u32_t sys_now_offset;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup sys_time
|
* @ingroup sys_time
|
||||||
* Returns the current time in milliseconds,
|
* Returns the current time in milliseconds,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user