1 /* Check ISA level on shared object in glibc-hwcaps subdirectories.
2 Copyright (C) 2021-2023 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/>. */
23 #include <get-isa-level.h>
24 #include <support/check.h>
25 #include <support/test-driver.h>
27 extern int dso_isa_level (void);
32 const struct cpu_features
*cpu_features
= __get_cpu_features ();
33 unsigned int isa_level
= get_isa_level (cpu_features
);
34 bool has_isa_baseline
= ((isa_level
& GNU_PROPERTY_X86_ISA_1_BASELINE
)
35 == GNU_PROPERTY_X86_ISA_1_BASELINE
);
36 bool has_isa_v2
= ((isa_level
& GNU_PROPERTY_X86_ISA_1_V2
)
37 == GNU_PROPERTY_X86_ISA_1_V2
);
38 bool has_isa_v3
= ((isa_level
& GNU_PROPERTY_X86_ISA_1_V3
)
39 == GNU_PROPERTY_X86_ISA_1_V3
);
40 bool has_isa_v4
= ((isa_level
& GNU_PROPERTY_X86_ISA_1_V4
)
41 == GNU_PROPERTY_X86_ISA_1_V4
);
43 if (!has_isa_baseline
)
46 int level
= dso_isa_level ();
52 /* The default libx86-64-isa-level.so is used. */
53 printf ("The default shared library is used.\n");
54 if (has_isa_v3
|| has_isa_v4
|| (!has_isa_v2
&& level
== 2))
60 /* libx86-64-isa-level.so marked as x86-64 ISA level 3 needed in
61 x86-64-v2 should be ignored on lesser CPU. */
62 printf ("x86-64 ISA level 3 shared library is used.\n");
63 if (has_isa_v4
|| !has_isa_v3
)
69 /* libx86-64-isa-level.so marked as x86-64 ISA level 4 needed in
70 x86-64-v3 should be ignored on lesser CPU. */
71 printf ("x86-64 ISA level 4 shared library is used.\n");
83 #include <support/test-driver.c>