ld x86_64 tests: Accept x86-64-v3 as a needed ISA
[binutils-gdb.git] / libsframe / sframe-error.c
blobc6265eb8441424800eb08739f56827564d33a9cc
1 /* sframe-error.c - Error messages.
3 Copyright (C) 2022-2023 Free Software Foundation, Inc.
5 This file is part of libsframe.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "sframe-api.h"
21 #include <stddef.h>
22 #include <string.h>
24 /* In this file, we want to treat the first item of the SFrame error
25 macro like subsequent items. */
26 #define _SFRAME_FIRST(NAME, VALUE) _SFRAME_ITEM(NAME, VALUE)
28 /* The error message strings, each in a unique structure member precisely big
29 enough for that error, plus a str member to access them all as a string
30 table. */
32 static const char *const _sframe_errlist[] = {
33 #define _SFRAME_ITEM(n, s) s,
34 _SFRAME_ERRORS
35 #undef _SFRAME_ITEM
38 const char *
39 sframe_errmsg (int error)
41 const char *str;
43 if (error >= SFRAME_ERR_BASE && (error - SFRAME_ERR_BASE) < SFRAME_ERR_NERR)
44 str = _sframe_errlist[error - SFRAME_ERR_BASE];
45 else
46 str = (const char *) strerror (error);
48 return (str ? str : "Unknown error");