1 /* glibc-hwcaps subdirectory test.  powerpc64le version.
2    Copyright (C) 2020-2021 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 
28 /* Return the POWER level, 8 for the baseline.  */
29 static int
compute_level(void)30 compute_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   printf ("warning: unrecognized AT_PLATFORM value: %s\n", platform);
40   /* Assume that the new platform supports POWER10.  */
41   return 10;
42 }
43 
44 static int
do_test(void)45 do_test (void)
46 {
47   int level = compute_level ();
48   printf ("info: detected POWER level: %d\n", level);
49   TEST_COMPARE (marker2 (), MIN (level - 7, 2));
50   TEST_COMPARE (marker3 (), MIN (level - 7, 3));
51   return 0;
52 }
53 
54 #include <support/test-driver.c>
55