[tz] [PROPOSED 4/5] Use C23 [[unsequenced]] if available

Paul Eggert eggert at cs.ucla.edu
Mon Nov 21 18:36:42 UTC 2022


* private.h (ATTRIBUTE_UNSEQUENCED): Rename from ATTRIBUTE_CONST,
and use C23 style [[unsequenced]] if available.  All uses changed.
---
 private.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/private.h b/private.h
index 643068a7..4d667aa0 100644
--- a/private.h
+++ b/private.h
@@ -426,11 +426,9 @@ typedef unsigned long uintmax_t;
 #endif
 
 #if 3 <= __GNUC__
-# define ATTRIBUTE_CONST __attribute__((const))
 # define ATTRIBUTE_MALLOC __attribute__((malloc))
 # define ATTRIBUTE_FORMAT(spec) __attribute__((format spec))
 #else
-# define ATTRIBUTE_CONST /* empty */
 # define ATTRIBUTE_MALLOC /* empty */
 # define ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
@@ -483,6 +481,19 @@ typedef unsigned long uintmax_t;
 # endif
 #endif
 
+#if HAVE_HAS_C_ATTRIBUTE
+# if __has_c_attribute(unsequenced)
+#  define ATTRIBUTE_UNSEQUENCED [[unsequenced]]
+# endif
+#endif
+#ifndef ATTRIBUTE_UNSEQUENCED
+# if 3 <= __GNUC__
+#  define ATTRIBUTE_UNSEQUENCED __attribute__((const))
+# else
+#  define ATTRIBUTE_UNSEQUENCED /* empty */
+# endif
+#endif
+
 #if __STDC_VERSION__ < 199901 && !defined restrict
 # define restrict /* empty */
 #endif
@@ -604,7 +615,7 @@ char *asctime(struct tm const *);
 char *asctime_r(struct tm const *restrict, char *restrict);
 char *ctime(time_t const *);
 char *ctime_r(time_t const *, char *);
-double difftime(time_t, time_t) ATTRIBUTE_CONST;
+double difftime(time_t, time_t) ATTRIBUTE_UNSEQUENCED;
 size_t strftime(char *restrict, size_t, char const *restrict,
 		struct tm const *restrict);
 # if HAVE_STRFTIME_L
-- 
2.37.2



More information about the tz mailing list