summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2024-03-29 17:10:26 -0700
committerAlejandro Colomar <alx@kernel.org>2024-03-31 23:33:23 +0200
commitc1e10426dc22ca976ba1107f7ca95a373bb22f83 (patch)
treeee7067d6e87963f3184c30993373a4d78f95bed3
parent570c98b78b8d3afcc30486cac35a8bd18e36c097 (diff)
getpagesize.2, syscalls.2: Modernization
Remove the HP-UX portability advice, since getpagesize() is a slightly better option than sysconf() for Linux systems. Explain why this function exists, and why this man page is in the wrong section. (The previous text tried to do both at the same, which was confusing.) Also explain how the vast majority of architectures that don't have a syscall (but do support multiple page sizes) actually work. Also de-emphasize the glibc 2.0 bug, since most people don't need to worry about compatibility with versions of glibc from 1997. Finally, change "not on x86" in syscalls.2 to say where there _is_ a syscall. Co-developed-by: Elliott Hughes <enh@google.com> Co-developed-by: Alejandro Colomar <alx@kernel.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r--man2/getpagesize.256
-rw-r--r--man2/syscalls.24
2 files changed, 20 insertions, 40 deletions
diff --git a/man2/getpagesize.2 b/man2/getpagesize.2
index b82586f36..7abc3a246 100644
--- a/man2/getpagesize.2
+++ b/man2/getpagesize.2
@@ -37,6 +37,19 @@ returns the number of bytes in a memory page,
where "page" is a fixed-length block,
the unit for memory allocation and file mapping performed by
.BR mmap (2).
+.SH VERSIONS
+A user program should not hard-code a page size,
+neither as a literal nor using the
+.B PAGE_SIZE
+macro,
+because some architectures support multiple page sizes.
+.P
+This manual page is in section 2 because
+Alpha, SPARC, and SPARC64
+all have a Linux system call
+.BR getpagesize ()
+though other architectures do not,
+and use the ELF auxiliary vector instead.
.SH STANDARDS
None.
.SH HISTORY
@@ -44,46 +57,11 @@ This call first appeared in 4.2BSD.
SVr4, 4.4BSD, SUSv2.
In SUSv2 the
.BR getpagesize ()
-call is labeled LEGACY, and in POSIX.1-2001
-it has been dropped;
-HP-UX does not have this call.
-.SH NOTES
-Portable applications should employ
-.I sysconf(_SC_PAGESIZE)
-instead of
-.BR getpagesize ():
-.P
-.in +4n
-.EX
-#include <unistd.h>
-long sz = sysconf(_SC_PAGESIZE);
-.EE
-.in
+call was labeled LEGACY,
+and it was removed in POSIX.1-2001.
.P
-(Most systems allow the synonym
-.B _SC_PAGE_SIZE
-for
-.BR _SC_PAGESIZE .)
-.P
-Whether
-.BR getpagesize ()
-is present as a Linux system call depends on the architecture.
-If it is, it returns the kernel symbol
-.BR PAGE_SIZE ,
-whose value depends on the architecture and machine model.
-Generally, one uses binaries that are dependent on the architecture but not
-on the machine model, in order to have a single binary
-distribution per architecture.
-This means that a user program
-should not find
-.B PAGE_SIZE
-at compile time from a header file,
-but use an actual system call, at least for those architectures
-(like sun4) where this dependency exists.
-Here glibc 2.0 fails because its
-.BR getpagesize ()
-returns a statically derived value, and does not use a system call.
-Things are OK in glibc 2.1.
+glibc 2.0 returned a constant
+even on architectures with mutliple page sizes.
.SH SEE ALSO
.BR mmap (2),
.BR sysconf (3)
diff --git a/man2/syscalls.2 b/man2/syscalls.2
index 6c2313506..69f24ef29 100644
--- a/man2/syscalls.2
+++ b/man2/syscalls.2
@@ -324,7 +324,9 @@ T}
\fBgetpeername\fP(2) 2.0 T{
See notes on \fBsocketcall\fP(2)
T}
-\fBgetpagesize\fP(2) 2.0 Not on x86
+\fBgetpagesize\fP(2) 2.0 T{
+Alpha, SPARC/SPARC64 only
+T}
\fBgetpgid\fP(2) 1.0
\fBgetpgrp\fP(2) 1.0
\fBgetpid\fP(2) 1.0