mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 13:53:11 +00:00
Add support for clock_gettime_nsec_np()
Prefer clock_gettime_nsec_np(CLOCK_UPTIME_RAW) to mach_absolute_time().
This commit is contained in:
10
configure.ac
10
configure.ac
@@ -2126,6 +2126,16 @@ if test "x${je_cv_clock_realtime}" = "xyes" ; then
|
|||||||
AC_DEFINE([JEMALLOC_HAVE_CLOCK_REALTIME], [ ], [ ])
|
AC_DEFINE([JEMALLOC_HAVE_CLOCK_REALTIME], [ ], [ ])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl Check for clock_gettime_nsec_np().
|
||||||
|
JE_COMPILABLE([clock_gettime_nsec_np()], [
|
||||||
|
#include <time.h>
|
||||||
|
], [
|
||||||
|
clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
|
||||||
|
], [je_cv_clock_gettime_nsec_np])
|
||||||
|
if test "x${je_cv_clock_gettime_nsec_np}" = "xyes" ; then
|
||||||
|
AC_DEFINE([JEMALLOC_HAVE_CLOCK_GETTIME_NSEC_NP], [ ], [ ])
|
||||||
|
fi
|
||||||
|
|
||||||
dnl Use syscall(2) (if available) by default.
|
dnl Use syscall(2) (if available) by default.
|
||||||
AC_ARG_ENABLE([syscall],
|
AC_ARG_ENABLE([syscall],
|
||||||
[AS_HELP_STRING([--disable-syscall], [Disable use of syscall(2)])],
|
[AS_HELP_STRING([--disable-syscall], [Disable use of syscall(2)])],
|
||||||
|
|||||||
@@ -117,6 +117,11 @@
|
|||||||
*/
|
*/
|
||||||
#undef JEMALLOC_HAVE_CLOCK_REALTIME
|
#undef JEMALLOC_HAVE_CLOCK_REALTIME
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Defined if clock_gettime_nsec_np(CLOCK_UPTIME_RAW) is available.
|
||||||
|
*/
|
||||||
|
#undef JEMALLOC_HAVE_CLOCK_GETTIME_NSEC_NP
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defined if _malloc_thread_cleanup() exists. At least in the case of
|
* Defined if _malloc_thread_cleanup() exists. At least in the case of
|
||||||
* FreeBSD, pthread_key_create() allocates, which if used during malloc
|
* FreeBSD, pthread_key_create() allocates, which if used during malloc
|
||||||
|
|||||||
13
src/nstime.c
13
src/nstime.c
@@ -201,11 +201,22 @@ nstime_get(nstime_t *time) {
|
|||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
nstime_init2(time, ts.tv_sec, ts.tv_nsec);
|
nstime_init2(time, ts.tv_sec, ts.tv_nsec);
|
||||||
}
|
}
|
||||||
|
#elif defined(JEMALLOC_HAVE_CLOCK_GETTIME_NSEC_NP)
|
||||||
|
# define NSTIME_MONOTONIC true
|
||||||
|
static void
|
||||||
|
nstime_get(nstime_t *time) {
|
||||||
|
nstime_init(time, clock_gettime_nsec_np(CLOCK_UPTIME_RAW));
|
||||||
|
}
|
||||||
#elif defined(JEMALLOC_HAVE_MACH_ABSOLUTE_TIME)
|
#elif defined(JEMALLOC_HAVE_MACH_ABSOLUTE_TIME)
|
||||||
# define NSTIME_MONOTONIC true
|
# define NSTIME_MONOTONIC true
|
||||||
static void
|
static void
|
||||||
nstime_get(nstime_t *time) {
|
nstime_get(nstime_t *time) {
|
||||||
nstime_init(time, mach_absolute_time());
|
static mach_timebase_info_data_t sTimebaseInfo;
|
||||||
|
if (sTimebaseInfo.denom == 0) {
|
||||||
|
(void) mach_timebase_info(&sTimebaseInfo);
|
||||||
|
}
|
||||||
|
nstime_init(time, mach_absolute_time() * sTimebaseInfo.numer
|
||||||
|
/ sTimebaseInfo.denom);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define NSTIME_MONOTONIC false
|
# define NSTIME_MONOTONIC false
|
||||||
|
|||||||
Reference in New Issue
Block a user