2 * <sys/stat.h> wrapper functions.
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004-2006 Jonathan Pryor
10 #include <sys/types.h>
19 struct Mono_Posix_Timeval {
20 /* time_t */ mph_time_t tv_sec; /* seconds */
21 /* suseconds_t */ gint64 tv_usec; /* microseconds */
24 struct Mono_Posix_Timezone {
25 int tz_minuteswest; /* minutes W of Greenwich */
26 int tz_dsttime; /* ignored */
30 Mono_Posix_Syscall_gettimeofday (
31 struct Mono_Posix_Timeval *tv,
38 r = gettimeofday (&_tv, &_tz);
42 tv->tv_sec = _tv.tv_sec;
43 tv->tv_usec = _tv.tv_usec;
46 struct Mono_Posix_Timezone *tz_ = (struct Mono_Posix_Timezone *) tz;
47 tz_->tz_minuteswest = _tz.tz_minuteswest;
56 Mono_Posix_Syscall_settimeofday (
57 struct Mono_Posix_Timeval *tv,
58 struct Mono_Posix_Timezone *tz)
60 struct timeval _tv = {0};
61 struct timeval *ptv = NULL;
62 struct timezone _tz = {0};
63 struct timezone *ptz = NULL;
67 _tv.tv_sec = tv->tv_sec;
68 _tv.tv_usec = tv->tv_usec;
72 _tz.tz_minuteswest = tz->tz_minuteswest;
77 r = settimeofday (ptv, ptz);
82 /* Remove this at some point in the future */
84 Mono_Posix_Syscall_utimes_bad (const char *filename,
85 struct Mono_Posix_Timeval *tv)
88 struct timeval *ptv = NULL;
91 _tv.tv_sec = tv->tv_sec;
92 _tv.tv_usec = tv->tv_usec;
96 return utimes (filename, ptv);
99 static inline struct timeval*
100 copy_utimes (struct timeval* to, struct Mono_Posix_Timeval *from)
103 to[0].tv_sec = from->tv_sec;
104 to[0].tv_usec = from->tv_usec;
105 to[1].tv_sec = from->tv_sec;
106 to[1].tv_usec = from->tv_usec;
114 Mono_Posix_Syscall_utimes(const char *filename, struct Mono_Posix_Timeval *tv)
116 struct timeval _tv[2];
119 ptv = copy_utimes (_tv, tv);
121 return utimes (filename, ptv);
126 Mono_Posix_Syscall_lutimes(const char *filename, struct Mono_Posix_Timeval *tv)
128 struct timeval _tv[2];
131 ptv = copy_utimes (_tv, tv);
133 return lutimes (filename, ptv);
135 #endif /* def HAVE_LUTIMES */
138 Mono_Posix_Syscall_futimes(int fd, struct Mono_Posix_Timeval *tv)
140 struct timeval _tv[2];
143 ptv = copy_utimes (_tv, tv);
145 return futimes (fd, ptv);