postgresql/src/include/common
Michael Paquier 7dedfd22b7 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
2019-09-02 09:38:23 +09:00
..
base64.h Introduce safer encoding and decoding routines for base64.c 2019-07-04 16:08:09 +09:00
config_info.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
controldata_utils.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
fe_memutils.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
file_perm.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
file_utils.h Initial pgindent run for v12. 2019-05-22 12:55:34 -04:00
int.h Add overflow-safe math inline functions for unsigned integers 2019-09-02 09:38:23 +09:00
int128.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
ip.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
keywords.h Replace the data structure used for keyword lookup. 2019-01-06 17:02:57 -05:00
kwlookup.h Use perfect hashing, instead of binary search, for keyword lookup. 2019-01-09 19:47:46 -05:00
link-canary.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
logging.h Initial pgindent run for v12. 2019-05-22 12:55:34 -04:00
md5.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_lzcompress.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
relpath.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
restricted_token.h Unified logging system for command-line programs 2019-04-01 20:01:35 +02:00
saslprep.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
scram-common.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
sha2.h Use OpenSSL-specific ifdefs in sha2.h 2019-06-14 09:00:36 +09:00
shortest_dec.h Change floating-point output format for improved performance. 2019-02-13 15:20:33 +00:00
string.h Refactor logic to remove trailing CR/LF characters from strings 2019-08-09 11:05:14 +09:00
unicode_norm.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
unicode_norm_table.h Update unicode_norm_table.h to Unicode 12.1.0 2019-06-24 22:50:56 +02:00
username.h Update copyright for 2019 2019-01-02 12:44:25 -05:00