mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Merge remote-tracking branch 'public/feature24427'
This commit is contained in:
commit
ea929e8456
5
changes/feature24427
Normal file
5
changes/feature24427
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
o Minor features (OSX, iOS, performance):
|
||||||
|
- Use the mach_approximate_time() function (when available) to
|
||||||
|
implement coarse monotonic time. Having a coarse time function
|
||||||
|
should avoid a large number of system calls, and improve
|
||||||
|
performance slightly, especially under load. Closes ticket 24427.
|
@ -506,6 +506,7 @@ AC_CHECK_FUNCS(
|
|||||||
llround \
|
llround \
|
||||||
localtime_r \
|
localtime_r \
|
||||||
lround \
|
lround \
|
||||||
|
mach_approximate_time \
|
||||||
memmem \
|
memmem \
|
||||||
memset_s \
|
memset_s \
|
||||||
pipe \
|
pipe \
|
||||||
|
@ -314,6 +314,21 @@ monotime_get(monotime_t *out)
|
|||||||
out->abstime_ = mach_absolute_time();
|
out->abstime_ = mach_absolute_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_MACH_APPROXIMATE_TIME)
|
||||||
|
void
|
||||||
|
monotime_coarse_get(monotime_coarse_t *out)
|
||||||
|
{
|
||||||
|
#ifdef TOR_UNIT_TESTS
|
||||||
|
if (monotime_mocking_enabled) {
|
||||||
|
out->abstime_ = (mock_time_nsec_coarse * mach_time_info.denom)
|
||||||
|
/ mach_time_info.numer;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif /* defined(TOR_UNIT_TESTS) */
|
||||||
|
out->abstime_ = mach_approximate_time();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of nanoseconds between <b>start</b> and <b>end</b>.
|
* Return the number of nanoseconds between <b>start</b> and <b>end</b>.
|
||||||
*/
|
*/
|
||||||
|
@ -65,6 +65,9 @@ typedef struct monotime_t {
|
|||||||
typedef struct monotime_coarse_t {
|
typedef struct monotime_coarse_t {
|
||||||
uint64_t tick_count_;
|
uint64_t tick_count_;
|
||||||
} monotime_coarse_t;
|
} monotime_coarse_t;
|
||||||
|
#elif defined(__APPLE__) && defined(HAVE_MACH_APPROXIMATE_TIME)
|
||||||
|
#define MONOTIME_COARSE_FN_IS_DIFFERENT
|
||||||
|
#define monotime_coarse_t monotime_t
|
||||||
#else
|
#else
|
||||||
#define monotime_coarse_t monotime_t
|
#define monotime_coarse_t monotime_t
|
||||||
#endif /* defined(CLOCK_MONOTONIC_COARSE) && ... || ... */
|
#endif /* defined(CLOCK_MONOTONIC_COARSE) && ... || ... */
|
||||||
|
Loading…
Reference in New Issue
Block a user