]> git.ipfire.org Git - thirdparty/gcc.git/commit
libcpp: Add support for gnu::offset #embed/__has_embed parameter
authorJakub Jelinek <jakub@redhat.com>
Thu, 12 Sep 2024 09:34:06 +0000 (11:34 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 12 Sep 2024 09:34:06 +0000 (11:34 +0200)
commit44058b847145166715f15e49fa8854f30e852f24
tree6a05f67450a55752b5494c725d0cc982d0d6cc72
parenteba6d2aa71a9b59386e5a2453cbe924371626b0b
libcpp: Add support for gnu::offset #embed/__has_embed parameter

The following patch adds on top of the just posted #embed patch
a first extension, gnu::offset which allows to seek in the data
file (for seekable files, otherwise read and throw away).
I think this is useful e.g. when some binary data start with
some well known header which shouldn't be included in the data etc.

2024-09-12  Jakub Jelinek  <jakub@redhat.com>

libcpp/
* internal.h (struct cpp_embed_params): Add offset member.
* directives.cc (EMBED_PARAMS): Add gnu::offset entry.
(enum embed_param_kind): Add NUM_EMBED_STD_PARAMS.
(_cpp_parse_embed_params): Use NUM_EMBED_STD_PARAMS rather than
NUM_EMBED_PARAMS when parsing standard parameters.  Parse gnu::offset
parameter.
* files.cc (struct _cpp_file): Add offset member.
(_cpp_stack_embed): Handle params->offset.
gcc/
* doc/cpp.texi (Binary Resource Inclusion): Document gnu::offset
#embed parameter.
gcc/testsuite/
* c-c++-common/cpp/embed-15.c: New test.
* c-c++-common/cpp/embed-16.c: New test.
* gcc.dg/cpp/embed-5.c: New test.
gcc/doc/cpp.texi
gcc/testsuite/c-c++-common/cpp/embed-15.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/cpp/embed-16.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/embed-5.c [new file with mode: 0644]
libcpp/directives.cc
libcpp/files.cc
libcpp/internal.h