VLC 4.0.0-dev
Collaboration diagram for Overflowing arithmetic:

Macros

#define add_overflow(a, b, r)
 Overflowing addition. More...
 
#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)
 

Detailed Description

Macro Definition Documentation

◆ add_overflow

#define add_overflow (   a,
  b,
 
)
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:861
static bool uadd_overflow(unsigned a, unsigned b, unsigned *res)
Definition: vlc_common.h:840
static bool uaddl_overflow(unsigned long a, unsigned long b, unsigned long *res)
Definition: vlc_common.h:850

Overflowing addition.

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
aan integer
ban integer
ra pointer to an integer [OUT]
Return values
falseThe sum did not overflow.
trueThe sum overflowed.

◆ mul_overflow

#define mul_overflow (   a,
  b,
 
)
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:935
static bool umull_overflow(unsigned long a, unsigned long b, unsigned long *res)
Definition: vlc_common.h:924
static bool umul_overflow(unsigned a, unsigned b, unsigned *res)
Definition: vlc_common.h:914

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
aan integer
ban integer
ra pointer to an integer [OUT]
Return values
falseThe product did not overflow.
trueThe product overflowed.

Function Documentation

◆ uadd_overflow()

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

◆ uaddl_overflow()

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

◆ uaddll_overflow()

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