From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: HAVE_FAST_UNALIGNED_ACCESS Date: Thu, 30 Mar 2023 11:34:42 +0200 Message-ID: <87sfdmlgzx.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40068"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Po Lu To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Mar 30 11:35:38 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phogz-000A9J-Bo for ged-emacs-devel@m.gmane-mx.org; Thu, 30 Mar 2023 11:35:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phogD-0000UO-45; Thu, 30 Mar 2023 05:34:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1phogA-0000U7-La for emacs-devel@gnu.org; Thu, 30 Mar 2023 05:34:46 -0400 Original-Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phog9-0001s3-5c for emacs-devel@gnu.org; Thu, 30 Mar 2023 05:34:46 -0400 Original-Received: by mail-wm1-x331.google.com with SMTP id l37so10493249wms.2 for ; Thu, 30 Mar 2023 02:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680168883; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=L04hXnZF7LC9uGFn4KdOtd4bwoYc+EOyb4OXZf3aLSQ=; b=gKCnJMWOZ3DUY40YIwgUawYoTGlhC7/BObVppDsvC+WyAzFNKTMSnpQUlhqqhuyRMF EQk35InyFk3Yg2ZrrldzVdo/PL0FejilIqQ5AHjVtPpRukARXUAuF7Kccwg+0LKc+Z6o 0sb3KWM82ZCf6vBKGr0WYUny6NHhCz2LLrZCqetyQApuBJOvkcUoaolVijfsywJ5EXmM jSllbqLAvp0ucCcxJLSaOp4DExSxmewqD8JPqjk52ybeMK5PlhUx4zP9zvW57mrXlpbm Sc3VDfEIAj+hBB/D7ZqL4+hI2fpo3Rm35yJ9kF0uIAbyPowYvfxqj4ZVtZt4nGIr67WB VkLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680168883; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L04hXnZF7LC9uGFn4KdOtd4bwoYc+EOyb4OXZf3aLSQ=; b=6oGYqhsnmdxreaVv2vJu5t4Pv5fSoiDFG/W4HnObLMxXw7X2b2yMVB1+p8Wi8eNASM e5ZbKuF3NpXSjTHgr5qgshBs0BzeT71n0UMAd1rS0ZO3YGXuJXSqwLADUNMDIlBAUGKu 5Bz5dKbHy12WtFcgFWu606boAax53qsKsVe+Ji0KAtSvQdw0fe6ZYdFk6thC02vzG7aZ jSxcEcF9eIzM/QLNAMSUDJ4ep74ogArWjwECG1t8V9Ty6aTi+EpQZ87QYT/dGT1wYtzS TlBzN9Z2Zbj1I9Ig5XWskb9n1NSyyJ9EzM/rLVmmElBy0PBzeDWjQTEeGnyBhN+Ijx4S AllA== X-Gm-Message-State: AO0yUKWS6w1YIKk38WwicPUd1IYv7T++YTW5SG9o4RR8xsdIJmoEVxPb llW5Yt51cn3skJMjoJVFGtxz4DVLX9k= X-Google-Smtp-Source: AK7set/E5Jzpj7EsVEXFlhqJDWnULRrDTlA9HESSl1CJfXDTCFyUlh46lKBVhr5mH+9SNeDk3dSd0w== X-Received: by 2002:a7b:cd87:0:b0:3ed:de58:1559 with SMTP id y7-20020a7bcd87000000b003edde581559mr18095275wmj.2.1680168883277; Thu, 30 Mar 2023 02:34:43 -0700 (PDT) Original-Received: from rltb ([82.66.8.55]) by smtp.gmail.com with ESMTPSA id s17-20020a7bc391000000b003edd1c44b57sm5151334wmj.27.2023.03.30.02.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 02:34:42 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=rpluim@gmail.com; helo=mail-wm1-x331.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:304846 Archived-At: Sending this on behalf of Po Lu, who=CA=BCs 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.