CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
time.c
Go to the documentation of this file.
1/* FUNCTION: time */
2
3#ifndef __CPROVER_TIME_H_INCLUDED
4#include <time.h>
5#define __CPROVER_TIME_H_INCLUDED
6#endif
7
8#undef time
9
12
14{
15 return __time64(tloc);
16}
17
18/* FUNCTION: __time64 */
19
20#ifndef __CPROVER_TIME_H_INCLUDED
21# include <time.h>
22# define __CPROVER_TIME_H_INCLUDED
23#endif
24
26
28{
30 if(tloc)
31 *tloc = res;
32 return res;
33}
34
35/* FUNCTION: _time64 */
36
37#ifdef _WIN32
38
39# ifndef __CPROVER_TIME_H_INCLUDED
40# include <time.h>
41# define __CPROVER_TIME_H_INCLUDED
42# endif
43
45
47{
49 if(tloc)
50 *tloc = res;
51 return res;
52}
53
54#endif
55
56/* FUNCTION: _time32 */
57
58#if defined(_WIN32) && defined(_USE_32BIT_TIME_T)
59
60# ifndef __CPROVER_TIME_H_INCLUDED
61# include <time.h>
62# define __CPROVER_TIME_H_INCLUDED
63# endif
64
66
68{
70 if(tloc)
71 *tloc = res;
72 return res;
73}
74
75#endif
76
77/* FUNCTION: gmtime */
78
79#ifndef __CPROVER_TIME_H_INCLUDED
80#include <time.h>
81#define __CPROVER_TIME_H_INCLUDED
82#endif
83
84#undef gmtime
85
86struct tm *gmtime(const time_t *clock)
87{
88 // not very general, may be too restrictive
89 // need to set the fields to something meaningful
90 (void)*clock;
91 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
92 __CPROVER_event("invalidate_pointer", "gmtime_result");
93 struct tm *gmtime_result;
94 __CPROVER_set_must(gmtime_result, "gmtime_result");
95 return gmtime_result;
96 #else
97 static struct tm return_value;
98 return &return_value;
99 #endif
100}
101
102/* FUNCTION: gmtime_r */
103
104#ifndef __CPROVER_TIME_H_INCLUDED
105#include <time.h>
106#define __CPROVER_TIME_H_INCLUDED
107#endif
108
109#undef gmtime
110
111struct tm *gmtime_r(const time_t *clock, struct tm *result)
112{
113 // need to set the fields to something meaningful
114 (void)*clock;
115 return result;
116}
117
118/* FUNCTION: localtime */
119
120#ifndef __CPROVER_TIME_H_INCLUDED
121#include <time.h>
122#define __CPROVER_TIME_H_INCLUDED
123#endif
124
125#undef localtime
126
127struct tm *localtime(const time_t *clock)
128{
129 // not very general, may be too restrictive
130 // need to set the fields to something meaningful
131 (void)*clock;
132 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
133 __CPROVER_event("invalidate_pointer", "localtime_result");
134 struct tm *localtime_result;
135 __CPROVER_set_must(localtime_result, "localtime_result");
136 return localtime_result;
137 #else
138 static struct tm return_value;
139 return &return_value;
140 #endif
141}
142
143/* FUNCTION: localtime_r */
144
145#ifndef __CPROVER_TIME_H_INCLUDED
146#include <time.h>
147#define __CPROVER_TIME_H_INCLUDED
148#endif
149
150#undef localtime
151
152struct tm *localtime_r(const time_t *clock, struct tm *result)
153{
154 // need to set the fields to something meaningful
155 (void)*clock;
156 return result;
157}
158
159/* FUNCTION: mktime */
160
161#ifndef __CPROVER_TIME_H_INCLUDED
162#include <time.h>
163#define __CPROVER_TIME_H_INCLUDED
164#endif
165
166#undef mktime
167
169
171{
172 (void)*timeptr;
174 return result;
175}
176
177/* FUNCTION: timegm */
178
179#ifndef __CPROVER_TIME_H_INCLUDED
180#include <time.h>
181#define __CPROVER_TIME_H_INCLUDED
182#endif
183
184#undef timegm
185
187
189{
190 (void)*timeptr;
192 return result;
193}
194
195/* FUNCTION: asctime */
196
197#ifndef __CPROVER_TIME_H_INCLUDED
198#include <time.h>
199#define __CPROVER_TIME_H_INCLUDED
200#endif
201
202char *asctime(const struct tm *timeptr)
203{
204 (void)*timeptr;
205 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
206 __CPROVER_event("invalidate_pointer", "asctime_result");
207 char *asctime_result;
208 __CPROVER_set_must(asctime_result, "asctime_result");
209 return asctime_result;
210 #else
211 static char asctime_result[1];
212 return asctime_result;
213 #endif
214}
215
216/* FUNCTION: ctime */
217
218#ifndef __CPROVER_TIME_H_INCLUDED
219#include <time.h>
220#define __CPROVER_TIME_H_INCLUDED
221#endif
222
223char *ctime(const time_t *clock)
224{
225 (void)*clock;
226 #ifdef __CPROVER_CUSTOM_BITVECTOR_ANALYSIS
227 __CPROVER_event("invalidate_pointer", "ctime_result");
228 char *ctime_result;
229 __CPROVER_set_must(ctime_result, "ctime_result");
230 return ctime_result;
231 #else
232 static char ctime_result[1];
233 return ctime_result;
234 #endif
235}
236
237/* FUNCTION: strftime */
238
239#ifndef __CPROVER_TIME_H_INCLUDED
240# include <time.h>
241# define __CPROVER_TIME_H_INCLUDED
242#endif
243
245
247strftime(char *s, __CPROVER_size_t max, const char *format, const struct tm *tm)
248{
249 (void)*format;
250 (void)*tm;
251 __CPROVER_havoc_slice(s, max);
253 if(length >= max)
254 return 0;
255 s[length] = '\0';
256 return length;
257}
258
259/* FUNCTION: _strftime */
260
261#ifndef __CPROVER_TIME_H_INCLUDED
262# include <time.h>
263# define __CPROVER_TIME_H_INCLUDED
264#endif
265
267
269 char *s,
271 const char *format,
272 const struct tm *tm)
273{
274 (void)*format;
275 (void)*tm;
276 __CPROVER_havoc_slice(s, max);
278 if(length >= max)
279 return 0;
280 s[length] = '\0';
281 return length;
282}
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
ait()
Definition ai.h:565
void __CPROVER_havoc_slice(void *, __CPROVER_size_t)
void __CPROVER_set_must(const void *, const char *)
static format_containert< T > format(const T &o)
Definition format.h:37
char * asctime(const struct tm *timeptr)
Definition time.c:202
char * ctime(const time_t *clock)
Definition time.c:223
time_t __VERIFIER_nondet_time_t(void)
time_t timegm(struct tm *timeptr)
Definition time.c:188
struct tm * gmtime(const time_t *clock)
Definition time.c:86
struct tm * gmtime_r(const time_t *clock, struct tm *result)
Definition time.c:111
__CPROVER_size_t strftime(char *s, __CPROVER_size_t max, const char *format, const struct tm *tm)
Definition time.c:247
struct tm * localtime_r(const time_t *clock, struct tm *result)
Definition time.c:152
time_t time(time_t *tloc)
Definition time.c:13
__CPROVER_size_t __VERIFIER_nondet_size_t(void)
struct tm * localtime(const time_t *clock)
Definition time.c:127
time_t __time64(time_t *)
Definition time.c:27
__CPROVER_size_t _strftime(char *s, __CPROVER_size_t max, const char *format, const struct tm *tm)
Definition time.c:268
time_t mktime(struct tm *timeptr)
Definition time.c:170