Author: rfm
Date: Fri Jan 16 15:29:38 2015
New Revision: 38294

URL: http://svn.gna.org/viewcvs/gnustep?rev=38294&view=rev
Log:
fix hash generation for 64bit processors

Modified:
    libs/base/trunk/Source/NSObject.m

Modified: libs/base/trunk/Source/NSObject.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Source/NSObject.m?rev=38294&r1=38293&r2=38294&view=diff
==============================================================================
--- libs/base/trunk/Source/NSObject.m   (original)
+++ libs/base/trunk/Source/NSObject.m   Fri Jan 16 15:29:38 2015
@@ -1902,13 +1902,16 @@
 - (NSUInteger) hash
 {
   /*
-   * Ideally we would shift left to lose any zero bits produced by the
-   * alignment of the object in memory ... but that depends on the
-   * processor architecture and the memory allocatiion implementation.
-   * In the absence of detailed information, pick a reasonable value
-   * assuming the object will be aligned to an eight byte boundary.
+   *  malloc() must return pointers aligned to point to any data type
    */
-  return (NSUInteger)(uintptr_t)self >> 3;
+#define MAXALIGN (__alignof__(_Complex long double))
+
+  static int shift = MAXALIGN==16 ? 4 : (MAXALIGN==8 ? 3 : 2);
+
+  /* We shift left to lose any zero bits produced by the
+   * alignment of the object in memory.
+   */
+  return (NSUInteger)((uintptr_t)self >> shift);
 }
 
 /**


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to