mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-20 21:44:05 +08:00
score: Use unsigned type for processor masks
Using signed integers for bit fields may result in undefined or implementation-defined behaviour. Use an unsigned type instead. Requires a matching Newlib version. Update #4864. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This commit is contained in:
committed by
Joel Sherrill
parent
ba0b035a21
commit
7bc1fefaa8
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016, 2023 embedded brains GmbH & Co. KG
|
||||
* Copyright (C) 2016, 2026 embedded brains GmbH & Co. KG
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -297,7 +297,7 @@ static inline uint32_t _Processor_mask_To_uint32_t(
|
||||
uint32_t index
|
||||
)
|
||||
{
|
||||
long bits = mask->__bits[ index / _BITSET_BITS ];
|
||||
unsigned long bits = mask->__bits[ index / _BITSET_BITS ];
|
||||
|
||||
return (uint32_t) ( bits >> ( 32 * ( ( index % _BITSET_BITS ) / 32 ) ) );
|
||||
}
|
||||
@@ -317,7 +317,7 @@ static inline void _Processor_mask_From_uint32_t(
|
||||
)
|
||||
{
|
||||
_Processor_mask_Zero( mask );
|
||||
mask->__bits[ __bitset_words( index ) ] = ( (long) bits )
|
||||
mask->__bits[ __bitset_words( index ) ] = ( (unsigned long) bits )
|
||||
<< ( 32 *
|
||||
( index % _BITSET_BITS ) /
|
||||
32 );
|
||||
@@ -377,10 +377,10 @@ static inline bool _Processor_mask_Is_at_most_partial_loss(
|
||||
* is invalid (bigger than the size of a long).
|
||||
*/
|
||||
Processor_mask_Copy_status _Processor_mask_Copy(
|
||||
long *dst,
|
||||
size_t dst_size,
|
||||
const long *src,
|
||||
size_t src_size
|
||||
unsigned long *dst,
|
||||
size_t dst_size,
|
||||
const unsigned long *src,
|
||||
size_t src_size
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2017 embedded brains GmbH & Co. KG
|
||||
* Copyright (c) 2017, 2026 embedded brains GmbH & Co. KG
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -44,40 +44,40 @@
|
||||
const Processor_mask _Processor_mask_The_one_and_only = { .__bits[ 0 ] = 1 };
|
||||
|
||||
Processor_mask_Copy_status _Processor_mask_Copy(
|
||||
long *dst,
|
||||
size_t dst_size,
|
||||
const long *src,
|
||||
size_t src_size
|
||||
unsigned long *dst,
|
||||
size_t dst_size,
|
||||
const unsigned long *src,
|
||||
size_t src_size
|
||||
)
|
||||
{
|
||||
long inclusive = 0;
|
||||
long exclusive = 0;
|
||||
unsigned long inclusive = 0;
|
||||
unsigned long exclusive = 0;
|
||||
|
||||
if ( ( dst_size | src_size ) % sizeof( long ) != 0 ) {
|
||||
if ( ( dst_size | src_size ) % sizeof( unsigned long ) != 0 ) {
|
||||
return PROCESSOR_MASK_COPY_INVALID_SIZE;
|
||||
}
|
||||
|
||||
while ( dst_size > 0 && src_size > 0 ) {
|
||||
long bits = *src;
|
||||
unsigned long bits = *src;
|
||||
|
||||
inclusive |= bits;
|
||||
*dst = bits;
|
||||
++dst;
|
||||
++src;
|
||||
dst_size -= sizeof( long );
|
||||
src_size -= sizeof( long );
|
||||
dst_size -= sizeof( unsigned long );
|
||||
src_size -= sizeof( unsigned long );
|
||||
}
|
||||
|
||||
while ( dst_size > 0 ) {
|
||||
*dst = 0;
|
||||
++dst;
|
||||
dst_size -= sizeof( long );
|
||||
dst_size -= sizeof( unsigned long );
|
||||
}
|
||||
|
||||
while ( src_size > 0 ) {
|
||||
exclusive |= *src;
|
||||
++src;
|
||||
src_size -= sizeof( long );
|
||||
src_size -= sizeof( unsigned long );
|
||||
}
|
||||
|
||||
if ( exclusive != 0 ) {
|
||||
|
||||
Reference in New Issue
Block a user