i386: Disable Intel Xeon Phi tests for GCC 15 and above (BZ 31782)
[glibc.git] / sysdeps / unix / sysv / linux / personality.c
blob3c975bf76ff54f5b61b2ba830e97c7bb204f3369
1 /* Copyright (C) 2015-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #include <sys/personality.h>
19 #include <sysdep.h>
21 extern __typeof (personality) __personality;
23 int
24 __personality (unsigned long persona)
26 #ifdef PERSONALITY_TRUNCATE_ARGUMENT
27 /* Starting with kernel commit v2.6.21-3117-g97dc32c, the type of
28 task_struct->pesonality is "unsigned int".
29 Starting with kernel commit v2.6.35-rc1-372-g485d527, the personality
30 syscall accepts "unsigned int" instead of "long unsigned int".
31 In between, a personality argument that does not fit into "unsigned int"
32 would result to system call returning -EINVAL.
33 We explicitly truncate the personality argument to "unsigned int"
34 to eliminate the uncertainty. */
35 persona = (unsigned int) persona;
36 #endif
38 long int ret = INTERNAL_SYSCALL_CALL (personality, persona);
40 /* Starting with kernel commit v2.6.29-6609-g11d06b2, the personality syscall
41 never fails. However, 32-bit kernels might flag valid values as errors, so
42 we need to reverse the error setting. We can't use the raw result as some
43 arches split the return/error values. */
44 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (ret)))
45 ret = -INTERNAL_SYSCALL_ERRNO (ret);
46 return ret;
48 weak_alias (__personality, personality)