[libc-commits] [libc] [libc][unistd] Fix generated at-function prototypes (PR #195341)

via libc-commits libc-commits at lists.llvm.org
Fri May 1 13:02:38 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Petter Berntsson (petbernt)

<details>
<summary>Changes</summary>

Fixes generated <unistd.h> prototypes for readlinkat/symlinkat and adds compile-time public-header coverage

---
Full diff: https://github.com/llvm/llvm-project/pull/195341.diff


3 Files Affected:

- (modified) libc/include/unistd.yaml (+1-1) 
- (modified) libc/test/include/CMakeLists.txt (+11) 
- (added) libc/test/include/unistd_test.cpp (+27) 


``````````diff
diff --git a/libc/include/unistd.yaml b/libc/include/unistd.yaml
index b3c19fe638d6d..24e2bcbb9650c 100644
--- a/libc/include/unistd.yaml
+++ b/libc/include/unistd.yaml
@@ -330,6 +330,7 @@ functions:
       - POSIX
     return_type: ssize_t
     arguments:
+      - type: int
       - type: const char *__restrict
       - type: char *__restrict
       - type: size_t
@@ -365,7 +366,6 @@ functions:
       - POSIX
     return_type: int
     arguments:
-      - type: int
       - type: const char *
       - type: int
       - type: const char *
diff --git a/libc/test/include/CMakeLists.txt b/libc/test/include/CMakeLists.txt
index 85915f5a2fbda..6511a58551fff 100644
--- a/libc/test/include/CMakeLists.txt
+++ b/libc/test/include/CMakeLists.txt
@@ -98,6 +98,17 @@ add_libc_test(
     libc.include.sched
 )
 
+add_libc_test(
+  unistd_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_include_tests
+  SRCS
+    unistd_test.cpp
+  DEPENDS
+    libc.include.unistd
+)
+
 add_libc_test(
   issubnormal_test
   SUITE
diff --git a/libc/test/include/unistd_test.cpp b/libc/test/include/unistd_test.cpp
new file mode 100644
index 0000000000000..f6a80a0761947
--- /dev/null
+++ b/libc/test/include/unistd_test.cpp
@@ -0,0 +1,27 @@
+//===-- Unittests for unistd ----------------------------------------------===//
+//
+// 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 <unistd.h>
+
+template <typename T, typename U> struct SameType {
+  static constexpr bool value = false;
+};
+
+template <typename T> struct SameType<T, T> {
+  static constexpr bool value = true;
+};
+
+static_assert(
+    SameType<decltype(readlinkat(0, (const char *)0, (char *)0, (size_t)0)),
+             ssize_t>::value,
+    "");
+static_assert(SameType<decltype(symlinkat((const char *)0, 0, (const char *)0)),
+                       int>::value,
+              "");
+
+extern "C" int main() { return 0; }

``````````

</details>


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


More information about the libc-commits mailing list