From: Stefan Eßer <s...@freebsd.org> The introduction of <sched.h> improved compatibility with some 3rd party software, but caused the configure scripts of some ports to assume that they were run in a GLIBC compatible environment.
Parts of sched.h were made conditional on -D_WITH_CPU_SET_T being added to ports, but there still were compatibility issues due to invalid assumptions made in autoconfigure scripts. The differences between the FreeBSD version of macros like CPU_AND, CPU_OR, etc. and the GLIBC versions was in the number of arguments: FreeBSD used a 2-address scheme (one source argument is also used as the destination of the operation), while GLIBC uses a 3-adderess scheme (2 source operands and a separately passed destination). The GLIBC scheme provides a super-set of the functionality of the FreeBSD macros, since it does not prevent passing the same variable as source and destination arguments. In code that wanted to preserve both source arguments, the FreeBSD macros required a temporary copy of one of the source arguments. This patch set allows to unconditionally provide functions and macros expected by 3rd party software written for GLIBC based systems, but breaks builds of externally maintained sources that use any of the following macros: CPU_AND, CPU_ANDNOT, CPU_OR, CPU_XOR. One contributed driver (contrib/ofed/libmlx5) has been patched to support both the old and the new CPU_OR signatures. If this commit is merged to -STABLE, the version test will have to be extended to cover more ranges. Ports that have added -D_WITH_CPU_SET_T to build on -CURRENT do no longer require that option. The FreeBSD version has been bumped to 1400046 to reflect this incompatible change. Reviewed by: kib MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D33451 --- newlib/libc/sys/rtems/include/sys/_cpuset.h | 9 ++++++++- newlib/libc/sys/rtems/include/sys/bitset.h | 8 +++++--- newlib/libc/sys/rtems/include/sys/cpuset.h | 6 +----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/newlib/libc/sys/rtems/include/sys/_cpuset.h b/newlib/libc/sys/rtems/include/sys/_cpuset.h index c6383f363..f27bfcc03 100644 --- a/newlib/libc/sys/rtems/include/sys/_cpuset.h +++ b/newlib/libc/sys/rtems/include/sys/_cpuset.h @@ -1,4 +1,4 @@ -/*- +#/*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2008, Jeffrey Roberson <j...@freebsd.org> @@ -49,4 +49,11 @@ __BITSET_DEFINE(_cpuset, CPU_SETSIZE); typedef struct _cpuset cpuset_t; +#ifndef _KERNEL +__BEGIN_DECLS +cpuset_t *__cpuset_alloc(size_t set_size); +void __cpuset_free(cpuset_t *ptr); +__END_DECLS +#endif + #endif /* !_SYS__CPUSET_H_ */ diff --git a/newlib/libc/sys/rtems/include/sys/bitset.h b/newlib/libc/sys/rtems/include/sys/bitset.h index c9448a73a..5ff6beeb8 100644 --- a/newlib/libc/sys/rtems/include/sys/bitset.h +++ b/newlib/libc/sys/rtems/include/sys/bitset.h @@ -315,8 +315,6 @@ /* * Dynamically allocate a bitset. */ -#define __BITSET_ALLOC(_s, mt, mf) malloc(__BITSET_SIZE((_s)), mt, (mf)) - #define BIT_AND(_s, d, s) __BIT_AND(_s, d, s) #define BIT_AND2(_s, d, s1, s2) __BIT_AND2(_s, d, s1, s2) #define BIT_ANDNOT(_s, d, s) __BIT_ANDNOT(_s, d, s) @@ -354,7 +352,11 @@ #define BIT_XOR2(_s, d, s1, s2) __BIT_XOR2(_s, d, s1, s2) #define BIT_ZERO(_s, p) __BIT_ZERO(_s, p) -#define BITSET_ALLOC(_s, mt, mf) __BITSET_ALLOC(_s, mt, mf) +#if defined(_KERNEL) +#define BITSET_ALLOC(_s, mt, mf) malloc(__BITSET_SIZE((_s)), mt, (mf)) +#define BITSET_FREE(p, mt) free(p, mt) +#endif /* _KERNEL */ + #define BITSET_FSET(n) __BITSET_FSET(n) #define BITSET_SIZE(_s) __BITSET_SIZE(_s) #define BITSET_T_INITIALIZER(x) __BITSET_T_INITIALIZER(x) diff --git a/newlib/libc/sys/rtems/include/sys/cpuset.h b/newlib/libc/sys/rtems/include/sys/cpuset.h index e24bce30c..09278242f 100644 --- a/newlib/libc/sys/rtems/include/sys/cpuset.h +++ b/newlib/libc/sys/rtems/include/sys/cpuset.h @@ -71,14 +71,10 @@ typedef cpuset_t cpu_set_t; #define _cpu_set_bits(_setsize) (8 * (_setsize)) -#define CPU_ALLOC_SIZE(_num_cpus) (sizeof(long) * __bitset_words(_num_cpus)) +#define CPU_ALLOC_SIZE(_s) __BITSET_SIZE(_s) __BEGIN_DECLS -cpu_set_t *__cpuset_alloc(int num_cpus); - -void __cpuset_free(cpu_set_t *set); - static __inline cpu_set_t *CPU_ALLOC(int num_cpus) { return __cpuset_alloc(num_cpus); -- 2.35.3 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel