Paul Irofti:
> > Userland gettime support for alpha.
> > Alas, completely untested since I don't have access to that arch.
>
> Never had an alpha. Reads OK to me (if you make the function static like
> kettenis@ said).
For the archives, here's a version that looks like kettenis@'s
style.
Unfortunately, as Theo has discovered, on multi-socket machines the
PCCs are not in sync. Fixing this will require kernel work...
so consider this diff withdrawn.
Index: lib/libc/arch/alpha/gen/usertc.c
===================================================================
RCS file: /cvs/src/lib/libc/arch/alpha/gen/usertc.c,v
retrieving revision 1.1
diff -u -p -r1.1 usertc.c
--- lib/libc/arch/alpha/gen/usertc.c 6 Jul 2020 13:33:05 -0000 1.1
+++ lib/libc/arch/alpha/gen/usertc.c 8 Jul 2020 11:39:37 -0000
@@ -18,4 +18,25 @@
#include <sys/types.h>
#include <sys/timetc.h>
-int (*const _tc_get_timecount)(struct timekeep *, u_int *) = NULL;
+static inline u_int
+rpcc_get_timecount(void)
+{
+ unsigned long val;
+
+ __asm volatile("rpcc %0" : "=r" (val));
+ return val;
+}
+
+static int
+tc_get_timecount(struct timekeep *tk, u_int *tc)
+{
+ switch (tk->tk_user) {
+ case TC_RPCC:
+ *tc = rpcc_get_timecount();
+ return 0;
+ }
+
+ return -1;
+}
+
+int (*const _tc_get_timecount)(struct timekeep *, u_int *) = tc_get_timecount;
Index: sys/arch/alpha/alpha/clock.c
===================================================================
RCS file: /cvs/src/sys/arch/alpha/alpha/clock.c,v
retrieving revision 1.24
diff -u -p -r1.24 clock.c
--- sys/arch/alpha/alpha/clock.c 6 Jul 2020 13:33:06 -0000 1.24
+++ sys/arch/alpha/alpha/clock.c 7 Jul 2020 20:29:47 -0000
@@ -64,7 +64,7 @@ int clk_irq = 0;
u_int rpcc_get_timecount(struct timecounter *);
struct timecounter rpcc_timecounter = {
- rpcc_get_timecount, NULL, ~0u, 0, "rpcc", 0, NULL, 0
+ rpcc_get_timecount, NULL, ~0u, 0, "rpcc", 0, NULL, TC_RPCC
};
extern todr_chip_handle_t todr_handle;
Index: sys/arch/alpha/include/timetc.h
===================================================================
RCS file: /cvs/src/sys/arch/alpha/include/timetc.h,v
retrieving revision 1.1
diff -u -p -r1.1 timetc.h
--- sys/arch/alpha/include/timetc.h 6 Jul 2020 13:33:06 -0000 1.1
+++ sys/arch/alpha/include/timetc.h 8 Jul 2020 11:30:17 -0000
@@ -18,6 +18,6 @@
#ifndef _MACHINE_TIMETC_H_
#define _MACHINE_TIMETC_H_
-#define TC_LAST 0
+#define TC_RPCC 1
#endif /* _MACHINE_TIMETC_H_ */
--
Christian "naddy" Weisgerber [email protected]