all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* HAVE_FAST_UNALIGNED_ACCESS
@ 2023-03-30  9:34 Robert Pluim
  2023-03-30 10:26 ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Robert Pluim @ 2023-03-30  9:34 UTC (permalink / raw)
  To: emacs-devel; +Cc: Po Lu


Sending this on behalf of Po Lu, whoʼs still having email problems:

Fstring_lessp has:

/* Check whether the platform allows access to unaligned addresses for
   size_t integers without trapping or undue penalty (a few cycles is OK).

   This whitelist is incomplete but since it is only used to improve
   performance, omitting cases is safe.  */
#if defined __x86_64__|| defined __amd64__	\
    || defined __i386__ || defined __i386	\
    || defined __arm64__ || defined __aarch64__	\
    || defined __powerpc__ || defined __powerpc	\
    || defined __ppc__ || defined __ppc		\
    || defined __s390__ || defined __s390x__
#define HAVE_FAST_UNALIGNED_ACCESS 1
#else
#define HAVE_FAST_UNALIGNED_ACCESS 0
#endif

but even if unaligned access is normally permitted by a machine, it is
still undefined behavior to dereference an unaligned pointer.

Instead, HAVE_FAST_UNALIGNED_ACCESS and UNALIGNED_LOAD_SIZE should be
removed and memcpy used instead:

  word_t a, c;

  memcpy (&a, w1 + b / ws, sizeof a);
  memcpy (&c, w2 + b / ws, sizeof c);

doing so will make the compiler itself generate the right sequence of
instructions for performing unaligned accesses, normally with only a few
cycles penalty.  Some RISCs have explicit ``load unaligned''
instructions, and others (such as MIPS and the Alpha) need special
sequences of instructions to perform such loads, and the compiler will
DTRT.

I would like to install such a change on emacs-29.  Emacs currently
crashes when built with various compilers performing pointer alignment
checks.



^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2023-04-02  0:50 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30  9:34 HAVE_FAST_UNALIGNED_ACCESS Robert Pluim
2023-03-30 10:26 ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-03-30 11:09   ` HAVE_FAST_UNALIGNED_ACCESS Sam James
2023-03-30 12:18   ` HAVE_FAST_UNALIGNED_ACCESS Arsen Arsenović
     [not found]     ` <87v8ihu3t8.fsf@yahoo.com>
2023-03-31  7:15       ` HAVE_FAST_UNALIGNED_ACCESS Robert Pluim
2023-03-31  7:45       ` HAVE_FAST_UNALIGNED_ACCESS Arsen Arsenović
2023-03-31 17:29     ` HAVE_FAST_UNALIGNED_ACCESS Mattias Engdegård
2023-03-31 20:13       ` HAVE_FAST_UNALIGNED_ACCESS Arsen Arsenović
2023-03-30 10:28 ` HAVE_FAST_UNALIGNED_ACCESS Mattias Engdegård
2023-03-30 11:38 ` HAVE_FAST_UNALIGNED_ACCESS Vibhav Pant
2023-03-31 16:57   ` HAVE_FAST_UNALIGNED_ACCESS Mattias Engdegård
2023-03-31 17:59     ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-03-31 18:03       ` HAVE_FAST_UNALIGNED_ACCESS Mattias Engdegård
2023-03-31 18:12         ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-04-01  0:45         ` HAVE_FAST_UNALIGNED_ACCESS Po Lu
2023-04-01  5:43           ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-04-01  6:31             ` HAVE_FAST_UNALIGNED_ACCESS Po Lu
2023-04-01  6:39               ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-04-01  7:42                 ` HAVE_FAST_UNALIGNED_ACCESS Mattias Engdegård
2023-04-01  8:19                   ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-04-01  9:17                     ` HAVE_FAST_UNALIGNED_ACCESS Po Lu
2023-04-01 11:25                       ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-04-01 12:59                         ` HAVE_FAST_UNALIGNED_ACCESS Arsen Arsenović
2023-04-01 13:33                           ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-04-01 15:22                             ` HAVE_FAST_UNALIGNED_ACCESS Arsen Arsenović
2023-04-01 16:22                               ` HAVE_FAST_UNALIGNED_ACCESS Eli Zaretskii
2023-04-02  0:50                                 ` HAVE_FAST_UNALIGNED_ACCESS Po Lu
2023-04-02  0:48                             ` HAVE_FAST_UNALIGNED_ACCESS Po Lu

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.