* Header conflicts with shmget() and SHM_HUGE_2MB
@ 2024-06-03 18:27 Carlos Llamas
2024-06-03 19:27 ` Andi Kleen
0 siblings, 1 reply; 2+ messages in thread
From: Carlos Llamas @ 2024-06-03 18:27 UTC (permalink / raw)
To: linux-mm
Cc: Mike Kravetz, Andi Kleen, Hugh Dickins, Edward Liaw, kernel-team,
linux-kernel, linux-api
Hi, I'm trying to figure out how one would use SHM_HUGE_{2MB/1GB}
defines through shmget() from userspace. After having a look at the
man-pages I thought the #include pattern would be similar to that of
mmap(), e.g.:
#include <sys/mman.h>
#include <linux/mman.h>
[...]
mmap(NULL, size, prot, flags | MAP_HUGETLB | MAP_HUGE_2MB,
fd, 0);
However, when doing the shmem equivalent with the headers I get several
redefinition conflicts. When attempting to compile something like this:
#include <sys/shm.h>
#include <linux/shm.h>
[...]
shmid = shmget(key, size, flags | SHM_HUGETLB | SHM_HUGE_2MB);
I run into the following type of issues:
/usr/include/linux/shm.h:26:8: error: redefinition of ‘struct shmid_ds’
26 | struct shmid_ds {
| ^~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/bits/shm.h:45,
from /usr/include/x86_64-linux-gnu/sys/shm.h:30:
/usr/include/x86_64-linux-gnu/bits/types/struct_shmid_ds.h:24:8: note: originally defined here
24 | struct shmid_ds
| ^~~~~~~~
I can see such definitions are tagged as "obsolete" in the uapi headers.
Do we need some ifndef protection with the glibc headers?
What is the advice to follow for userspace? Skip <linux/shm.h> and
openly redefine the SHM_HUGE_* wherever needed?
Thanks,
--
Carlos Llamas
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Header conflicts with shmget() and SHM_HUGE_2MB
2024-06-03 18:27 Header conflicts with shmget() and SHM_HUGE_2MB Carlos Llamas
@ 2024-06-03 19:27 ` Andi Kleen
0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2024-06-03 19:27 UTC (permalink / raw)
To: Carlos Llamas
Cc: linux-mm, Mike Kravetz, Hugh Dickins, Edward Liaw, kernel-team,
linux-kernel, linux-api
> I can see such definitions are tagged as "obsolete" in the uapi headers.
> Do we need some ifndef protection with the glibc headers?
They should be still supported, but also the more generic macro.
>
> What is the advice to follow for userspace? Skip <linux/shm.h> and
> openly redefine the SHM_HUGE_* wherever needed?
glibc (or other C libraries if not using linux/shm) should add the
defines. Short term you would need to redefine on your own yes.
-Andi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-03 19:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03 18:27 Header conflicts with shmget() and SHM_HUGE_2MB Carlos Llamas
2024-06-03 19:27 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).