diff options
author | Rickard Green <[email protected]> | 2015-03-24 16:56:08 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2015-03-24 16:56:08 +0100 |
commit | 5345727d647ea65b7a0417c87b94cf958ef9ee13 (patch) | |
tree | bcc1c75102741e9768c88b1481390e40e32586e7 /erts/aclocal.m4 | |
parent | a11cec66e37c039d33091db056c0ae44405043ac (diff) | |
parent | c20482023b70768bd84d25f1e34dbbc2fe09cf31 (diff) | |
download | otp-5345727d647ea65b7a0417c87b94cf958ef9ee13.tar.gz otp-5345727d647ea65b7a0417c87b94cf958ef9ee13.tar.bz2 otp-5345727d647ea65b7a0417c87b94cf958ef9ee13.zip |
Merge branch 'rickard/time_api/OTP-11997'
* rickard/time_api/OTP-11997:
Better OS system time implementation
Documentation adjustments
Fix zero timout timers
erts_sys_hrtime() for lcnt
Better support for poor os monotonic sources
Conflicts:
erts/preloaded/ebin/erlang.beam
Diffstat (limited to 'erts/aclocal.m4')
-rw-r--r-- | erts/aclocal.m4 | 99 |
1 files changed, 91 insertions, 8 deletions
diff --git a/erts/aclocal.m4 b/erts/aclocal.m4 index b2d30449cd..fb5ae4f02d 100644 --- a/erts/aclocal.m4 +++ b/erts/aclocal.m4 @@ -745,11 +745,9 @@ AC_DEFUN(ERL_MONOTONIC_CLOCK, done ]) - AC_CHECK_FUNC(clock_getres) - - AC_CHECK_FUNC(gethrtime) + AC_CHECK_FUNCS([clock_getres gethrtime]) - AC_CACHE_CHECK([for mach clock_get_time()], erl_cv_mach_clock_get_time, + AC_CACHE_CHECK([for mach clock_get_time()], erl_cv_mach_clock_get_time_monotonic, [ AC_TRY_COMPILE([ #include <mach/clock.h> @@ -764,13 +762,13 @@ AC_DEFUN(ERL_MONOTONIC_CLOCK, res = clock_get_time(clk_srv, &time_spec); mach_port_deallocate(mach_task_self(), clk_srv); ], - erl_cv_mach_clock_get_time=yes, - erl_cv_mach_clock_get_time=no) + erl_cv_mach_clock_get_time_monotonic=yes, + erl_cv_mach_clock_get_time_monotonic=no) ]) - case $erl_cv_clock_gettime_monotonic-$ac_cv_func_gethrtime-$erl_cv_mach_clock_get_time-$host_os in + case $erl_cv_clock_gettime_monotonic-$ac_cv_func_gethrtime-$erl_cv_mach_clock_get_time_monotonic-$host_os in *-*-*-win32) - erl_monotonic_clock_func=GetTickCount + erl_monotonic_clock_func=WindowsAPI ;; CLOCK_*-*-*-linux*) if test X$cross_compiling != Xyes; then @@ -835,6 +833,70 @@ AC_DEFUN(ERL_MONOTONIC_CLOCK, ]) +AC_DEFUN(ERL_WALL_CLOCK, +[ + AC_CACHE_CHECK([for clock_gettime() with wall clock type], erl_cv_clock_gettime_wall, + [ + for clock_type in CLOCK_REALTIME; do + AC_TRY_COMPILE([ +#include <time.h> + ], + [ + struct timespec ts; + long long result; + clock_gettime($clock_type,&ts); + result = ((long long) ts.tv_sec) * 1000000000LL + + ((long long) ts.tv_nsec); + ], + erl_cv_clock_gettime_wall=$clock_type, + erl_cv_clock_gettime_wall=no) + test $erl_cv_clock_gettime_wall = no || break + done + ]) + + AC_CHECK_FUNCS([clock_getres gettimeofday]) + + AC_CACHE_CHECK([for mach clock_get_time()], erl_cv_mach_clock_get_time_wall, + [ + AC_TRY_COMPILE([ +#include <mach/clock.h> +#include <mach/mach.h> + ], + [ + kern_return_t res; + clock_serv_t clk_srv; + mach_timespec_t time_spec; + + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &clk_srv); + res = clock_get_time(clk_srv, &time_spec); + mach_port_deallocate(mach_task_self(), clk_srv); + ], + erl_cv_mach_clock_get_time_wall=yes, + erl_cv_mach_clock_get_time_wall=no) + ]) + + erl_wall_clock_id= + case $erl_cv_clock_gettime_wall-$erl_cv_mach_clock_get_time_wall-$ac_cv_func_gettimeofday-$host_os in + *-*-*-win32) + erl_wall_clock_func=WindowsAPI + ;; + no-yes-*-*) + erl_wall_clock_func=mach_clock_get_time + erl_wall_clock_id=CALENDAR_CLOCK + ;; + CLOCK_*-*-*-*) + erl_wall_clock_func=clock_gettime + erl_wall_clock_id=$erl_cv_clock_gettime_wall + ;; + no-no-yes-*) + erl_wall_clock_func=gettimeofday + ;; + *) + erl_wall_clock_func=none + ;; + esac +]) + dnl ---------------------------------------------------------------------- dnl dnl LM_CHECK_THR_LIB @@ -2079,6 +2141,27 @@ dnl AC_DEFUN(ERL_TIME_CORRECTION, [ +ERL_WALL_CLOCK + +case $erl_wall_clock_func in + mach_clock_get_time) + AC_DEFINE(OS_SYSTEM_TIME_USING_MACH_CLOCK_GET_TIME, [1], [Define if you want to implement erts_os_system_time() using mach clock_get_time()]) + ;; + clock_gettime) + AC_DEFINE(OS_SYSTEM_TIME_USING_CLOCK_GETTIME, [1], [Define if you want to implement erts_os_system_time() using clock_gettime()]) + ;; + gettimeofday) + AC_DEFINE(OS_SYSTEM_TIME_GETTIMEOFDAY, [1], [Define if you want to implement erts_os_system_time() using gettimeofday()]) + ;; + *) + ;; +esac + +if test "x$erl_wall_clock_id" != "x"; then + AC_DEFINE_UNQUOTED(WALL_CLOCK_ID_STR, ["$erl_wall_clock_id"], [Define as a string of wall clock id to use]) + AC_DEFINE_UNQUOTED(WALL_CLOCK_ID, [$erl_wall_clock_id], [Define to wall clock id to use]) +fi + ERL_MONOTONIC_CLOCK case $erl_monotonic_clock_func in |