X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fdecimal.c;h=6524443eab3d57168325a710d2ac93e05d74671a;hb=e6d98ba2612414fbd67e463442e17de88d868cb1;hp=095c974e24510cbe1cf034beb84fb62b8ddb73c3;hpb=74a6eee32f0d82b598761d826507b3ab00dd2ef2;p=mono.git diff --git a/mono/metadata/decimal.c b/mono/metadata/decimal.c index 095c974e245..6524443eab3 100644 --- a/mono/metadata/decimal.c +++ b/mono/metadata/decimal.c @@ -1,12 +1,12 @@ /* - decimal.c - - conversions and numerical operations for the c# type System.Decimal - - Author: Martin Weindel (martin.weindel@t-online.de) - - (C) 2001 by Martin Weindel -*/ + * decimal.c + * + * conversions and numerical operations for the c# type System.Decimal + * + * Author: Martin Weindel (martin.weindel@t-online.de) + * + * (C) 2001 by Martin Weindel + */ /* * machine dependent configuration for @@ -22,6 +22,9 @@ #ifdef HAVE_MEMORY_H #include #endif +#ifdef _MSC_VER +#include +#endif #ifndef DISABLE_DECIMAL @@ -565,8 +568,26 @@ my_g_bit_nth_msf (gsize mask) __asm__("bsrq %1,%0\n\t" : "=r" (r) : "rm" (mask)); return r; +#elif defined(__i386__) && defined(_MSC_VER) + unsigned long bIndex = 0; + if (_BitScanReverse (&bIndex, mask)) + return bIndex; + return -1; +#elif defined(__x86_64__) && defined(_MSC_VER) + unsigned long bIndex = 0; + if (_BitScanReverse64 (&bIndex, mask)) + return bIndex; + return -1; #else - return g_bit_nth_msf (mask, sizeof (gsize) * 8); + int i; + + i = sizeof (gsize) * 8; + while (i > 0) { + i --; + if (mask & (1UL << i)) + return i; + } + return -1; #endif } @@ -680,11 +701,6 @@ DECINLINE static int rescale128(guint64* pclo, guint64* pchi, int* pScale, int t overhang = (guint32)(*pchi >> 32); } */ - - /* - * FIXME: This code seems to cause crashes on the x86 buildbot during the - * System.Data.DataSetExtensions tests. - */ if (overhang > 0) { int msf = my_g_bit_nth_msf (overhang); int shift = msf - (DECIMAL_MAX_INTFACTORS + 2);