[RFC 01/47] eal: add BSD version of queue.h

Stephen Hemminger stephen at networkplumber.org
Tue Aug 19 18:03:41 CEST 2025


On Tue, 19 Aug 2025 16:40:28 +0100
Bruce Richardson <bruce.richardson at intel.com> wrote:

> On Tue, Aug 19, 2025 at 05:29:28PM +0200, Thomas Monjalon wrote:
> > 19/08/2025 17:24, Stephen Hemminger:  
> > > On Tue, 19 Aug 2025 10:37:27 +0200
> > > Thomas Monjalon <thomas at monjalon.net> wrote:
> > >   
> > > > 19/08/2025 01:27, Stephen Hemminger:  
> > > > > +++ b/lib/eal/include/bsd_queue.h
> > > > > @@ -0,0 +1,1075 @@
> > > > > +/*-
> > > > > + * SPDX-License-Identifier: BSD-3-Clause
> > > > > + *
> > > > > + * Copyright (c) 1991, 1993
> > > > > + *     The Regents of the University of California.  All rights reserved.
> > > > > + *
> > > > > + * This is a copy of sys/queue.h which is used to overcome
> > > > > + * missing parts in the glibc version (and Windows).
> > > > > + */
> > > > > +
> > > > > +#ifndef _SYS_QUEUE_H_
> > > > > +#define _SYS_QUEUE_H_    
> > > > 
> > > > Shouldn't we rename this include flag? with RTE_ prefix?  
> > > 
> > > 
> > > No, by keeping the same prefix if the user includes both sys/queue.h and bsd_queue.h
> > > there will be no confilcts.  
> > 
> > You mean by checking _SYS_QUEUE_H_ which is the same as sys/queue.h?
> > So if I include sys/queue.h first, I will have a limited version.
> > It means we should not include it before any DPDK include.
> > It looks like a limitation for DPDK users.
> >   
> I think we should define two defines for our header, and warn if
> sys/queue.h is included first.
> 
> #ifndef _RTE_BSD_QUEUE_H_
> #ifdef _SYS_QUEUE_H_
> #warning ...
> #endif
> 
> #define _RTE_BSD_QUEUE_H_
> #define _SYS_QUEUE_H_
> 
> ...
> 
> #endif
> 
> This way, sys/queue.h contents will be skipped after our header, but if
> it's included first, the user gets a warning about incomplete
> implementation.
> 
> /Bruce

There is a similar issue with kernel headers already. And it lead
to lots if #ifdef __UAPI_DEF_XXX which I want to avoid.

Rather just do wholesale replacement and if application includes
the other header, it will work since the BSD stuff is only used
as add on.



More information about the dev mailing list