libc: Add missing pipe2() declaration and implementation.

Change-Id: Iacb914bd6ac5adc60c5671e6fef680ede21f9b0c
diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h
index 9e2aa2f..6a7fc40 100644
--- a/libc/include/sys/linux-syscalls.h
+++ b/libc/include/sys/linux-syscalls.h
@@ -138,6 +138,7 @@
 #define __NR_openat                       (__NR_SYSCALL_BASE + 322)
 #define __NR_madvise                      (__NR_SYSCALL_BASE + 220)
 #define __NR_mincore                      (__NR_SYSCALL_BASE + 219)
+#define __NR_pipe2                        (__NR_SYSCALL_BASE + 359)
 #define __NR_getdents64                   (__NR_SYSCALL_BASE + 217)
 #define __NR_fstatfs64                    (__NR_SYSCALL_BASE + 267)
 #define __NR_fstatat64                    (__NR_SYSCALL_BASE + 327)
@@ -194,6 +195,7 @@
 #define __NR_openat                       (__NR_SYSCALL_BASE + 295)
 #define __NR_madvise                      (__NR_SYSCALL_BASE + 219)
 #define __NR_mincore                      (__NR_SYSCALL_BASE + 218)
+#define __NR_pipe2                        (__NR_SYSCALL_BASE + 331)
 #define __NR_getdents64                   (__NR_SYSCALL_BASE + 220)
 #define __NR_fstatfs64                    (__NR_SYSCALL_BASE + 269)
 #define __NR_fstatat64                    (__NR_SYSCALL_BASE + 300)
@@ -235,6 +237,7 @@
 #define __NR_openat                       (__NR_SYSCALL_BASE + 295)
 #define __NR_madvise                      (__NR_SYSCALL_BASE + 219)
 #define __NR_mincore                      (__NR_SYSCALL_BASE + 218)
+#define __NR_pipe2                        (__NR_SYSCALL_BASE + 331)
 #define __NR_getdents64                   (__NR_SYSCALL_BASE + 220)
 #define __NR_fstatfs64                    (__NR_SYSCALL_BASE + 269)
 #define __NR_fstatat64                    (__NR_SYSCALL_BASE + 300)
@@ -270,8 +273,8 @@
 #define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
 #define __NR_socketcall                   (__NR_SYSCALL_BASE + 102)
 #define __NR___socketcall                 (__NR_SYSCALL_BASE + 102)
-#define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 289)
-#define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 290)
+#define __NR_ioprio_set                   (__NR_SYSCALL_BASE + 288)
+#define __NR_ioprio_get                   (__NR_SYSCALL_BASE + 289)
 #define __NR_epoll_create                 (__NR_SYSCALL_BASE + 254)
 #define __NR_epoll_ctl                    (__NR_SYSCALL_BASE + 255)
 #define __NR_epoll_wait                   (__NR_SYSCALL_BASE + 256)
diff --git a/libc/include/sys/linux-unistd.h b/libc/include/sys/linux-unistd.h
index 6bd9ac7..7494efe 100644
--- a/libc/include/sys/linux-unistd.h
+++ b/libc/include/sys/linux-unistd.h
@@ -79,6 +79,7 @@
 int              fchmod (int, mode_t);
 int              dup (int);
 int              pipe (int *);
+int              pipe2 (int *, int);
 int              dup2 (int, int);
 int              select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
 int              ftruncate (int, off_t);
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 7554198..cd09e3d 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -118,6 +118,9 @@
 extern int fchdir(int);
 extern int rmdir(const char *);
 extern int pipe(int *);
+#ifdef _GNU_SOURCE  /* GLibc compatibility */
+extern int pipe2(int *, int);
+#endif
 extern int chroot(const char *);
 extern int symlink(const char *, const char *);
 extern int readlink(const char *, char *, size_t);