Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / support / grp.c
index 47749b2131cababc8c5411136dc13107dc43ce95..827bc550d938fa91252db4ca620d739b939cb508 100644 (file)
@@ -8,7 +8,9 @@
  */
 
 #include <sys/types.h>
+#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
+#endif
 #include <grp.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -226,6 +228,7 @@ Mono_Posix_Syscall_getgrgid_r (mph_gid_t gid,
 }
 #endif /* ndef HAVE_GETGRGID_R */
 
+#if HAVE_GETGRENT
 gint32
 Mono_Posix_Syscall_getgrent (struct Mono_Posix_Syscall__Group *grbuf)
 {
@@ -247,6 +250,7 @@ Mono_Posix_Syscall_getgrent (struct Mono_Posix_Syscall__Group *grbuf)
        }
        return 0;
 }
+#endif  /* def HAVE_GETGRENT */
 
 #ifdef HAVE_FGETGRENT
 gint32
@@ -272,28 +276,36 @@ Mono_Posix_Syscall_fgetgrent (void *stream, struct Mono_Posix_Syscall__Group *gr
 }
 #endif /* ndef HAVE_FGETGRENT */
 
+#if HAVE_SETGROUPS
 gint32
 Mono_Posix_Syscall_setgroups (mph_size_t size, mph_gid_t *list)
 {
        mph_return_if_size_t_overflow (size);
        return setgroups ((size_t) size, list);
 }
+#endif  /* def HAVE_SETGROUPS */
 
+#if HAVE_SETGRENT
 int
 Mono_Posix_Syscall_setgrent (void)
 {
        errno = 0;
-       setgrent ();
-       return errno == 0 ? 0 : -1;
+       do {
+               setgrent ();
+       } while (errno == EINTR);
+       mph_return_if_val_in_list5(errno, EIO, EMFILE, ENFILE, ENOMEM, ERANGE);
+       return 0;
 }
+#endif  /* def HAVE_SETGRENT */
 
+#if HAVE_ENDGRENT
 int
 Mono_Posix_Syscall_endgrent (void)
 {
-       errno = 0;
        endgrent();
-       return errno == 0 ? 0 : -1;
+       return 0;
 }
+#endif  /* def HAVE_ENDGRENT */
 
 
 G_END_DECLS