[PATCH v6 02/23] Prepare for the addition of the <sys/pagesize.h> header
Florian Weimer
fweimer@redhat.com
Tue May 20 09:21:31 GMT 2025
Add a stub version of <bits/pagesize.h>. This header is similar to
<bits/wordsize.h> in that every port must define its own version.
Add <sys/pagesize.h>, which will become the installed version
of this header. PAGE_SIZE_MIN and PAGE_SIZE_MAX have type long
int, so that roundup (offset, PAGE_SIZE_MAX) gives the correct
result if offset has type off64_t on 32-bit architectures.
(With an unsigned type for PAGE_SIZE_MAX, the roundup macro
does not work as expected if the first argument is wider than
the second argument.)
---
bits/pagesize.h | 10 ++++++++++
include/sys/pagesize.h | 1 +
misc/sys/pagesize.h | 32 ++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
create mode 100644 bits/pagesize.h
create mode 100644 include/sys/pagesize.h
create mode 100644 misc/sys/pagesize.h
diff --git a/bits/pagesize.h b/bits/pagesize.h
new file mode 100644
index 0000000000..d83561d0c1
--- /dev/null
+++ b/bits/pagesize.h
@@ -0,0 +1,10 @@
+#error "This file must be written based on the possible page sizes"
+
+/* 1 << __GLIBC_PAGE_SHIFT_MIN is the minimum possible page size.
+ The least significant __GLIBC_PAGE_SHIFT_MIN bits of pointers
+ return by mmap are guaranteed to be cleared. */
+#define __GLIBC_PAGE_SHIFT_MIN
+
+/* 1 << __GLIBC_PAGE_SHIFT_MAX is the maximum possible page size.
+ On-disk file formats must not require smaller mapping offsets. */
+#define __GLIBC_PAGE_SHIFT_MAX
diff --git a/include/sys/pagesize.h b/include/sys/pagesize.h
new file mode 100644
index 0000000000..2533ee7e90
--- /dev/null
+++ b/include/sys/pagesize.h
@@ -0,0 +1 @@
+#include <misc/sys/pagesize.h>
diff --git a/misc/sys/pagesize.h b/misc/sys/pagesize.h
new file mode 100644
index 0000000000..c314395e49
--- /dev/null
+++ b/misc/sys/pagesize.h
@@ -0,0 +1,32 @@
+/* Information about supported page sizes.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _SYS_PAGESIZE_H
+#define _SYS_PAGESIZE_H
+
+#include <bits/pagesize.h>
+
+/* Minimum and maximum possible page sizes, in bytes. */
+#define PAGE_SIZE_MIN (1L << __GLIBC_PAGE_SHIFT_MIN)
+#define PAGE_SIZE_MAX (1L << __GLIBC_PAGE_SHIFT_MAX)
+
+/* Base-2 logarithm of the size limits. */
+#define PAGE_SHIFT_MIN __GLIBC_PAGE_SHIFT_MIN
+#define PAGE_SHIFT_MAX __GLIBC_PAGE_SHIFT_MAX
+
+#endif /* _SYS_PAGESIZE_H */
--
2.49.0
More information about the Libc-alpha
mailing list