-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtimeget.c
59 lines (51 loc) · 1.51 KB
/
timeget.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <edidentifier.h>
__CIDENT_RCSID(gr_timeget_c,"$Id: timeget.c,v 1.6 2024/04/17 15:57:14 cvsuser Exp $")
/* -*- mode: c; indent-width: 4; -*- */
/*
*
*
* Copyright (c) 1998 - 2024, Adam Young.
* All rights reserved.
*
* This file is part of the GRIEF Editor.
*
* The GRIEF Editor is free software: you can redistribute it
* and/or modify it under the terms of the GRIEF Editor License.
*
* Redistributions of source code must retain the above copyright
* notice, and must be distributed with the license document above.
*
* Redistributions in binary form must reproduce the above copyright
* notice, and must include the license document above in
* the documentation and/or other materials provided with the
* distribution.
*
* The GRIEF Editor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License for more details.
* ==end==
*/
#if defined(HAVE_CONFIG_H)
#include <config.h>
#endif
#include <edthreads.h>
#include <libtime.h>
void
timespec_current(struct timespec *ts)
{
#ifdef HAVE_TIMESPEC_GET
return timespec_get(&ts, TIME_UTC);
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
return clock_gettime(CLOCK_REALTIME, ts);
#elif defined(HAVE_GETTIMEOFDAY)
struct timeval tv;
(void) gettimeofday(&tv, NULL);
ts->tv_sec = tv.tv_sec;
ts->tv_nsec = tv.tv_usec * 1000;
#else
ts->tv_sec = time(NULL);
ts->tv_nsec = 0;
#endif
}
/*end*/