emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 12d004d 2/2: Assume C99-style ‘long long’


From: Paul Eggert
Subject: master 12d004d 2/2: Assume C99-style ‘long long’
Date: Tue, 31 Dec 2019 23:18:28 -0500 (EST)

branch: master
commit 12d004d6eee2d136825df92eca33eaa6b705030b
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Assume C99-style ‘long long’
    
    Now that Gnulib assumes ‘long long’, it is a good time to clean
    out old cruft porting to pre-C99 compilers that lack it.
    * src/data.c (ULL_WIDTH, ULL_MAX): Remove.
    All uses replaced by ULLONG_WIDTH, ULLONG_MAX.
    (bits_word_to_host_endian): Assume ‘unsigned long long’.
    By the way, the old code had a performance typo: it used
    HAVE_UNSIGNED_LONG_LONG where it should have used
    HAVE_UNSIGNED_LONG_LONG_INT.
    * src/sysdep.c (ULLONG_MAX): Remove, as lib/limits.h does this now.
    (time_from_jiffies) [GNU_LINUX]: Assume ‘long long’.
---
 admin/CPP-DEFINES |  2 --
 src/data.c        | 33 +++++++++------------------------
 src/sysdep.c      |  7 +------
 3 files changed, 10 insertions(+), 32 deletions(-)

diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index ea99d50..ce9a444 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -201,7 +201,6 @@ HAVE_LIBXML2
 HAVE_LIBXMU
 HAVE_LOCALTIME_R
 HAVE_LOCAL_SOCKETS
-HAVE_LONG_LONG_INT
 HAVE_LRAND48
 HAVE_LSTAT
 HAVE_LUTIMES
@@ -322,7 +321,6 @@ HAVE_TM_ZONE
 HAVE_TOUCHLOCK
 HAVE_TZNAME
 HAVE_TZSET
-HAVE_UNSIGNED_LONG_LONG_INT
 HAVE_UTIL_H
 HAVE_UTIMENSAT
 HAVE_UTIMES
diff --git a/src/data.c b/src/data.c
index b153068..56e363f 100644
--- a/src/data.c
+++ b/src/data.c
@@ -3310,27 +3310,14 @@ bool_vector_spare_mask (EMACS_INT nr_bits)
   return (((bits_word) 1) << (nr_bits % BITS_PER_BITS_WORD)) - 1;
 }
 
-/* Info about unsigned long long, falling back on unsigned long
-   if unsigned long long is not available.  */
-
-#if HAVE_UNSIGNED_LONG_LONG_INT && defined ULLONG_WIDTH
-enum { ULL_WIDTH = ULLONG_WIDTH };
-# define ULL_MAX ULLONG_MAX
-#else
-enum { ULL_WIDTH = ULONG_WIDTH };
-# define ULL_MAX ULONG_MAX
-# define count_one_bits_ll count_one_bits_l
-# define count_trailing_zeros_ll count_trailing_zeros_l
-#endif
-
 /* Shift VAL right by the width of an unsigned long long.
-   ULL_WIDTH must be less than BITS_PER_BITS_WORD.  */
+   ULLONG_WIDTH must be less than BITS_PER_BITS_WORD.  */
 
 static bits_word
 shift_right_ull (bits_word w)
 {
   /* Pacify bogus GCC warning about shift count exceeding type width.  */
-  int shift = ULL_WIDTH - BITS_PER_BITS_WORD < 0 ? ULL_WIDTH : 0;
+  int shift = ULLONG_WIDTH - BITS_PER_BITS_WORD < 0 ? ULLONG_WIDTH : 0;
   return w >> shift;
 }
 
@@ -3347,7 +3334,7 @@ count_one_bits_word (bits_word w)
     {
       int i = 0, count = 0;
       while (count += count_one_bits_ll (w),
-            (i += ULL_WIDTH) < BITS_PER_BITS_WORD)
+            (i += ULLONG_WIDTH) < BITS_PER_BITS_WORD)
        w = shift_right_ull (w);
       return count;
     }
@@ -3478,7 +3465,7 @@ count_trailing_zero_bits (bits_word val)
     return count_trailing_zeros (val);
   if (BITS_WORD_MAX == ULONG_MAX)
     return count_trailing_zeros_l (val);
-  if (BITS_WORD_MAX == ULL_MAX)
+  if (BITS_WORD_MAX == ULLONG_MAX)
     return count_trailing_zeros_ll (val);
 
   /* The rest of this code is for the unlikely platform where bits_word differs
@@ -3492,18 +3479,18 @@ count_trailing_zero_bits (bits_word val)
     {
       int count;
       for (count = 0;
-          count < BITS_PER_BITS_WORD - ULL_WIDTH;
-          count += ULL_WIDTH)
+          count < BITS_PER_BITS_WORD - ULLONG_WIDTH;
+          count += ULLONG_WIDTH)
        {
-         if (val & ULL_MAX)
+         if (val & ULLONG_MAX)
            return count + count_trailing_zeros_ll (val);
          val = shift_right_ull (val);
        }
 
-      if (BITS_PER_BITS_WORD % ULL_WIDTH != 0
+      if (BITS_PER_BITS_WORD % ULLONG_WIDTH != 0
          && BITS_WORD_MAX == (bits_word) -1)
        val |= (bits_word) 1 << pre_value (ULONG_MAX < BITS_WORD_MAX,
-                                          BITS_PER_BITS_WORD % ULL_WIDTH);
+                                          BITS_PER_BITS_WORD % ULLONG_WIDTH);
       return count + count_trailing_zeros_ll (val);
     }
 }
@@ -3516,10 +3503,8 @@ bits_word_to_host_endian (bits_word val)
 #else
   if (BITS_WORD_MAX >> 31 == 1)
     return bswap_32 (val);
-# if HAVE_UNSIGNED_LONG_LONG
   if (BITS_WORD_MAX >> 31 >> 31 >> 1 == 1)
     return bswap_64 (val);
-# endif
   {
     int i;
     bits_word r = 0;
diff --git a/src/sysdep.c b/src/sysdep.c
index cb2f7f2..c6344d8 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -135,11 +135,6 @@ int _cdecl _spawnlp (int, const char *, const char *, ...);
 # include <sys/socket.h>
 #endif
 
-/* ULLONG_MAX is missing on Red Hat Linux 7.3; see Bug#11781.  */
-#ifndef ULLONG_MAX
-#define ULLONG_MAX TYPE_MAXIMUM (unsigned long long int)
-#endif
-
 /* Declare here, including term.h is problematic on some systems.  */
 extern void tputs (const char *, int, int (*)(int));
 
@@ -3141,7 +3136,7 @@ make_lisp_timeval (struct timeval t)
 
 #endif
 
-#if defined GNU_LINUX && defined HAVE_LONG_LONG_INT
+#ifdef GNU_LINUX
 static struct timespec
 time_from_jiffies (unsigned long long tval, long hz)
 {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]