summaryrefslogtreecommitdiffstats
path: root/cpukit/score
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-07-03 13:14:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-07-06 15:29:27 +0200
commit7a5e4d94774d2cbfeb96664ed7295f20b8618fe8 (patch)
tree6b375c8f969675d6db8729f9c90d005a1ae089f7 /cpukit/score
parentscore: Use <sys/bitset.h> for Processor_mask (diff)
downloadrtems-7a5e4d94774d2cbfeb96664ed7295f20b8618fe8.tar.bz2
score: Add processor mask to/from cpu_set_t
Update #3059.
Diffstat (limited to 'cpukit/score')
-rw-r--r--cpukit/score/Makefile.am1
-rw-r--r--cpukit/score/include/rtems/score/processormask.h52
-rw-r--r--cpukit/score/src/processormaskcopy.c75
3 files changed, 126 insertions, 2 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 46b441737f..1ac7c1545c 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -354,6 +354,7 @@ libscore_a_SOURCES += src/semaphore.c
libscore_a_SOURCES += src/smpbarrierwait.c
libscore_a_SOURCES += src/kern_tc.c
libscore_a_SOURCES += src/libatomic.c
+libscore_a_SOURCES += src/processormaskcopy.c
EXTRA_DIST = src/Unlimited.txt
diff --git a/cpukit/score/include/rtems/score/processormask.h b/cpukit/score/include/rtems/score/processormask.h
index ebf19ca035..27c35d38f1 100644
--- a/cpukit/score/include/rtems/score/processormask.h
+++ b/cpukit/score/include/rtems/score/processormask.h
@@ -25,8 +25,7 @@
#include <rtems/score/cpu.h>
-#include <sys/_bitset.h>
-#include <sys/bitset.h>
+#include <sys/cpuset.h>
#ifdef __cplusplus
extern "C" {
@@ -105,6 +104,55 @@ RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_To_uint32_t(
return (uint32_t) (bits >> (32 * (index % _BITSET_BITS) / 32));
}
+typedef enum {
+ PROCESSOR_MASK_COPY_LOSSLESS,
+ PROCESSOR_MASK_COPY_PARTIAL_LOSS,
+ PROCESSOR_MASK_COPY_COMPLETE_LOSS,
+ PROCESSOR_MASK_COPY_INVALID_SIZE
+} Processor_mask_Copy_status;
+
+RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_at_most_partial_loss(
+ Processor_mask_Copy_status status
+)
+{
+ return (unsigned int) status <= PROCESSOR_MASK_COPY_PARTIAL_LOSS;
+}
+
+Processor_mask_Copy_status _Processor_mask_Copy(
+ long *dst,
+ size_t dst_size,
+ const long *src,
+ size_t src_size
+);
+
+RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_To_cpu_set_t(
+ const Processor_mask *src,
+ size_t dst_size,
+ cpu_set_t *dst
+)
+{
+ return _Processor_mask_Copy(
+ &dst->__bits[ 0 ],
+ dst_size,
+ &src->__bits[ 0 ],
+ sizeof( *src )
+ );
+}
+
+RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_From_cpu_set_t(
+ Processor_mask *dst,
+ size_t src_size,
+ const cpu_set_t *src
+)
+{
+ return _Processor_mask_Copy(
+ &dst->__bits[ 0 ],
+ sizeof( *dst ),
+ &src->__bits[ 0 ],
+ src_size
+ );
+}
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/score/src/processormaskcopy.c b/cpukit/score/src/processormaskcopy.c
new file mode 100644
index 0000000000..bf8082d3c4
--- /dev/null
+++ b/cpukit/score/src/processormaskcopy.c
@@ -0,0 +1,75 @@
+/**
+ * @file
+ *
+ * @brief Processor Mask Implementation
+ *
+ * @ingroup ScoreProcessorMask
+ */
+
+/*
+ * Copyright (c) 2017 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/processormask.h>
+
+Processor_mask_Copy_status _Processor_mask_Copy(
+ long *dst,
+ size_t dst_size,
+ const long *src,
+ size_t src_size
+)
+{
+ long inclusive = 0;
+ long exclusive = 0;
+
+ if ( ( dst_size | src_size ) % sizeof( long ) != 0 ) {
+ return PROCESSOR_MASK_COPY_INVALID_SIZE;
+ }
+
+ while ( dst_size > 0 && src_size > 0 ) {
+ long bits = *src;
+
+ inclusive |= bits;
+ *dst = bits;
+ ++dst;
+ ++src;
+ dst_size -= sizeof( long );
+ src_size -= sizeof( long );
+ }
+
+ while ( dst_size > 0 ) {
+ *dst = 0;
+ ++dst;
+ dst_size -= sizeof( long );
+ }
+
+ while ( src_size > 0 ) {
+ exclusive |= *src;
+ ++src;
+ src_size -= sizeof( long );
+ }
+
+ if ( exclusive != 0 ) {
+ if ( inclusive != 0 ) {
+ return PROCESSOR_MASK_COPY_PARTIAL_LOSS;
+ } else {
+ return PROCESSOR_MASK_COPY_COMPLETE_LOSS;
+ }
+ }
+
+ return PROCESSOR_MASK_COPY_LOSSLESS;
+}