X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fsys-time.c;h=83afa0c8466b65f1a565d529cd01af9a7a728510;hb=1091bd94fd707a8373ff561821457a45ff9a3d9c;hp=b81f4657ebd93bfd0ff06ec0c0eceb4cca21f842;hpb=b585d00928892398dfbfc315ed78b8032fa14708;p=mono.git diff --git a/support/sys-time.c b/support/sys-time.c index b81f4657ebd..83afa0c8466 100644 --- a/support/sys-time.c +++ b/support/sys-time.c @@ -4,7 +4,7 @@ * Authors: * Jonathan Pryor (jonpryor@vt.edu) * - * Copyright (C) 2004 Jonathan Pryor + * Copyright (C) 2004-2006 Jonathan Pryor */ #include @@ -16,16 +16,6 @@ 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, @@ -57,6 +47,11 @@ Mono_Posix_Syscall_settimeofday ( struct Mono_Posix_Timeval *tv, struct Mono_Posix_Timezone *tz) { +#if defined(__HAIKU__) + /* FIXME: Haiku doesn't support this either, consider + using set_real_time_clock instead? */ + return -1; +#else struct timeval _tv = {0}; struct timeval *ptv = NULL; struct timezone _tz = {0}; @@ -77,24 +72,60 @@ Mono_Posix_Syscall_settimeofday ( r = settimeofday (ptv, ptz); return r; +#endif +} + +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) +Mono_Posix_Syscall_utimes(const char *filename, struct Mono_Posix_Timeval *tv) { - struct timeval _tv; - struct timeval *ptv = NULL; + struct timeval _tv[2]; + struct timeval *ptv; - if (tv) { - _tv.tv_sec = tv->tv_sec; - _tv.tv_usec = tv->tv_usec; - ptv = &_tv; - } + 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 /*