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

via libc-commits libc-commits at lists.llvm.org
Wed Mar 20 06:26:45 PDT 2024


================
@@ -0,0 +1,21 @@
+//===-- Definition of macros from watch-queue.h
+//---------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// References
+// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/watch_queue.h
+// https://kernelnewbies.org/Linux_5.8#Core_.28various.29
+// https://docs.kernel.org/core-api/watch_queue.html
+
+#ifndef LLVM_LIBC_MACROS_LINUX_WATCH_QUEUE_MACROS_H
+#define LLVM_LIBC_MACROS_LINUX_WATCH_QUEUE_MACROS_H
+
+#define O_NOTIFICATION_PIPE                                                    \
+  O_EXCL /* Parameter to pipe2() selecting notification pipe */
----------------
muffpy wrote:

There are weird conflict errors coming from including `libc/include/llvm-libc-macros/unistd-macros.h` in the pipe2_test.cpp file because I have included `src/unistd/read.h` too which contains `#include <unistd.h>`. And `<unistd.h>` has some beef with `libc/.../unistd-macros.h`.

```
[27/29] Building CXX object projects/libc/test/src/unistd/CMa...ibc.test.src.unistd.pipe2_test.__build__.dir/pipe2_test.cpp.o
FAILED: projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.pipe2_test.__build__.dir/pipe2_test.cpp.o 
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_19_0_0_git -I/home/llvm-project/build/projects/libc/test/src/unistd -I/home/llvm-project/libc/test/src/unistd -I/home/llvm-project/libc -isystem /home/llvm-project/build/projects/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fpie -mcpu=native -fno-exceptions -fno-rtti -std=c++17 -MD -MT projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.pipe2_test.__build__.dir/pipe2_test.cpp.o -MF projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.pipe2_test.__build__.dir/pipe2_test.cpp.o.d -o projects/libc/test/src/unistd/CMakeFiles/libc.test.src.unistd.pipe2_test.__build__.dir/pipe2_test.cpp.o -c /home/llvm-project/libc/test/src/unistd/pipe2_test.cpp
In file included from /home/llvm-project/libc/test/src/unistd/pipe2_test.cpp:15:
In file included from /home/llvm-project/libc/src/unistd/read.h:12:
In file included from /usr/include/unistd.h:630:
/usr/include/aarch64-linux-gnu/bits/confname.h:133:5: error: expected identifier
    _SC_PAGESIZE,
    ^
/home/llvm-project/libc/include/llvm-libc-macros/linux/unistd-macros.h:21:22: note: expanded from macro '_SC_PAGESIZE'
#define _SC_PAGESIZE 1
                     ^
In file included from /home/llvm-project/libc/test/src/unistd/pipe2_test.cpp:15:
In file included from /home/llvm-project/libc/src/unistd/read.h:12:
/usr/include/unistd.h:1091:35: error: expected ')'
extern long int syscall (long int __sysno, ...) __THROW;
                                  ^
/usr/include/unistd.h:1091:17: note: to match this '('
extern long int syscall (long int __sysno, ...) __THROW;
                ^
/home/llvm-project/libc/include/llvm-libc-macros/linux/unistd-macros.h:31:22: note: expanded from macro 'syscall'
#define syscall(...) __syscall_helper(__VA_ARGS__, 0, 1, 2, 3, 4, 5, 6)
                     ^
/home/llvm-project/libc/include/llvm-libc-macros/linux/unistd-macros.h:29:29: note: expanded from macro '__syscall_helper'
  __llvm_libc_syscall((long)(sysno), (long)(arg1), (long)(arg2), (long)(arg3), \
                            ^
In file included from /home/llvm-project/libc/test/src/unistd/pipe2_test.cpp:15:
In file included from /home/llvm-project/libc/src/unistd/read.h:12:
/usr/include/unistd.h:1091:17: error: expected expression
extern long int syscall (long int __sysno, ...) __THROW;
                ^
/home/llvm-project/libc/include/llvm-libc-macros/linux/unistd-macros.h:31:22: note: expanded from macro 'syscall'
#define syscall(...) __syscall_helper(__VA_ARGS__, 0, 1, 2, 3, 4, 5, 6)
                     ^
/home/llvm-project/libc/include/llvm-libc-macros/linux/unistd-macros.h:29:36: note: expanded from macro '__syscall_helper'
  __llvm_libc_syscall((long)(sysno), (long)(arg1), (long)(arg2), (long)(arg3), \
                                   ^
In file included from /home/llvm-project/libc/test/src/unistd/pipe2_test.cpp:15:
In file included from /home/llvm-project/libc/src/unistd/read.h:12:
/usr/include/unistd.h:1091:44: error: expected expression
extern long int syscall (long int __sysno, ...) __THROW;
                                           ^
/usr/include/unistd.h:1091:48: error: expected ';' after top level declarator
extern long int syscall (long int __sysno, ...) __THROW;
                                               ^
5 errors generated.
ninja: build stopped: subcommand failed.
```


PS: Btw, this error happens even without `#include <linux/watch_queue.h>` in `libc/include/llvm-libc-macros/unistd-macros.h` but that should be clear from the error.

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


More information about the libc-commits mailing list