Module Name: src
Committed By: riastradh
Date: Mon Jul 17 13:44:24 UTC 2023
Modified Files:
src/sys/kern: kern_tc.c
src/sys/sys: timevar.h
Log Message:
timecounter(9): Limit scope of time__second/uptime.
Relevant only if __HAVE_ATOMIC64_LOADSTORE -- not updated otherwise.
To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/kern/kern_tc.c
cvs rdiff -u -r1.50 -r1.51 src/sys/sys/timevar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_tc.c
diff -u src/sys/kern/kern_tc.c:1.67 src/sys/kern/kern_tc.c:1.68
--- src/sys/kern/kern_tc.c:1.67 Mon Jul 17 13:42:23 2023
+++ src/sys/kern/kern_tc.c Mon Jul 17 13:44:24 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_tc.c,v 1.67 2023/07/17 13:42:23 riastradh Exp $ */
+/* $NetBSD: kern_tc.c,v 1.68 2023/07/17 13:44:24 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */
-__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.67 2023/07/17 13:42:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.68 2023/07/17 13:44:24 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ntp.h"
@@ -134,10 +134,10 @@ static struct timehands *volatile timeha
struct timecounter *timecounter = &dummy_timecounter;
static struct timecounter *timecounters = &dummy_timecounter;
-volatile time_t time__second __cacheline_aligned = 1;
-volatile time_t time__uptime __cacheline_aligned = 1;
-
-#ifndef __HAVE_ATOMIC64_LOADSTORE
+#ifdef __HAVE_ATOMIC64_LOADSTORE
+static volatile time_t time__second __cacheline_aligned = 1;
+static volatile time_t time__uptime __cacheline_aligned = 1;
+#else
static volatile struct {
uint32_t lo, hi;
} time__uptime32 __cacheline_aligned = {
Index: src/sys/sys/timevar.h
diff -u src/sys/sys/timevar.h:1.50 src/sys/sys/timevar.h:1.51
--- src/sys/sys/timevar.h:1.50 Mon Jul 17 12:55:20 2023
+++ src/sys/sys/timevar.h Mon Jul 17 13:44:24 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: timevar.h,v 1.50 2023/07/17 12:55:20 riastradh Exp $ */
+/* $NetBSD: timevar.h,v 1.51 2023/07/17 13:44:24 riastradh Exp $ */
/*
* Copyright (c) 2005, 2008, 2020 The NetBSD Foundation, Inc.
@@ -235,15 +235,15 @@ void itimer_gettime(const struct itimer
void ptimer_tick(struct lwp *, bool);
void ptimers_free(struct proc *, int);
-extern volatile time_t time__second; /* current second in the epoch */
-extern volatile time_t time__uptime; /* system uptime in seconds */
-
#define time_second getrealtime()
#define time_uptime getuptime()
#define time_uptime32 getuptime32()
#ifdef __HAVE_ATOMIC64_LOADSTORE
+extern volatile time_t time__second; /* current second in the epoch */
+extern volatile time_t time__uptime; /* system uptime in seconds */
+
static inline time_t
getrealtime(void)
{