argp: Don't pass invalid arguments to isspace, isalnum, isalpha, isdigit.
[glibc.git] / sysdeps / powerpc / hwcapinfo.c
blobb54bab4c5f5ff142732964b1180e8b7ff19c11e8
1 /* powerpc HWCAP/HWCAP2 and AT_PLATFORM data pre-processing.
2 Copyright (C) 2015-2021 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 <https://www.gnu.org/licenses/>. */
19 #include <unistd.h>
20 #include <shlib-compat.h>
21 #include <dl-procinfo.h>
23 uint64_t __tcb_hwcap __attribute__ ((visibility ("hidden")));
24 uint32_t __tcb_platform __attribute__ ((visibility ("hidden")));
26 /* This function parses the HWCAP/HWCAP2 fields, adding the previous supported
27 ISA bits, as well as converting the AT_PLATFORM string to a number. This
28 data is stored in two global variables that can be used later by the
29 powerpc-specific code to store it into the TCB. */
30 void
31 __tcb_parse_hwcap_and_convert_at_platform (void)
34 uint64_t h1, h2;
36 /* Read AT_PLATFORM string from auxv and convert it to a number. */
37 __tcb_platform = _dl_string_platform (GLRO (dl_platform));
39 /* Read HWCAP and HWCAP2 from auxv. */
40 h1 = GLRO (dl_hwcap);
41 h2 = GLRO (dl_hwcap2);
43 /* hwcap contains only the latest supported ISA, the code checks which is
44 and fills the previous supported ones. */
46 if (h2 & PPC_FEATURE2_ARCH_2_07)
47 h1 |= PPC_FEATURE_ARCH_2_06
48 | PPC_FEATURE_ARCH_2_05
49 | PPC_FEATURE_POWER5_PLUS
50 | PPC_FEATURE_POWER5
51 | PPC_FEATURE_POWER4;
52 else if (h1 & PPC_FEATURE_ARCH_2_06)
53 h1 |= PPC_FEATURE_ARCH_2_05
54 | PPC_FEATURE_POWER5_PLUS
55 | PPC_FEATURE_POWER5
56 | PPC_FEATURE_POWER4;
57 else if (h1 & PPC_FEATURE_ARCH_2_05)
58 h1 |= PPC_FEATURE_POWER5_PLUS
59 | PPC_FEATURE_POWER5
60 | PPC_FEATURE_POWER4;
61 else if (h1 & PPC_FEATURE_POWER5_PLUS)
62 h1 |= PPC_FEATURE_POWER5
63 | PPC_FEATURE_POWER4;
64 else if (h1 & PPC_FEATURE_POWER5)
65 h1 |= PPC_FEATURE_POWER4;
67 /* Consolidate both HWCAP and HWCAP2 into a single doubleword so that
68 we can read both in a single load later. */
69 __tcb_hwcap = h2;
70 __tcb_hwcap = (h1 << 32) | __tcb_hwcap;
73 #if IS_IN (rtld)
74 versioned_symbol (ld, __tcb_parse_hwcap_and_convert_at_platform, \
75 __parse_hwcap_and_convert_at_platform, GLIBC_2_23);
76 #endif
78 /* Export __parse_hwcap_and_convert_at_platform in libc.a. This is used by
79 GCC to make sure that the HWCAP/Platform bits are stored in the TCB when
80 using __builtin_cpu_is()/__builtin_cpu_supports() in the static case. */
81 #ifndef SHARED
82 weak_alias (__tcb_parse_hwcap_and_convert_at_platform, \
83 __parse_hwcap_and_convert_at_platform);
84 #endif