source: rtems/cpukit/score/src/processormaskcopy.c @ 4a0e418

Last change on this file since 4a0e418 was 4a0e418, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 21:09:20

score/src/[n-s]*.c: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSScoreProcessorMask
7 *
8 * @brief This source file contains the definition of
9 *   ::_Processor_mask_The_one_and_only and the implementation of
10 *   _Processor_mask_Copy().
11 */
12
13/*
14 * Copyright (c) 2017 embedded brains GmbH.  All rights reserved.
15 *
16 *  embedded brains GmbH
17 *  Dornierstr. 4
18 *  82178 Puchheim
19 *  Germany
20 *  <rtems@embedded-brains.de>
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 * 1. Redistributions of source code must retain the above copyright
26 *    notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 *    notice, this list of conditions and the following disclaimer in the
29 *    documentation and/or other materials provided with the distribution.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
32 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
35 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGE.
42 */
43
44#ifdef HAVE_CONFIG_H
45#include "config.h"
46#endif
47
48#include <rtems/score/processormask.h>
49
50const Processor_mask _Processor_mask_The_one_and_only = { .__bits[ 0 ] = 1 };
51
52Processor_mask_Copy_status _Processor_mask_Copy(
53  long       *dst,
54  size_t      dst_size,
55  const long *src,
56  size_t      src_size
57)
58{
59  long inclusive = 0;
60  long exclusive = 0;
61
62  if ( ( dst_size | src_size ) % sizeof( long ) != 0 ) {
63    return PROCESSOR_MASK_COPY_INVALID_SIZE;
64  }
65
66  while ( dst_size > 0 && src_size > 0 ) {
67    long bits = *src;
68
69    inclusive |= bits;
70    *dst = bits;
71    ++dst;
72    ++src;
73    dst_size -= sizeof( long );
74    src_size -= sizeof( long );
75  }
76
77  while ( dst_size > 0 ) {
78    *dst = 0;
79    ++dst;
80    dst_size -= sizeof( long );
81  }
82
83  while ( src_size > 0 ) {
84    exclusive |= *src;
85    ++src;
86    src_size -= sizeof( long );
87  }
88
89  if ( exclusive != 0 ) {
90    if ( inclusive != 0 ) {
91      return PROCESSOR_MASK_COPY_PARTIAL_LOSS;
92    } else {
93      return PROCESSOR_MASK_COPY_COMPLETE_LOSS;
94    }
95  }
96
97  return PROCESSOR_MASK_COPY_LOSSLESS;
98}
Note: See TracBrowser for help on using the repository browser.