08c3a6
commit b38c9cdb58061d357cdf9bca4f6967d487becb82
08c3a6
Author: Florian Weimer <fweimer@redhat.com>
08c3a6
Date:   Wed May 4 15:37:21 2022 +0200
08c3a6
08c3a6
    Linux: Define MMAP_CALL_INTERNAL
08c3a6
    
08c3a6
    Unlike MMAP_CALL, this avoids a TCB dependency for an errno update
08c3a6
    on failure.
08c3a6
    
08c3a6
    <mmap_internal.h> cannot be included as is on several architectures
08c3a6
    due to the definition of page_unit, so introduce a separate header
08c3a6
    file for the definition of MMAP_CALL and MMAP_CALL_INTERNAL,
08c3a6
    <mmap_call.h>.
08c3a6
    
08c3a6
    Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
08c3a6
    (cherry picked from commit c1b68685d438373efe64e5f076f4215723004dfb)
08c3a6
08c3a6
diff --git a/sysdeps/unix/sysv/linux/mmap_call.h b/sysdeps/unix/sysv/linux/mmap_call.h
08c3a6
new file mode 100644
08c3a6
index 0000000000000000..3547c99e149e5064
08c3a6
--- /dev/null
08c3a6
+++ b/sysdeps/unix/sysv/linux/mmap_call.h
08c3a6
@@ -0,0 +1,22 @@
08c3a6
+/* Generic definition of MMAP_CALL and MMAP_CALL_INTERNAL.
08c3a6
+   Copyright (C) 2017-2022 Free Software Foundation, Inc.
08c3a6
+   This file is part of the GNU C Library.
08c3a6
+
08c3a6
+   The GNU C Library is free software; you can redistribute it and/or
08c3a6
+   modify it under the terms of the GNU Lesser General Public
08c3a6
+   License as published by the Free Software Foundation; either
08c3a6
+   version 2.1 of the License, or (at your option) any later version.
08c3a6
+
08c3a6
+   The GNU C Library is distributed in the hope that it will be useful,
08c3a6
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
08c3a6
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
08c3a6
+   Lesser General Public License for more details.
08c3a6
+
08c3a6
+   You should have received a copy of the GNU Lesser General Public
08c3a6
+   License along with the GNU C Library; if not, see
08c3a6
+   <https://www.gnu.org/licenses/>.  */
08c3a6
+
08c3a6
+#define MMAP_CALL(__nr, __addr, __len, __prot, __flags, __fd, __offset) \
08c3a6
+  INLINE_SYSCALL_CALL (__nr, __addr, __len, __prot, __flags, __fd, __offset)
08c3a6
+#define MMAP_CALL_INTERNAL(__nr, __addr, __len, __prot, __flags, __fd, __offset) \
08c3a6
+  INTERNAL_SYSCALL_CALL (__nr, __addr, __len, __prot, __flags, __fd, __offset)
08c3a6
diff --git a/sysdeps/unix/sysv/linux/mmap_internal.h b/sysdeps/unix/sysv/linux/mmap_internal.h
08c3a6
index 5ca6976191137f95..989eb0c7c6b57dc1 100644
08c3a6
--- a/sysdeps/unix/sysv/linux/mmap_internal.h
08c3a6
+++ b/sysdeps/unix/sysv/linux/mmap_internal.h
08c3a6
@@ -40,10 +40,6 @@ static uint64_t page_unit;
08c3a6
 /* Do not accept offset not multiple of page size.  */
08c3a6
 #define MMAP_OFF_LOW_MASK  (MMAP2_PAGE_UNIT - 1)
08c3a6
 
08c3a6
-/* An architecture may override this.  */
08c3a6
-#ifndef MMAP_CALL
08c3a6
-# define MMAP_CALL(__nr, __addr, __len, __prot, __flags, __fd, __offset) \
08c3a6
-  INLINE_SYSCALL_CALL (__nr, __addr, __len, __prot, __flags, __fd, __offset)
08c3a6
-#endif
08c3a6
+#include <mmap_call.h>
08c3a6
 
08c3a6
 #endif /* MMAP_INTERNAL_LINUX_H  */
08c3a6
diff --git a/sysdeps/unix/sysv/linux/s390/mmap_internal.h b/sysdeps/unix/sysv/linux/s390/mmap_call.h
08c3a6
similarity index 78%
08c3a6
rename from sysdeps/unix/sysv/linux/s390/mmap_internal.h
08c3a6
rename to sysdeps/unix/sysv/linux/s390/mmap_call.h
08c3a6
index 46f1c3769d6b586a..bdd30cc83764c2c1 100644
08c3a6
--- a/sysdeps/unix/sysv/linux/s390/mmap_internal.h
08c3a6
+++ b/sysdeps/unix/sysv/linux/s390/mmap_call.h
08c3a6
@@ -16,9 +16,6 @@
08c3a6
    License along with the GNU C Library; if not, see
08c3a6
    <https://www.gnu.org/licenses/>.  */
08c3a6
 
08c3a6
-#ifndef MMAP_S390_INTERNAL_H
08c3a6
-# define MMAP_S390_INTERNAL_H
08c3a6
-
08c3a6
 #define MMAP_CALL(__nr, __addr, __len, __prot, __flags, __fd, __offset)	\
08c3a6
   ({									\
08c3a6
     long int __args[6] = { (long int) (__addr), (long int) (__len),	\
08c3a6
@@ -26,7 +23,10 @@
08c3a6
 			   (long int) (__fd), (long int) (__offset) };	\
08c3a6
     INLINE_SYSCALL_CALL (__nr, __args);					\
08c3a6
   })
08c3a6
-
08c3a6
-#include_next <mmap_internal.h>
08c3a6
-
08c3a6
-#endif
08c3a6
+#define MMAP_CALL_INTERNAL(__nr, __addr, __len, __prot, __flags, __fd, __offset)	\
08c3a6
+  ({									\
08c3a6
+    long int __args[6] = { (long int) (__addr), (long int) (__len),	\
08c3a6
+			   (long int) (__prot), (long int) (__flags),	\
08c3a6
+			   (long int) (__fd), (long int) (__offset) };	\
08c3a6
+    INTERNAL_SYSCALL_CALL (__nr, __args);				\
08c3a6
+  })