unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Spencer Baugh <sbaugh@janestreet.com>
Cc: 63556@debbugs.gnu.org
Subject: bug#63556: 29.0.90; Use of _Generic breaks Emacs build on GCC <4.9
Date: Wed, 17 May 2023 10:57:38 -0700	[thread overview]
Message-ID: <4b378d55-ef65-7a0f-b03d-e304785cf60d@cs.ucla.edu> (raw)
In-Reply-To: <iermt22dfjd.fsf@janestreet.com>

[-- Attachment #1: Type: text/plain, Size: 397 bytes --]

On 2023-05-17 10:38, Spencer Baugh wrote:
> I think it's because I'm on gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44),
> and _Generic was added in 4.9?

Thanks for reporting the problem. Since _Generic is used here merely as 
a micro-optimization on 32-bit platforms, it's not worth whatever 
porting hassle you've run into, so I installed the attached patch so 
that modiff no longer uses _Generic.

[-- Attachment #2: 0001-Port-modiff-changes-to-GCC-4.8.5.patch --]
[-- Type: text/x-patch, Size: 1767 bytes --]

From 0bba1b8c3df8b7b53e08fd69dcc832d253e7a2d1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 17 May 2023 10:53:26 -0700
Subject: [PATCH] Port modiff changes to GCC 4.8.5
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Spencer Baugh.
* src/lisp.h (elogb): Now simply a function on unsigned long long int.
This avoids problems porting to GCC 4.8.5 20150623 (Red Hat 4.8.5-44).
There may be a minor runtime cost on 32-bit platforms but it’s
not worth worrying about.
---
 src/lisp.h | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/lisp.h b/src/lisp.h
index c9a64f07427..57c1c7395c1 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3906,18 +3906,11 @@ integer_to_uintmax (Lisp_Object num, uintmax_t *n)
 }
 
 /* Return floor (log2 (N)) as an int, where 0 < N <= ULLONG_MAX.  */
-#if (201112 <= __STDC_VERSION__ && INT_MAX <= UINT_MAX \
-     && LONG_MAX <= ULONG_MAX && LLONG_MAX <= ULLONG_MAX)
-# define elogb(n) \
-    _Generic (+(n), \
-	      int:           UINT_WIDTH   - 1 - count_leading_zeros    (n), \
-	      unsigned int:  UINT_WIDTH   - 1 - count_leading_zeros    (n), \
-	      long:          ULONG_WIDTH  - 1 - count_leading_zeros_l  (n), \
-	      unsigned long: ULONG_WIDTH  - 1 - count_leading_zeros_l  (n), \
-	      default:       ULLONG_WIDTH - 1 - count_leading_zeros_ll (n))
-#else
-# define elogb(n) (ULLONG_WIDTH - 1 - count_leading_zeros_ll (n))
-#endif
+INLINE int
+elogb (unsigned long long int n)
+{
+  return ULLONG_WIDTH - 1 - count_leading_zeros_ll (n);
+}
 
 /* A modification count.  These are wide enough, and incremented
    rarely enough, so that they should never overflow a 60-bit counter
-- 
2.39.2


  parent reply	other threads:[~2023-05-17 17:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 17:38 bug#63556: 29.0.90; Use of _Generic breaks Emacs build on GCC <4.9 Spencer Baugh
2023-05-17 17:45 ` Eli Zaretskii
2023-05-17 17:57 ` Paul Eggert [this message]
2023-05-18 11:11   ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-18 11:42     ` Eli Zaretskii
2023-05-18 13:21       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-18 14:12         ` Eli Zaretskii
2023-05-18 14:40     ` Paul Eggert
2023-05-19  0:46       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-19  3:05         ` Paul Eggert
2023-05-19  3:18           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-05-18 20:32   ` Paul Eggert

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=4b378d55-ef65-7a0f-b03d-e304785cf60d@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=63556@debbugs.gnu.org \
    --cc=sbaugh@janestreet.com \
    /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).