1 | /* glibc-hwcaps subdirectory test. s390x version. |
2 | Copyright (C) 2020-2024 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
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. |
9 | |
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. |
14 | |
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/>. */ |
18 | |
19 | #include <stdio.h> |
20 | #include <string.h> |
21 | #include <support/check.h> |
22 | #include <sys/auxv.h> |
23 | #include <sys/param.h> |
24 | |
25 | extern int marker2 (void); |
26 | extern int marker3 (void); |
27 | extern int marker4 (void); |
28 | extern int marker5 (void); |
29 | |
30 | /* Return the arch level, 10 for the baseline libmarkermod*.so's. */ |
31 | static int |
32 | compute_level (void) |
33 | { |
34 | const char *platform = (const char *) getauxval (AT_PLATFORM); |
35 | |
36 | /* The arch* versions refer to the edition of the Principles of |
37 | Operation, and they are off by two when compared with the recent |
38 | product names. (The code below should not be considered an |
39 | accurate mapping to Principles of Operation editions for earlier |
40 | AT_PLATFORM strings). */ |
41 | if (strcmp (platform, "z900" ) == 0) |
42 | return 10; |
43 | if (strcmp (platform, "z990" ) == 0) |
44 | return 10; |
45 | if (strcmp (platform, "z9-109" ) == 0) |
46 | return 10; |
47 | if (strcmp (platform, "z10" ) == 0) |
48 | return 10; |
49 | if (strcmp (platform, "z196" ) == 0) |
50 | return 10; |
51 | if (strcmp (platform, "zEC12" ) == 0) |
52 | return 10; |
53 | |
54 | /* If we are running on z13 or newer and the kernel was booted with novx, |
55 | then AT_PLATFORM is z13 or newer, but _dl_hwcaps_subdirs_active will |
56 | return zero and the _dl_hwcaps_subdirs are not searched. */ |
57 | const unsigned long int hwcap = getauxval (AT_HWCAP); |
58 | if ((hwcap & HWCAP_S390_VX) == 0) |
59 | return 10; |
60 | |
61 | if (strcmp (platform, "z13" ) == 0) |
62 | return 11; |
63 | if (strcmp (platform, "z14" ) == 0) |
64 | return 12; |
65 | if (strcmp (platform, "z15" ) == 0) |
66 | return 13; |
67 | if (strcmp (platform, "z16" ) == 0) |
68 | return 14; |
69 | printf (format: "warning: unrecognized AT_PLATFORM value: %s\n" , platform); |
70 | /* Assume that the new platform supports z16. */ |
71 | return 14; |
72 | } |
73 | |
74 | static int |
75 | do_test (void) |
76 | { |
77 | int level = compute_level (); |
78 | printf (format: "info: detected architecture level: arch%d\n" , level); |
79 | TEST_COMPARE (marker2 (), MIN (level - 9, 2)); |
80 | TEST_COMPARE (marker3 (), MIN (level - 9, 3)); |
81 | TEST_COMPARE (marker4 (), MIN (level - 9, 4)); |
82 | TEST_COMPARE (marker5 (), MIN (level - 9, 5)); |
83 | return 0; |
84 | } |
85 | |
86 | #include <support/test-driver.c> |
87 | |