From: Nick Alcock Date: Mon, 10 Nov 2025 15:52:47 +0000 (+0000) Subject: include, libctf: deprecate ctf_lookup_enumerator_next X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21a906dec5400fb1d0bc98f61c52dcd6d07a608c;p=thirdparty%2Fbinutils-gdb.git include, libctf: deprecate ctf_lookup_enumerator_next This function is only useful for looking up enumerators in dictionaries where multiple enumerators can have the same value. C cannot define such dictionaries, and as of 2024 the deduplicator will not produce them, so they should get rarer over time. Adjust the deprecation attribute so that it's more specifically libctf-named, and arrange to turn it off when compiling libctf itself, because other functions (notably ctf_arc_lookup_enumerator_next) use ctf_lookup_enumerator_next internally, and we don't want deprecation warnings for internal uses by libctf of its own functionality. --- diff --git a/include/ctf-api.h b/include/ctf-api.h index 0f408ece7c2..f037e217f43 100644 --- a/include/ctf-api.h +++ b/include/ctf-api.h @@ -34,11 +34,11 @@ extern "C" { #endif -#ifndef __attribute__deprecated__ -# ifdef __GNUC__ -# define __attribute__deprecated__(x) __attribute__((__deprecated__(x))) +#ifndef __libctf_attribute_deprecated__ +# if defined (__GNUC__) && !defined(IN_LIBCTF) +# define __libctf_attribute_deprecated__(x) __attribute__((__deprecated__(x))) # else -# define __attribute__deprecated__(x) +# define __libctf_attribute_deprecated__(x) # endif #endif @@ -711,7 +711,7 @@ extern const char *ctf_type_name_raw (ctf_dict_t *, ctf_id_t); than LEN, return NULL, set ECTF_NAMELEN on the errno, and put the actual number of bytes needed into LEN. Consider using ctf_type_aname instead. */ -__attribute__deprecated__ ("consider using ctf_type_aname instead") +__libctf_attribute_deprecated__ ("consider using ctf_type_aname instead") extern char *ctf_type_sname (ctf_dict_t *, ctf_id_t, char *, size_t *); /* Retrieve raw (BTF or CTF-format) type data for the type with a given ID. @@ -861,8 +861,13 @@ extern const char *ctf_enum_next (ctf_dict_t *, ctf_id_t, ctf_next_t **, There is nothing preventing NAME from being changed by the caller in the middle of iteration: the results might be slightly confusing, but they are - well-defined. */ + well-defined. + This function is only useful for dicts containing multiple enumerators with + the same name. These things are not valid C, and as of 2024 the deduplicator + will not produce them; so this function is somewhat deprecated. */ + +__libctf_attribute_deprecated__("consider using ctf_lookup_enumerator instead") extern ctf_id_t ctf_lookup_enumerator_next (ctf_dict_t *, const char *name, ctf_next_t **, ctf_enum_value_t *enum_value); diff --git a/libctf/Makefile.am b/libctf/Makefile.am index 4e59c5e8f50..64c4a105bfd 100644 --- a/libctf/Makefile.am +++ b/libctf/Makefile.am @@ -40,7 +40,7 @@ ZLIBINC = @zlibinc@ BASEDIR = $(srcdir)/.. BFDDIR = $(BASEDIR)/bfd INCDIR = $(srcdir)/../include -AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@ +AM_CPPFLAGS = -D_GNU_SOURCE -DIN_LIBCTF -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@ AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC) if INSTALL_LIBBFD diff --git a/libctf/Makefile.in b/libctf/Makefile.in index 3309323bb2c..2c5c86b3755 100644 --- a/libctf/Makefile.in +++ b/libctf/Makefile.in @@ -599,7 +599,7 @@ ZLIBINC = @zlibinc@ BASEDIR = $(srcdir)/.. BFDDIR = $(BASEDIR)/bfd INCDIR = $(srcdir)/../include -AM_CPPFLAGS = -D_GNU_SOURCE -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@ +AM_CPPFLAGS = -D_GNU_SOURCE -DIN_LIBCTF -I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../bfd -I../bfd @INCINTL@ AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC) @INSTALL_LIBBFD_TRUE@lib_LTLIBRARIES = libctf.la libctf-nobfd.la @INSTALL_LIBBFD_FALSE@include_HEADERS =