* lib/timespec.h (timespec_cmp, timespec_sign):
These functions are const, not merely pure.
(timespec_sign): Tweak for efficiency.
---
 ChangeLog      | 7 +++++++
 lib/timespec.h | 8 ++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c297091d0f..891c2edb67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-12-20  Paul Eggert  <[email protected]>
+
+       timespec: tweak timespec_sign
+       * lib/timespec.h (timespec_cmp, timespec_sign):
+       These functions are const, not merely pure.
+       (timespec_sign): Tweak for efficiency.
+
 2025-12-19  Collin Funk  <[email protected]>
 
        doc: Use UTF-8 in Texinfo sources.
diff --git a/lib/timespec.h b/lib/timespec.h
index 138467eca6..ecddaef863 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -20,7 +20,7 @@
 #define TIMESPEC_H
 
 /* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE, _GL_ATTRIBUTE_CONST,
-   _GL_ATTRIBUTE_PURE, _GL_CMP.  */
+   _GL_CMP.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
 #endif
@@ -60,7 +60,7 @@ make_timespec (time_t s, long int ns)
 
 /* Return negative, zero, positive if A < B, A == B, A > B, respectively.  */
 
-_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE
+_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_CONST
 timespec_cmp (struct timespec a, struct timespec b)
 {
   return 2 * _GL_CMP (a.tv_sec, b.tv_sec) + _GL_CMP (a.tv_nsec, b.tv_nsec);
@@ -68,10 +68,10 @@ timespec_cmp (struct timespec a, struct timespec b)
 
 /* Return -1, 0, 1, depending on the sign of A.  A.tv_nsec must be
    nonnegative.  */
-_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE
+_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_CONST
 timespec_sign (struct timespec a)
 {
-  return _GL_CMP (a.tv_sec, 0) + (!a.tv_sec & !!a.tv_nsec);
+  return _GL_CMP (a.tv_sec | a.tv_nsec, 0);
 }
 
 struct timespec timespec_add (struct timespec, struct timespec)
-- 
2.51.0


Reply via email to