Fixed warnings

master
Christophe Riccio ago%!(EXTRA string=8 years)
parent 6c23545fbc
commit d799c282db
  1. 37
      test/core/core_func_integer_find_msb.cpp

@ -34,7 +34,7 @@ int nlz1a(unsigned x) {
int n; int n;
/* if (x == 0) return(32); */ /* if (x == 0) return(32); */
if ((int)x <= 0) return (~x >> 26) & 32; if (static_cast<int>(x) <= 0) return (~x >> 26) & 32;
n = 1; n = 1;
if ((x >> 16) == 0) {n = n +16; x = x <<16;} if ((x >> 16) == 0) {n = n +16; x = x <<16;}
if ((x >> 24) == 0) {n = n + 8; x = x << 8;} if ((x >> 24) == 0) {n = n + 8; x = x << 8;}
@ -141,26 +141,28 @@ gcc/AIX, and gcc/NT, at some optimization levels.
BTW, these programs use the "anonymous union" feature of C++, not BTW, these programs use the "anonymous union" feature of C++, not
available in C. */ available in C. */
int nlz6(unsigned k) { int nlz6(unsigned k)
{
union { union {
unsigned asInt[2]; unsigned asInt[2];
double asDouble; double asDouble;
}; };
int n; int n;
asDouble = (double)k + 0.5; asDouble = static_cast<double>(k) + 0.5;
n = 1054 - (asInt[LE] >> 20); n = 1054 - (asInt[LE] >> 20);
return n; return n;
} }
int nlz7(unsigned k) { int nlz7(unsigned k)
{
union { union {
unsigned asInt[2]; unsigned asInt[2];
double asDouble; double asDouble;
}; };
int n; int n;
asDouble = (double)k; asDouble = static_cast<double>(k);
n = 1054 - (asInt[LE] >> 20); n = 1054 - (asInt[LE] >> 20);
n = (n & 31) + (n >> 9); n = (n & 31) + (n >> 9);
return n; return n;
@ -175,7 +177,8 @@ int nlz7(unsigned k) {
FFFFFF80 <= k <= FFFFFFFF. FFFFFF80 <= k <= FFFFFFFF.
For k = 0 it gives 158, and for the other values it is too low by 1. */ For k = 0 it gives 158, and for the other values it is too low by 1. */
int nlz8(unsigned k) { int nlz8(unsigned k)
{
union { union {
unsigned asInt; unsigned asInt;
float asFloat; float asFloat;
@ -183,7 +186,7 @@ int nlz8(unsigned k) {
int n; int n;
k = k & ~(k >> 1); /* Fix problem with rounding. */ k = k & ~(k >> 1); /* Fix problem with rounding. */
asFloat = (float)k + 0.5f; asFloat = static_cast<float>(k) + 0.5f;
n = 158 - (asInt >> 23); n = 158 - (asInt >> 23);
return n; return n;
} }
@ -196,7 +199,8 @@ expressions (see "Using and Porting GNU CC", by Richard M. Stallman
possibility that the macro argument will conflict with one of its local possibility that the macro argument will conflict with one of its local
variables, e.g., NLZ(k). */ variables, e.g., NLZ(k). */
int nlz9(unsigned k) { int nlz9(unsigned k)
{
union { union {
unsigned asInt; unsigned asInt;
float asFloat; float asFloat;
@ -204,7 +208,7 @@ int nlz9(unsigned k) {
int n; int n;
k = k & ~(k >> 1); /* Fix problem with rounding. */ k = k & ~(k >> 1); /* Fix problem with rounding. */
asFloat = (float)k; asFloat = static_cast<float>(k);
n = 158 - (asInt >> 23); n = 158 - (asInt >> 23);
n = (n & 31) + (n >> 6); /* Fix problem with k = 0. */ n = (n & 31) + (n >> 6); /* Fix problem with k = 0. */
return n; return n;
@ -229,8 +233,8 @@ multiplication expanded into shifts and adds, but the table size is
getting a bit large). */ getting a bit large). */
#define u 99 #define u 99
int nlz10(unsigned x) { int nlz10(unsigned x)
{
static char table[64] = static char table[64] =
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u, {32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u, u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
@ -249,8 +253,8 @@ int nlz10(unsigned x) {
/* Harley's algorithm with multiply expanded. /* Harley's algorithm with multiply expanded.
19 elementary ops plus an indexed load. */ 19 elementary ops plus an indexed load. */
int nlz10a(unsigned x) { int nlz10a(unsigned x)
{
static char table[64] = static char table[64] =
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u, {32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u, u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
@ -273,8 +277,8 @@ int nlz10a(unsigned x) {
17 elementary ops plus an indexed load, if the machine 17 elementary ops plus an indexed load, if the machine
has "and not." */ has "and not." */
int nlz10b(unsigned x) { int nlz10b(unsigned x)
{
static char table[64] = static char table[64] =
{32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u, {32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u,
u, 9, u,16, u, u, 1,26, u,13, u, u,24, 5, u, u, u, 9, u,16, u, u, 1,26, u,13, u, u,24, 5, u, u,
@ -294,7 +298,8 @@ int nlz10b(unsigned x) {
} }
int errors; int errors;
void error(int x, int y) { void error(int x, int y)
{
errors = errors + 1; errors = errors + 1;
printf("Error for x = %08x, got %d\n", x, y); printf("Error for x = %08x, got %d\n", x, y);
} }

Loading…
Cancel
Save