591933907936f76a18150351a4872811837669c8
[mono.git] / support / time.c
1 /*
2  * <time.h> wrapper functions.
3  *
4  * Authors:
5  *   Jonathan Pryor (jonpryor@vt.edu)
6  *
7  * Copyright (C) 2004 Jonathan Pryor
8  */
9
10 #define _SVID_SOURCE
11 #include <time.h>
12 #include <errno.h>
13
14 #include "mph.h"
15 #include <glib/gtypes.h>
16
17 G_BEGIN_DECLS
18
19 gint32
20 Mono_Posix_Syscall_stime (mph_time_t *t)
21 {
22         time_t _t;
23         if (t == NULL) {
24                 errno = EFAULT;
25                 return -1;
26         }
27         mph_return_if_time_t_overflow (*t);
28         _t = (time_t) *t;
29         return stime (&_t);
30 }
31
32 mph_time_t
33 Mono_Posix_Syscall_time (mph_time_t *t)
34 {
35         time_t _t, r;
36         if (t == NULL) {
37                 errno = EFAULT;
38                 return -1;
39         }
40
41         mph_return_if_time_t_overflow (*t);
42
43         _t = (time_t) *t;
44         r = time (&_t);
45         *t = _t;
46
47         return r;
48 }
49
50 G_END_DECLS
51
52 /*
53  * vim: noexpandtab
54  */