1/* glibc-hwcaps subdirectory test. powerpc64le 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
25extern int marker2 (void);
26extern int marker3 (void);
27
28/* Return the POWER level, 8 for the baseline. */
29static int
30compute_level (void)
31{
32 const char *platform = (const char *) getauxval (AT_PLATFORM);
33 if (strcmp (platform, "power8") == 0)
34 return 8;
35 if (strcmp (platform, "power9") == 0)
36 return 9;
37 if (strcmp (platform, "power10") == 0)
38 return 10;
39 if (strcmp (platform, "power11") == 0)
40 return 11;
41 printf (format: "warning: unrecognized AT_PLATFORM value: %s\n", platform);
42 /* Assume that the new platform supports POWER11. */
43 return 11;
44}
45
46static int
47do_test (void)
48{
49 int level = compute_level ();
50 printf (format: "info: detected POWER level: %d\n", level);
51 TEST_COMPARE (marker2 (), MIN (level - 7, 2));
52 TEST_COMPARE (marker3 (), MIN (level - 7, 3));
53 return 0;
54}
55
56#include <support/test-driver.c>
57

source code of glibc/sysdeps/powerpc/powerpc64/le/tst-glibc-hwcaps.c