From: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
---|---|
To: | Matthew Kim <matthewkmkim(at)gmail(dot)com> |
Cc: | Joseph Koshakow <koshy44(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de> |
Subject: | Re: Remove dependence on integer wrapping |
Date: | 2024-08-07 15:08:04 |
Message-ID: | ZrON1CT7Lk9_EJOG@nathan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I started looking at 0001 again with the intent of committing it, and this
caught my eye:
- /* make the amount positive for digit-reconstruction loop */
- value = -value;
+ /*
+ * make the amount positive for digit-reconstruction loop, we can
+ * leave INT64_MIN unchanged
+ */
+ pg_neg_s64_overflow(value, &value);
The comment mentions that we can leave the minimum value unchanged, but it
doesn't explain why. Can we explain why?
+static inline bool
+pg_neg_s64_overflow(int64 a, int64 *result)
+{
+ if (unlikely(a == PG_INT64_MIN))
+ {
+ return true;
+ }
+ else
+ {
+ *result = -a;
+ return false;
+ }
+}
Can we add a comment that these routines do not set "result" when true is
returned?
--
nathan
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2024-08-07 15:28:06 | Re: Remaining dependency on setlocale() |
Previous Message | Aleksander Alekseev | 2024-08-07 15:00:45 | Re: Fsync (flush) all inserted WAL records |