Re: Remove dependence on integer wrapping - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Remove dependence on integer wrapping
Date
Msg-id ZrvUOkL19KHEH2sb@nathan
Whole thread Raw
In response to Re: Remove dependence on integer wrapping  (jian he <jian.universality@gmail.com>)
Responses Re: Remove dependence on integer wrapping
List pgsql-hackers
I've been preparing 0001 for commit.  I've attached what I have so far.

The main changes are the implementations of pg_abs_* and pg_neg_*.  For the
former, I've used abs()/i64abs() for the short/int implementations.  For
the latter, I've tried to use __builtin_sub_overflow() when possible, as
that appears to produce slightly better code.  When
__builtin_sub_overflow() is not available, the values are upcasted before
negation, and we check that result before casting to the return type.  That
approach more closely matches the surrounding functions.  (One exception is
pg_neg_u64_overflow() when we have neither HAVE__BUILTIN_OP_OVERFLOW nor
HAVE_INT128.  In that case, we have to hand-roll everything.)

Thoughts?

-- 
nathan

Attachment

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: Restart pg_usleep when interrupted
Next
From: "Tristan Partin"
Date:
Subject: Re: Subscription to Postgres Releases via ICS