X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fmap.c;h=cb653bcda9a81e0c8f09b4e26c3da802b1c4ab96;hb=202e0a1a78fa647e0b2f20935af345bdb13e099a;hp=40faa84e72db51d9195163d13ae04fbacb1708f7;hpb=66cbda12a3503582b9b0f9b4eb3f9803a27006b1;p=mono.git diff --git a/support/map.c b/support/map.c index 40faa84e72d..cb653bcda9a 100644 --- a/support/map.c +++ b/support/map.c @@ -27,7 +27,9 @@ */ #include #include +#ifdef HAVE_SYS_TIME_H #include +#endif /* ndef HAVE_SYS_TIME_H */ #ifdef HAVE_SYS_POLL_H #include #endif /* ndef HAVE_SYS_POLL_H */ @@ -43,7 +45,9 @@ #ifdef HAVE_SYS_MMAN_H #include #endif /* ndef HAVE_SYS_MMAN_H */ +#ifdef HAVE_UNISTD_H #include +#endif /* ndef HAVE_UNISTD_H */ #include #include #ifdef HAVE_POLL_H @@ -56,8 +60,13 @@ #ifdef HAVE_SYSLOG_H #include #endif /* ndef HAVE_SYSLOG_H */ +#ifdef HAVE_DIRENT_H #include +#endif /* ndef HAVE_DIRENT_H */ +#ifdef HAVE_UTIME_H #include +#endif /* ndef HAVE_UTIME_H */ +#include #include "mph.h" #include "map.h" @@ -186,32 +195,46 @@ ? CNM_MAXINT64 \ : (g_assert_not_reached (), 0)) -#ifdef DEBUG -#define _cnm_dump_(to_t,from) \ - printf ("# %s -> %s: min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \ +#ifdef _CNM_DUMP +#define _cnm_dump(to_t,from) \ + printf ("# %s -> %s: uns=%i; min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \ #from, #to_t, \ - (gint64) (_cnm_integral_type_min(to_t)), \ + (int) _cnm_integral_type_is_unsigned (to_t), \ + (gint64) (_cnm_integral_type_min (to_t)), \ (gint64) (_cnm_integral_type_max (to_t)), \ (gint64) (from), \ - (_cnm_integral_type_min (to_t) <= from), \ + (((gint64) _cnm_integral_type_min (to_t)) <= (gint64) from), \ (from < 0), \ - /* (_cnm_integral_type_max (to_t) >= from) */ \ - (from <= _cnm_integral_type_max (to_t)), \ - ((_cnm_integral_type_min(to_t) >= from) && \ - ((from < 0) ? 1 : (from <= _cnm_integral_type_max(to_t)))) \ + (((guint64) from) <= (guint64) _cnm_integral_type_max (to_t)), \ + !((int) _cnm_integral_type_is_unsigned (to_t) \ + ? ((0 <= from) && \ + ((guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \ + : ((gint64) _cnm_integral_type_min(to_t) <= (gint64) from && \ + (guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \ ) -#else -#define _cnm_dump_(to_t, from) do {} while (0) -#endif +#else /* ndef _CNM_DUMP */ +#define _cnm_dump(to_t, from) do {} while (0) +#endif /* def _CNM_DUMP */ +#ifdef DEBUG #define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \ - if (!(_cnm_integral_type_min(to_t) <= from && \ - ((from < 0) || (from <= _cnm_integral_type_max(to_t))))) { \ - _cnm_dump_(to_t, from); \ + int uns = _cnm_integral_type_is_unsigned (to_t); \ + gint64 min = (gint64) _cnm_integral_type_min (to_t); \ + guint64 max = (guint64) _cnm_integral_type_max (to_t); \ + gint64 sf = (gint64) from; \ + guint64 uf = (guint64) from; \ + if (!(uns ? ((0 <= from) && (uf <= max)) \ + : (min <= sf && (from < 0 || uf <= max)))) { \ + _cnm_dump(to_t, from); \ errno = EOVERFLOW; \ return (val); \ } \ } G_STMT_END +#else /* !def DEBUG */ +/* don't do any overflow checking */ +#define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \ + } G_STMT_END +#endif /* def DEBUG */ int Mono_Posix_FromAccessModes (int x, int *r) { @@ -811,6 +834,188 @@ int Mono_Posix_ToDirectoryNotifyFlags (int x, int *r) return 0; } +int Mono_Posix_FromEpollEvents (unsigned int x, unsigned int *r) +{ + *r = 0; + if ((x & Mono_Posix_EpollEvents_EPOLLERR) == Mono_Posix_EpollEvents_EPOLLERR) +#ifdef EPOLLERR + *r |= EPOLLERR; +#else /* def EPOLLERR */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLERR */ + if ((x & Mono_Posix_EpollEvents_EPOLLET) == Mono_Posix_EpollEvents_EPOLLET) +#ifdef EPOLLET + *r |= EPOLLET; +#else /* def EPOLLET */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLET */ + if ((x & Mono_Posix_EpollEvents_EPOLLHUP) == Mono_Posix_EpollEvents_EPOLLHUP) +#ifdef EPOLLHUP + *r |= EPOLLHUP; +#else /* def EPOLLHUP */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLHUP */ + if ((x & Mono_Posix_EpollEvents_EPOLLIN) == Mono_Posix_EpollEvents_EPOLLIN) +#ifdef EPOLLIN + *r |= EPOLLIN; +#else /* def EPOLLIN */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLIN */ + if ((x & Mono_Posix_EpollEvents_EPOLLMSG) == Mono_Posix_EpollEvents_EPOLLMSG) +#ifdef EPOLLMSG + *r |= EPOLLMSG; +#else /* def EPOLLMSG */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLMSG */ + if ((x & Mono_Posix_EpollEvents_EPOLLONESHOT) == Mono_Posix_EpollEvents_EPOLLONESHOT) +#ifdef EPOLLONESHOT + *r |= EPOLLONESHOT; +#else /* def EPOLLONESHOT */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLONESHOT */ + if ((x & Mono_Posix_EpollEvents_EPOLLOUT) == Mono_Posix_EpollEvents_EPOLLOUT) +#ifdef EPOLLOUT + *r |= EPOLLOUT; +#else /* def EPOLLOUT */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLOUT */ + if ((x & Mono_Posix_EpollEvents_EPOLLPRI) == Mono_Posix_EpollEvents_EPOLLPRI) +#ifdef EPOLLPRI + *r |= EPOLLPRI; +#else /* def EPOLLPRI */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLPRI */ + if ((x & Mono_Posix_EpollEvents_EPOLLRDBAND) == Mono_Posix_EpollEvents_EPOLLRDBAND) +#ifdef EPOLLRDBAND + *r |= EPOLLRDBAND; +#else /* def EPOLLRDBAND */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLRDBAND */ + if ((x & Mono_Posix_EpollEvents_EPOLLRDHUP) == Mono_Posix_EpollEvents_EPOLLRDHUP) +#ifdef EPOLLRDHUP + *r |= EPOLLRDHUP; +#else /* def EPOLLRDHUP */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLRDHUP */ + if ((x & Mono_Posix_EpollEvents_EPOLLRDNORM) == Mono_Posix_EpollEvents_EPOLLRDNORM) +#ifdef EPOLLRDNORM + *r |= EPOLLRDNORM; +#else /* def EPOLLRDNORM */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLRDNORM */ + if ((x & Mono_Posix_EpollEvents_EPOLLWRBAND) == Mono_Posix_EpollEvents_EPOLLWRBAND) +#ifdef EPOLLWRBAND + *r |= EPOLLWRBAND; +#else /* def EPOLLWRBAND */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLWRBAND */ + if ((x & Mono_Posix_EpollEvents_EPOLLWRNORM) == Mono_Posix_EpollEvents_EPOLLWRNORM) +#ifdef EPOLLWRNORM + *r |= EPOLLWRNORM; +#else /* def EPOLLWRNORM */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLLWRNORM */ + if (x == 0) + return 0; + return 0; +} + +int Mono_Posix_ToEpollEvents (unsigned int x, unsigned int *r) +{ + *r = 0; + if (x == 0) + return 0; +#ifdef EPOLLERR + if ((x & EPOLLERR) == EPOLLERR) + *r |= Mono_Posix_EpollEvents_EPOLLERR; +#endif /* ndef EPOLLERR */ +#ifdef EPOLLET + if ((x & EPOLLET) == EPOLLET) + *r |= Mono_Posix_EpollEvents_EPOLLET; +#endif /* ndef EPOLLET */ +#ifdef EPOLLHUP + if ((x & EPOLLHUP) == EPOLLHUP) + *r |= Mono_Posix_EpollEvents_EPOLLHUP; +#endif /* ndef EPOLLHUP */ +#ifdef EPOLLIN + if ((x & EPOLLIN) == EPOLLIN) + *r |= Mono_Posix_EpollEvents_EPOLLIN; +#endif /* ndef EPOLLIN */ +#ifdef EPOLLMSG + if ((x & EPOLLMSG) == EPOLLMSG) + *r |= Mono_Posix_EpollEvents_EPOLLMSG; +#endif /* ndef EPOLLMSG */ +#ifdef EPOLLONESHOT + if ((x & EPOLLONESHOT) == EPOLLONESHOT) + *r |= Mono_Posix_EpollEvents_EPOLLONESHOT; +#endif /* ndef EPOLLONESHOT */ +#ifdef EPOLLOUT + if ((x & EPOLLOUT) == EPOLLOUT) + *r |= Mono_Posix_EpollEvents_EPOLLOUT; +#endif /* ndef EPOLLOUT */ +#ifdef EPOLLPRI + if ((x & EPOLLPRI) == EPOLLPRI) + *r |= Mono_Posix_EpollEvents_EPOLLPRI; +#endif /* ndef EPOLLPRI */ +#ifdef EPOLLRDBAND + if ((x & EPOLLRDBAND) == EPOLLRDBAND) + *r |= Mono_Posix_EpollEvents_EPOLLRDBAND; +#endif /* ndef EPOLLRDBAND */ +#ifdef EPOLLRDHUP + if ((x & EPOLLRDHUP) == EPOLLRDHUP) + *r |= Mono_Posix_EpollEvents_EPOLLRDHUP; +#endif /* ndef EPOLLRDHUP */ +#ifdef EPOLLRDNORM + if ((x & EPOLLRDNORM) == EPOLLRDNORM) + *r |= Mono_Posix_EpollEvents_EPOLLRDNORM; +#endif /* ndef EPOLLRDNORM */ +#ifdef EPOLLWRBAND + if ((x & EPOLLWRBAND) == EPOLLWRBAND) + *r |= Mono_Posix_EpollEvents_EPOLLWRBAND; +#endif /* ndef EPOLLWRBAND */ +#ifdef EPOLLWRNORM + if ((x & EPOLLWRNORM) == EPOLLWRNORM) + *r |= Mono_Posix_EpollEvents_EPOLLWRNORM; +#endif /* ndef EPOLLWRNORM */ + return 0; +} + +int Mono_Posix_FromEpollFlags (int x, int *r) +{ + *r = 0; + if ((x & Mono_Posix_EpollFlags_EPOLL_CLOEXEC) == Mono_Posix_EpollFlags_EPOLL_CLOEXEC) +#ifdef EPOLL_CLOEXEC + *r |= EPOLL_CLOEXEC; +#else /* def EPOLL_CLOEXEC */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLL_CLOEXEC */ + if ((x & Mono_Posix_EpollFlags_EPOLL_NONBLOCK) == Mono_Posix_EpollFlags_EPOLL_NONBLOCK) +#ifdef EPOLL_NONBLOCK + *r |= EPOLL_NONBLOCK; +#else /* def EPOLL_NONBLOCK */ + {errno = EINVAL; return -1;} +#endif /* ndef EPOLL_NONBLOCK */ + if (x == 0) + return 0; + return 0; +} + +int Mono_Posix_ToEpollFlags (int x, int *r) +{ + *r = 0; + if (x == 0) + return 0; +#ifdef EPOLL_CLOEXEC + if ((x & EPOLL_CLOEXEC) == EPOLL_CLOEXEC) + *r |= Mono_Posix_EpollFlags_EPOLL_CLOEXEC; +#endif /* ndef EPOLL_CLOEXEC */ +#ifdef EPOLL_NONBLOCK + if ((x & EPOLL_NONBLOCK) == EPOLL_NONBLOCK) + *r |= Mono_Posix_EpollFlags_EPOLL_NONBLOCK; +#endif /* ndef EPOLL_NONBLOCK */ + return 0; +} + int Mono_Posix_FromErrno (int x, int *r) { *r = 0; @@ -2256,31 +2461,31 @@ int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r) #endif /* ndef DEFFILEMODE */ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFBLK) #ifdef S_IFBLK - {*r = S_IFBLK; return 0;} + *r |= S_IFBLK; #else /* def S_IFBLK */ {errno = EINVAL; return -1;} #endif /* ndef S_IFBLK */ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFCHR) #ifdef S_IFCHR - {*r = S_IFCHR; return 0;} + *r |= S_IFCHR; #else /* def S_IFCHR */ {errno = EINVAL; return -1;} #endif /* ndef S_IFCHR */ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFDIR) #ifdef S_IFDIR - {*r = S_IFDIR; return 0;} + *r |= S_IFDIR; #else /* def S_IFDIR */ {errno = EINVAL; return -1;} #endif /* ndef S_IFDIR */ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFIFO) #ifdef S_IFIFO - {*r = S_IFIFO; return 0;} + *r |= S_IFIFO; #else /* def S_IFIFO */ {errno = EINVAL; return -1;} #endif /* ndef S_IFIFO */ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFLNK) #ifdef S_IFLNK - {*r = S_IFLNK; return 0;} + *r |= S_IFLNK; #else /* def S_IFLNK */ {errno = EINVAL; return -1;} #endif /* ndef S_IFLNK */ @@ -2292,13 +2497,13 @@ int Mono_Posix_FromFilePermissions (unsigned int x, unsigned int *r) #endif /* ndef S_IFMT */ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFREG) #ifdef S_IFREG - {*r = S_IFREG; return 0;} + *r |= S_IFREG; #else /* def S_IFREG */ {errno = EINVAL; return -1;} #endif /* ndef S_IFREG */ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFSOCK) #ifdef S_IFSOCK - {*r = S_IFSOCK; return 0;} + *r |= S_IFSOCK; #else /* def S_IFSOCK */ {errno = EINVAL; return -1;} #endif /* ndef S_IFSOCK */ @@ -2509,6 +2714,56 @@ int Mono_Posix_ToFilePermissions (unsigned int x, unsigned int *r) return 0; } +#ifdef HAVE_STRUCT_FLOCK +int +Mono_Posix_FromFlock (struct Mono_Posix_Flock *from, struct flock *to) +{ + _cnm_return_val_if_overflow (off_t, from->l_start, -1); + _cnm_return_val_if_overflow (off_t, from->l_len, -1); + _cnm_return_val_if_overflow (pid_t, from->l_pid, -1); + + memset (to, 0, sizeof(*to)); + + if (Mono_Posix_FromLockType (from->l_type, &to->l_type) != 0) { + return -1; + } + if (Mono_Posix_FromSeekFlags (from->l_whence, &to->l_whence) != 0) { + return -1; + } + to->l_start = from->l_start; + to->l_len = from->l_len; + to->l_pid = from->l_pid; + + return 0; +} +#endif /* ndef HAVE_STRUCT_FLOCK */ + + +#ifdef HAVE_STRUCT_FLOCK +int +Mono_Posix_ToFlock (struct flock *from, struct Mono_Posix_Flock *to) +{ + _cnm_return_val_if_overflow (gint64, from->l_start, -1); + _cnm_return_val_if_overflow (gint64, from->l_len, -1); + _cnm_return_val_if_overflow (int, from->l_pid, -1); + + memset (to, 0, sizeof(*to)); + + if (Mono_Posix_ToLockType (from->l_type, &to->l_type) != 0) { + return -1; + } + if (Mono_Posix_ToSeekFlags (from->l_whence, &to->l_whence) != 0) { + return -1; + } + to->l_start = from->l_start; + to->l_len = from->l_len; + to->l_pid = from->l_pid; + + return 0; +} +#endif /* ndef HAVE_STRUCT_FLOCK */ + + int Mono_Posix_FromLockType (short x, short *r) { *r = 0; @@ -2888,6 +3143,12 @@ int Mono_Posix_FromMountFlags (guint64 x, guint64 *r) #else /* def ST_APPEND */ {errno = EINVAL; return -1;} #endif /* ndef ST_APPEND */ + if ((x & Mono_Posix_MountFlags_ST_BIND) == Mono_Posix_MountFlags_ST_BIND) +#ifdef ST_BIND + *r |= ST_BIND; +#else /* def ST_BIND */ + {errno = EINVAL; return -1;} +#endif /* ndef ST_BIND */ if ((x & Mono_Posix_MountFlags_ST_IMMUTABLE) == Mono_Posix_MountFlags_ST_IMMUTABLE) #ifdef ST_IMMUTABLE *r |= ST_IMMUTABLE; @@ -2918,6 +3179,12 @@ int Mono_Posix_FromMountFlags (guint64 x, guint64 *r) #else /* def ST_NODIRATIME */ {errno = EINVAL; return -1;} #endif /* ndef ST_NODIRATIME */ + if ((x & Mono_Posix_MountFlags_ST_NOEXEC) == Mono_Posix_MountFlags_ST_NOEXEC) +#ifdef ST_NOEXEC + *r |= ST_NOEXEC; +#else /* def ST_NOEXEC */ + {errno = EINVAL; return -1;} +#endif /* ndef ST_NOEXEC */ if ((x & Mono_Posix_MountFlags_ST_NOSUID) == Mono_Posix_MountFlags_ST_NOSUID) #ifdef ST_NOSUID *r |= ST_NOSUID; @@ -2930,6 +3197,12 @@ int Mono_Posix_FromMountFlags (guint64 x, guint64 *r) #else /* def ST_RDONLY */ {errno = EINVAL; return -1;} #endif /* ndef ST_RDONLY */ + if ((x & Mono_Posix_MountFlags_ST_REMOUNT) == Mono_Posix_MountFlags_ST_REMOUNT) +#ifdef ST_REMOUNT + *r |= ST_REMOUNT; +#else /* def ST_REMOUNT */ + {errno = EINVAL; return -1;} +#endif /* ndef ST_REMOUNT */ if ((x & Mono_Posix_MountFlags_ST_SYNCHRONOUS) == Mono_Posix_MountFlags_ST_SYNCHRONOUS) #ifdef ST_SYNCHRONOUS *r |= ST_SYNCHRONOUS; @@ -2956,6 +3229,10 @@ int Mono_Posix_ToMountFlags (guint64 x, guint64 *r) if ((x & ST_APPEND) == ST_APPEND) *r |= Mono_Posix_MountFlags_ST_APPEND; #endif /* ndef ST_APPEND */ +#ifdef ST_BIND + if ((x & ST_BIND) == ST_BIND) + *r |= Mono_Posix_MountFlags_ST_BIND; +#endif /* ndef ST_BIND */ #ifdef ST_IMMUTABLE if ((x & ST_IMMUTABLE) == ST_IMMUTABLE) *r |= Mono_Posix_MountFlags_ST_IMMUTABLE; @@ -2976,6 +3253,10 @@ int Mono_Posix_ToMountFlags (guint64 x, guint64 *r) if ((x & ST_NODIRATIME) == ST_NODIRATIME) *r |= Mono_Posix_MountFlags_ST_NODIRATIME; #endif /* ndef ST_NODIRATIME */ +#ifdef ST_NOEXEC + if ((x & ST_NOEXEC) == ST_NOEXEC) + *r |= Mono_Posix_MountFlags_ST_NOEXEC; +#endif /* ndef ST_NOEXEC */ #ifdef ST_NOSUID if ((x & ST_NOSUID) == ST_NOSUID) *r |= Mono_Posix_MountFlags_ST_NOSUID; @@ -2984,6 +3265,10 @@ int Mono_Posix_ToMountFlags (guint64 x, guint64 *r) if ((x & ST_RDONLY) == ST_RDONLY) *r |= Mono_Posix_MountFlags_ST_RDONLY; #endif /* ndef ST_RDONLY */ +#ifdef ST_REMOUNT + if ((x & ST_REMOUNT) == ST_REMOUNT) + *r |= Mono_Posix_MountFlags_ST_REMOUNT; +#endif /* ndef ST_REMOUNT */ #ifdef ST_SYNCHRONOUS if ((x & ST_SYNCHRONOUS) == ST_SYNCHRONOUS) *r |= Mono_Posix_MountFlags_ST_SYNCHRONOUS; @@ -6695,6 +6980,40 @@ int Mono_Posix_ToSyslogOptions (int x, int *r) return 0; } +#ifdef HAVE_STRUCT_TIMESPEC +int +Mono_Posix_FromTimespec (struct Mono_Posix_Timespec *from, struct timespec *to) +{ + _cnm_return_val_if_overflow (time_t, from->tv_sec, -1); + _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1); + + memset (to, 0, sizeof(*to)); + + to->tv_sec = from->tv_sec; + to->tv_nsec = from->tv_nsec; + + return 0; +} +#endif /* ndef HAVE_STRUCT_TIMESPEC */ + + +#ifdef HAVE_STRUCT_TIMESPEC +int +Mono_Posix_ToTimespec (struct timespec *from, struct Mono_Posix_Timespec *to) +{ + _cnm_return_val_if_overflow (gint64, from->tv_sec, -1); + _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1); + + memset (to, 0, sizeof(*to)); + + to->tv_sec = from->tv_sec; + to->tv_nsec = from->tv_nsec; + + return 0; +} +#endif /* ndef HAVE_STRUCT_TIMESPEC */ + + #ifdef HAVE_STRUCT_TIMEVAL int Mono_Posix_FromTimeval (struct Mono_Posix_Timeval *from, struct timeval *to) @@ -6763,6 +7082,40 @@ Mono_Posix_ToTimezone (struct timezone *from, struct Mono_Posix_Timezone *to) #endif /* ndef HAVE_STRUCT_TIMEZONE */ +#ifdef HAVE_STRUCT_UTIMBUF +int +Mono_Posix_FromUtimbuf (struct Mono_Posix_Utimbuf *from, struct utimbuf *to) +{ + _cnm_return_val_if_overflow (time_t, from->actime, -1); + _cnm_return_val_if_overflow (time_t, from->modtime, -1); + + memset (to, 0, sizeof(*to)); + + to->actime = from->actime; + to->modtime = from->modtime; + + return 0; +} +#endif /* ndef HAVE_STRUCT_UTIMBUF */ + + +#ifdef HAVE_STRUCT_UTIMBUF +int +Mono_Posix_ToUtimbuf (struct utimbuf *from, struct Mono_Posix_Utimbuf *to) +{ + _cnm_return_val_if_overflow (gint64, from->actime, -1); + _cnm_return_val_if_overflow (gint64, from->modtime, -1); + + memset (to, 0, sizeof(*to)); + + to->actime = from->actime; + to->modtime = from->modtime; + + return 0; +} +#endif /* ndef HAVE_STRUCT_UTIMBUF */ + + int Mono_Posix_FromWaitOptions (int x, int *r) { *r = 0;