2005-04-12 Dick Porter <dick@ximian.com>
[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 #ifdef HAVE_STIME
20 gint32
21 Mono_Posix_Syscall_stime (mph_time_t *t)
22 {
23         time_t _t;
24         if (t == NULL) {
25                 errno = EFAULT;
26                 return -1;
27         }
28         mph_return_if_time_t_overflow (*t);
29         _t = (time_t) *t;
30         return stime (&_t);
31 }
32 #endif /* ndef HAVE_STIME */
33
34 mph_time_t
35 Mono_Posix_Syscall_time (mph_time_t *t)
36 {
37         time_t _t, r;
38         if (t == NULL) {
39                 errno = EFAULT;
40                 return -1;
41         }
42
43         mph_return_if_time_t_overflow (*t);
44
45         _t = (time_t) *t;
46         r = time (&_t);
47         *t = _t;
48
49         return r;
50 }
51
52 G_END_DECLS
53
54 /*
55  * vim: noexpandtab
56  */