On 14.01.2026 18:49, Matthieu Longo wrote:
> The prototype declaration macros currently do not allow functions to be
> excluded from the dynamic symbol table. There is an on-going effort in
> the bfd library in binutils to reduce the size of the dynamic symbol
> table by applying a visibility attribute to non-public symbols declared
> in headers.
> 
> The doubly linked list utilities are used in the bfd library, and
> therefore need to support passing such a visibility attribute to their
> function prototypes. This patch extends the existing DECL macros with
> a new ATTRIBUTE parameter.
> ---
>  include/doubly-linked-list.h                  | 89 ++++++++++---------
>  libiberty/testsuite/test-doubly-linked-list.c |  4 +-
>  2 files changed, 50 insertions(+), 43 deletions(-)
> 
> diff --git a/include/doubly-linked-list.h b/include/doubly-linked-list.h
> index 0108af73f96..c9db5220240 100644
> --- a/include/doubly-linked-list.h
> +++ b/include/doubly-linked-list.h
> @@ -30,9 +30,11 @@
>  
>     Each function (### is a placeholder for method name) has a macro for:
>     (1) its invocation LINKED_LIST_###(LTYPE).
> -   (2) its prototype LINKED_LIST_DECL_###(A, A2, scope). To add in a header
> -       file, or a source file for forward declaration. 'scope' should be set
> -       respectively to 'extern', or 'static'.
> +   (2) its prototype LINKED_LIST_DECL_###(A, A2, scope, visibility 
> attribute).

If already we add such a parameter (see below as to whether to), let's not
limit its potential purpose in the description. I.e. drop "visibility".

> +       To add in a header file, or a source file for forward declaration.
> +       'scope' should be set respectively to 'extern', or 'static'.
> +       'visibility attribute' can be used to set a visibility attribute to
> +       remove the symbol from the dynamic symbol table.
>     (3) its definition LINKED_LIST_DEFN_###(A, A2, scope). To add in a source
>         file with the 'scope' set respectively to nothing, or 'static' 
> depending
>         on (2).
> @@ -68,9 +70,9 @@
>     Precondition: prev and next of new_ must be NULL.  */
>  #define LINKED_LIST_APPEND(LTYPE)            LTYPE##_append
>  
> -#define LINKED_LIST_DECL_APPEND(LWRAPPERTYPE, LTYPE, EXPORT)         \
> +#define LINKED_LIST_DECL_APPEND(LWRAPPERTYPE, LTYPE, EXPORT, ATTRIBUTE)      
> \

Is the extra parameter really needed? Can't the use site of the macro ...

>    EXPORT void                                                                
> \

... append (or prepend?) it to what it passes for EXPORT? That may then also
allow use of this argument with e.g. MSVC's __declspec() (don't know whether
nowadays this is still of interest; it certainly used to be at some point).

Jan

Reply via email to