Changeset 9561e24 in rtems-libbsd


Ignore:
Timestamp:
12/05/21 21:27:33 (12 months ago)
Author:
Stefan Eßer <se@…>
Branches:
6-freebsd-12
Children:
ba1b041
Parents:
63dae71
git-author:
Stefan Eßer <se@…> (12/05/21 21:27:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/28/22 11:26:14)
Message:

sys/bitset.h: reduce visibility of BIT_* macros

Add two underscore characters "" to names of BIT_* and BITSET_*
macros to move them to the implementation name space and to prevent
a name space pollution due to BIT_* macros in 3rd party programs with
conflicting parameter signatures.

These prefixed macro names are used in kernel header files to define
macros in e.g. sched.h, sys/cpuset.h and sys/domainset.h.

If C programs are built with either -D_KERNEL (automatically passed
when building a kernel or kernel modules) or -D_WANT_FREENBSD_BITSET
(or this macros is defined in the source code before including the
bitset macros), then all macros are made visible with their previous
names, too. E.g., both BIT_SET() and BIT_SET() are visible with
either of _KERNEL or _WANT_FREEBSD_BITSET defined.

The main reason for this change is that some 3rd party sources
including sched.h have been found to contain conflicting BIT_*
macros.

As a work-around, parts of shed.h have been made conditional and
depend on _WITH_CPU_SET_T being set when sched.h is included.
Ports that expect the full functionality provided by sched.h need
to be built with -D_WITH_CPU_SET_T. But this leads to conflicts if
BIT_* macros are defined in that program, too.

This patch set makes all of sched.h visible again without this
parameter being passed and without any name space pollution due
to BIT_* macros becoming visible when sched.h is included.

This patch set will be backported to the STABLE branches, but ports
will need to use -D_WITH_CPU_SET_T as long as there are supported
releases that do not contain these patches.

Reviewed by: kib, markj
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D33235

Location:
freebsd
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • freebsd/sbin/pfctl/pfctl_altq.c

    r63dae71 r9561e24  
    3232
    3333#define PFIOC_USE_LATEST
     34#define _WANT_FREEBSD_BITSET
    3435
    3536#include <sys/types.h>
  • freebsd/sbin/pfctl/pfctl_parser.h

    r63dae71 r9561e24  
    179179
    180180#define QPRI_BITSET_SIZE        256
    181 BITSET_DEFINE(qpri_bitset, QPRI_BITSET_SIZE);
     181__BITSET_DEFINE(qpri_bitset, QPRI_BITSET_SIZE);
    182182LIST_HEAD(gen_sc, segment);
    183183
  • freebsd/sys/sys/_domainset.h

    r63dae71 r9561e24  
    4444#endif
    4545
    46 BITSET_DEFINE(_domainset, DOMAINSET_SETSIZE);
     46__BITSET_DEFINE(_domainset, DOMAINSET_SETSIZE);
    4747typedef struct _domainset domainset_t;
    4848
  • freebsd/sys/sys/domainset.h

    r63dae71 r9561e24  
    4545
    4646
    47 #define DOMAINSET_CLR(n, p)             BIT_CLR(DOMAINSET_SETSIZE, n, p)
    48 #define DOMAINSET_COPY(f, t)            BIT_COPY(DOMAINSET_SETSIZE, f, t)
    49 #define DOMAINSET_ISSET(n, p)           BIT_ISSET(DOMAINSET_SETSIZE, n, p)
    50 #define DOMAINSET_SET(n, p)             BIT_SET(DOMAINSET_SETSIZE, n, p)
    51 #define DOMAINSET_ZERO(p)               BIT_ZERO(DOMAINSET_SETSIZE, p)
    52 #define DOMAINSET_FILL(p)               BIT_FILL(DOMAINSET_SETSIZE, p)
    53 #define DOMAINSET_SETOF(n, p)           BIT_SETOF(DOMAINSET_SETSIZE, n, p)
    54 #define DOMAINSET_EMPTY(p)              BIT_EMPTY(DOMAINSET_SETSIZE, p)
    55 #define DOMAINSET_ISFULLSET(p)          BIT_ISFULLSET(DOMAINSET_SETSIZE, p)
    56 #define DOMAINSET_SUBSET(p, c)          BIT_SUBSET(DOMAINSET_SETSIZE, p, c)
    57 #define DOMAINSET_OVERLAP(p, c)         BIT_OVERLAP(DOMAINSET_SETSIZE, p, c)
    58 #define DOMAINSET_CMP(p, c)             BIT_CMP(DOMAINSET_SETSIZE, p, c)
    59 #define DOMAINSET_OR(d, s)              BIT_OR(DOMAINSET_SETSIZE, d, s)
    60 #define DOMAINSET_AND(d, s)             BIT_AND(DOMAINSET_SETSIZE, d, s)
    61 #define DOMAINSET_NAND(d, s)            BIT_NAND(DOMAINSET_SETSIZE, d, s)
    62 #define DOMAINSET_CLR_ATOMIC(n, p)      BIT_CLR_ATOMIC(DOMAINSET_SETSIZE, n, p)
    63 #define DOMAINSET_SET_ATOMIC(n, p)      BIT_SET_ATOMIC(DOMAINSET_SETSIZE, n, p)
     47#define DOMAINSET_CLR(n, p)             __BIT_CLR(DOMAINSET_SETSIZE, n, p)
     48#define DOMAINSET_COPY(f, t)            __BIT_COPY(DOMAINSET_SETSIZE, f, t)
     49#define DOMAINSET_ISSET(n, p)           __BIT_ISSET(DOMAINSET_SETSIZE, n, p)
     50#define DOMAINSET_SET(n, p)             __BIT_SET(DOMAINSET_SETSIZE, n, p)
     51#define DOMAINSET_ZERO(p)               __BIT_ZERO(DOMAINSET_SETSIZE, p)
     52#define DOMAINSET_FILL(p)               __BIT_FILL(DOMAINSET_SETSIZE, p)
     53#define DOMAINSET_SETOF(n, p)           __BIT_SETOF(DOMAINSET_SETSIZE, n, p)
     54#define DOMAINSET_EMPTY(p)              __BIT_EMPTY(DOMAINSET_SETSIZE, p)
     55#define DOMAINSET_ISFULLSET(p)          __BIT_ISFULLSET(DOMAINSET_SETSIZE, p)
     56#define DOMAINSET_SUBSET(p, c)          __BIT_SUBSET(DOMAINSET_SETSIZE, p, c)
     57#define DOMAINSET_OVERLAP(p, c)         __BIT_OVERLAP(DOMAINSET_SETSIZE, p, c)
     58#define DOMAINSET_CMP(p, c)             __BIT_CMP(DOMAINSET_SETSIZE, p, c)
     59#define DOMAINSET_OR(d, s)              __BIT_OR(DOMAINSET_SETSIZE, d, s)
     60#define DOMAINSET_AND(d, s)             __BIT_AND(DOMAINSET_SETSIZE, d, s)
     61#define DOMAINSET_NAND(d, s)            __BIT_NAND(DOMAINSET_SETSIZE, d, s)
     62#define DOMAINSET_CLR_ATOMIC(n, p)      __BIT_CLR_ATOMIC(DOMAINSET_SETSIZE, n, p)
     63#define DOMAINSET_SET_ATOMIC(n, p)      __BIT_SET_ATOMIC(DOMAINSET_SETSIZE, n, p)
    6464#define DOMAINSET_SET_ATOMIC_ACQ(n, p)                                  \
    65             BIT_SET_ATOMIC_ACQ(DOMAINSET_SETSIZE, n, p)
    66 #define DOMAINSET_AND_ATOMIC(n, p)      BIT_AND_ATOMIC(DOMAINSET_SETSIZE, n, p)
    67 #define DOMAINSET_OR_ATOMIC(d, s)       BIT_OR_ATOMIC(DOMAINSET_SETSIZE, d, s)
     65            __BIT_SET_ATOMIC_ACQ(DOMAINSET_SETSIZE, n, p)
     66#define DOMAINSET_AND_ATOMIC(n, p)      __BIT_AND_ATOMIC(DOMAINSET_SETSIZE, n, p)
     67#define DOMAINSET_OR_ATOMIC(d, s)       __BIT_OR_ATOMIC(DOMAINSET_SETSIZE, d, s)
    6868#define DOMAINSET_COPY_STORE_REL(f, t)                                  \
    69             BIT_COPY_STORE_REL(DOMAINSET_SETSIZE, f, t)
    70 #define DOMAINSET_FFS(p)                BIT_FFS(DOMAINSET_SETSIZE, p)
    71 #define DOMAINSET_FLS(p)                BIT_FLS(DOMAINSET_SETSIZE, p)
    72 #define DOMAINSET_COUNT(p)              BIT_COUNT(DOMAINSET_SETSIZE, p)
    73 #define DOMAINSET_FSET                  BITSET_FSET(_NDOMAINSETWORDS)
    74 #define DOMAINSET_T_INITIALIZER         BITSET_T_INITIALIZER
     69            __BIT_COPY_STORE_REL(DOMAINSET_SETSIZE, f, t)
     70#define DOMAINSET_FFS(p)                __BIT_FFS(DOMAINSET_SETSIZE, p)
     71#define DOMAINSET_FLS(p)                __BIT_FLS(DOMAINSET_SETSIZE, p)
     72#define DOMAINSET_COUNT(p)              __BIT_COUNT(DOMAINSET_SETSIZE, p)
     73#define DOMAINSET_FSET                  __BITSET_FSET(_NDOMAINSETWORDS)
     74#define DOMAINSET_T_INITIALIZER         __BITSET_T_INITIALIZER
    7575
    7676#define DOMAINSET_POLICY_INVALID        0
Note: See TracChangeset for help on using the changeset viewer.