Graphviz 16.1.1~dev.20261017.1520
Loading...
Searching...
No Matches
overflow.h File Reference

arithmetic overflow helpers More...

#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for overflow.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static bool sadd_overflow (int a, int b, int *res)
 
static int sadd_saturate (int a, int b)
 
static bool size_overflow (size_t a, size_t b, size_t *res)
 
static bool u64add_overflow (uint64_t a, uint64_t b, uint64_t *res)
 
static bool u64mul_overflow (uint64_t a, uint64_t b, uint64_t *res)
 
static bool fdiv_overflow (double n, double d, double *res)
 
static bool fdivf_overflow (float n, float d, float *res)
 

Detailed Description

Replace this with stdckdint.h when moving to C23.

Definition in file overflow.h.

Function Documentation

◆ fdiv_overflow()

static bool fdiv_overflow ( double  n,
double  d,
double *  res 
)
inlinestatic

divide two double floating-point values, checking for overflow

Parameters
nDivision numerator
dDivision denominator
res[out] Result on success
Returns
True if overflow would occur

Definition at line 142 of file overflow.h.

References NULL.

Referenced by bend(), and poly_inside().

Here is the caller graph for this function:

◆ fdivf_overflow()

static bool fdivf_overflow ( float  n,
float  d,
float *  res 
)
inlinestatic

divide two floating-point values, checking for overflow

Parameters
nDivision numerator
dDivision denominator
res[out] Result on success
Returns
True if overflow would occur

Definition at line 162 of file overflow.h.

References NULL.

◆ sadd_overflow()

static bool sadd_overflow ( int  a,
int  b,
int *  res 
)
inlinestatic

add two integers, checking for overflow

Parameters
aOperand 1
bOperand 2
res[out] Result on success
Returns
True if overflow would occur

Definition at line 23 of file overflow.h.

References NULL.

Referenced by x_cutval().

Here is the caller graph for this function:

◆ sadd_saturate()

static int sadd_saturate ( int  a,
int  b 
)
inlinestatic

add two integers, clamping to lower and upper type bounds

Parameters
aOperand 1
bOperand 2
Returns
The sum a + b, or INT_MAX/INT_MIN on overflow/underflow

Definition at line 49 of file overflow.h.

Referenced by tree_adjust().

Here is the caller graph for this function:

◆ size_overflow()

static bool size_overflow ( size_t  a,
size_t  b,
size_t *  res 
)
inlinestatic

add two sizes, checking for overflow

Parameters
aOperand 1
bOperand 2
res[out] Result on success
Returns
True if overflow would occur

Definition at line 70 of file overflow.h.

References NULL, and SIZE_MAX.

Referenced by SparseMatrix_multiply(), and SparseMatrix_multiply3().

Here is the caller graph for this function:

◆ u64add_overflow()

static bool u64add_overflow ( uint64_t  a,
uint64_t  b,
uint64_t *  res 
)
inlinestatic

add two 64-bit unsigned integers, checking for overflow

Parameters
aOperand 1
bOperand 2
res[out] Result on success
Returns
True if overflow would occur

Definition at line 94 of file overflow.h.

References NULL.

Referenced by uadd().

Here is the caller graph for this function:

◆ u64mul_overflow()

static bool u64mul_overflow ( uint64_t  a,
uint64_t  b,
uint64_t *  res 
)
inlinestatic

multiply two 64-bit unsigned integers, checking for overflow

Parameters
aOperand 1
bOperand 2
res[out] Result on success
Returns
True if overflow would occur

Definition at line 118 of file overflow.h.

References NULL.

Referenced by umul().

Here is the caller graph for this function: