diff options
author | Michael Paquier <michael@paquier.xyz> | 2019-09-02 09:38:23 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2019-09-02 09:38:23 +0900 |
commit | 7dedfd22b79822b7f4210e6255b672ea82db6678 (patch) | |
tree | f5e7e3047b5bb394983834a498d925396e379623 /src/backend/executor/nodeModifyTable.c | |
parent | 36515e4f14fc1b22787a54d5de45b1e6b5e6cd9c (diff) | |
download | postgresql-7dedfd22b79822b7f4210e6255b672ea82db6678.tar.gz postgresql-7dedfd22b79822b7f4210e6255b672ea82db6678.zip |
Add overflow-safe math inline functions for unsigned integers
Similarly to the signed versions added in 4d6ad31, this adds a set of
inline functions for overflow checks with unsigned integers, including
uint16, uint32 and uint64. This relies on compiler built-in overflow
checks by default if available. The behavior of unsigned integers is
well-defined so the fallback implementations checks are simple for
additions and subtractions. Multiplications avoid division-based checks
which are expensive if possible, still this can happen for uint64 if
128-bit integers are not available.
While on it, the code in common/int.h is reorganized to avoid too many
duplicated comments. The new macros will be used in a follow-up patch.
All thanks to Andres Freund for the input provided.
Author: Fabien Coelho, Michael Paquier
Discussion: https://postgr.es/m/20190830073423.GB2354@paquier.xyz
Diffstat (limited to 'src/backend/executor/nodeModifyTable.c')
0 files changed, 0 insertions, 0 deletions