[libc-commits] [libc] [libc][unistd] Fix generated at-function prototypes (PR #195341)
Petter Berntsson via libc-commits
libc-commits at lists.llvm.org
Fri May 1 13:02:03 PDT 2026
https://github.com/petbernt created https://github.com/llvm/llvm-project/pull/195341
Fixes generated <unistd.h> prototypes for readlinkat/symlinkat and adds compile-time public-header coverage
>From 8d0f78d6d690f42b57bfe886c1ebe71544816eba Mon Sep 17 00:00:00 2001
From: Petter Berntsson <petter.berntsson at arm.com>
Date: Fri, 1 May 2026 19:58:32 +0100
Subject: [PATCH] [libc][unistd] Fix generated at-function prototypes
---
libc/include/unistd.yaml | 2 +-
libc/test/include/CMakeLists.txt | 11 +++++++++++
libc/test/include/unistd_test.cpp | 27 +++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletion(-)
create mode 100644 libc/test/include/unistd_test.cpp
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; }
More information about the libc-commits
mailing list