aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-error.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-10-21 08:54:17 -0600
committerTom Tromey <tromey@adacore.com>2020-10-21 11:52:17 -0600
commit0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2 (patch)
tree454f3fb08e8503fa243a44badf74f05a9a7128d9 /libctf/ctf-error.c
parentffd73a8b9ed30934b3cd00c15f5aa041621dcf9c (diff)
downloadfsf-binutils-gdb-0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2.zip
fsf-binutils-gdb-0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2.tar.gz
fsf-binutils-gdb-0d01fbe64f6f3f66fb6bd3b4e79e389e600b69a2.tar.bz2
Remove libctf/mkerrors.sed
This patch removes libctf/mkerrors.sed, replacing it with a macro in ctf-api.h. This simplifies the build and avoids possible unportable code in the sed script. 2020-10-21 Tom Tromey <tromey@adacore.com> * ctf-api.h (_CTF_ERRORS): New macro. libctf/ChangeLog 2020-10-21 Tom Tromey <tromey@adacore.com> * mkerrors.sed: Remove. * ctf-error.c (_CTF_FIRST): New define. (_CTF_ITEM): Define this, not _CTF_STR. (_ctf_errlist, _ctf_erridx): Use _CTF_ERRORS. (ERRSTRFIELD): Rewrite. (ERRSTRFIELD1): Remove. * Makefile.in: Rebuild. * Makefile.am (BUILT_SOURCES): Remove. (ctf-error.h): Remove.
Diffstat (limited to 'libctf/ctf-error.c')
-rw-r--r--libctf/ctf-error.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libctf/ctf-error.c b/libctf/ctf-error.c
index 9611e36..cb46a82 100644
--- a/libctf/ctf-error.c
+++ b/libctf/ctf-error.c
@@ -24,10 +24,13 @@
/* This construct is due to Bruno Haible: much thanks. */
/* Give each structure member a unique name. The name does not matter, so we
- use the line number in ctf-error.h to uniquify them. */
+ use the enum constant to uniquify them. */
-#define ERRSTRFIELD(line) ERRSTRFIELD1 (line)
-#define ERRSTRFIELD1(line) ctf_errstr##line
+#define ERRSTRFIELD(N) ctf_errstr##N
+
+/* In this file, we want to treat the first item of the ctf error
+ macro like subsequent items. */
+#define _CTF_FIRST(NAME, VALUE) _CTF_ITEM(NAME, VALUE)
/* The error message strings, each in a unique structure member precisely big
enough for that error, plus a str member to access them all as a string
@@ -37,17 +40,17 @@ static const union _ctf_errlist_t
{
__extension__ struct
{
-#define _CTF_STR(n, s) char ERRSTRFIELD (__LINE__) [sizeof (s)];
-#include "ctf-error.h"
-#undef _CTF_STR
+#define _CTF_ITEM(n, s) char ERRSTRFIELD (n) [sizeof (s)];
+_CTF_ERRORS
+#undef _CTF_ITEM
};
char str[1];
} _ctf_errlist =
{
{
-#define _CTF_STR(n, s) N_(s),
-#include "ctf-error.h"
-#undef _CTF_STR
+#define _CTF_ITEM(n, s) N_(s),
+_CTF_ERRORS
+#undef _CTF_ITEM
}
};
@@ -55,9 +58,9 @@ static const union _ctf_errlist_t
static const unsigned int _ctf_erridx[] =
{
-#define _CTF_STR(n, s) [n - ECTF_BASE] = offsetof (union _ctf_errlist_t, ERRSTRFIELD (__LINE__)),
-#include "ctf-error.h"
-#undef _CTF_STR
+#define _CTF_ITEM(n, s) [n - ECTF_BASE] = offsetof (union _ctf_errlist_t, ERRSTRFIELD (n)),
+_CTF_ERRORS
+#undef _CTF_ITEM
};
const char *