public inbox for [email protected]
help / color / mirror / Atom feedFrom: Nathan Bossart <[email protected]>
To: Matthew Kim <[email protected]>
Cc: Joseph Koshakow <[email protected]>
Cc: jian he <[email protected]>
Cc: Alexander Lakhin <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Andres Freund <[email protected]>
Subject: Re: Remove dependence on integer wrapping
Date: Wed, 7 Aug 2024 10:08:04 -0500
Message-ID: <ZrON1CT7Lk9_EJOG@nathan> (raw)
In-Reply-To: <ZrKY8PJwGg23eZ3R@nathan>
References: <Zp54I4WMbWW6AQnP@nathan>
<CAAvxfHdWseDnK0gLYY51fdw-_pE=5Q2=K=pToVv5jo3YNVfHoQ@mail.gmail.com>
<Zp7Q4erYWVjtWzQr@nathan>
<Zp7cwd_6NXlHt6Ye@nathan>
<CAAvxfHeg0En5VV_9pjoHgd0kerK7REL84XEiS6=PUDOSKwx9rg@mail.gmail.com>
<CACJufxERqAgy4YBwc2hLZY=hw1kD2m6AVD3=kyAen8=HeLsfmw@mail.gmail.com>
<CAAvxfHeOdkaQXoca3W54=RZ6opCWLzqgmDM6s8GrUxKG1Tk+_g@mail.gmail.com>
<ZqBzEucmgeib_6Fe@nathan>
<CAGzNdfGMe8vK1BRvUmW29T7rkqUhM67t=wbgsCSDBu=T+rqZrw@mail.gmail.com>
<ZrKY8PJwGg23eZ3R@nathan>
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
view thread (17+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Remove dependence on integer wrapping
In-Reply-To: <ZrON1CT7Lk9_EJOG@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox