]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - include/ChangeLog
libctf: restructure error handling to reduce relocations
authorNick Alcock <nick.alcock@oracle.com>
Tue, 2 Jun 2020 18:07:08 +0000 (19:07 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Wed, 22 Jul 2020 16:57:20 +0000 (17:57 +0100)
commit7eea9d3bdb037a3953101eccdb05826daf2da39a
tree9146958b0707822dabf56fc5e30381b0122f16e3
parentb64751cf0bc4466066c35e6c63348f900ce10272
libctf: restructure error handling to reduce relocations

Jose Marchesi noted that the traditional-Unix error array in ctf-error.c
introduces one reloc per error to initialize the array: 58 so far.  We
can reduce this to zero using an array of carefully-sized individual
members which is used to construct a string table, that is then
referenced by the lookup functions: but doing this automatically is a
pain.

Bruno Haible wrote suitable code years ago: I got permission to reuse it
(Bruno says "... which I hereby put in the public domain"); I modified
it a tiny bit (similarly to what Ulrich Drepper did in the dsohowto
text, but I redid it from scratch), commented it up a bit, and shifted
the error table into that form, migrating it into the new file
ctf-error.h.

This has the advantage that it spotted both typos in the text of the
errors in the comments in ctf-api.h and typos in the error defines in
the comments in ctf-error.c, and places where the two were simply not
in sync.  All are now fixed.

One new constant exists in ctf-api.h: CTF_NERR, since the old method of
working out the number of errors in ctf-error.c was no longer usable,
and it seems that the number of CTF errors is something users might
reasonably want as well.  It should be pretty easy to keep up to date as
new errors are introduced.

include/
* ctf-api.h (ECTF_*): Improve comments.
(ECTF_NERR): New.

libctf/
* ctf-error.c: Include <stddef.h>, for offsetof.
(_ctf_errlist): Migrate to...
(_ctf_errlist_t): ... this.
(_ctf_erridx): New, indexes into _ctf_errlist_t.
(_ctf_nerr): Remove.
(ctf_errmsg): Adjust accordingly.
* Makefile.am (BUILT_SOURCES): Note...
(ctf-error.h): ... this new rule.
* Makefile.in: Regenerate.
* mkerrors.sed: New, process ctf-api.h to generate ctf-error.h.
* .gitignore: New, ignore ctf-error.h.
include/ChangeLog
include/ctf-api.h
libctf/.gitignore [new file with mode: 0644]
libctf/ChangeLog
libctf/Makefile.am
libctf/Makefile.in
libctf/ctf-error.c
libctf/mkerrors.sed [new file with mode: 0644]