This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: New hash function


Andrew Haley wrote:
>  > Are there any platforms where sizeof(long) != sizeof(void*) that we
>  > care about?
> 
> Good question.  I think that some compilers (eg IA-64) allow long
> optionally to be 32-bit, but as far as I know Linux doesn't support
> that.  M$ W*ndows NT, might, though...  :-)

Yes, that'll be the case on Win64.  We might have to deal with that eventually.

This OK with you?

2000-08-18  Jeff Sturm  <jeff.sturm@appnet.com>

	* include/jvm.h (_Jv_HashCode): Cast object ptr to `unsigned long'
	to avoid long long division.

Index: jvm.h
===================================================================
RCS file: /cvs/java/libgcj/libjava/include/jvm.h,v
retrieving revision 1.26
diff -u -p -r1.26 jvm.h
--- jvm.h       2000/08/16 15:30:02     1.26
+++ jvm.h       2000/08/18 14:51:01
@@ -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);
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]