HP-UX doesn't suport CLOCK_MONOTONIC but we can use gethrtime() instead.

This commit is contained in:
Todd C. Miller
2018-08-20 10:56:34 -06:00
parent 5cca421867
commit df1c062526
4 changed files with 40 additions and 10 deletions

View File

@@ -298,6 +298,9 @@
/* Define to 1 if you have the `getgrset' function. */
#undef HAVE_GETGRSET
/* Define to 1 if you have the `gethrtime' function. */
#undef HAVE_GETHRTIME
/* Define to 1 if you have the `getifaddrs' function. */
#undef HAVE_GETIFADDRS

18
configure vendored
View File

@@ -15604,12 +15604,13 @@ _ACEOF
# HP-UX won't unlink a shared lib that is open
INSTALL_BACKUP='~'
for ac_func in pstat_getproc
for ac_func in pstat_getproc gethrtime
do :
ac_fn_c_check_func "$LINENO" "pstat_getproc" "ac_cv_func_pstat_getproc"
if test "x$ac_cv_func_pstat_getproc" = xyes; then :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_PSTAT_GETPROC 1
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
@@ -15720,12 +15721,13 @@ $as_echo "$sudo_cv_var_daportable" >&6; }
test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
;;
esac
for ac_func in pstat_getproc
for ac_func in pstat_getproc gethrtime
do :
ac_fn_c_check_func "$LINENO" "pstat_getproc" "ac_cv_func_pstat_getproc"
if test "x$ac_cv_func_pstat_getproc" = xyes; then :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_PSTAT_GETPROC 1
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi

View File

@@ -1875,7 +1875,7 @@ case "$host" in
# HP-UX won't unlink a shared lib that is open
INSTALL_BACKUP='~'
AC_CHECK_FUNCS([pstat_getproc])
AC_CHECK_FUNCS([pstat_getproc gethrtime])
;;
*-*-hpux*)
AC_DEFINE([PAM_SUN_CODEBASE])
@@ -1954,7 +1954,7 @@ case "$host" in
test -z "$with_pam" && AUTH_EXCL_DEF="PAM"
;;
esac
AC_CHECK_FUNCS([pstat_getproc])
AC_CHECK_FUNCS([pstat_getproc gethrtime])
;;
*-dec-osf*)
# ignore envariables wrt dynamic lib path

View File

@@ -111,6 +111,18 @@ sudo_gettime_mono_v1(struct timespec *ts)
}
debug_return_int(0);
}
#elif defined(HAVE_GETHRTIME)
int
sudo_gettime_mono_v1(struct timespec *ts)
{
hrtime_t nsec;
debug_decl(sudo_gettime_mono, SUDO_DEBUG_UTIL)
nsec = gethrtime();
ts->tv_sec = nsec / 1000000000;
ts->tv_nsec = nsec % 1000000000;
debug_return_int(0);
}
#elif defined(__MACH__)
int
sudo_gettime_mono_v1(struct timespec *ts)
@@ -167,6 +179,19 @@ sudo_gettime_awake_v1(struct timespec *ts)
}
debug_return_int(0);
}
#elif defined(HAVE_GETHRTIME)
int
sudo_gettime_awake_v1(struct timespec *ts)
{
hrtime_t nsec;
debug_decl(sudo_gettime_awake, SUDO_DEBUG_UTIL)
/* Currently the same as sudo_gettime_mono() */
nsec = gethrtime();
ts->tv_sec = nsec / 1000000000;
ts->tv_nsec = nsec % 1000000000;
debug_return_int(0);
}
#elif defined(__MACH__)
int
sudo_gettime_awake_v1(struct timespec *ts)