Fix a build failure with musl

```
compiling gc.c
In file included from gc.c:80:
/usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map'
   88 | struct prctl_mm_map {
      |        ^~~~~~~~~~~~
In file included from gc.c:79:
/usr/include/linux/prctl.h:134:8: note: originally defined here
  134 | struct prctl_mm_map {
      |        ^~~~~~~~~~~~
```

The first include is not needed and is what causes this issue.
Two other places in ruby exclusively use the sys import.

See https://github.com/seccomp/libseccomp/issues/19 for a similar problem.
This commit is contained in:
Earlopain 2024-11-23 11:50:00 +01:00 committed by Nobuyoshi Nakada
parent a8c2d5e7be
commit 3826019f31
Notes: git 2024-11-24 08:47:25 +00:00
2 changed files with 4 additions and 6 deletions

5
gc.c
View file

@ -75,8 +75,7 @@
#endif
/* For ruby_annotate_mmap */
#ifdef __linux__
#include <linux/prctl.h>
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
@ -4516,7 +4515,7 @@ Init_GC(void)
void
ruby_annotate_mmap(const void *addr, unsigned long size, const char *name)
{
#if defined(__linux__) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
// The name length cannot exceed 80 (including the '\0').
RUBY_ASSERT(strlen(name) < 80);
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name);

View file

@ -5,8 +5,7 @@
#ifndef _WIN32
# include <sys/mman.h>
# include <unistd.h>
# ifdef __linux__
# include <linux/prctl.h>
# ifdef HAVE_SYS_PRCTL_H
# include <sys/prctl.h>
# endif
#endif
@ -1875,7 +1874,7 @@ heap_page_body_allocate(void)
// `default.c` as a shared library, we will not have access to private
// symbols, and we have to either call prctl directly or make our own
// wrapper.
#if defined(__linux__) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, mmap_size, "Ruby:GC:default:heap_page_body_allocate");
errno = 0;
#endif