librfn
An ad-hoc utility library
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
librfn
posix
time_posix.c
Go to the documentation of this file.
1
/*
2
* time_posix.c
3
*
4
* Part of librfn (a general utility library from redfelineninja.org.uk)
5
*
6
* Copyright (C) 2012 Daniel Thompson <daniel@redfelineninja.org.uk>
7
*
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published
10
* by the Free Software Foundation; either version 3 of the License, or
11
* (at your option) any later version.
12
*/
13
14
#include <stdint.h>
15
#include <
time.h
>
16
17
#include "
librfn/time.h
"
18
19
void
time_init
(
void
)
20
{
21
}
22
23
uint32_t
time_now
()
24
{
25
struct
timespec now;
26
27
clock_gettime(CLOCK_REALTIME, &now);
28
29
// this expression does overflow but will "promote" everything
30
// to unsigned meaning the overflow behavior is well defined
31
// (and right for this instance)
32
return
(now.tv_sec * (uint32_t) 1000000) + (now.tv_nsec / 1000);
33
}
34
35
36
uint64_t
time64_now
()
37
{
38
struct
timespec now;
39
40
clock_gettime(CLOCK_REALTIME, &now);
41
42
return
(now.tv_sec * 1000000ull) + (now.tv_nsec / 1000);
43
}
time64_now
uint64_t time64_now()
Definition:
time_posix.c:36
time.h
time_now
uint32_t time_now()
Definition:
time_posix.c:23
time_init
void time_init(void)
Definition:
time_posix.c:19
Generated on Sat Feb 6 2016 21:25:32 for librfn by
1.8.10