]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
include, libctf: deprecate ctf_lookup_enumerator_next
authorNick Alcock <nick.alcock@oracle.com>
Mon, 10 Nov 2025 15:52:47 +0000 (15:52 +0000)
committerNick Alcock <nick.alcock@oracle.com>
Tue, 9 Dec 2025 13:02:31 +0000 (13:02 +0000)
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.

include/ctf-api.h
libctf/Makefile.am
libctf/Makefile.in

index 0f408ece7c206102ed61c42aa8fd24df9447c0f7..f037e217f434eb222033e35f0a02b2ee12b9dca8 100644 (file)
@@ -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);
index 4e59c5e8f501012a39d1e43c3ca44a8696eae4cb..64c4a105bfd81edeb77751f6cc8fe02e03921515 100644 (file)
@@ -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
index 3309323bb2cf0d877fb256f0a25f533bdf190a13..2c5c86b37554cd92e86877df573c3eea5e6199b4 100644 (file)
@@ -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 =