Skip to content

Commit f4d9fe8

Browse files
author
camilo
committed
fix for compliance
1 parent ebe01e8 commit f4d9fe8

File tree

18 files changed

+45
-41
lines changed

18 files changed

+45
-41
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![MISRAC++2008](https://img.shields.io/badge/MISRAC++2008-Compliant-blue.svg?logo=verizon)](https://www.misra.org.uk/)
66
[![CERT](https://img.shields.io/badge/CERT-Compliant-blue.svg?logo=cplusplus)](https://wiki.sei.cmu.edu/confluence/display/seccode/SEI+CERT+Coding+Standards)
77
[![C++ Standard](https://img.shields.io/badge/STD-C++11-green.svg?logo=cplusplus)](https://en.cppreference.com/w/cpp/11)
8+
[![arduino-library-badge](https://www.ardu-badge.com/badge/qlibs.svg?)](https://www.ardu-badge.com/qlibs)
89
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?logo=textpattern)](https://github.com/kmilo17pet/QuarkTS-cpp/graphs/commit-activity)
910
[![License](https://img.shields.io/github/license/kmilo17pet/QuarkTS-cpp?logo=livejournal)](https://github.com/kmilo17pet/QuarkTS-cpp/blob/master/LICENSE)
1011

src/bitfield.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <include/bitfield.hpp>
2-
#include <cstring>
32

43
using namespace qlibs;
54

@@ -28,7 +27,7 @@ bool bitfield::clearAll( void ) noexcept
2827
bool retValue = false;
2928

3029
if ( nullptr != field ) {
31-
(void)std::memset( field, 0, size/8U );
30+
(void)memset( field, 0, size/8U );
3231
retValue = true;
3332
}
3433
return retValue;
@@ -39,7 +38,7 @@ bool bitfield::setAll( void ) noexcept
3938
bool retValue = false;
4039

4140
if ( nullptr != field ) {
42-
(void)std::memset( field, 0xFF, size/8U );
41+
(void)memset( field, 0xFF, size/8U );
4342
retValue = true;
4443
}
4544

@@ -169,7 +168,7 @@ float bitfield::readFloat( const size_t index ) const noexcept
169168
uint32_t rval;
170169

171170
rval = read_uint32( index );
172-
(void)std::memcpy( &retValue, &rval, sizeof(float) );
171+
(void)memcpy( &retValue, &rval, sizeof(float) );
173172
}
174173

175174
return retValue;
@@ -183,7 +182,7 @@ bool bitfield::writeFloat( const size_t index,
183182
if ( nullptr != field ) {
184183
uint32_t fval = 0U;
185184

186-
(void)std::memcpy( &fval, &value, sizeof(float) );
185+
(void)memcpy( &fval, &value, sizeof(float) );
187186
write_uint32( index, fval );
188187
retValue = true;
189188
}
@@ -198,7 +197,7 @@ void* bitfield::dump( void * const dst,
198197

199198
if ( ( nullptr != field ) && ( nullptr != dst ) ) {
200199
if ( n <= ( size/8U ) ) {
201-
retValue = std::memcpy( dst, static_cast<const void*>( field ), n );
200+
retValue = memcpy( dst, static_cast<const void*>( field ), n );
202201
}
203202
}
204203

src/fp16.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using namespace qlibs;
44

55
fp16Raw_t fp16::Min = -2147483647; // skipcq: CXX-W2009
66
fp16Raw_t fp16::Max = 2147483647; // skipcq: CXX-W2009
7-
bool fp16::rounding = true; // skipcq: CXX-W2009
7+
bool fp16::flag_rounding = true; // skipcq: CXX-W2009
88
bool fp16::saturation = false; // skipcq: CXX-W2009
99
const fp16Raw_t fp16::exp_max = 681391;
1010
const fp16Raw_t fp16::f2 = 131072;
@@ -22,7 +22,7 @@ int fp16::toInt( const fp16 &x ) noexcept
2222
{
2323
int retValue;
2424

25-
if ( rounding ) {
25+
if ( flag_rounding ) {
2626
if ( x.value >= 0 ) {
2727
retValue = ( x.value + ( one >> 1 ) ) / one;
2828
}
@@ -61,7 +61,7 @@ fp16Raw_t fp16::fromFloat( const float x ) noexcept
6161
float f_value;
6262
/*cstat -CERT-FLP36-C -CERT-FLP34-C*/
6363
f_value = x * static_cast<float>( one );
64-
if ( rounding ) {
64+
if ( flag_rounding ) {
6565
f_value += ( f_value >= 0.0F ) ? 0.5F : -0.5F;
6666
}
6767
return static_cast<fp16Raw_t>( f_value );
@@ -73,7 +73,7 @@ fp16Raw_t fp16::fromDouble( const double x ) noexcept
7373
double d_value;
7474
/*cstat -CERT-FLP36-C -CERT-FLP34-C*/
7575
d_value = x * static_cast<double>( one );
76-
if ( rounding ) {
76+
if ( flag_rounding ) {
7777
d_value += ( d_value >= 0.0 ) ? 0.5 : -0.5;
7878
}
7979
return static_cast<fp16Raw_t>( d_value );
@@ -149,7 +149,7 @@ fp16Raw_t fp16::mul( const fp16Raw_t x,
149149
a = ( mulH < 0 ) ? -1 : 0;
150150
/*cstat +MISRAC++2008-5-0-3*/
151151
if ( a == ( mulH >> 15 ) ) {
152-
if ( rounding ) {
152+
if ( flag_rounding ) {
153153
uint32_t tmp2;
154154

155155
tmp2 = mulL;
@@ -207,7 +207,7 @@ fp16Raw_t fp16::div( const fp16Raw_t x,
207207
xRem <<= 1;
208208
bit >>= 1;
209209
}
210-
if ( rounding ) {
210+
if ( flag_rounding ) {
211211
if ( xRem >= xDiv ) {
212212
++quotient;
213213
}
@@ -228,7 +228,7 @@ fp16Raw_t fp16::div( const fp16Raw_t x,
228228
return saturate( retValue, x, y );
229229
}
230230
/*============================================================================*/
231-
fp16Raw_t fp16::abs( fp16Raw_t x ) noexcept
231+
fp16Raw_t fp16::absolute( fp16Raw_t x ) noexcept
232232
{
233233
fp16Raw_t retValue;
234234

@@ -260,7 +260,7 @@ fp16Raw_t fp16::sqrt( fp16Raw_t x ) noexcept
260260

261261
retValue = 0;
262262
/*cstat -MISRAC++2008-5-0-3*/
263-
bit = ( 0 != ( x & static_cast<fp16Raw_t>( 4293918720 ) ) ) ? ( 1U << 30U ) : ( 1U << 18U );
263+
bit = ( 0 != ( x & static_cast<fp16Raw_t>( 4293918720 ) ) ) ? 1073741824U : 262144U;
264264
/*cstat +MISRAC++2008-5-0-3*/
265265
while ( bit > static_cast<uint32_t>( x ) ) {
266266
bit >>= 2U;
@@ -292,7 +292,7 @@ fp16Raw_t fp16::sqrt( fp16Raw_t x ) noexcept
292292
}
293293
}
294294
}
295-
if ( ( rounding ) && ( x > retValue ) ) {
295+
if ( ( flag_rounding ) && ( x > retValue ) ) {
296296
++retValue;
297297
}
298298

@@ -386,7 +386,7 @@ fp16Raw_t fp16::rs( fp16Raw_t x ) noexcept
386386
{
387387
fp16Raw_t retValue;
388388

389-
if ( rounding ) {
389+
if ( flag_rounding ) {
390390
retValue = ( x >> 1U ) + ( x & 1 );
391391
}
392392
else {
@@ -418,7 +418,7 @@ fp16Raw_t fp16::log2i( fp16Raw_t x ) noexcept
418418
x = rs( x );
419419
}
420420
}
421-
if ( rounding ) {
421+
if ( flag_rounding ) {
422422
x = mul( x, x );
423423
if ( x >= f2 ) {
424424
++retValue;
@@ -657,7 +657,7 @@ fp16Raw_t fp16::tanh( fp16Raw_t x ) noexcept
657657
retValue = -one;
658658
}
659659
else {
660-
retValue = abs( x );
660+
retValue = absolute( x );
661661
epx = exp( retValue );
662662
enx = exp( -retValue );
663663
retValue = div( epx - enx, epx + enx );
@@ -704,7 +704,7 @@ fp16Raw_t fp16::pow( fp16Raw_t x,
704704
}
705705
else {
706706
fp16Raw_t tmp;
707-
tmp = mul( y, log( abs( x ) ) );
707+
tmp = mul( y, log( absolute( x ) ) );
708708
if ( overflow != tmp ) {
709709
retValue = exp( tmp );
710710
if ( x < 0 ) {

src/generic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void* generic::set( void * const pbase,
223223

224224
if ( ( nullptr != pbase ) && ( size > 0U ) && ( n > 0U ) && ( nullptr != ref ) ) {
225225
for ( size_t i = 0U ; i < n ; i++ ) {
226-
retVal = std::memcpy( &p[ size*i ], ref, size );
226+
retVal = memcpy( &p[ size*i ], ref, size );
227227
}
228228
}
229229

src/include/bitfield.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef QLIBS_BITFIELD
1111
#define QLIBS_BITFIELD
1212

13-
#include "include/types.hpp"
13+
#include "include/qlibs_types.hpp"
1414

1515

1616
/**

src/include/crc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef QLIBS_CRC
1010
#define QLIBS_CRC
1111

12-
#include "include/types.hpp"
12+
#include "include/qlibs_types.hpp"
1313

1414
/**
1515
* @brief The qLibs++ library namespace.

src/include/fis.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef QLIBS_FIS
1010
#define QLIBS_FIS
1111

12-
#include "include/types.hpp"
12+
#include "include/qlibs_types.hpp"
1313

1414
/**
1515
* @brief The qLibs++ library namespace.

src/include/fp16.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
#ifndef QLIBS_FP16
1010
#define QLIBS_FP16
1111

12-
#include "include/types.hpp"
13-
#include <iostream>
12+
#include "include/qlibs_types.hpp"
13+
#if !defined( ARDUINO_PLATFORM )
14+
#include <iostream>
15+
#endif
1416

1517
/**
1618
* @brief The qLibs++ library namespace.
@@ -34,7 +36,7 @@ namespace qlibs {
3436
fp16Raw_t value{ overflow };
3537
static fp16Raw_t Min; // skipcq: CXX-W2009
3638
static fp16Raw_t Max; // skipcq: CXX-W2009
37-
static bool rounding; // skipcq: CXX-W2009
39+
static bool flag_rounding; // skipcq: CXX-W2009
3840
static bool saturation; // skipcq: CXX-W2009
3941

4042
static const fp16Raw_t exp_max;
@@ -64,7 +66,7 @@ namespace qlibs {
6466
const fp16Raw_t y ) noexcept;
6567
static fp16Raw_t div( const fp16Raw_t x,
6668
const fp16Raw_t y ) noexcept;
67-
static fp16Raw_t abs( fp16Raw_t x ) noexcept;
69+
static fp16Raw_t absolute( fp16Raw_t x ) noexcept;
6870
static fp16Raw_t ceil( fp16Raw_t x ) noexcept;
6971
static fp16Raw_t sqrt( fp16Raw_t x ) noexcept;
7072
static fp16Raw_t exp( fp16Raw_t x ) noexcept;
@@ -318,7 +320,7 @@ namespace qlibs {
318320
* @param[in] x The fixed-point(q16.16) value.
319321
* @return This function returns the nearest integral value of @a x.
320322
*/
321-
static inline fp16 round( const fp16 &x ) noexcept
323+
static inline fp16 rounding( const fp16 &x ) noexcept
322324
{
323325
return fp16( { x.raw() + one } );
324326
}
@@ -328,9 +330,9 @@ namespace qlibs {
328330
* @param[in] x The fixed-point(q16.16) value.
329331
* @return This function returns the absolute value of x.
330332
*/
331-
static inline fp16 abs( const fp16 &x ) noexcept
333+
static inline fp16 absolute( const fp16 &x ) noexcept
332334
{
333-
return fp16( { abs( x.raw() ) } );
335+
return fp16( { absolute( x.raw() ) } );
334336
}
335337

336338
/**
@@ -576,13 +578,15 @@ namespace qlibs {
576578
};
577579

578580
/*! @cond */
581+
#if !defined( ARDUINO_PLATFORM )
579582
inline std::ostream& operator<<( std::ostream& os,
580583
const fp16& obj )
581584
{
582585
char buff[ 64 ] = { 0 };
583586
os << fp16::toASCII( obj, buff, static_cast<int>( os.precision() ) );
584587
return os;
585588
}
589+
#endif
586590
/*cstat -MISRAC++2008-5-0-7 -CERT-FLP34-C -MISRAC++2008-5-0-9*/
587591
constexpr fp16 operator"" _fp( long double val )
588592
{

src/include/generic.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef QLIBS_GENERIC
22
#define QLIBS_GENERIC
33

4-
#include "include/types.hpp"
4+
#include "include/qlibs_types.hpp"
55

66
/*!
77
* @file generic.hpp

src/include/ltisys.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef QLIBS_LTISYS
1010
#define QLIBS_LTISYS
1111

12-
#include "include/types.hpp"
12+
#include "include/qlibs_types.hpp"
1313
#include "include/tdl.hpp"
1414
#include "include/numa.hpp"
1515

0 commit comments

Comments
 (0)