|
Packit Service |
4f62bc |
/* x86 cache info.
|
|
Packit Service |
4f62bc |
Copyright (C) 2003-2020 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#if IS_IN (libc)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <assert.h>
|
|
Packit |
6c4009 |
#include <unistd.h>
|
|
Packit |
6c4009 |
#include <cpuid.h>
|
|
Packit Service |
4f62bc |
#include <ldsodefs.h>
|
|
Packit Service |
4f62bc |
#include <dl-cacheinfo.h>
|
|
Packit Service |
1c0d50 |
|
|
Packit |
6c4009 |
/* Get the value of the system variable NAME. */
|
|
Packit |
6c4009 |
long int
|
|
Packit |
6c4009 |
attribute_hidden
|
|
Packit |
6c4009 |
__cache_sysconf (int name)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
const struct cpu_features *cpu_features = __get_cpu_features ();
|
|
Packit |
6c4009 |
|
|
Packit Service |
881915 |
if (cpu_features->basic.kind == arch_kind_intel)
|
|
Packit |
6c4009 |
return handle_intel (name, cpu_features);
|
|
Packit |
6c4009 |
|
|
Packit Service |
881915 |
if (cpu_features->basic.kind == arch_kind_amd)
|
|
Packit |
6c4009 |
return handle_amd (name);
|
|
Packit |
6c4009 |
|
|
Packit Service |
1c0d50 |
if (cpu_features->basic.kind == arch_kind_zhaoxin)
|
|
Packit Service |
1c0d50 |
return handle_zhaoxin (name);
|
|
Packit Service |
1c0d50 |
|
|
Packit |
6c4009 |
// XXX Fill in more vendors.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* CPU not known, we have no information. */
|
|
Packit |
6c4009 |
return 0;
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit Service |
4f62bc |
# ifdef SHARED
|
|
Packit Service |
4f62bc |
/* NB: In libc.a, cacheinfo.h is included in libc-start.c. In libc.so,
|
|
Packit Service |
4f62bc |
cacheinfo.h is included here and call init_cacheinfo by initializing
|
|
Packit Service |
4f62bc |
a dummy function pointer via IFUNC relocation after CPU features in
|
|
Packit Service |
4f62bc |
ld.so have been initialized by DL_PLATFORM_INIT or IFUNC relocation. */
|
|
Packit Service |
4f62bc |
# include <cacheinfo.h>
|
|
Packit Service |
4f62bc |
# include <ifunc-init.h>
|
|
Packit |
6c4009 |
|
|
Packit Service |
4f62bc |
extern void __x86_cacheinfo (void) attribute_hidden;
|
|
Packit Service |
4f62bc |
const void (*__x86_cacheinfo_p) (void) attribute_hidden
|
|
Packit Service |
4f62bc |
= __x86_cacheinfo;
|
|
Packit Service |
541783 |
|
|
Packit Service |
4f62bc |
__ifunc (__x86_cacheinfo, __x86_cacheinfo, NULL, void, init_cacheinfo);
|
|
Packit Service |
bed2b7 |
# endif
|
|
Packit |
6c4009 |
#endif
|