X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Funistd.c;h=145de5192eb07e34b7893c457b926ee8508b1383;hb=ef7a4c06206976de7ef2e974267407347ddb75a4;hp=9fe9d7c6ad6ac3b60fa41ab06f5824a25bcc2e50;hpb=3d693eeb90339833968d66c3dc9fde2fa3ba2cef;p=mono.git diff --git a/support/unistd.c b/support/unistd.c index 9fe9d7c6ad6..145de5192eb 100644 --- a/support/unistd.c +++ b/support/unistd.c @@ -7,6 +7,8 @@ * Copyright (C) 2004-2006 Jonathan Pryor */ +#include + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif /* ndef _GNU_SOURCE */ @@ -19,8 +21,8 @@ #include #include /* for swab(3) on Mac OS X */ +#include "mph.h" /* Don't remove or move after map.h! Works around issues with Android SDK unified headers */ #include "map.h" -#include "mph.h" G_BEGIN_DECLS @@ -116,6 +118,7 @@ Mono_Posix_Syscall_sysconf (int name, int defaultError) return sysconf (name); } +#if HAVE_CONFSTR mph_size_t Mono_Posix_Syscall_confstr (int name, char *buf, mph_size_t len) { @@ -124,6 +127,7 @@ Mono_Posix_Syscall_confstr (int name, char *buf, mph_size_t len) return -1; return confstr (name, buf, (size_t) len); } +#endif /* def HAVE_CONFSTR */ #ifdef HAVE_TTYNAME_R gint32 @@ -134,23 +138,38 @@ Mono_Posix_Syscall_ttyname_r (int fd, char *buf, mph_size_t len) } #endif /* ndef HAVE_TTYNAME_R */ -gint32 -Mono_Posix_Syscall_readlink (const char *path, char *buf, mph_size_t len) +gint64 +Mono_Posix_Syscall_readlink (const char *path, unsigned char *buf, mph_size_t len) { - int r; + gint64 r; mph_return_if_size_t_overflow (len); - r = readlink (path, buf, (size_t) len); + r = readlink (path, (char*) buf, (size_t) len); if (r >= 0 && r < len) buf [r] = '\0'; return r; } +#ifdef HAVE_READLINKAT +gint64 +Mono_Posix_Syscall_readlinkat (int dirfd, const char *path, unsigned char *buf, mph_size_t len) +{ + gint64 r; + mph_return_if_size_t_overflow (len); + r = readlinkat (dirfd, path, (char*) buf, (size_t) len); + if (r >= 0 && r < len) + buf [r] = '\0'; + return r; +} +#endif /* def HAVE_READLINKAT */ + +#if HAVE_GETLOGIN_R gint32 Mono_Posix_Syscall_getlogin_r (char *buf, mph_size_t len) { mph_return_if_size_t_overflow (len); return getlogin_r (buf, (size_t) len); } +#endif /* def HAVE_GETLOGIN_R */ gint32 Mono_Posix_Syscall_gethostname (char *buf, mph_size_t len) @@ -159,18 +178,22 @@ Mono_Posix_Syscall_gethostname (char *buf, mph_size_t len) return gethostname (buf, (size_t) len); } +#if HAVE_SETHOSTNAME gint32 Mono_Posix_Syscall_sethostname (const char *name, mph_size_t len) { mph_return_if_size_t_overflow (len); return sethostname (name, (size_t) len); } +#endif /* def HAVE_SETHOSTNAME */ +#if HAVE_GETHOSTID gint64 Mono_Posix_Syscall_gethostid (void) { return gethostid (); } +#endif /* def HAVE_GETHOSTID */ #ifdef HAVE_SETHOSTID gint32 @@ -204,12 +227,17 @@ Mono_Posix_Syscall_setdomainname (const char *name, mph_size_t len) } #endif /* def HAVE_SETDOMAINNAME */ +/* Android implements truncate, but doesn't declare it. + * Result is a warning during compilation, so skip it. + */ +#ifndef HOST_ANDROID gint32 Mono_Posix_Syscall_truncate (const char *path, mph_off_t length) { mph_return_if_off_t_overflow (length); return truncate (path, (off_t) length); } +#endif gint32 Mono_Posix_Syscall_ftruncate (int fd, mph_off_t length) @@ -218,6 +246,7 @@ Mono_Posix_Syscall_ftruncate (int fd, mph_off_t length) return ftruncate (fd, (off_t) length); } +#if HAVE_LOCKF gint32 Mono_Posix_Syscall_lockf (int fd, int cmd, mph_off_t len) { @@ -226,7 +255,9 @@ Mono_Posix_Syscall_lockf (int fd, int cmd, mph_off_t len) return -1; return lockf (fd, cmd, (off_t) len); } +#endif /* def HAVE_LOCKF */ +#if HAVE_SWAB int Mono_Posix_Syscall_swab (void *from, void *to, mph_ssize_t n) { @@ -235,29 +266,31 @@ Mono_Posix_Syscall_swab (void *from, void *to, mph_ssize_t n) swab (from, to, (ssize_t) n); return 0; } +#endif /* def HAVE_SWAB */ +#if HAVE_SETUSERSHELL int Mono_Posix_Syscall_setusershell (void) { - errno = 0; setusershell (); - return errno == 0 ? 0 : -1; + return 0; } +#endif /* def HAVE_SETUSERSHELL */ +#if HAVE_ENDUSERSHELL int Mono_Posix_Syscall_endusershell (void) { - errno = 0; endusershell (); - return errno == 0 ? 0 : -1; + return 0; } +#endif /* def HAVE_ENDUSERSHELL */ int Mono_Posix_Syscall_sync (void) { - errno = 0; sync (); - return errno == 0 ? 0 : -1; + return 0; }