From c28859c3e10c84fd9f81ebf88336c9b693448eeb Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 6 Dec 2025 10:21:36 +0100 Subject: Add overflow and underflow prediction functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libj2.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'libj2.h') diff --git a/libj2.h b/libj2.h index aa1747f..4130c97 100644 --- a/libj2.h +++ b/libj2.h @@ -52,6 +52,32 @@ struct libj2_j2u { }; +/** + * Arithmetic overflow prediction result + * + * Use by some functions for which prediction + * is costly in edge cases, and thus stopped + * as soon as such an edge case is detected + */ +enum libj2_overflow { + /** + * Where will not be an overflow + */ + LIBJ2_NO_OVERFLOW = 0, + + /** + * Where will be an overflow + */ + LIBJ2_OVERFLOW = 1, + + /** + * Overflow prediction stopped + * (due to high cost) + */ + LIBJ2_OVERFLOW_UNKNOWN +}; + + #include "libj2/constants.h" #include "libj2/signum.h" #include "libj2/constructors.h" -- cgit v1.2.3-70-g09d2