bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH 4/4] mktime: prefer static_assert to verify


From: Paul Eggert
Subject: [PATCH 4/4] mktime: prefer static_assert to verify
Date: Thu, 3 Oct 2024 22:12:21 -0700

This should work better with glibc.
* lib/mktime.c: Do not include verify.h.
Use static_assert instead of verify.
* modules/mktime (Depends-on): Depend on assert-h, not verify.
---
 ChangeLog      | 6 ++++++
 lib/mktime.c   | 7 +++----
 modules/mktime | 2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 08a452130d..4316c1bed4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2024-10-03  Paul Eggert  <eggert@cs.ucla.edu>
 
+       mktime: prefer static_assert to verify
+       This should work better with glibc.
+       * lib/mktime.c: Do not include verify.h.
+       Use static_assert instead of verify.
+       * modules/mktime (Depends-on): Depend on assert-h, not verify.
+
        mktime: refactor convert_time
        This is to better merge with a future version of glibc.
        This merges a glibc patch by Florian Weimer in:
diff --git a/lib/mktime.c b/lib/mktime.c
index a4974de63f..561c948713 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -51,7 +51,6 @@
 #include <string.h>
 
 #include <intprops.h>
-#include <verify.h>
 
 #ifndef NEED_MKTIME_INTERNAL
 # define NEED_MKTIME_INTERNAL 0
@@ -124,7 +123,7 @@ typedef long int long_int;
 # else
 typedef long long int long_int;
 # endif
-verify (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60);
+static_assert (INT_MAX <= TYPE_MAXIMUM (long_int) / 4 / 366 / 24 / 60 / 60);
 
 /* Shift A right by B bits portably, by dividing A by 2**B and
    truncating towards minus infinity.  B should be in the range 0 <= B
@@ -157,7 +156,7 @@ static long_int const mktime_max
 
 # define EPOCH_YEAR 1970
 # define TM_YEAR_BASE 1900
-verify (TM_YEAR_BASE % 100 == 0);
+static_assert (TM_YEAR_BASE % 100 == 0);
 
 /* Is YEAR + TM_YEAR_BASE a leap year?  */
 static bool
@@ -206,7 +205,7 @@ static long_int
 ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
            int year0, int yday0, int hour0, int min0, int sec0)
 {
-  verify (-1 / 2 == 0);
+  static_assert (-1 / 2 == 0);
 
   /* Compute intervening leap days correctly even if year is negative.
      Take care to avoid integer overflow here.  */
diff --git a/modules/mktime b/modules/mktime
index e5c4c05687..6d924477c5 100644
--- a/modules/mktime
+++ b/modules/mktime
@@ -10,12 +10,12 @@ Depends-on:
 time-h
 c99
 multiarch
+assert-h        [test $REPLACE_MKTIME = 1]
 intprops        [test $REPLACE_MKTIME = 1]
 libc-config     [test $REPLACE_MKTIME = 1]
 stdbool         [test $REPLACE_MKTIME = 1]
 stdckdint       [test $REPLACE_MKTIME = 1]
 time_r          [test $REPLACE_MKTIME = 1]
-verify          [test $REPLACE_MKTIME = 1]
 
 configure.ac:
 gl_FUNC_MKTIME
-- 
2.43.0




reply via email to

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