Skip to content

Commit 52775ff

Browse files
committed
kernel: rename reserved 'exp' symbol
This symbol is reserved and usage of reserved symbols violates the coding guidelines. (MISRA 21.2) NAME exp, expf, expl - base-e exponential function SYNOPSIS #include <math.h> double exp(double x); Signed-off-by: Anas Nashif <[email protected]>
1 parent 1b6933d commit 52775ff

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

lib/os/cbprintf_complete.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -884,14 +884,14 @@ static char *encode_float(double value,
884884
* whether the value is subnormal.
885885
*/
886886
char c = conv->specifier;
887-
int exp = (u.u64 >> FRACTION_BITS) & BIT_MASK(EXPONENT_BITS);
887+
int expo = (u.u64 >> FRACTION_BITS) & BIT_MASK(EXPONENT_BITS);
888888
uint64_t fract = u.u64 & BIT64_MASK(FRACTION_BITS);
889-
bool is_subnormal = (exp == 0) && (fract != 0);
889+
bool is_subnormal = (expo == 0) && (fract != 0);
890890

891891
/* Exponent of all-ones signals infinity or NaN, which are
892892
* text constants regardless of specifier.
893893
*/
894-
if (exp == BIT_MASK(EXPONENT_BITS)) {
894+
if (expo == BIT_MASK(EXPONENT_BITS)) {
895895
if (fract == 0) {
896896
if (isupper((int)c)) {
897897
*buf++ = 'I';
@@ -937,10 +937,10 @@ static char *encode_float(double value,
937937
* non-fractional value. Subnormals require increasing the
938938
* exponent as first bit isn't the implicit bit.
939939
*/
940-
exp -= 1023;
940+
expo -= 1023;
941941
if (is_subnormal) {
942942
*buf++ = '0';
943-
++exp;
943+
++expo;
944944
} else {
945945
*buf++ = '1';
946946
}
@@ -1017,15 +1017,15 @@ static char *encode_float(double value,
10171017
}
10181018

10191019
*buf++ = 'p';
1020-
if (exp >= 0) {
1020+
if (expo >= 0) {
10211021
*buf++ = '+';
10221022
} else {
10231023
*buf++ = '-';
1024-
exp = -exp;
1024+
expo = -expo;
10251025
}
10261026

10271027
aconv.specifier = 'i';
1028-
sp = encode_uint(exp, &aconv, buf, spe);
1028+
sp = encode_uint(expo, &aconv, buf, spe);
10291029

10301030
while (sp < spe) {
10311031
*buf++ = *sp++;
@@ -1043,64 +1043,64 @@ static char *encode_float(double value,
10431043
fract &= ~SIGN_MASK;
10441044

10451045
/* Non-zero values need normalization. */
1046-
if ((exp | fract) != 0) {
1046+
if ((expo | fract) != 0) {
10471047
if (is_subnormal) {
10481048
/* Fraction is subnormal. Normalize it and correct
10491049
* the exponent.
10501050
*/
10511051
while (((fract <<= 1) & BIT_63) == 0) {
1052-
exp--;
1052+
expo--;
10531053
}
10541054
}
10551055
/* Adjust the offset exponent to be signed rather than offset,
10561056
* and set the implicit 1 bit in the (shifted) 53-bit
10571057
* fraction.
10581058
*/
1059-
exp -= (1023 - 1); /* +1 since .1 vs 1. */
1059+
expo -= (1023 - 1); /* +1 since .1 vs 1. */
10601060
fract |= BIT_63;
10611061
}
10621062

10631063
/*
10641064
* Let's consider:
10651065
*
1066-
* value = fract * 2^exp * 10^decexp
1066+
* value = fract * 2^expo * 10^decexp
10671067
*
10681068
* Initially decexp = 0. The goal is to bring exp between
10691069
* 0 and -2 as the magnitude of a fractional decimal digit is 3 bits.
10701070
*/
10711071
int decexp = 0;
10721072

1073-
while (exp < -2) {
1073+
while (expo < -2) {
10741074
/*
10751075
* Make roon to allow a multiplication by 5 without overflow.
10761076
* We test only the top part for faster code.
10771077
*/
10781078
do {
10791079
fract >>= 1;
1080-
exp++;
1080+
expo++;
10811081
} while ((uint32_t)(fract >> 32) >= (UINT32_MAX / 5U));
10821082

10831083
/* Perform fract * 5 * 2 / 10 */
10841084
fract *= 5U;
1085-
exp++;
1085+
expo++;
10861086
decexp--;
10871087
}
10881088

1089-
while (exp > 0) {
1089+
while (expo > 0) {
10901090
/*
10911091
* Perform fract / 5 / 2 * 10.
10921092
* The +2 is there to do round the result of the division
10931093
* by 5 not to lose too much precision in extreme cases.
10941094
*/
10951095
fract += 2;
10961096
_ldiv5(&fract);
1097-
exp--;
1097+
expo--;
10981098
decexp++;
10991099

11001100
/* Bring back our fractional number to full scale */
11011101
do {
11021102
fract <<= 1;
1103-
exp--;
1103+
expo--;
11041104
} while (!(fract & BIT_63));
11051105
}
11061106

@@ -1109,7 +1109,7 @@ static char *encode_float(double value,
11091109
* Move it between bits 59 and 60 to give 4 bits of room to the
11101110
* integer part.
11111111
*/
1112-
fract >>= (4 - exp);
1112+
fract >>= (4 - expo);
11131113

11141114
if ((c == 'g') || (c == 'G')) {
11151115
/* Use the specified precision and exponent to select the

0 commit comments

Comments
 (0)