source: rtems/cpukit/score/src/processormaskcopy.c @ 2afb22b

5
Last change on this file since 2afb22b was 7851555, checked in by Sebastian Huber <sebastian.huber@…>, on 07/03/17 at 12:05:26

score: Move processor affinity to Thread_Control

Update #3059.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Processor Mask Implementation
5 *
6 * @ingroup ScoreProcessorMask
7 */
8
9/*
10 * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.org/license/LICENSE.
21 */
22
23#if HAVE_CONFIG_H
24#include "config.h"
25#endif
26
27#include <rtems/score/processormask.h>
28
29const Processor_mask _Processor_mask_The_one_and_only = { .__bits[ 0 ] = 1 };
30
31Processor_mask_Copy_status _Processor_mask_Copy(
32  long       *dst,
33  size_t      dst_size,
34  const long *src,
35  size_t      src_size
36)
37{
38  long inclusive = 0;
39  long exclusive = 0;
40
41  if ( ( dst_size | src_size ) % sizeof( long ) != 0 ) {
42    return PROCESSOR_MASK_COPY_INVALID_SIZE;
43  }
44
45  while ( dst_size > 0 && src_size > 0 ) {
46    long bits = *src;
47
48    inclusive |= bits;
49    *dst = bits;
50    ++dst;
51    ++src;
52    dst_size -= sizeof( long );
53    src_size -= sizeof( long );
54  }
55
56  while ( dst_size > 0 ) {
57    *dst = 0;
58    ++dst;
59    dst_size -= sizeof( long );
60  }
61
62  while ( src_size > 0 ) {
63    exclusive |= *src;
64    ++src;
65    src_size -= sizeof( long );
66  }
67
68  if ( exclusive != 0 ) {
69    if ( inclusive != 0 ) {
70      return PROCESSOR_MASK_COPY_PARTIAL_LOSS;
71    } else {
72      return PROCESSOR_MASK_COPY_COMPLETE_LOSS;
73    }
74  }
75
76  return PROCESSOR_MASK_COPY_LOSSLESS;
77}
Note: See TracBrowser for help on using the repository browser.