summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwukong <wukong@longaeva>2025-12-06 00:22:16 -0800
committerwukong <wukong@longaeva>2025-12-06 00:22:16 -0800
commit062bef37b16f6b06f3147ec90fd018f361a17207 (patch)
tree881b60eafc0140ebe2647cf3fba53ef5c59150b3
parenta57c9ad6feac3417bfef88395a4b1ab8c6995867 (diff)
merged changes from FreeBSD environment;
Diffstat (limited to '')
-rw-r--r--ckcptime.awk7
-rw-r--r--ckcptime.sh2
-rw-r--r--ckt0.awk25
-rw-r--r--ckt0.sh6
4 files changed, 25 insertions, 15 deletions
diff --git a/ckcptime.awk b/ckcptime.awk
index 9d8d5a7..e6c88d1 100644
--- a/ckcptime.awk
+++ b/ckcptime.awk
@@ -1,7 +1,9 @@
#!/usr/bin/env awk -f
-function log10(n) { return log(n)/log(10.0) }
+function log10(n) {
+ return log(n)/log(10.0)
+}
function merge_meas(est_val, est_unc, meas_val, meas_unc) {
@@ -135,9 +137,6 @@ function ck_uptime(t0_est, t0_unc) {
BEGIN {
OFMT="%.21g"
- pi = 4.0*atan2(1.0, 1.0)
- c0 = 299792458 # m/sec
-
#print("_systime_", systime())
#print("_boottime_", ck_boottime())
printf("%s" ORS, ck_cptime())
diff --git a/ckcptime.sh b/ckcptime.sh
index 079faa6..697854b 100644
--- a/ckcptime.sh
+++ b/ckcptime.sh
@@ -11,7 +11,7 @@ set -e
#sysctl kern.cp_time | awk -F= '{print($0)}'
#printf "sec\n" | column -t
-for N in $(seq 0 45) ; do
+for N in $(seq 0 15) ; do
#printf "${N} ${t0_est}\n" | column -t
awk -f ckcptime.awk
sleep $( awk 'BEGIN {print( rand()^2.0 + 1.0 )}' )
diff --git a/ckt0.awk b/ckt0.awk
index dac07ea..baeb599 100644
--- a/ckt0.awk
+++ b/ckt0.awk
@@ -1,7 +1,9 @@
#!/usr/bin/env awk -f
-function log10(n) { return log(n)/log(10.0) }
+function log10(n) {
+ return log(n)/log(10.0)
+}
function merge_meas(est_val, est_unc, meas_val, meas_unc) {
@@ -56,7 +58,22 @@ function ck_boottime() {
t0_k = mktime(t0_k)
}
- return t0_k
+ if (uname ~/FreeBSD/) {
+ "sysctl kern.boottime" | getline t0_k
+ close("sysctl kern.boottime")
+ sub("^.*{", "", t0_k)
+ sub("}.*$", "", t0_k)
+ split(t0_k, t0_k_arr, ",")
+ for (n in t0_k_arr) {
+ sub("^.*= ", "", t0_k_arr[n])
+ }
+ t0_k = t0_k_arr[1] "." t0_k_arr[2]
+
+ }
+
+ t0_k_unc = systime()
+
+ return sprintf("%s %s", t0_k, t0_k_unc)
}
@@ -140,8 +157,8 @@ BEGIN {
# check ARGV for previous estimate
if (ARGC > 0) {
- ARGV[1] ? t0_est[1] = ARGV[1] : t0_est[1] = ck_boottime()
- ARGV[2] ? t0_est[2] = ARGV[2] : t0_est[2] = systime()
+ ARGV[1] ? t0_est[1] = ARGV[1] : split(ck_boottime(), t0_est)
+ ARGV[2] ? t0_est[2] = ARGV[2] : split(ck_boottime(), t0_est)
}
#print("t0_est = ", t0_est[1])
#print("t_boot_unc = ", t0_est[2])
diff --git a/ckt0.sh b/ckt0.sh
index e7953ba..eeb0479 100644
--- a/ckt0.sh
+++ b/ckt0.sh
@@ -11,12 +11,6 @@ set -e
#sysctl_t0_str=$( sysctl kern.boottime | mawk -F= '{print($NF)}' )
#sysctl_t0=$( date -jf "%a %b %d %H:%M:%S %G" "${sysctl_t0_str}" +%s )
-#epsilon1="$( mawk 'BEGIN{print(rand()^2.0)}' )"
-#t0_est="${sysctl_t0} $(date +%s)"
-#t0_est="${sysctl_t0} ${sysctl_t0}"
-#t0_est="${sysctl_t0} ${epsilon1}"
-#t0_est="${sysctl_t0} 1.0"
-
if [ -f t0_est.log ] ; then {
t0_est="$( cat t0_est.log )"
} else {