VLC  4.0.0-dev
Overflowing arithmetic
Collaboration diagram for Overflowing arithmetic: ## Macros

#define mul_overflow(a, b, r)
Overflowing multiplication. More...

## Functions

static bool uadd_overflow (unsigned a, unsigned b, unsigned *res)

static bool uaddl_overflow (unsigned long a, unsigned long b, unsigned long *res)

static bool uaddll_overflow (unsigned long long a, unsigned long long b, unsigned long long *res)

static bool umul_overflow (unsigned a, unsigned b, unsigned *res)

static bool umull_overflow (unsigned long a, unsigned long b, unsigned long *res)

static bool umulll_overflow (unsigned long long a, unsigned long long b, unsigned long long *res)

## Macro Definition Documentation

 #define add_overflow ( a, b, r )
Value:
_Generic(*(r), \
unsigned: uadd_overflow(a, b, (unsigned *)(r)), \
unsigned long: uaddl_overflow(a, b, (unsigned long *)(r)), \
unsigned long long: uaddll_overflow(a, b, (unsigned long long *)(r)))
static bool uaddll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res)
Definition: vlc_common.h:836
static bool uadd_overflow(unsigned a, unsigned b, unsigned *res)
Definition: vlc_common.h:815
static bool uaddl_overflow(unsigned long a, unsigned long b, unsigned long *res)
Definition: vlc_common.h:825

Converts `a` and `b` to the type of `*r`. Then computes the sum of both conversions while checking for overflow. Finally stores the result in `*r`.

Parameters
 a an integer b an integer r a pointer to an integer [OUT]
Return values
 false The sum did not overflow. true The sum overflowed.

## ◆ mul_overflow

 #define mul_overflow ( a, b, r )
Value:
_Generic(*(r), \
unsigned: umul_overflow(a, b, (unsigned *)(r)), \
unsigned long: umull_overflow(a, b, (unsigned long *)(r)), \
unsigned long long: umulll_overflow(a, b, (unsigned long long *)(r)))
static bool umulll_overflow(unsigned long long a, unsigned long long b, unsigned long long *res)
Definition: vlc_common.h:910
static bool umull_overflow(unsigned long a, unsigned long b, unsigned long *res)
Definition: vlc_common.h:899
static bool umul_overflow(unsigned a, unsigned b, unsigned *res)
Definition: vlc_common.h:889

Overflowing multiplication.

Converts `a` and `b` to the type of `*r`. Then computes the product of both conversions while checking for overflow. Finally stores the result in `*r`.

Parameters
 a an integer b an integer r a pointer to an integer [OUT]
Return values
 false The product did not overflow. true The product overflowed.

## Function Documentation

 static bool uadd_overflow ( unsigned a, unsigned b, unsigned * res )
inlinestatic

 static bool uaddl_overflow ( unsigned long a, unsigned long b, unsigned long * res )
inlinestatic

 static bool uaddll_overflow ( unsigned long long a, unsigned long long b, unsigned long long * res )
inlinestatic

## ◆ umul_overflow()

 static bool umul_overflow ( unsigned a, unsigned b, unsigned * res )
inlinestatic

## ◆ umull_overflow()

 static bool umull_overflow ( unsigned long a, unsigned long b, unsigned long * res )
inlinestatic

## ◆ umulll_overflow()

 static bool umulll_overflow ( unsigned long long a, unsigned long long b, unsigned long long * res )
inlinestatic