diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2017-01-15 09:25:33 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2017-01-15 09:25:33 +0000 |
commit | d75a7880850137d06e72a9f161dbf3f2850ea54b (patch) | |
tree | e082f4f8e18f267e1a7ae6a5781279b8d03f0d26 /sys/kern | |
parent | 437999a767914f1e420da3069ad8a45663171fc2 (diff) | |
download | src-d75a7880850137d06e72a9f161dbf3f2850ea54b.tar.gz src-d75a7880850137d06e72a9f161dbf3f2850ea54b.zip |
Revert r312119 and reword the intent to fix -Wshadow issues
between exp(3) and `exp` var.
The approach taken previously was not ideal for multiple
functional and stylistic reasons.
Add to existing sed call in Makefile to replace `exp` with
`exponent` instead.
MFC after: 13 days
Requested by: bde
Notes
Notes:
svn path=/head/; revision=312216
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_acct.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 5d17642e625b..622a6a49ea19 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -469,8 +469,8 @@ static uint32_t encode_timeval(struct timeval tv) { int log2_s; - int val, exponent; /* Unnormalized value and exponent */ - int norm_exponent; /* Normalized exponent */ + int val, exp; /* Unnormalized value and exponent */ + int norm_exp; /* Normalized exponent */ int shift; /* @@ -481,7 +481,7 @@ encode_timeval(struct timeval tv) if (tv.tv_sec == 0) { if (tv.tv_usec == 0) return (0); - exponent = 0; + exp = 0; val = tv.tv_usec; } else { /* @@ -490,24 +490,24 @@ encode_timeval(struct timeval tv) */ log2_s = fls(tv.tv_sec) - 1; if (log2_s + LOG2_1M < CALC_BITS) { - exponent = 0; + exp = 0; val = 1000000 * tv.tv_sec + tv.tv_usec; } else { - exponent = log2_s + LOG2_1M - CALC_BITS; + exp = log2_s + LOG2_1M - CALC_BITS; val = (unsigned int)(((uint64_t)1000000 * tv.tv_sec + - tv.tv_usec) >> exponent); + tv.tv_usec) >> exp); } } /* Now normalize and pack the value into an IEEE-754 float. */ - norm_exponent = fls(val) - 1; - shift = FLT_MANT_DIG - norm_exponent - 1; + norm_exp = fls(val) - 1; + shift = FLT_MANT_DIG - norm_exp - 1; #ifdef ACCT_DEBUG printf("val=%d exp=%d shift=%d log2(val)=%d\n", - val, exponent, shift, norm_exponent); - printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exponent + norm_exponent, + val, exp, shift, norm_exp); + printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exp + norm_exp, ((shift > 0 ? (val << shift) : (val >> -shift)) & MANT_MASK)); #endif - return (((FLT_MAX_EXP - 1 + exponent + norm_exponent) << (FLT_MANT_DIG - 1)) | + return (((FLT_MAX_EXP - 1 + exp + norm_exp) << (FLT_MANT_DIG - 1)) | ((shift > 0 ? val << shift : val >> -shift) & MANT_MASK)); } @@ -518,7 +518,7 @@ encode_timeval(struct timeval tv) static uint32_t encode_long(long val) { - int norm_exponent; /* Normalized exponent */ + int norm_exp; /* Normalized exponent */ int shift; if (val == 0) @@ -529,15 +529,15 @@ encode_long(long val) val); val = LONG_MAX; } - norm_exponent = fls(val) - 1; - shift = FLT_MANT_DIG - norm_exponent - 1; + norm_exp = fls(val) - 1; + shift = FLT_MANT_DIG - norm_exp - 1; #ifdef ACCT_DEBUG printf("val=%d shift=%d log2(val)=%d\n", - val, shift, norm_exponent); - printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exp + norm_exponent, + val, shift, norm_exp); + printf("exp=%x mant=%x\n", FLT_MAX_EXP - 1 + exp + norm_exp, ((shift > 0 ? (val << shift) : (val >> -shift)) & MANT_MASK)); #endif - return (((FLT_MAX_EXP - 1 + norm_exponent) << (FLT_MANT_DIG - 1)) | + return (((FLT_MAX_EXP - 1 + norm_exp) << (FLT_MANT_DIG - 1)) | ((shift > 0 ? val << shift : val >> -shift) & MANT_MASK)); } |