GNU bug report logs -
#46111
Reverting fns.c hash function due to OpenBSD/SPARC64 compile breaking
Previous Next
Reported by: Ahmed Khanzada <me <at> enzu.ru>
Date: Tue, 26 Jan 2021 09:07:01 UTC
Severity: normal
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #71 received at 46111 <at> debbugs.gnu.org (full text, mbox):
> And the backtrace shows we're hashing the string `DndProtocol` which
> comes from `lisp/x-dnd.el` which is indeed preloaded, so I think that's
> what's going on.
Could you try the patch below?
Stefan
diff --git a/src/fns.c b/src/fns.c
index 7ab2e8f1a0..0c6bb770ef 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4610,7 +4610,20 @@ hash_string (char const *ptr, ptrdiff_t len)
* as `p <= end - 1`. */
while (p <= end - 1)
{
+ /* Here `p` is *almost* always be properly aligned, so we want to
+ optimize for the aligned case, but we still need to support the
+ non-aligned case. */
+ /* FIXME: Could we just always use `memcpy` and rely on GCC optimizing
+ it to a single word-sized memory access on all-but-sparc64? */
+#ifdef __sparc64__ /* Arch that still insists on aligned memory accesses. */
+ EMACS_UINT c;
+ if (!((unsigned long)p) % sizeof (c))
+ c = *p;
+ else
+ memcpy (&c, (char const *)p, sizeof (c)); /* `p` is unaligned! */
+#else
EMACS_UINT c = *p;
+#fi
p += step;
hash = sxhash_combine (hash, c);
}
This bug report was last modified 4 years and 117 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.