[libc-commits] [libc] [libc] Add loff_t type (PR #204641)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Fri Jun 19 05:47:00 PDT 2026


https://github.com/kaladron updated https://github.com/llvm/llvm-project/pull/204641

>From 474f23094e4e595e15f56a3aa93903de62c74af2 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Thu, 18 Jun 2026 17:57:50 +0100
Subject: [PATCH] [libc] Add loff_t type

Added loff_t type definition. This is a Linux extension required for
large file offsets.

* llvm-libc-types/loff_t.h: Defined loff_t as __kernel_loff_t on Linux, falling back to __INT64_TYPE__.
* sys/types.yaml: Added loff_t to sys/types.
* llvm-libc-types/CMakeLists.txt: Registered loff_t.h.
* libc/include/CMakeLists.txt: Added dependency to sys_types target.

Assisted-by: Automated tooling, human reviewed.
---
 libc/include/CMakeLists.txt                 |  1 +
 libc/include/llvm-libc-types/CMakeLists.txt |  1 +
 libc/include/llvm-libc-types/loff_t.h       | 24 +++++++++++++++++++++
 libc/include/sys/types.yaml                 |  1 +
 4 files changed, 27 insertions(+)
 create mode 100644 libc/include/llvm-libc-types/loff_t.h

diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 549dbd9e4c3f8..8d980cfbd3d0b 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -877,6 +877,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..11a62a8a0c9c1 100644
--- a/libc/include/llvm-libc-types/CMakeLists.txt
+++ b/libc/include/llvm-libc-types/CMakeLists.txt
@@ -48,6 +48,7 @@ add_header(
 )
 add_header(ldiv_t HDR ldiv_t.h)
 add_header(lldiv_t HDR lldiv_t.h)
+add_header(loff_t HDR loff_t.h)
 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/loff_t.h b/libc/include/llvm-libc-types/loff_t.h
new file mode 100644
index 0000000000000..080d0cf6111dc
--- /dev/null
+++ b/libc/include/llvm-libc-types/loff_t.h
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+#ifdef __linux__
+#include <asm/posix_types.h>
+typedef __kernel_loff_t loff_t;
+#else
+typedef __INT64_TYPE__ loff_t;
+#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