* Authors:
* Jonathan Pryor (jonpryor@vt.edu)
*
- * Copyright (C) 2004-2005 Jonathan Pryor
+ * Copyright (C) 2004-2006 Jonathan Pryor
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include "map.h"
#include "mph.h"
G_BEGIN_DECLS
-#ifndef PLATFORM_WIN32
+#ifndef HOST_WIN32
gint32
Mono_Posix_Syscall_L_ctermid (void)
{
gint32
Mono_Posix_Syscall_L_cuserid (void)
{
+#ifdef __APPLE__
+ return -1;
+#else
return L_cuserid;
+#endif
}
-#endif /* ndef PLATFORM_WIN32 */
+#endif /* ndef HOST_WIN32 */
mph_size_t
-Mono_Posix_Stdlib_fread (void *ptr, mph_size_t size, mph_size_t nmemb, void *stream)
+Mono_Posix_Stdlib_fread (unsigned char *ptr, mph_size_t size, mph_size_t nmemb, void *stream)
{
mph_return_if_size_t_overflow (size);
mph_return_if_size_t_overflow (nmemb);
}
mph_size_t
-Mono_Posix_Stdlib_fwrite (void *ptr, mph_size_t size, mph_size_t nmemb, void *stream)
+Mono_Posix_Stdlib_fwrite (unsigned char *ptr, mph_size_t size, mph_size_t nmemb, void *stream)
{
mph_return_if_size_t_overflow (size);
mph_return_if_size_t_overflow (nmemb);
int
Mono_Posix_Stdlib_setbuf (void* stream, void* buf)
{
- errno = 0;
setbuf (stream, buf);
- return errno == 0 ? 0 : -1;
+ return 0;
}
gint32
int
Mono_Posix_Stdlib_rewind (void* stream)
{
- errno = 0;
- rewind (stream);
- return errno == 0 ? 0 : -1;
+ do {
+ rewind (stream);
+ } while (errno == EINTR);
+ mph_return_if_val_in_list5(errno, EAGAIN, EBADF, EFBIG, EINVAL, EIO);
+ mph_return_if_val_in_list5(errno, ENOSPC, ENXIO, EOVERFLOW, EPIPE, ESPIPE);
+ return 0;
}
int
Mono_Posix_Stdlib_clearerr (void* stream)
{
- errno = 0;
- clearerr (stream);
- return errno == 0 ? 0 : -1;
+ clearerr (((FILE*) stream));
+ return 0;
}
int
-Mono_Posix_Stdlib_perror (const char* s)
+Mono_Posix_Stdlib_perror (const char* s, int err)
{
- errno = 0;
+ errno = err;
perror (s);
- return errno == 0 ? 0 : -1;
+ return 0;
}
#define MPH_FPOS_LENGTH (sizeof(fpos_t)*2)