1 | /** @file
|
---|
2 | * IPRT / No-CRT - Our minimal time.h.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_nocrt_time_h
|
---|
27 | #define IPRT_INCLUDED_nocrt_time_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #define RTTIME_INCL_TIMESPEC
|
---|
33 | /*#define RTTIME_INCL_TIMEVAL*/
|
---|
34 | #include <iprt/types.h>
|
---|
35 | #include <iprt/nocrt/sys/types.h>
|
---|
36 |
|
---|
37 | /* #if !defined(MSC-define) && !defined(GNU/LINUX-define) */
|
---|
38 | #if !defined(_TIME_T_DEFINED) && !defined(__time_t_defined)
|
---|
39 | # if defined(RT_OS_WINDOWS) && defined(_USE_32BIT_TIME_T) && ARCH_BITS == 32
|
---|
40 | typedef long time_t;
|
---|
41 | # else
|
---|
42 | typedef int64_t time_t;
|
---|
43 | # endif
|
---|
44 | # ifdef _MSC_VER
|
---|
45 | typedef int64_t __time64_t;
|
---|
46 | # endif
|
---|
47 | #endif /* !_TIME_T_DEFINED */
|
---|
48 |
|
---|
49 | #if !defined(_INC_TIME) /* MSC/UCRT guard */
|
---|
50 |
|
---|
51 | # if !defined(_STRUCT_TIMESPEC) && !defined(__struct_timespec_defined) && !defined(_TIMESPEC_DEFINED) && !defined(__timespec_defined) /* << linux variations, new to old. */
|
---|
52 | struct timespec
|
---|
53 | {
|
---|
54 | time_t tv_sec;
|
---|
55 | long tv_nsec;
|
---|
56 | };
|
---|
57 | # endif
|
---|
58 |
|
---|
59 | #if !defined(__struct_tm_defined)
|
---|
60 | struct tm
|
---|
61 | {
|
---|
62 | int tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year;
|
---|
63 | int tm_wday, tm_yday, tm_isdst, tm_gmtoff;
|
---|
64 | const char *tm_zone;
|
---|
65 | };
|
---|
66 | # endif
|
---|
67 |
|
---|
68 | #endif /* !_INC_TIME */
|
---|
69 |
|
---|
70 | RT_C_DECLS_BEGIN
|
---|
71 |
|
---|
72 | time_t RT_NOCRT(time)(time_t *);
|
---|
73 | errno_t RT_NOCRT(localtime_s)(struct tm *, const time_t *); /* The Microsoft version, not the C11 one. */
|
---|
74 | struct tm *RT_NOCRT(localtime_r)(const time_t *, struct tm *);
|
---|
75 |
|
---|
76 | time_t RT_NOCRT(_time)(time_t *);
|
---|
77 | errno_t RT_NOCRT(_localtime_s)(struct tm *, const time_t *);
|
---|
78 | struct tm *RT_NOCRT(_localtime_r)(const time_t *, struct tm *);
|
---|
79 |
|
---|
80 | # if !defined(RT_WITHOUT_NOCRT_WRAPPERS) && !defined(RT_WITHOUT_NOCRT_WRAPPER_ALIASES)
|
---|
81 | # define time RT_NOCRT(time)
|
---|
82 | # define localtime_s RT_NOCRT(localtime_s)
|
---|
83 | # define localtime_r RT_NOCRT(localtime_r)
|
---|
84 |
|
---|
85 | # define _time RT_NOCRT(time)
|
---|
86 | # define _localtime_s RT_NOCRT(localtime_s)
|
---|
87 | # define _localtime_r RT_NOCRT(localtime_r)
|
---|
88 | # endif
|
---|
89 |
|
---|
90 | RT_C_DECLS_END
|
---|
91 |
|
---|
92 | #ifdef IPRT_INCLUDED_time_h
|
---|
93 | # error nocrt/time.h after time.h
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | #endif /* !IPRT_INCLUDED_nocrt_time_h */
|
---|
97 |
|
---|