source: rtems/cpukit/score/src/processormaskcopy.c @ 7a5e4d94

5
Last change on this file since 7a5e4d94 was 7a5e4d94, checked in by Sebastian Huber <sebastian.huber@…>, on 07/03/17 at 11:14:35

score: Add processor mask to/from cpu_set_t

Update #3059.

  • Property mode set to 100644
File size: 1.4 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
29Processor_mask_Copy_status _Processor_mask_Copy(
30  long       *dst,
31  size_t      dst_size,
32  const long *src,
33  size_t      src_size
34)
35{
36  long inclusive = 0;
37  long exclusive = 0;
38
39  if ( ( dst_size | src_size ) % sizeof( long ) != 0 ) {
40    return PROCESSOR_MASK_COPY_INVALID_SIZE;
41  }
42
43  while ( dst_size > 0 && src_size > 0 ) {
44    long bits = *src;
45
46    inclusive |= bits;
47    *dst = bits;
48    ++dst;
49    ++src;
50    dst_size -= sizeof( long );
51    src_size -= sizeof( long );
52  }
53
54  while ( dst_size > 0 ) {
55    *dst = 0;
56    ++dst;
57    dst_size -= sizeof( long );
58  }
59
60  while ( src_size > 0 ) {
61    exclusive |= *src;
62    ++src;
63    src_size -= sizeof( long );
64  }
65
66  if ( exclusive != 0 ) {
67    if ( inclusive != 0 ) {
68      return PROCESSOR_MASK_COPY_PARTIAL_LOSS;
69    } else {
70      return PROCESSOR_MASK_COPY_COMPLETE_LOSS;
71    }
72  }
73
74  return PROCESSOR_MASK_COPY_LOSSLESS;
75}
Note: See TracBrowser for help on using the repository browser.