1/* Copyright (C) 2012-2025 Free Software Foundation, Inc.
 2   This file is part of the GNU C Library.
 3
 4   The GNU C Library is free software; you can redistribute it and/or
 5   modify it under the terms of the GNU Lesser General Public
 6   License as published by the Free Software Foundation; either
 7   version 2.1 of the License, or (at your option) any later version.
 8
 9   The GNU C Library is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with the GNU C Library; if not, see
16   <https://www.gnu.org/licenses/>.  */
17
18#ifndef _LINUX_X32_SYSDEP_H
19#define _LINUX_X32_SYSDEP_H 1
20
21/* There is some commonality.  */
22#include <sysdeps/unix/sysv/linux/x86_64/sysdep.h>
23#include <sysdeps/x86_64/x32/sysdep.h>
24
25/* How to pass the off{64}_t argument on p{readv,writev}{64}.  */
26#undef LO_HI_LONG
27#define LO_HI_LONG(val) (val)
28
29#ifdef __ASSEMBLER__
30/* Zero-extend 32-bit unsigned long int arguments to 64 bits.  */
31# undef ZERO_EXTEND_1
32# define ZERO_EXTEND_1 movl %edi, %edi;
33# undef ZERO_EXTEND_2
34# define ZERO_EXTEND_2 movl %esi, %esi;
35# undef ZERO_EXTEND_3
36# define ZERO_EXTEND_3 movl %edx, %edx;
37# if SYSCALL_ULONG_ARG_1 == 4 || SYSCALL_ULONG_ARG_2 == 4
38#  undef DOARGS_4
39#  define DOARGS_4 movl %ecx, %r10d;
40# else
41#  undef ZERO_EXTEND_4
42#  define ZERO_EXTEND_4 movl %r10d, %r10d;
43# endif
44# undef ZERO_EXTEND_5
45# define ZERO_EXTEND_5 movl %r8d, %r8d;
46# undef ZERO_EXTEND_6
47# define ZERO_EXTEND_6 movl %r9d, %r9d;
48#else /* !__ASSEMBLER__ */
49# undef ARGIFY
50/* Enforce zero-extension for pointers and array system call arguments.
51   For integer types, extend to int64_t (the full register) using a
52   regular cast, resulting in zero or sign extension based on the
53   signedness of the original type.  */
54# define ARGIFY(X) \
55 ({									\
56    _Pragma ("GCC diagnostic push");					\
57    _Pragma ("GCC diagnostic ignored \"-Wpointer-to-int-cast\"");	\
58    (__builtin_classify_type (X) == 5					\
59     ? (uintptr_t) (X) : (int64_t) (X));				\
60    _Pragma ("GCC diagnostic pop");					\
61  })
62#endif	/* __ASSEMBLER__ */
63
64#endif /* linux/x86_64/x32/sysdep.h */