Skip to content

Commit

Permalink
getrlimit03: adjust a bit of code to compatiable with mips32
Browse files Browse the repository at this point in the history
Error info:
getrlimit03.c:104: FAIL: __NR_prlimit64(0) had rlim_cur =
ffffffffffffffff but __NR_getrlimit(0) had rlim_cur = 7fffffff

According to kernel code: [arch/mips/include/uapi/asm/resource.h]
RLIM_INFINITY is set to 0x7fffffffUL instead of ULONG_MAX on mips32.

 /*
 * SuS says limits have to be unsigned.
 * Which makes a ton more sense anyway,
 * but we keep the old value on MIPS32,
 * for compatibility:
 */
 #ifndef __mips64
 # define RLIM_INFINITY      0x7fffffffUL
 #endif

Adding conditional statement about mips to fix this.

Signed-off-by: Hongzhi.Song <hongzhi.song@windriver.com>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
  • Loading branch information
Hongzhi.Song authored and jstancek committed Jul 17, 2019
1 parent 90c2dc8 commit 7a3bca6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion testcases/kernel/syscalls/getrlimit/getrlimit03.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "tst_test.h"
#include "lapi/syscalls.h"
#include "lapi/abisize.h"

/**
* Linux provides an "old" getrlimit syscall handler that uses signed long,
Expand Down Expand Up @@ -61,7 +62,12 @@ struct rlimit_ulong {
unsigned long rlim_cur;
unsigned long rlim_max;
};
const unsigned long RLIM_INFINITY_UL = ULONG_MAX;

#if defined(__mips__) && defined(TST_ABI32)
const unsigned long RLIM_INFINITY_UL = 0x7fffffffUL;
#else
const unsigned long RLIM_INFINITY_UL = ULONG_MAX;
#endif

static int getrlimit_ulong(int resource, struct rlimit_ulong *rlim)
{
Expand Down

0 comments on commit 7a3bca6

Please sign in to comment.