From d82e6535c6efd8305182f77041b2246ccfae1196 Mon Sep 17 00:00:00 2001 From: pirofti Date: Mon, 6 Jul 2020 13:33:05 +0000 Subject: Add support for timeconting in userland. This diff exposes parts of clock_gettime(2) and gettimeofday(2) to userland via libc eliberating processes from the need for a context switch everytime they want to count the passage of time. If a timecounter clock can be exposed to userland than it needs to set its tc_user member to a non-zero value. Tested with one or multiple counters per architecture. The timing data is shared through a pointer found in the new ELF auxiliary vector AUX_openbsd_timekeep containing timehands information that is frequently updated by the kernel. Timing differences between the last kernel update and the current time are adjusted in userland by the tc_get_timecount() function inside the MD usertc.c file. This permits a much more responsive environment, quite visible in browsers, office programs and gaming (apparently one is are able to fly in Minecraft now). Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others! OK from at least kettenis@, cheloha@, naddy@, sthen@ --- lib/libc/rpc/auth_unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/libc/rpc/auth_unix.c') diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c index 402d98cede4..de2c14d246e 100644 --- a/lib/libc/rpc/auth_unix.c +++ b/lib/libc/rpc/auth_unix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth_unix.c,v 1.27 2019/06/28 13:32:42 deraadt Exp $ */ +/* $OpenBSD: auth_unix.c,v 1.28 2020/07/06 13:33:06 pirofti Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -121,7 +121,7 @@ authunix_create(char *machname, int uid, int gid, int len, int *aup_gids) /* * fill in param struct from the given params */ - (void)gettimeofday(&now, NULL); + (void)WRAP(gettimeofday)(&now, NULL); aup.aup_time = now.tv_sec; aup.aup_machname = machname; aup.aup_uid = uid; @@ -274,7 +274,7 @@ authunix_refresh(AUTH *auth) goto done; /* update the time and serialize in place */ - (void)gettimeofday(&now, NULL); + (void)WRAP(gettimeofday)(&now, NULL); aup.aup_time = now.tv_sec; xdrs.x_op = XDR_ENCODE; XDR_SETPOS(&xdrs, 0); -- cgit v1.2.3-59-g8ed1b