1 /* arch_prctl call for Linux/x32.
2 Copyright (C) 2012-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 #include <sys/prctl.h>
21 #include <sys/syscall.h>
25 /* Since x32 arch_prctl stores 32-bit base address of segment registers
26 %fs and %gs as unsigned 64-bit value via ARCH_GET_FS and ARCH_GET_GS,
27 we use an unsigned 64-bit variable to hold the base address and copy
28 it to ADDR after the system call returns. */
31 __arch_prctl (int code
, uintptr_t *addr
)
35 void *prctl_arg
= addr
;
45 res
= INLINE_SYSCALL (arch_prctl
, 2, code
, prctl_arg
);
51 /* Check for a large value that overflows. */
52 if ((uintptr_t) addr64
!= addr64
)
54 __set_errno (EOVERFLOW
);
57 *addr
= (uintptr_t) addr64
;
63 weak_alias (__arch_prctl
, arch_prctl
)