Blame sysdeps/powerpc/powerpc64/le/tst-glibc-hwcaps.c

Packit Service df6c8a
/* glibc-hwcaps subdirectory test.  powerpc64le version.
Packit Service df6c8a
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Service df6c8a
   This file is part of the GNU C Library.
Packit Service df6c8a
Packit Service df6c8a
   The GNU C Library is free software; you can redistribute it and/or
Packit Service df6c8a
   modify it under the terms of the GNU Lesser General Public
Packit Service df6c8a
   License as published by the Free Software Foundation; either
Packit Service df6c8a
   version 2.1 of the License, or (at your option) any later version.
Packit Service df6c8a
Packit Service df6c8a
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service df6c8a
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service df6c8a
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service df6c8a
   Lesser General Public License for more details.
Packit Service df6c8a
Packit Service df6c8a
   You should have received a copy of the GNU Lesser General Public
Packit Service df6c8a
   License along with the GNU C Library; if not, see
Packit Service df6c8a
   <https://www.gnu.org/licenses/>.  */
Packit Service df6c8a
Packit Service df6c8a
#include <stdio.h>
Packit Service df6c8a
#include <string.h>
Packit Service df6c8a
#include <support/check.h>
Packit Service df6c8a
#include <sys/auxv.h>
Packit Service df6c8a
#include <sys/param.h>
Packit Service df6c8a
Packit Service df6c8a
extern int marker2 (void);
Packit Service df6c8a
extern int marker3 (void);
Packit Service df6c8a
Packit Service df6c8a
/* Return the POWER level, 8 for the baseline.  */
Packit Service df6c8a
static int
Packit Service df6c8a
compute_level (void)
Packit Service df6c8a
{
Packit Service df6c8a
  const char *platform = (const char *) getauxval (AT_PLATFORM);
Packit Service df6c8a
  if (strcmp (platform, "power8") == 0)
Packit Service df6c8a
    return 8;
Packit Service df6c8a
  if (strcmp (platform, "power9") == 0)
Packit Service df6c8a
    return 9;
Packit Service df6c8a
  if (strcmp (platform, "power10") == 0)
Packit Service df6c8a
    return 10;
Packit Service df6c8a
  printf ("warning: unrecognized AT_PLATFORM value: %s\n", platform);
Packit Service df6c8a
  /* Assume that the new platform supports POWER10.  */
Packit Service df6c8a
  return 10;
Packit Service df6c8a
}
Packit Service df6c8a
Packit Service df6c8a
static int
Packit Service df6c8a
do_test (void)
Packit Service df6c8a
{
Packit Service df6c8a
  int level = compute_level ();
Packit Service df6c8a
  printf ("info: detected POWER level: %d\n", level);
Packit Service df6c8a
  TEST_COMPARE (marker2 (), MIN (level - 7, 2));
Packit Service df6c8a
  TEST_COMPARE (marker3 (), MIN (level - 7, 3));
Packit Service df6c8a
  return 0;
Packit Service df6c8a
}
Packit Service df6c8a
Packit Service df6c8a
#include <support/test-driver.c>