Fix <sys/resource.h>.

The situation here is a bit confusing. On 64-bit, rlimit and rlimit64 are
the same, and so getrlimit/getrlimit64, setrlimit/setrlimit64,
and prlimit/prlimit64 are all the same. On 32-bit, rlimit and rlimit64 are
different. 32-bit architectures other than MIPS go one step further by having
an even more limited getrlimit system call, so arm and x86 need to use
ugetrlimit instead of getrlimit. Worse, the 32-bit architectures don't have
64-bit getrlimit- and setrlimit-equivalent system calls, and you have to use
prlimit64 instead. There's no 32-bit prlimit system call, so there's no
easy implementation of that --- what should we do if the result of prlimit64
won't fit in a struct rlimit? Since 32-bit survived without prlimit/prlimit64
for this long, I'm not going to bother implementing prlimit for 32-bit.

We need the rlimit64 functions to be able to build strace 4.8 out of the box.

Change-Id: I1903d913b23016a2fc3b9f452885ac730d71e001
diff --git a/libc/arch-x86_64/syscalls.mk b/libc/arch-x86_64/syscalls.mk
index cac7423..ec09e77 100644
--- a/libc/arch-x86_64/syscalls.mk
+++ b/libc/arch-x86_64/syscalls.mk
@@ -124,6 +124,7 @@
 syscall_src += arch-x86_64/syscalls/pipe2.S
 syscall_src += arch-x86_64/syscalls/prctl.S
 syscall_src += arch-x86_64/syscalls/pread64.S
+syscall_src += arch-x86_64/syscalls/prlimit64.S
 syscall_src += arch-x86_64/syscalls/pwrite64.S
 syscall_src += arch-x86_64/syscalls/read.S
 syscall_src += arch-x86_64/syscalls/readahead.S
diff --git a/libc/arch-x86_64/syscalls/getrlimit.S b/libc/arch-x86_64/syscalls/getrlimit.S
index 1417b28..0b3536c 100644
--- a/libc/arch-x86_64/syscalls/getrlimit.S
+++ b/libc/arch-x86_64/syscalls/getrlimit.S
@@ -14,3 +14,6 @@
 1:
     ret
 END(getrlimit)
+
+    .globl _C_LABEL(getrlimit64)
+    .equ _C_LABEL(getrlimit64), _C_LABEL(getrlimit)
diff --git a/libc/arch-x86_64/syscalls/prlimit64.S b/libc/arch-x86_64/syscalls/prlimit64.S
new file mode 100644
index 0000000..b451e8f
--- /dev/null
+++ b/libc/arch-x86_64/syscalls/prlimit64.S
@@ -0,0 +1,20 @@
+/* Generated by gensyscalls.py. Do not edit. */
+
+#include <private/bionic_asm.h>
+
+ENTRY(prlimit64)
+    movq    %rcx, %r10
+    movl    $__NR_prlimit64, %eax
+    syscall
+    cmpq    $-MAX_ERRNO, %rax
+    jb      1f
+    negl    %eax
+    movl    %eax, %edi
+    call    __set_errno
+    orq     $-1, %rax
+1:
+    ret
+END(prlimit64)
+
+    .globl _C_LABEL(prlimit)
+    .equ _C_LABEL(prlimit), _C_LABEL(prlimit64)
diff --git a/libc/arch-x86_64/syscalls/setrlimit.S b/libc/arch-x86_64/syscalls/setrlimit.S
index de5b3b7..e445ec0 100644
--- a/libc/arch-x86_64/syscalls/setrlimit.S
+++ b/libc/arch-x86_64/syscalls/setrlimit.S
@@ -14,3 +14,6 @@
 1:
     ret
 END(setrlimit)
+
+    .globl _C_LABEL(setrlimit64)
+    .equ _C_LABEL(setrlimit64), _C_LABEL(setrlimit)