X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fsys-time.c;h=1759ec0fcb8e23f2435d8cb45d0e846a53b9edcb;hb=fb8e77d1b769b1f5e7bcef9993267f02a758c02b;hp=0b41489463f7bb78acdc53219af005b48d5cf06c;hpb=234225d112c4b018b8d1796f4c06a15812137500;p=mono.git diff --git a/support/sys-time.c b/support/sys-time.c index 0b41489463f..1759ec0fcb8 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,20 +16,10 @@ G_BEGIN_DECLS -struct Mono_Posix_Syscall_Timeval { - /* time_t */ mph_time_t tv_sec; /* seconds */ - /* suseconds_t */ gint64 tv_usec; /* microseconds */ -}; - -struct Mono_Posix_Syscall_Timezone { - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* ignored */ -}; - gint32 Mono_Posix_Syscall_gettimeofday ( - struct Mono_Posix_Syscall_Timeval *tv, - struct Mono_Posix_Syscall_Timezone *tz) + struct Mono_Posix_Timeval *tv, + void *tz) { struct timeval _tv; struct timezone _tz; @@ -43,8 +33,9 @@ Mono_Posix_Syscall_gettimeofday ( tv->tv_usec = _tv.tv_usec; } if (tz) { - tz->tz_minuteswest = _tz.tz_minuteswest; - tz->tz_dsttime = 0; + struct Mono_Posix_Timezone *tz_ = (struct Mono_Posix_Timezone *) tz; + tz_->tz_minuteswest = _tz.tz_minuteswest; + tz_->tz_dsttime = 0; } } @@ -53,8 +44,8 @@ Mono_Posix_Syscall_gettimeofday ( gint32 Mono_Posix_Syscall_settimeofday ( - const struct Mono_Posix_Syscall_Timeval *tv, - const struct Mono_Posix_Syscall_Timezone *tz) + struct Mono_Posix_Timeval *tv, + struct Mono_Posix_Timezone *tz) { struct timeval _tv = {0}; struct timeval *ptv = NULL; @@ -78,9 +69,10 @@ Mono_Posix_Syscall_settimeofday ( return r; } +/* Remove this at some point in the future */ gint32 -Mono_Posix_Syscall_utimes (const char *filename, - struct Mono_Posix_Syscall_Timeval *tv) +Mono_Posix_Syscall_utimes_bad (const char *filename, + struct Mono_Posix_Timeval *tv) { struct timeval _tv; struct timeval *ptv = NULL; @@ -94,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 /*