]> git.lizzy.rs Git - plan9front.git/blob - sys/man/9/seconds
turn ptrdiff_t into a 64 bit type
[plan9front.git] / sys / man / 9 / seconds
1 .TH SECONDS 9
2 .SH NAME
3 seconds, ticks, fastticks, HZ, MS2HZ, MS2TK, TK2MS, TK2SEC \- kernel times and time conversions
4 .SH SYNOPSIS
5 .ta \w'\fL#define 'u
6 .B
7 long    seconds(void)
8 .PP
9 .B
10 vlong   fastticks(uvlong *hz)
11 .PP
12 .EX
13 #define HZ          ...
14 #define MS2HZ       (1000/HZ)
15 #define TK2SEC(t)   ((t)/HZ)
16 #define TK2MS(t)    ((t)*(1000/HZ))
17 .EE
18 .SH DESCRIPTION
19 .I Seconds
20 returns the system's idea of the current time as the number of seconds
21 since the start of the epoch
22 (00:00:00 GMT, January 1, 1970).
23 .PP
24 The
25 .B ticks
26 field of the
27 .B Mach
28 structure returns the number of system-dependent clock ticks on the
29 given processor since system boot.
30 On a multiprocessor,
31 .B MACHP(0)
32 is sometimes used to provide a reference time, since the tick value
33 might vary slightly across processors.
34 .PP
35 .I Fastticks
36 returns the number of ticks since boot as measured by the
37 fastest clock provided by the platform.
38 The frequency of the clock, in ticks per second,
39 is returned through
40 .IR hz ,
41 unless it is nil.
42 .PP
43 The system clock frequencies are platform-dependent.
44 Several symbolic constants and macro functions are defined by
45 the file
46 .B mem.h
47 to convert between different time units:
48 .TF TK2SEC(t)
49 .PD
50 .TP
51 .B HZ
52 The number of clock ticks per second.
53 .TP
54 .B MS2HZ
55 Milliseconds per clock tick.
56 .TP
57 .BI TK2SEC( t )
58 Convert
59 .I t
60 clock ticks to seconds (truncating not rounding).
61 .TP
62 .BI TK2MS( t )
63 Convert
64 .I t
65 clock ticks to milliseconds.
66 .SH SOURCE
67 .B /sys/src/9/*/mem.h
68 .br
69 .B /sys/src/9/*/clock.c
70 .br
71 .B /sys/src/9/*/devarch.c
72 .br
73 .B /sys/src/9/*/timer.c
74 .br
75 .B /sys/src/9/port/tod.c