1 /* arch_prctl call for Linux/x32.
2 Copyright (C) 2012-2013 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>
24 /* Since x32 arch_prctl stores 32-bit base address of segment registers
25 %fs and %gs as unsigned 64-bit value via ARCH_GET_FS and ARCH_GET_GS,
26 we use an unsigned 64-bit variable to hold the base address and copy
27 it to ADDR after the system call returns. */
30 __arch_prctl (int code
, uintptr_t *addr
)
34 void *prctl_arg
= addr
;
44 res
= INLINE_SYSCALL (arch_prctl
, 2, code
, prctl_arg
);
50 /* Check for a large value that overflows. */
51 if ((uintptr_t) addr64
!= addr64
)
53 __set_errno (EOVERFLOW
);
56 *addr
= (uintptr_t) addr64
;
62 weak_alias (__arch_prctl
, arch_prctl
)