[libc-commits] [libc] 0914d20 - [libc] Add loff_t type (#204641)
via libc-commits
libc-commits at lists.llvm.org
Tue Jun 23 09:46:19 PDT 2026
Author: Jeff Bailey
Date: 2026-06-23T16:46:14Z
New Revision: 0914d20f2f8fc3c85e956d93b643a54f683638c3
URL: https://github.com/llvm/llvm-project/commit/0914d20f2f8fc3c85e956d93b643a54f683638c3
DIFF: https://github.com/llvm/llvm-project/commit/0914d20f2f8fc3c85e956d93b643a54f683638c3.diff
LOG: [libc] Add loff_t type (#204641)
Added loff_t type definition. This is a Linux extension required for
large file offsets.
* llvm-libc-types/loff_t.h: Include linux/loff_t.h on Linux.
* llvm-libc-types/linux/loff_t.h: Added Linux definition using
__kernel_loff_t.
* llvm-libc-types/CMakeLists.txt: Include linux subdirectory and add
dependency for loff_t.
* llvm-libc-types/linux/CMakeLists.txt: Registered loff_t.
* sys/types.yaml: Added loff_t to sys/types.
* libc/include/CMakeLists.txt: Added dependency to sys_types target.
Assisted-by: Automated tooling, human reviewed.
Added:
libc/include/llvm-libc-types/linux/CMakeLists.txt
libc/include/llvm-libc-types/linux/loff_t.h
libc/include/llvm-libc-types/loff_t.h
Modified:
libc/include/CMakeLists.txt
libc/include/llvm-libc-types/CMakeLists.txt
libc/include/sys/types.yaml
Removed:
################################################################################
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index e8168687109b0..ab24c854692d0 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -885,6 +885,7 @@ add_header_macro(
.llvm-libc-types.gid_t
.llvm-libc-types.ino_t
.llvm-libc-types.key_t
+ .llvm-libc-types.loff_t
.llvm-libc-types.mode_t
.llvm-libc-types.nlink_t
.llvm-libc-types.off_t
diff --git a/libc/include/llvm-libc-types/CMakeLists.txt b/libc/include/llvm-libc-types/CMakeLists.txt
index 46b0eb7d71183..c0c600983ba12 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -1,3 +1,6 @@
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+endif()
add_header(off64_t HDR off64_t.h)
add_header(size_t HDR size_t.h)
add_header(
@@ -48,6 +51,11 @@ add_header(
)
add_header(ldiv_t HDR ldiv_t.h)
add_header(lldiv_t HDR lldiv_t.h)
+if(TARGET libc.include.llvm-libc-types.${LIBC_TARGET_OS}.loff_t)
+ add_header(loff_t HDR loff_t.h DEPENDS .${LIBC_TARGET_OS}.loff_t)
+else()
+ add_header(loff_t HDR loff_t.h)
+endif()
add_header(FILE HDR FILE.h)
add_header(fd_set HDR fd_set.h DEPENDS libc.include.llvm-libc-macros.sys_select_macros)
add_header(fenv_t HDR fenv_t.h)
diff --git a/libc/include/llvm-libc-types/linux/CMakeLists.txt b/libc/include/llvm-libc-types/linux/CMakeLists.txt
new file mode 100644
index 0000000000000..ccb986a7b54c8
--- /dev/null
+++ b/libc/include/llvm-libc-types/linux/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_header(
+ loff_t
+ HDR
+ loff_t.h
+)
diff --git a/libc/include/llvm-libc-types/linux/loff_t.h b/libc/include/llvm-libc-types/linux/loff_t.h
new file mode 100644
index 0000000000000..408f9bdb9754e
--- /dev/null
+++ b/libc/include/llvm-libc-types/linux/loff_t.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of loff_t type for Linux.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_LINUX_LOFF_T_H
+#define LLVM_LIBC_TYPES_LINUX_LOFF_T_H
+
+#include <asm/posix_types.h>
+
+typedef __kernel_loff_t loff_t;
+
+#endif // LLVM_LIBC_TYPES_LINUX_LOFF_T_H
diff --git a/libc/include/llvm-libc-types/loff_t.h b/libc/include/llvm-libc-types/loff_t.h
new file mode 100644
index 0000000000000..4e95135fdb81a
--- /dev/null
+++ b/libc/include/llvm-libc-types/loff_t.h
@@ -0,0 +1,21 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Definition of loff_t type.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TYPES_LOFF_T_H
+#define LLVM_LIBC_TYPES_LOFF_T_H
+
+#if defined(__linux__)
+#include "linux/loff_t.h"
+#endif
+
+#endif // LLVM_LIBC_TYPES_LOFF_T_H
diff --git a/libc/include/sys/types.yaml b/libc/include/sys/types.yaml
index 605b0c9258841..37c58e708af34 100644
--- a/libc/include/sys/types.yaml
+++ b/libc/include/sys/types.yaml
@@ -9,6 +9,7 @@ types:
- type_name: gid_t
- type_name: ino_t
- type_name: key_t
+ - type_name: loff_t
- type_name: mode_t
- type_name: nlink_t
- type_name: off_t
More information about the libc-commits
mailing list