c-template
safe_math.h File Reference
#include <limits.h>
#include <stdbool.h>
Include dependency graph for safe_math.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Abs(i, flag)   ((i) >= 0 ? (i): ((i) == (flag) ? (flag) : -(i)))
 

Functions

int safe_add_int (int x, int y, bool *passed)
 
int safe_sub_int (int x, int y, bool *passed)
 
int safe_div_int (int x, int y, bool *passed)
 
int safe_mod_int (int x, int y, bool *passed)
 
unsigned int safe_sub_uint (unsigned int x, unsigned int y, bool *passed)
 
unsigned int safe_add_uint (unsigned int x, unsigned int y, bool *passed)
 
unsigned int safe_div_uint (unsigned int x, unsigned int y, bool *passed)
 
unsigned int safe_mod_uint (unsigned int x, unsigned int y, bool *passed)
 
unsigned int safe_mul_uint (unsigned int x, unsigned int y, bool *passed)
 

Macro Definition Documentation

◆ Abs

#define Abs (   i,
  flag 
)    ((i) >= 0 ? (i): ((i) == (flag) ? (flag) : -(i)))

Definition at line 5 of file safe_math.h.

Function Documentation

◆ safe_add_int()

int safe_add_int ( int  x,
int  y,
bool *  passed 
)

Definition at line 5 of file safe_math.c.

◆ safe_add_uint()

unsigned int safe_add_uint ( unsigned int  x,
unsigned int  y,
bool *  passed 
)

Definition at line 54 of file safe_math.c.

Here is the caller graph for this function:

◆ safe_div_int()

int safe_div_int ( int  x,
int  y,
bool *  passed 
)

Definition at line 25 of file safe_math.c.

◆ safe_div_uint()

unsigned int safe_div_uint ( unsigned int  x,
unsigned int  y,
bool *  passed 
)

Definition at line 64 of file safe_math.c.

◆ safe_mod_int()

int safe_mod_int ( int  x,
int  y,
bool *  passed 
)

Definition at line 35 of file safe_math.c.

◆ safe_mod_uint()

unsigned int safe_mod_uint ( unsigned int  x,
unsigned int  y,
bool *  passed 
)

Definition at line 74 of file safe_math.c.

◆ safe_mul_uint()

unsigned int safe_mul_uint ( unsigned int  x,
unsigned int  y,
bool *  passed 
)

Definition at line 84 of file safe_math.c.

◆ safe_sub_int()

int safe_sub_int ( int  x,
int  y,
bool *  passed 
)

Definition at line 15 of file safe_math.c.

◆ safe_sub_uint()

unsigned int safe_sub_uint ( unsigned int  x,
unsigned int  y,
bool *  passed 
)

Definition at line 44 of file safe_math.c.

Here is the caller graph for this function: