From: Jeff Sturm Date: Wed, 6 Sep 2000 22:25:56 +0000 (+0000) Subject: jvm.h (_Jv_HashCode): Cast object ptr to `unsigned long' to avoid long long division. X-Git-Tag: prereleases/libstdc++-2.92~4208 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26aa75bef97454f65b437067cf77a5a0255934a3;p=thirdparty%2Fgcc.git jvm.h (_Jv_HashCode): Cast object ptr to `unsigned long' to avoid long long division. 2000-09-06 Jeff Sturm * include/jvm.h (_Jv_HashCode): Cast object ptr to `unsigned long' to avoid long long division. From-SVN: r36215 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 66bec434ead1..a7fa378e12a6 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2000-09-06 Jeff Sturm + + * include/jvm.h (_Jv_HashCode): Cast object ptr to `unsigned long' + to avoid long long division. + 2000-09-06 Tom Tromey * java/lang/reflect/Constructor.java (toString): Use `getName' for diff --git a/libjava/include/jvm.h b/libjava/include/jvm.h index 65178851085c..e6e6fa6e4aaf 100644 --- a/libjava/include/jvm.h +++ b/libjava/include/jvm.h @@ -164,8 +164,9 @@ inline jint _Jv_HashCode (jobject obj) { // This was chosen to yield relatively well distributed results on - // both 32- and 64-bit architectures. - return (jint) ((unsigned long long) obj % 0x7fffffff); + // both 32- and 64-bit architectures. Note 0x7fffffff is prime. + // FIXME: we assume sizeof(long) == sizeof(void *). + return (jint) ((unsigned long) obj % 0x7fffffff); } // Return a raw pointer to the elements of an array given the array