[libc-commits] [libc] [libc] pipe(2) linux syscall wrapper and unittest (PR #85514)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Mar 18 12:00:59 PDT 2024


================
@@ -0,0 +1,36 @@
+//===-- Linux implementation of pipe2
+//---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/unistd/pipe2.h"
+
+#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
+#include "src/__support/common.h"
+
+#include "src/errno/libc_errno.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, pipe2, (int pipefd[2], int flags)) {
+  int ret;
+#ifdef SYS_pipe2
+  ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_pipe2, pipefd, flags);
+#elif defined(SYS_pipe)
----------------
michaelrj-google wrote:

you can't use `SYS_pipe` for `SYS_pipe2` since it doesn't respect the `flags` argument. We only define one syscall in terms of another when it can completely mimic the behavior.

https://github.com/llvm/llvm-project/pull/85514


More information about the libc-commits mailing list