]> granicus.if.org Git - sudo/commitdiff
HP-UX doesn't suport CLOCK_MONOTONIC but we can use gethrtime() instead.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Mon, 20 Aug 2018 16:56:34 +0000 (10:56 -0600)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Mon, 20 Aug 2018 16:56:34 +0000 (10:56 -0600)
config.h.in
configure
configure.ac
lib/util/gettime.c

index f8d09ceb0e81df3c8197fd1c3bd182ded6c3dec6..17b0681eab34c8ce1451e6986bdbb2f2c731f2a6 100644 (file)
 /* 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
 
index 77eef570d5569c5aeb9fd4c90b42deeace988e47..64e8dac27d2b5ee67bd109dd98cd588f72ddbfea 100755 (executable)
--- a/configure
+++ b/configure
@@ -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
index a91ca18d973e7ef54c313f9d414ed179e23e6c5c..ed3027f142f78172cb2dfe78532b3586480e5e41 100644 (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
index 63c9ea11da6f1c35f23ec0243accd9e7e652e592..72bdbe6d767c35770519d20870615e68a5a0d5c6 100644 (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)