5
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 | |
---|
29 | Processor_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.