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