argp: Don't pass invalid arguments to isspace, isalnum, isalpha, isdigit.
[glibc.git] / sysdeps / x86 / cacheinfo.h
blob0f0ca7c08cbce13d1c48d75c848e6a8dea8f586c
1 /* x86 cache info.
2 Copyright (C) 2020-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 <assert.h>
20 #include <unistd.h>
21 #include <cpuid.h>
22 #include <cpu-features.h>
24 #if HAVE_TUNABLES
25 # define TUNABLE_NAMESPACE cpu
26 # include <unistd.h> /* Get STDOUT_FILENO for _dl_printf. */
27 # include <elf/dl-tunables.h>
28 #endif
30 #if IS_IN (libc)
31 /* Data cache size for use in memory and string routines, typically
32 L1 size, rounded to multiple of 256 bytes. */
33 long int __x86_data_cache_size_half attribute_hidden = 32 * 1024 / 2;
34 long int __x86_data_cache_size attribute_hidden = 32 * 1024;
35 /* Similar to __x86_data_cache_size_half, but not rounded. */
36 long int __x86_raw_data_cache_size_half attribute_hidden = 32 * 1024 / 2;
37 /* Similar to __x86_data_cache_size, but not rounded. */
38 long int __x86_raw_data_cache_size attribute_hidden = 32 * 1024;
39 /* Shared cache size for use in memory and string routines, typically
40 L2 or L3 size, rounded to multiple of 256 bytes. */
41 long int __x86_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2;
42 long int __x86_shared_cache_size attribute_hidden = 1024 * 1024;
43 /* Similar to __x86_shared_cache_size_half, but not rounded. */
44 long int __x86_raw_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2;
45 /* Similar to __x86_shared_cache_size, but not rounded. */
46 long int __x86_raw_shared_cache_size attribute_hidden = 1024 * 1024;
48 /* Threshold to use non temporal store. */
49 long int __x86_shared_non_temporal_threshold attribute_hidden;
51 /* Threshold to use Enhanced REP MOVSB. */
52 long int __x86_rep_movsb_threshold attribute_hidden = 2048;
54 /* Threshold to use Enhanced REP STOSB. */
55 long int __x86_rep_stosb_threshold attribute_hidden = 2048;
57 /* Threshold to stop using Enhanced REP MOVSB. */
58 long int __x86_rep_movsb_stop_threshold attribute_hidden;
60 static void
61 init_cacheinfo (void)
63 const struct cpu_features *cpu_features = __get_cpu_features ();
64 long int data = cpu_features->data_cache_size;
65 __x86_raw_data_cache_size_half = data / 2;
66 __x86_raw_data_cache_size = data;
67 /* Round data cache size to multiple of 256 bytes. */
68 data = data & ~255L;
69 __x86_data_cache_size_half = data / 2;
70 __x86_data_cache_size = data;
72 long int shared = cpu_features->shared_cache_size;
73 __x86_raw_shared_cache_size_half = shared / 2;
74 __x86_raw_shared_cache_size = shared;
75 /* Round shared cache size to multiple of 256 bytes. */
76 shared = shared & ~255L;
77 __x86_shared_cache_size_half = shared / 2;
78 __x86_shared_cache_size = shared;
80 __x86_shared_non_temporal_threshold
81 = cpu_features->non_temporal_threshold;
83 __x86_rep_movsb_threshold = cpu_features->rep_movsb_threshold;
84 __x86_rep_stosb_threshold = cpu_features->rep_stosb_threshold;
85 __x86_rep_movsb_stop_threshold = cpu_features->rep_movsb_stop_threshold;
87 #endif