[xbuild] Add missing api for Target.
[mono.git] / support / sys-time.c
index b81f4657ebd93bfd0ff06ec0c0eceb4cca21f842..1759ec0fcb8e23f2435d8cb45d0e846a53b9edcb 100644 (file)
@@ -4,7 +4,7 @@
  * Authors:
  *   Jonathan Pryor (jonpryor@vt.edu)
  *
- * Copyright (C) 2004 Jonathan Pryor
+ * Copyright (C) 2004-2006 Jonathan Pryor
  */
 
 #include <sys/types.h>
 
 G_BEGIN_DECLS
 
-struct Mono_Posix_Timeval {
-       /* time_t */      mph_time_t  tv_sec;   /* seconds */
-       /* suseconds_t */ gint64      tv_usec;  /* microseconds */
-};
-
-struct Mono_Posix_Timezone {
-       int tz_minuteswest;  /* minutes W of Greenwich */
-       int tz_dsttime;      /* ignored */
-};
-
 gint32
 Mono_Posix_Syscall_gettimeofday (
        struct Mono_Posix_Timeval *tv,
@@ -79,8 +69,9 @@ Mono_Posix_Syscall_settimeofday (
        return r;
 }
 
+/* Remove this at some point in the future */
 gint32
-Mono_Posix_Syscall_utimes (const char *filename,
+Mono_Posix_Syscall_utimes_bad (const char *filename,
        struct Mono_Posix_Timeval *tv)
 {
        struct timeval _tv;
@@ -95,6 +86,57 @@ Mono_Posix_Syscall_utimes (const char *filename,
        return utimes (filename, ptv);
 }
 
+static inline struct timeval*
+copy_utimes (struct timeval* to, struct Mono_Posix_Timeval *from)
+{
+       if (from) {
+               to[0].tv_sec  = from[0].tv_sec;
+               to[0].tv_usec = from[0].tv_usec;
+               to[1].tv_sec  = from[1].tv_sec;
+               to[1].tv_usec = from[1].tv_usec;
+               return to;
+       }
+
+       return NULL;
+}
+
+gint32
+Mono_Posix_Syscall_utimes(const char *filename, struct Mono_Posix_Timeval *tv)
+{
+       struct timeval _tv[2];
+       struct timeval *ptv;
+
+       ptv = copy_utimes (_tv, tv);
+
+       return utimes (filename, ptv);
+}
+
+#ifdef HAVE_LUTIMES
+gint32
+Mono_Posix_Syscall_lutimes(const char *filename, struct Mono_Posix_Timeval *tv)
+{
+       struct timeval _tv[2];
+       struct timeval *ptv;
+
+       ptv = copy_utimes (_tv, tv);
+
+       return lutimes (filename, ptv);
+}
+#endif /* def HAVE_LUTIMES */
+
+#if HAVE_FUTIMES
+gint32
+Mono_Posix_Syscall_futimes(int fd, struct Mono_Posix_Timeval *tv)
+{
+       struct timeval _tv[2];
+       struct timeval *ptv;
+
+       ptv = copy_utimes (_tv, tv);
+
+       return futimes (fd, ptv);
+}
+#endif  /* def HAVE_FUTIMES */
+
 G_END_DECLS
 
 /*