[libc-commits] [libc] [libc] Add missing POSIX macros to cpio.h (PR #188840)

via libc-commits libc-commits at lists.llvm.org
Thu Mar 26 14:01:41 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Jeff Bailey (kaladron)

<details>
<summary>Changes</summary>

Added POSIX macros for cpio:

* cpio.h.def
* cpio.yaml
* llvm-libc-macros/cpio-macros.h

This completes the cpio.h implementation by adding the POSIX-defined macros.

Documentation for cpio was previously merged in PR #<!-- -->123798.

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


5 Files Affected:

- (modified) libc/include/CMakeLists.txt (+9) 
- (added) libc/include/cpio.h.def (+17) 
- (added) libc/include/cpio.yaml (+7) 
- (modified) libc/include/llvm-libc-macros/CMakeLists.txt (+6) 
- (added) libc/include/llvm-libc-macros/cpio-macros.h (+34) 


``````````diff
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 3f4bbf85160b7..45964ba3c433a 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -236,6 +236,15 @@ add_header_macro(
     .llvm-libc-types.cfloat16
 )
 
+add_header_macro(
+  cpio
+  ../libc/include/cpio.yaml
+  cpio.h
+  DEPENDS
+    .llvm_libc_common_h
+    .llvm-libc-macros.cpio_macros
+)
+
 add_header_macro(
   setjmp
   ../libc/include/setjmp.yaml
diff --git a/libc/include/cpio.h.def b/libc/include/cpio.h.def
new file mode 100644
index 0000000000000..e4a782ae3b268
--- /dev/null
+++ b/libc/include/cpio.h.def
@@ -0,0 +1,17 @@
+//===-- C standard library header cpio.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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_CPIO_H
+#define LLVM_LIBC_CPIO_H
+
+#include "__llvm-libc-common.h"
+#include "llvm-libc-macros/cpio-macros.h"
+
+%%public_api()
+
+#endif // LLVM_LIBC_CPIO_H
diff --git a/libc/include/cpio.yaml b/libc/include/cpio.yaml
new file mode 100644
index 0000000000000..7e16ba0414df1
--- /dev/null
+++ b/libc/include/cpio.yaml
@@ -0,0 +1,7 @@
+header: cpio.h
+header_template: cpio.h.def
+macros: []
+types: []
+enums: []
+objects: []
+functions: []
diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt
index 1f34257c57e01..cef2c0c812c5d 100644
--- a/libc/include/llvm-libc-macros/CMakeLists.txt
+++ b/libc/include/llvm-libc-macros/CMakeLists.txt
@@ -415,3 +415,9 @@ else()
       _LIBC_MODULAR_FORMAT_PRINTF.h
   )
 endif()
+add_macro_header(
+  cpio_macros
+  HDR
+    cpio-macros.h
+)
+
diff --git a/libc/include/llvm-libc-macros/cpio-macros.h b/libc/include/llvm-libc-macros/cpio-macros.h
new file mode 100644
index 0000000000000..4f30ab68a19ea
--- /dev/null
+++ b/libc/include/llvm-libc-macros/cpio-macros.h
@@ -0,0 +1,34 @@
+//===-- Macros defined in cpio.h header file ------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_MACROS_CPIO_MACROS_H
+#define LLVM_LIBC_MACROS_CPIO_MACROS_H
+
+#define C_IRUSR 000400
+#define C_IWUSR 000200
+#define C_IXUSR 000100
+#define C_IRGRP 000040
+#define C_IWGRP 000020
+#define C_IXGRP 000010
+#define C_IROTH 000004
+#define C_IWOTH 000002
+#define C_IXOTH 000001
+#define C_ISUID 004000
+#define C_ISGID 002000
+#define C_ISVTX 001000
+#define C_ISDIR 040000
+#define C_ISFIFO 010000
+#define C_ISREG 0100000
+#define C_ISBLK 060000
+#define C_ISCHR 020000
+#define C_ISCTG 0110000
+#define C_ISLNK 0120000
+#define C_ISSOCK 0140000
+#define MAGIC "070707"
+
+#endif // LLVM_LIBC_MACROS_CPIO_MACROS_H

``````````

</details>


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


More information about the libc-commits mailing list