fix getrlimit handling on 32-bit systems, and ease porting to 64-bit
authorRich Felker <dalias@aerifal.cx>
Tue, 15 Feb 2011 10:42:27 +0000 (05:42 -0500)
committerRich Felker <dalias@aerifal.cx>
Tue, 15 Feb 2011 10:42:27 +0000 (05:42 -0500)
arch/i386/syscall.h
src/misc/getrlimit.c

index fcdae241a4f37f627029590d0c87b87721ca72b9..8df9b1b98aea9b00822858fab345c6df9c3f3c7f 100644 (file)
@@ -500,6 +500,8 @@ static inline long syscall6(long n, long a1, long a2, long a3, long a4, long a5,
 #define __NR_fstatat __NR_fstatat64
 #define __NR_pread __NR_pread64
 #define __NR_pwrite __NR_pwrite64
+#undef __NR_getrlimit
+#define __NR_getrlimit __NR_ugetrlimit
 
 #define __SC_socket      1
 #define __SC_bind        2
index db25943bc46567d2fd2bff144e0b4fd5d16f9066..84a659d4cf9552a5d8f2a5b2717024f83f5fe937 100644 (file)
@@ -5,10 +5,10 @@
 int getrlimit(int resource, struct rlimit *rlim)
 {
        long k_rlim[2];
-       if (syscall2(__NR_ugetrlimit, resource, (long)k_rlim) < 0)
+       if (syscall2(__NR_getrlimit, resource, (long)k_rlim) < 0)
                return -1;
-       rlim->rlim_cur = k_rlim[0];
-       rlim->rlim_max = k_rlim[1];
+       rlim->rlim_cur = k_rlim[0] == -1 ? -1 : (unsigned long)k_rlim[0];
+       rlim->rlim_max = k_rlim[1] == -1 ? -1 : (unsigned long)k_rlim[1];
        return 0;
 }