freebsd_network: Move ticks/seconds conversions to sys/time.h and
rename. They now match the names they have in FreeBSD. No functional change intended.
This commit is contained in:
parent
17af7f6298
commit
c70ec71d0c
@ -38,7 +38,7 @@ int
|
||||
conditionTimedWait(struct cv* variable, const int timeout)
|
||||
{
|
||||
status_t status = variable->condition.Wait(B_RELATIVE_TIMEOUT,
|
||||
ticks_to_usecs(timeout));
|
||||
TICKS_2_USEC(timeout));
|
||||
|
||||
if (status != B_OK)
|
||||
status = EWOULDBLOCK;
|
||||
@ -64,7 +64,7 @@ int
|
||||
publishedConditionTimedWait(const void* waitChannel, const int timeout)
|
||||
{
|
||||
ConditionVariableEntry variableEntry;
|
||||
bigtime_t usecs = ticks_to_usecs(timeout);
|
||||
bigtime_t usecs = TICKS_2_USEC(timeout);
|
||||
|
||||
// FreeBSD has a condition-variable scheduling system with different
|
||||
// scheduling semantics than ours does. As a result, it seems there are
|
||||
|
@ -191,7 +191,7 @@ callout_reset(struct callout *c, int _ticks, void (*func)(void *), void *arg)
|
||||
if (c->due <= 0)
|
||||
list_add_item(&sTimers, c);
|
||||
|
||||
c->due = system_time() + ticks_to_usecs(_ticks);
|
||||
c->due = system_time() + TICKS_2_USEC(_ticks);
|
||||
|
||||
// notify timer about the change if necessary
|
||||
if (sTimeout > c->due)
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
int32_t
|
||||
get_ticks()
|
||||
_get_ticks()
|
||||
{
|
||||
return usecs_to_ticks(system_time());
|
||||
return USEC_2_TICKS(system_time());
|
||||
}
|
||||
|
@ -25,11 +25,8 @@
|
||||
* as it defines a long long constant. */
|
||||
#define hz 1000LL
|
||||
|
||||
int32_t get_ticks();
|
||||
#define ticks (get_ticks())
|
||||
|
||||
#define ticks_to_usecs(t) (1000000*((bigtime_t)t) / hz)
|
||||
#define usecs_to_ticks(t) (((bigtime_t)t*hz) / 1000000)
|
||||
int32_t _get_ticks();
|
||||
#define ticks (_get_ticks())
|
||||
|
||||
|
||||
/* sysinit */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009, Colin Günther, coling@gmx.de.
|
||||
* Copyright 2020, Haiku, Inc. All rights reserved.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _FBSD_COMPAT_SYS_TIME_H_
|
||||
@ -12,9 +12,16 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#define time_uptime (system_time() / 1000000)
|
||||
#define TICKS_2_USEC(t) ((1000000*(bigtime_t)t) / hz)
|
||||
#define USEC_2_TICKS(t) (((bigtime_t)t*hz) / 1000000)
|
||||
|
||||
#define TICKS_2_MSEC(t) ((1000*(bigtime_t)t) / hz)
|
||||
#define MSEC_2_TICKS(t) (((bigtime_t)t*hz) / 1000)
|
||||
|
||||
#define time_uptime USEC_2_TICKS(system_time())
|
||||
|
||||
|
||||
int ppsratecheck(struct timeval*, int*, int);
|
||||
|
||||
|
||||
#endif /* _FBSD_COMPAT_SYS_TIME_H_ */
|
||||
|
@ -16,7 +16,7 @@ int
|
||||
_pause(const char* waitMessage, int timeout)
|
||||
{
|
||||
KASSERT(timeout != 0, ("pause: timeout required"));
|
||||
return snooze(ticks_to_usecs(timeout));
|
||||
return snooze(TICKS_2_USEC(timeout));
|
||||
}
|
||||
|
||||
|
||||
|
@ -265,9 +265,8 @@ void ieee80211_vap_destroy(struct ieee80211vap *);
|
||||
(((_ifp)->if_flags & IFF_UP) && \
|
||||
((_ifp)->if_drv_flags & IFF_DRV_RUNNING))
|
||||
|
||||
/* XXX TODO: cap these at 1, as hz may not be 1000 */
|
||||
#define msecs_to_ticks(ms) (((ms)*hz)/1000)
|
||||
#define ticks_to_msecs(t) (1000*(t) / hz)
|
||||
#define msecs_to_ticks(ms) MSEC_2_TICKS(ms)
|
||||
#define ticks_to_msecs(t) TICKS_2_MSEC(t)
|
||||
#define ticks_to_secs(t) ((t) / hz)
|
||||
|
||||
#define ieee80211_time_after(a,b) ((long)(b) - (long)(a) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user