POSIX_MEM_OFFSET(3POSIX)
π POSIX_MEM_OFFSET π
okay so bestie, this one is straight out of the POSIX Programmer's Manual, and it is lowkey a niche one. It's the <cyan>posix_mem_offset</cyan> page, and it's tagged ADVANCED REALTIME, which is basically the VIP section of POSIX. Let's get into it. π«Ά
π PROLOG π
This manual page is part of the POSIX Programmer's Manual. Heads up though, babes: the Linux implementation of this interface may differ (so if you're on Linux, go read the corresponding Linux manual page for the actual Linux behavior), or honestly the interface may not be implemented on Linux at all. Not every vibe is ported, and that's okay. π
β¨ NAME β¨
posix_mem_offset β find offset and length of a mapped typed memory block (ADVANCED REALTIME)
πΈ SYNOPSIS πΈ
#include <sys/mman.h>
int posix_mem_offset(const void *restrict addr, size_t len,
off_t *restrict off, size_t *restrict contig_len,
int *restrict fildes);
π DESCRIPTION π
So here's the tea, bestie. π
The posix_mem_offset() function shall return, in the variable pointed to by off, a value that identifies the offset (aka the location) β within a memory object β of the memory block that is currently mapped at addr.
Then, in the variable pointed to by fildes, it shall return the descriptor that was used (via mmap()) to establish the mapping which contains addr. And okay, plot twist: if that descriptor was closed since the mapping got established, then the returned value of fildes shall be -1. Periodt. π
The len argument specifies the length of the block of the memory object that you, the user, want the offset for. And upon return, the value pointed to by contig_len shall equal either:
len, or- the length of the largest contiguous block of the memory object that is currently mapped to the calling process starting at
addr,
β whichever is smaller. Yes, whichever is smaller. The function keeps it humble. π
Now for the iconic part. β¨ If the memory object mapped at addr is a typed memory object, then here's the deal: if the off and contig_len values you got from calling posix_mem_offset() get used in a call to mmap() β with a file descriptor that refers to the same memory pool as fildes (either through the same port or through a different port), and that was opened with neither the POSIX_TYPED_MEM_ALLOCATE nor the POSIX_TYPED_MEM_ALLOCATE_CONTIG flag β then the typed memory area that gets mapped shall be exactly the same area that was mapped at addr in the address space of the process that called posix_mem_offset(). Same area. No cap. π
And if the memory object specified by fildes is not a typed memory object? Then the behavior of this function is implementation-defined. So like, ask your implementation, bestie, because it's not our call. π€·
π RETURN VALUE π
Upon successful completion, posix_mem_offset() shall return zero. Otherwise, the corresponding error status value shall be returned. Zero is the slay outcome. Anything else is giving error. π
π₯ ERRORS π₯
The posix_mem_offset() function shall fail if:
EACCESβ The process has not mapped a memory object supported by this function at the given addressaddr. Basically, nothing's mapped there that this function recognizes, so it can't work with it. π«
Also important: this function shall not return an error code of [EINTR]. Not a thing here. Don't come for it.
The following sections are informative. π«
π¦ EXAMPLES π¦
None. π (Iconic of it to give us absolutely nothing.)
π§ APPLICATION USAGE π§
None. (Same energy, honestly.)
π RATIONALE π
None. (Truly a minimalist queen.)
β FUTURE DIRECTIONS β
None. (The future is bright but unspecified, bestie.)
π SEE ALSO π
mmap()posix_typed_mem_open()- The Base Definitions volume of POSIX.1β2017,
<sys_mman.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.
In the event of any discrepancy between this version and the original IEEE and The Open Group Standard β the original IEEE and The Open Group Standard is the referee document. So if there's beef between them, the original wins. π₯ The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
aaaand that's the whole page, bestie!! π this diva of a manpage is brought to you by IEEE/The Open Group, 2017, and the whole thing is filed under POSIX_MEM_OFFSET(3POSIX) β go map something responsibly, ily, bye! π
β¨π¦
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms