2013-11-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
* libc/sys/rtems/cpusetalloc.c: New file. * libc/sys/rtems/cpusetfree.c: Likewise. * libc/sys/rtems/Makefile.am (lib_a_SOURCES): Add new files. * libc/sys/rtems/Makefile.in: Regenerate. * libc/sys/rtems/sys/cpuset.h: Delete #if 0 block. Include <stddef.h> for size_t. (_NCPUBITS): Avoid NBBY and assume 8 bits per char. (__cpuset_mask): Use int instead of size_t parameter for Linux compatibility. (__cpuset_index): Likewise. (__cpuset_alloc): Declare. (__cpuset_free): Likewise. (CPU_ALLOC_SIZE): Likewise. (CPU_ALLOC): Define. (CPU_FREE): Likewise. (CPU_ZERO_S): Likewise. (CPU_FILL_S): Likewise. (CPU_SET_S): Likewise. (CPU_CLR_S): Likewise. (CPU_ISSET_S): Likewise. (CPU_COUNT_S): Likewise. (CPU_AND_S): Likewise. (CPU_OR_S): Likewise. (CPU_XOR_S): Likewise. (CPU_NAND_S): Likewise. (CPU_EQUAL_S): Likewise. (CPU_ZERO): Use CPU_ZERO_S(). (CPU_FILL): Use CPU_FILL_S(). (CPU_SET): Use CPU_SET_S(). (CPU_CLR): Use CPU_CLR_S(). (CPU_ISSET): Use CPU_ISSET_S(). (CPU_COUNT): Use CPU_COUNT_S(). (CPU_AND): Use CPU_AND_S(). (CPU_OR): Use CPU_OR_S(). (CPU_XOR): Use CPU_XOR_S(). (CPU_NAND): Use CPU_NAND_S(). (CPU_EQUAL): Use CPU_EQUAL_S(). (CPU_CMP): Delete superfluous const qualifier. (CPU_EMPTY): Likewise.
This commit is contained in:
parent
376b177749
commit
2d50094276
|
@ -1,3 +1,45 @@
|
|||
2013-11-27 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||
|
||||
* libc/sys/rtems/cpusetalloc.c: New file.
|
||||
* libc/sys/rtems/cpusetfree.c: Likewise.
|
||||
* libc/sys/rtems/Makefile.am (lib_a_SOURCES): Add new files.
|
||||
* libc/sys/rtems/Makefile.in: Regenerate.
|
||||
* libc/sys/rtems/sys/cpuset.h: Delete #if 0 block. Include
|
||||
<stddef.h> for size_t.
|
||||
(_NCPUBITS): Avoid NBBY and assume 8 bits per char.
|
||||
(__cpuset_mask): Use int instead of size_t parameter for Linux
|
||||
compatibility.
|
||||
(__cpuset_index): Likewise.
|
||||
(__cpuset_alloc): Declare.
|
||||
(__cpuset_free): Likewise.
|
||||
(CPU_ALLOC_SIZE): Likewise.
|
||||
(CPU_ALLOC): Define.
|
||||
(CPU_FREE): Likewise.
|
||||
(CPU_ZERO_S): Likewise.
|
||||
(CPU_FILL_S): Likewise.
|
||||
(CPU_SET_S): Likewise.
|
||||
(CPU_CLR_S): Likewise.
|
||||
(CPU_ISSET_S): Likewise.
|
||||
(CPU_COUNT_S): Likewise.
|
||||
(CPU_AND_S): Likewise.
|
||||
(CPU_OR_S): Likewise.
|
||||
(CPU_XOR_S): Likewise.
|
||||
(CPU_NAND_S): Likewise.
|
||||
(CPU_EQUAL_S): Likewise.
|
||||
(CPU_ZERO): Use CPU_ZERO_S().
|
||||
(CPU_FILL): Use CPU_FILL_S().
|
||||
(CPU_SET): Use CPU_SET_S().
|
||||
(CPU_CLR): Use CPU_CLR_S().
|
||||
(CPU_ISSET): Use CPU_ISSET_S().
|
||||
(CPU_COUNT): Use CPU_COUNT_S().
|
||||
(CPU_AND): Use CPU_AND_S().
|
||||
(CPU_OR): Use CPU_OR_S().
|
||||
(CPU_XOR): Use CPU_XOR_S().
|
||||
(CPU_NAND): Use CPU_NAND_S().
|
||||
(CPU_EQUAL): Use CPU_EQUAL_S().
|
||||
(CPU_CMP): Delete superfluous const qualifier.
|
||||
(CPU_EMPTY): Likewise.
|
||||
|
||||
2013-11-27 Matheus Almeida <Matheus.Almeida@imgtec.com>
|
||||
|
||||
* libc/machine/mips/setjmp.S: Fix definition of macro FPR_LAYOUT
|
||||
|
|
|
@ -8,7 +8,7 @@ AM_CCASFLAGS = $(INCLUDES)
|
|||
|
||||
noinst_LIBRARIES = lib.a
|
||||
|
||||
lib_a_SOURCES = dummysys.c
|
||||
lib_a_SOURCES = dummysys.c cpusetalloc.c cpusetfree.c
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
|
||||
|
|
|
@ -69,7 +69,8 @@ LIBRARIES = $(noinst_LIBRARIES)
|
|||
ARFLAGS = cru
|
||||
lib_a_AR = $(AR) $(ARFLAGS)
|
||||
lib_a_LIBADD =
|
||||
am_lib_a_OBJECTS = lib_a-dummysys.$(OBJEXT)
|
||||
am_lib_a_OBJECTS = lib_a-dummysys.$(OBJEXT) \
|
||||
lib_a-cpusetalloc.$(OBJEXT) lib_a-cpusetfree.$(OBJEXT)
|
||||
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp =
|
||||
|
@ -193,7 +194,7 @@ AUTOMAKE_OPTIONS = cygnus
|
|||
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
||||
AM_CCASFLAGS = $(INCLUDES)
|
||||
noinst_LIBRARIES = lib.a
|
||||
lib_a_SOURCES = dummysys.c
|
||||
lib_a_SOURCES = dummysys.c cpusetalloc.c cpusetfree.c
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
|
||||
|
@ -262,6 +263,18 @@ lib_a-dummysys.o: dummysys.c
|
|||
lib_a-dummysys.obj: dummysys.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dummysys.obj `if test -f 'dummysys.c'; then $(CYGPATH_W) 'dummysys.c'; else $(CYGPATH_W) '$(srcdir)/dummysys.c'; fi`
|
||||
|
||||
lib_a-cpusetalloc.o: cpusetalloc.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cpusetalloc.o `test -f 'cpusetalloc.c' || echo '$(srcdir)/'`cpusetalloc.c
|
||||
|
||||
lib_a-cpusetalloc.obj: cpusetalloc.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cpusetalloc.obj `if test -f 'cpusetalloc.c'; then $(CYGPATH_W) 'cpusetalloc.c'; else $(CYGPATH_W) '$(srcdir)/cpusetalloc.c'; fi`
|
||||
|
||||
lib_a-cpusetfree.o: cpusetfree.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cpusetfree.o `test -f 'cpusetfree.c' || echo '$(srcdir)/'`cpusetfree.c
|
||||
|
||||
lib_a-cpusetfree.obj: cpusetfree.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cpusetfree.obj `if test -f 'cpusetfree.c'; then $(CYGPATH_W) 'cpusetfree.c'; else $(CYGPATH_W) '$(srcdir)/cpusetfree.c'; fi`
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2013 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cpuset.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
cpu_set_t *__cpuset_alloc(int num_cpus)
|
||||
{
|
||||
return (cpu_set_t *)malloc(CPU_ALLOC_SIZE(num_cpus));
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2013 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cpuset.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void __cpuset_free(cpu_set_t *set)
|
||||
{
|
||||
free(set);
|
||||
}
|
|
@ -45,11 +45,13 @@
|
|||
#ifndef _SYS_CPUSET_H_
|
||||
#define _SYS_CPUSET_H_
|
||||
|
||||
#if 0
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* RTEMS supports a maximum of 32 CPU cores */
|
||||
#ifndef CPU_SETSIZE
|
||||
#define CPU_SETSIZE 32
|
||||
|
@ -59,10 +61,9 @@
|
|||
typedef uint32_t cpu_set_word_t;
|
||||
|
||||
/* Number of bits per cpu_set_t element */
|
||||
#define _NCPUBITS (sizeof(cpu_set_word_t) * NBBY) /* bits per mask */
|
||||
#define _NCPUBITS (sizeof(cpu_set_word_t) * 8)
|
||||
|
||||
/* Number of words in the cpu_set_t array */
|
||||
/* NOTE: Can't use howmany() because of circular dependency */
|
||||
#define _NCPUWORDS (((CPU_SETSIZE)+((_NCPUBITS)-1))/(_NCPUBITS))
|
||||
|
||||
/* Define the cpu set structure */
|
||||
|
@ -71,49 +72,98 @@ typedef struct _cpuset {
|
|||
} cpu_set_t;
|
||||
|
||||
/* determine the mask for a particular cpu within the element */
|
||||
static inline cpu_set_word_t __cpuset_mask( size_t cpu )
|
||||
static inline cpu_set_word_t __cpuset_mask(int cpu)
|
||||
{
|
||||
return ((cpu_set_word_t)1 << ((cpu) % _NCPUBITS));
|
||||
return (cpu_set_word_t)1 << ((size_t)cpu % _NCPUBITS);
|
||||
}
|
||||
|
||||
/* determine the index for this cpu within the cpu set array */
|
||||
static inline size_t __cpuset_index( size_t cpu )
|
||||
static inline size_t __cpuset_index(int cpu)
|
||||
{
|
||||
return ((cpu)/_NCPUBITS);
|
||||
return (size_t)cpu / _NCPUBITS;
|
||||
}
|
||||
|
||||
/* zero out set */
|
||||
static inline void CPU_ZERO( cpu_set_t *set )
|
||||
#define CPU_ALLOC_SIZE(_num_cpus) \
|
||||
(sizeof(cpu_set_word_t) * (((_num_cpus) + _NCPUBITS - 1) / _NCPUBITS))
|
||||
|
||||
cpu_set_t *__cpuset_alloc(int num_cpus);
|
||||
|
||||
static inline cpu_set_t *CPU_ALLOC(int num_cpus)
|
||||
{
|
||||
return __cpuset_alloc(num_cpus);
|
||||
}
|
||||
|
||||
void __cpuset_free(cpu_set_t *set);
|
||||
|
||||
static inline void CPU_FREE(cpu_set_t *set)
|
||||
{
|
||||
__cpuset_free(set);
|
||||
}
|
||||
|
||||
static inline void CPU_ZERO_S(size_t setsize, cpu_set_t *set)
|
||||
{
|
||||
cpu_set_word_t *w = &set->__bits[0];
|
||||
size_t n = setsize / sizeof(*w);
|
||||
size_t i;
|
||||
for (i = 0; i < _NCPUWORDS; i++)
|
||||
set->__bits[i] = 0;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
w[i] = 0;
|
||||
}
|
||||
|
||||
/* fill set */
|
||||
static inline void CPU_FILL( cpu_set_t *set )
|
||||
static inline void CPU_ZERO(cpu_set_t *set)
|
||||
{
|
||||
CPU_ZERO_S(sizeof(*set), set);
|
||||
}
|
||||
|
||||
static inline void CPU_FILL_S(size_t setsize, cpu_set_t *set)
|
||||
{
|
||||
cpu_set_word_t *w = &set->__bits[0];
|
||||
size_t n = setsize / sizeof(*w);
|
||||
size_t i;
|
||||
for (i = 0; i < _NCPUWORDS; i++)
|
||||
set->__bits[i] = -1;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
w[i] = ~(cpu_set_word_t)0;
|
||||
}
|
||||
|
||||
/* set cpu within set */
|
||||
static inline void CPU_SET( size_t cpu, cpu_set_t *set )
|
||||
static inline void CPU_FILL(cpu_set_t *set)
|
||||
{
|
||||
set->__bits[__cpuset_index(cpu)] |= __cpuset_mask(cpu);
|
||||
CPU_FILL_S(sizeof(*set), set);
|
||||
}
|
||||
|
||||
/* clear cpu within set */
|
||||
static inline void CPU_CLR( size_t cpu, cpu_set_t *set )
|
||||
static inline void CPU_SET_S(int cpu, size_t setsize, cpu_set_t *set)
|
||||
{
|
||||
set->__bits[__cpuset_index(cpu)] &= ~__cpuset_mask(cpu);
|
||||
cpu_set_word_t *w = &set->__bits[0];
|
||||
|
||||
w[__cpuset_index(cpu)] |= __cpuset_mask(cpu);
|
||||
}
|
||||
|
||||
/* Return 1 is cpu is set in set, 0 otherwise */
|
||||
static inline int const CPU_ISSET( size_t cpu, const cpu_set_t *set )
|
||||
static inline void CPU_SET(int cpu, cpu_set_t *set)
|
||||
{
|
||||
return ((set->__bits[__cpuset_index(cpu)] & __cpuset_mask(cpu)) != 0);
|
||||
CPU_SET_S(cpu, sizeof(*set), set);
|
||||
}
|
||||
|
||||
static inline void CPU_CLR_S(int cpu, size_t setsize, cpu_set_t *set)
|
||||
{
|
||||
cpu_set_word_t *w = &set->__bits[0];
|
||||
|
||||
w[__cpuset_index(cpu)] &= ~__cpuset_mask(cpu);
|
||||
}
|
||||
|
||||
static inline void CPU_CLR(int cpu, cpu_set_t *set)
|
||||
{
|
||||
CPU_CLR_S(cpu, sizeof(*set), set);
|
||||
}
|
||||
|
||||
static inline int CPU_ISSET_S(int cpu, size_t setsize, cpu_set_t *set)
|
||||
{
|
||||
const cpu_set_word_t *w = &set->__bits[0];
|
||||
|
||||
return ((w[__cpuset_index(cpu)] & __cpuset_mask(cpu)) != 0);
|
||||
}
|
||||
|
||||
static inline int CPU_ISSET(int cpu, cpu_set_t *set)
|
||||
{
|
||||
return CPU_ISSET_S(cpu, sizeof(*set), set);
|
||||
}
|
||||
|
||||
/* copy src set to dest set */
|
||||
|
@ -122,79 +172,130 @@ static inline void CPU_COPY( cpu_set_t *dest, const cpu_set_t *src )
|
|||
*dest = *src;
|
||||
}
|
||||
|
||||
/* logical and: dest set = src1 set and src2 set */
|
||||
static inline void CPU_AND(
|
||||
cpu_set_t *dest, const cpu_set_t *src1, const cpu_set_t *src2
|
||||
)
|
||||
static inline void CPU_AND_S(size_t setsize, cpu_set_t *destset,
|
||||
const cpu_set_t *srcset1, const cpu_set_t *srcset2)
|
||||
{
|
||||
cpu_set_word_t *wdest = &destset->__bits[0];
|
||||
const cpu_set_word_t *wsrc1 = &srcset1->__bits[0];
|
||||
const cpu_set_word_t *wsrc2 = &srcset2->__bits[0];
|
||||
size_t n = setsize / sizeof(*wdest);
|
||||
size_t i;
|
||||
for (i = 0; i < _NCPUWORDS; i++)
|
||||
dest->__bits[i] = src1->__bits[i] & src2->__bits[i];
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
wdest[i] = wsrc1[i] & wsrc2[i];
|
||||
}
|
||||
|
||||
/* logical or: dest set = src1 set or src2 set */
|
||||
static inline void CPU_OR(
|
||||
cpu_set_t *dest, const cpu_set_t *src1, const cpu_set_t *src2
|
||||
)
|
||||
static inline void CPU_AND(cpu_set_t *destset, const cpu_set_t *srcset1,
|
||||
const cpu_set_t *srcset2)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < _NCPUWORDS; i++)
|
||||
dest->__bits[i] = src1->__bits[i] | src2->__bits[i];
|
||||
CPU_AND_S(sizeof(*destset), destset, srcset1, srcset2);
|
||||
}
|
||||
|
||||
/* logical xor: dest set = src1 set xor src2 set */
|
||||
static inline void CPU_XOR(
|
||||
cpu_set_t *dest, const cpu_set_t *src1, const cpu_set_t *src2
|
||||
)
|
||||
static inline void CPU_OR_S(size_t setsize, cpu_set_t *destset,
|
||||
const cpu_set_t *srcset1, const cpu_set_t *srcset2)
|
||||
{
|
||||
cpu_set_word_t *wdest = &destset->__bits[0];
|
||||
const cpu_set_word_t *wsrc1 = &srcset1->__bits[0];
|
||||
const cpu_set_word_t *wsrc2 = &srcset2->__bits[0];
|
||||
size_t n = setsize / sizeof(*wdest);
|
||||
size_t i;
|
||||
for (i = 0; i < _NCPUWORDS; i++)
|
||||
dest->__bits[i] = src1->__bits[i] ^ src2->__bits[i];
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
wdest[i] = wsrc1[i] | wsrc2[i];
|
||||
}
|
||||
|
||||
/* logical nand: dest set = src1 set nand src2 set */
|
||||
static inline void CPU_NAND(
|
||||
cpu_set_t *dest, const cpu_set_t *src1, const cpu_set_t *src2
|
||||
)
|
||||
static inline void CPU_OR(cpu_set_t *destset, const cpu_set_t *srcset1,
|
||||
const cpu_set_t *srcset2)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < _NCPUWORDS; i++)
|
||||
dest->__bits[i] = ~(src1->__bits[i] & src2->__bits[i]);
|
||||
CPU_OR_S(sizeof(*destset), destset, srcset1, srcset2);
|
||||
}
|
||||
|
||||
/* return the number of set cpus in set */
|
||||
static inline int const CPU_COUNT( const cpu_set_t *set )
|
||||
static inline void CPU_XOR_S(size_t setsize, cpu_set_t *destset,
|
||||
const cpu_set_t *srcset1, const cpu_set_t *srcset2)
|
||||
{
|
||||
cpu_set_word_t *wdest = &destset->__bits[0];
|
||||
const cpu_set_word_t *wsrc1 = &srcset1->__bits[0];
|
||||
const cpu_set_word_t *wsrc2 = &srcset2->__bits[0];
|
||||
size_t n = setsize / sizeof(*wdest);
|
||||
size_t i;
|
||||
int count = 0;
|
||||
|
||||
for (i=0; i < _NCPUWORDS; i++)
|
||||
if (CPU_ISSET(i, set) != 0)
|
||||
count++;
|
||||
for (i = 0; i < n; ++i)
|
||||
wdest[i] = wsrc1[i] ^ wsrc2[i];
|
||||
}
|
||||
|
||||
static inline void CPU_XOR(cpu_set_t *destset, const cpu_set_t *srcset1,
|
||||
const cpu_set_t *srcset2)
|
||||
{
|
||||
CPU_XOR_S(sizeof(*destset), destset, srcset1, srcset2);
|
||||
}
|
||||
|
||||
static inline void CPU_NAND_S(size_t setsize, cpu_set_t *destset,
|
||||
const cpu_set_t *srcset1, const cpu_set_t *srcset2)
|
||||
{
|
||||
cpu_set_word_t *wdest = &destset->__bits[0];
|
||||
const cpu_set_word_t *wsrc1 = &srcset1->__bits[0];
|
||||
const cpu_set_word_t *wsrc2 = &srcset2->__bits[0];
|
||||
size_t n = setsize / sizeof(*wdest);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
wdest[i] = ~(wsrc1[i] & wsrc2[i]);
|
||||
}
|
||||
|
||||
static inline void CPU_NAND(cpu_set_t *destset, const cpu_set_t *srcset1,
|
||||
const cpu_set_t *srcset2)
|
||||
{
|
||||
CPU_NAND_S(sizeof(*destset), destset, srcset1, srcset2);
|
||||
}
|
||||
|
||||
static inline int CPU_COUNT_S(size_t setsize, const cpu_set_t *set)
|
||||
{
|
||||
int count = 0;
|
||||
const cpu_set_word_t *w = &set->__bits[0];
|
||||
size_t n = setsize / sizeof(*w);
|
||||
size_t i;
|
||||
int cpu;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
for (cpu = 0; cpu < (int)_NCPUBITS; ++cpu)
|
||||
count += (w[i] & __cpuset_mask(cpu)) != 0;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* return 1 if the sets set1 and set2 are equal, otherwise return 0 */
|
||||
static inline int const CPU_EQUAL(
|
||||
const cpu_set_t *set1, const cpu_set_t *set2
|
||||
)
|
||||
static inline int CPU_COUNT(const cpu_set_t *set)
|
||||
{
|
||||
return CPU_COUNT_S(sizeof(*set), set);
|
||||
}
|
||||
|
||||
static inline int CPU_EQUAL_S(size_t setsize, const cpu_set_t *set1,
|
||||
const cpu_set_t *set2)
|
||||
{
|
||||
const cpu_set_word_t *w1 = &set1->__bits[0];
|
||||
const cpu_set_word_t *w2 = &set2->__bits[0];
|
||||
size_t n = setsize / sizeof(*w1);
|
||||
size_t i;
|
||||
|
||||
for (i=0; i < _NCPUWORDS; i++)
|
||||
if (set1->__bits[i] != set2->__bits[i] )
|
||||
for (i = 0; i < n; ++i)
|
||||
if (w1[i] != w2[i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int CPU_EQUAL(const cpu_set_t *set1, const cpu_set_t *set2)
|
||||
{
|
||||
return CPU_EQUAL_S(sizeof(*set1), set1, set2);
|
||||
}
|
||||
|
||||
/* return 1 if the sets set1 and set2 are equal, otherwise return 0 */
|
||||
static inline int const CPU_CMP( const cpu_set_t *set1, const cpu_set_t *set2 )
|
||||
static inline int CPU_CMP( const cpu_set_t *set1, const cpu_set_t *set2 )
|
||||
{
|
||||
return CPU_EQUAL(set1, set2);
|
||||
}
|
||||
|
||||
/* return 1 if the set is empty, otherwise return 0 */
|
||||
static inline int const CPU_EMPTY( const cpu_set_t *set )
|
||||
static inline int CPU_EMPTY( const cpu_set_t *set )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -204,4 +305,8 @@ static inline int const CPU_EMPTY( const cpu_set_t *set )
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue