|
Packit |
6c4009 |
/* Reporting a numeric comparison failure.
|
|
Packit |
6c4009 |
Copyright (C) 2017-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <errno.h>
|
|
Packit |
6c4009 |
#include <stdio.h>
|
|
Packit |
6c4009 |
#include <support/check.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
static void
|
|
Packit |
6c4009 |
report (const char *which, const char *expr, long long value, int positive,
|
|
Packit |
6c4009 |
int size)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
printf (" %s: ", which);
|
|
Packit |
6c4009 |
if (positive)
|
|
Packit |
6c4009 |
printf ("%llu", (unsigned long long) value);
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
printf ("%lld", value);
|
|
Packit |
6c4009 |
unsigned long long mask
|
|
Packit |
6c4009 |
= (~0ULL) >> (8 * (sizeof (unsigned long long) - size));
|
|
Packit |
6c4009 |
printf (" (0x%llx); from: %s\n", (unsigned long long) value & mask, expr);
|
|
Packit |
6c4009 |
}
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
void
|
|
Packit |
6c4009 |
support_test_compare_failure (const char *file, int line,
|
|
Packit |
6c4009 |
const char *left_expr,
|
|
Packit |
6c4009 |
long long left_value,
|
|
Packit |
6c4009 |
int left_positive,
|
|
Packit |
6c4009 |
int left_size,
|
|
Packit |
6c4009 |
const char *right_expr,
|
|
Packit |
6c4009 |
long long right_value,
|
|
Packit |
6c4009 |
int right_positive,
|
|
Packit |
6c4009 |
int right_size)
|
|
Packit |
6c4009 |
{
|
|
Packit |
6c4009 |
int saved_errno = errno;
|
|
Packit |
6c4009 |
support_record_failure ();
|
|
Packit |
6c4009 |
if (left_size != right_size)
|
|
Packit |
6c4009 |
printf ("%s:%d: numeric comparison failure (widths %d and %d)\n",
|
|
Packit |
6c4009 |
file, line, left_size * 8, right_size * 8);
|
|
Packit |
6c4009 |
else
|
|
Packit |
6c4009 |
printf ("%s:%d: numeric comparison failure\n", file, line);
|
|
Packit |
6c4009 |
report (" left", left_expr, left_value, left_positive, left_size);
|
|
Packit |
6c4009 |
report ("right", right_expr, right_value, right_positive, right_size);
|
|
Packit |
6c4009 |
errno = saved_errno;
|
|
Packit |
6c4009 |
}
|