fundamental: Add overflow-safe math helpers
authorAdrian Vovk <adrianvovk@gmail.com>
Wed, 17 Jan 2024 19:48:45 +0000 (14:48 -0500)
committerAdrian Vovk <adrianvovk@gmail.com>
Tue, 13 Feb 2024 18:08:20 +0000 (13:08 -0500)
commita7a67dfd9d1da1c8027b58e691663a02e904987f
treebe3be93e64c6148066b59c9f167b2971cbcfd6c2
parent6d55e3a3641b35dd2bb4306711b4db4004bf6817
fundamental: Add overflow-safe math helpers

ADD_SAFE/SUB_SAFE/MUL_SAFE do addition/subtraction/multiplication
respectively with an overflow check. If an overflow occurs these return
false, otherwise true. Example: (c = a + b) would become ADD_SAFE(&c, a,
b)

INC_SAFE/DEC_SAFE/MUL_ASSIGN_SAFE are like above but they also reassign
the first argument. Example: (a += b) would become INC_SAFE(&a, b)
src/boot/efi/boot.c
src/boot/efi/efi-string.c
src/boot/efi/util.h
src/fundamental/macro-fundamental.h
src/shared/elf-util.c
src/test/test-macro.c