unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Ahmed Khanzada <me@enzu.ru>
Cc: 46111@debbugs.gnu.org
Subject: bug#46111: Reverting fns.c hash function due to OpenBSD/SPARC64 compile breaking
Date: Thu, 28 Jan 2021 11:17:31 -0500	[thread overview]
Message-ID: <jwv5z3hvy0r.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvh7n1vzad.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Thu, 28 Jan 2021 10:52:31 -0500")

> 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);
     }






  reply	other threads:[~2021-01-28 16:17 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26  6:37 bug#46111: Reverting fns.c hash function due to OpenBSD/SPARC64 compile breaking Ahmed Khanzada
2021-01-26  6:57 ` Ahmed Khanzada
2021-01-26 11:15   ` Eli Zaretskii
2021-01-28  4:06     ` Ahmed Khanzada
2021-01-28 13:58       ` Eli Zaretskii
2021-01-28 15:09       ` Stefan Monnier
2021-01-28 15:19         ` Eli Zaretskii
2021-01-28 15:44           ` Stefan Monnier
2021-01-28 15:52             ` Stefan Monnier
2021-01-28 16:17               ` Stefan Monnier [this message]
2021-01-28 16:22                 ` Andreas Schwab
2021-01-28 17:22                 ` Eli Zaretskii
2021-01-28 17:30                   ` Stefan Monnier
2021-01-28 16:04             ` Andreas Schwab
2021-01-28 16:14               ` Stefan Monnier
2021-01-26  9:36 ` Philipp Stephani
2021-01-26 11:12   ` Eli Zaretskii
2021-01-26 11:17     ` Andreas Schwab
2021-01-26 11:43       ` Eli Zaretskii
2021-01-26 11:49         ` Andreas Schwab
2021-01-26 15:36           ` Eli Zaretskii
2021-01-27  7:42       ` Richard Stallman
2021-01-27  8:24         ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv5z3hvy0r.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=46111@debbugs.gnu.org \
    --cc=me@enzu.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).