| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_tc.c,v 1.46 2013/09/14 20:52:43 martin Exp $ */ | | 1 | /* $NetBSD: kern_tc.c,v 1.47 2017/06/09 01:16:33 chs Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -30,27 +30,27 @@ | | | @@ -30,27 +30,27 @@ |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /*- | | 32 | /*- |
33 | * ---------------------------------------------------------------------------- | | 33 | * ---------------------------------------------------------------------------- |
34 | * "THE BEER-WARE LICENSE" (Revision 42): | | 34 | * "THE BEER-WARE LICENSE" (Revision 42): |
35 | * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you | | 35 | * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you |
36 | * can do whatever you want with this stuff. If we meet some day, and you think | | 36 | * can do whatever you want with this stuff. If we meet some day, and you think |
37 | * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp | | 37 | * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp |
38 | * --------------------------------------------------------------------------- | | 38 | * --------------------------------------------------------------------------- |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | /* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */ | | 42 | /* __FBSDID("$FreeBSD: src/sys/kern/kern_tc.c,v 1.166 2005/09/19 22:16:31 andre Exp $"); */ |
43 | __KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.46 2013/09/14 20:52:43 martin Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: kern_tc.c,v 1.47 2017/06/09 01:16:33 chs Exp $"); |
44 | | | 44 | |
45 | #ifdef _KERNEL_OPT | | 45 | #ifdef _KERNEL_OPT |
46 | #include "opt_ntp.h" | | 46 | #include "opt_ntp.h" |
47 | #endif | | 47 | #endif |
48 | | | 48 | |
49 | #include <sys/param.h> | | 49 | #include <sys/param.h> |
50 | #include <sys/kernel.h> | | 50 | #include <sys/kernel.h> |
51 | #include <sys/reboot.h> /* XXX just to get AB_VERBOSE */ | | 51 | #include <sys/reboot.h> /* XXX just to get AB_VERBOSE */ |
52 | #include <sys/sysctl.h> | | 52 | #include <sys/sysctl.h> |
53 | #include <sys/syslog.h> | | 53 | #include <sys/syslog.h> |
54 | #include <sys/systm.h> | | 54 | #include <sys/systm.h> |
55 | #include <sys/timepps.h> | | 55 | #include <sys/timepps.h> |
56 | #include <sys/timetc.h> | | 56 | #include <sys/timetc.h> |
| @@ -460,41 +460,57 @@ getbintime(struct bintime *bt) | | | @@ -460,41 +460,57 @@ getbintime(struct bintime *bt) |
460 | { | | 460 | { |
461 | struct timehands *th; | | 461 | struct timehands *th; |
462 | u_int gen; | | 462 | u_int gen; |
463 | | | 463 | |
464 | TC_COUNT(ngetbintime); | | 464 | TC_COUNT(ngetbintime); |
465 | do { | | 465 | do { |
466 | th = timehands; | | 466 | th = timehands; |
467 | gen = th->th_generation; | | 467 | gen = th->th_generation; |
468 | *bt = th->th_offset; | | 468 | *bt = th->th_offset; |
469 | } while (gen == 0 || gen != th->th_generation); | | 469 | } while (gen == 0 || gen != th->th_generation); |
470 | bintime_add(bt, &timebasebin); | | 470 | bintime_add(bt, &timebasebin); |
471 | } | | 471 | } |
472 | | | 472 | |
473 | void | | 473 | static inline void |
474 | getnanotime(struct timespec *tsp) | | 474 | dogetnanotime(struct timespec *tsp) |
475 | { | | 475 | { |
476 | struct timehands *th; | | 476 | struct timehands *th; |
477 | u_int gen; | | 477 | u_int gen; |
478 | | | 478 | |
479 | TC_COUNT(ngetnanotime); | | 479 | TC_COUNT(ngetnanotime); |
480 | do { | | 480 | do { |
481 | th = timehands; | | 481 | th = timehands; |
482 | gen = th->th_generation; | | 482 | gen = th->th_generation; |
483 | *tsp = th->th_nanotime; | | 483 | *tsp = th->th_nanotime; |
484 | } while (gen == 0 || gen != th->th_generation); | | 484 | } while (gen == 0 || gen != th->th_generation); |
485 | } | | 485 | } |
486 | | | 486 | |
487 | void | | 487 | void |
| | | 488 | getnanotime(struct timespec *tsp) |
| | | 489 | { |
| | | 490 | |
| | | 491 | dogetnanotime(tsp); |
| | | 492 | } |
| | | 493 | |
| | | 494 | void dtrace_getnanotime(struct timespec *tsp); |
| | | 495 | |
| | | 496 | void |
| | | 497 | dtrace_getnanotime(struct timespec *tsp) |
| | | 498 | { |
| | | 499 | |
| | | 500 | dogetnanotime(tsp); |
| | | 501 | } |
| | | 502 | |
| | | 503 | void |
488 | getmicrotime(struct timeval *tvp) | | 504 | getmicrotime(struct timeval *tvp) |
489 | { | | 505 | { |
490 | struct timehands *th; | | 506 | struct timehands *th; |
491 | u_int gen; | | 507 | u_int gen; |
492 | | | 508 | |
493 | TC_COUNT(ngetmicrotime); | | 509 | TC_COUNT(ngetmicrotime); |
494 | do { | | 510 | do { |
495 | th = timehands; | | 511 | th = timehands; |
496 | gen = th->th_generation; | | 512 | gen = th->th_generation; |
497 | *tvp = th->th_microtime; | | 513 | *tvp = th->th_microtime; |
498 | } while (gen == 0 || gen != th->th_generation); | | 514 | } while (gen == 0 || gen != th->th_generation); |
499 | } | | 515 | } |
500 | | | 516 | |