RTEMS
processormaskcopy.c
Go to the documentation of this file.
1 
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 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
26 
28 
29 const Processor_mask _Processor_mask_The_one_and_only = { .__bits[ 0 ] = 1 };
30 
31 Processor_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 }
Processor_mask_Copy_status _Processor_mask_Copy(long *dst, size_t dst_size, const long *src, size_t src_size)
Copies one mask to another.
Processor Mask API.