A Discrete-Event Network Simulator
API
Macros | Functions | Variables
cairo-wideint.c File Reference

Implementation of the cairo_x functions which implement high precision arithmetic. More...

#include "cairo-wideint-private.h"

Go to the source code of this file.

Macros

#define _cairo_msbset64(q)   (q & ((uint64_t) 1 << 63))
 
#define _cairo_uint32s_to_uint64(h, l)   ((uint64_t) (h) << 32 | (l))
 
#define uint64_carry32   (((uint64_t) 1) << 32)
 
#define uint64_hi(i)   ((i) >> 32)
 
#define uint64_hi32(i)   ((i) >> 32)
 
#define uint64_lo(i)   ((i) & 0xffffffff)
 
#define uint64_lo32(i)   ((i) & 0xffffffff)
 
#define uint64_shift32(i)   ((i) << 32)
 

Functions

cairo_quorem128_t _cairo_int128_divrem (cairo_int128_t num, cairo_int128_t den)
 
int _cairo_int128_lt (cairo_int128_t a, cairo_int128_t b)
 
cairo_int128_t _cairo_int32_to_int128 (int32_t i)
 
cairo_quorem64_t _cairo_int64_divrem (cairo_int64_t num, cairo_int64_t den)
 
cairo_int128_t _cairo_int64_to_int128 (cairo_int64_t i)
 
cairo_int128_t _cairo_int64x64_128_mul (cairo_int64_t a, cairo_int64_t b)
 
cairo_quorem64_t _cairo_int_96by64_32x64_divrem (cairo_int128_t num, cairo_int64_t den)
 
cairo_uint128_t _cairo_uint128_add (cairo_uint128_t a, cairo_uint128_t b)
 
cairo_uquorem128_t _cairo_uint128_divrem (cairo_uint128_t num, cairo_uint128_t den)
 
int _cairo_uint128_eq (cairo_uint128_t a, cairo_uint128_t b)
 
cairo_uint128_t _cairo_uint128_lsl (cairo_uint128_t a, int shift)
 
int _cairo_uint128_lt (cairo_uint128_t a, cairo_uint128_t b)
 
cairo_uint128_t _cairo_uint128_mul (cairo_uint128_t a, cairo_uint128_t b)
 
cairo_uint128_t _cairo_uint128_negate (cairo_uint128_t a)
 
cairo_uint128_t _cairo_uint128_not (cairo_uint128_t a)
 
cairo_uint128_t _cairo_uint128_rsa (cairo_int128_t a, int shift)
 
cairo_uint128_t _cairo_uint128_rsl (cairo_uint128_t a, int shift)
 
cairo_uint128_t _cairo_uint128_sub (cairo_uint128_t a, cairo_uint128_t b)
 
cairo_uint128_t _cairo_uint32_to_uint128 (uint32_t i)
 
cairo_uquorem64_t _cairo_uint64_divrem (cairo_uint64_t num, cairo_uint64_t den)
 
cairo_uint128_t _cairo_uint64_to_uint128 (cairo_uint64_t i)
 
cairo_uint128_t _cairo_uint64x64_128_mul (cairo_uint64_t a, cairo_uint64_t b)
 
cairo_uquorem64_t _cairo_uint_96by64_32x64_divrem (cairo_uint128_t num, cairo_uint64_t den)
 _cairo_uint_96by64_32x64_divrem: More...
 

Variables

const char * cairo_impl128 = "cairo_uint64_t"
 
const char * cairo_impl64 = "uint64_t"
 

Detailed Description

Implementation of the cairo_x functions which implement high precision arithmetic.

Definition in file cairo-wideint.c.

Macro Definition Documentation

◆ _cairo_msbset64

#define _cairo_msbset64 (   q)    (q & ((uint64_t) 1 << 63))

Definition at line 592 of file cairo-wideint.c.

Referenced by _cairo_uint128_divrem().

◆ _cairo_uint32s_to_uint64

#define _cairo_uint32s_to_uint64 (   h,
 
)    ((uint64_t) (h) << 32 | (l))

◆ uint64_carry32

#define uint64_carry32   (((uint64_t) 1) << 32)

Definition at line 415 of file cairo-wideint.c.

Referenced by _cairo_uint64x64_128_mul().

◆ uint64_hi

#define uint64_hi (   i)    ((i) >> 32)

Definition at line 413 of file cairo-wideint.c.

Referenced by _cairo_uint64x64_128_mul().

◆ uint64_hi32

#define uint64_hi32 (   i)    ((i) >> 32)

Definition at line 411 of file cairo-wideint.c.

Referenced by _cairo_uint64x64_128_mul(), and _cairo_uint_96by64_32x64_divrem().

◆ uint64_lo

#define uint64_lo (   i)    ((i) & 0xffffffff)

Definition at line 412 of file cairo-wideint.c.

Referenced by _cairo_uint64x64_128_mul().

◆ uint64_lo32

#define uint64_lo32 (   i)    ((i) & 0xffffffff)

Definition at line 410 of file cairo-wideint.c.

Referenced by _cairo_uint64x64_128_mul().

◆ uint64_shift32

#define uint64_shift32 (   i)    ((i) << 32)

Definition at line 414 of file cairo-wideint.c.

Referenced by _cairo_uint64x64_128_mul().

Function Documentation

◆ _cairo_int128_divrem()

cairo_quorem128_t _cairo_int128_divrem ( cairo_int128_t  num,
cairo_int128_t  den 
)

◆ _cairo_int128_lt()

int _cairo_int128_lt ( cairo_int128_t  a,
cairo_int128_t  b 
)

Definition at line 575 of file cairo-wideint.c.

References _cairo_int128_negative, and _cairo_uint128_lt().

◆ _cairo_int32_to_int128()

cairo_int128_t _cairo_int32_to_int128 ( int32_t  i)

Definition at line 355 of file cairo-wideint.c.

References _cairo_int32_to_int64, cairo_int128_t::hi, and cairo_int128_t::lo.

◆ _cairo_int64_divrem()

cairo_quorem64_t _cairo_int64_divrem ( cairo_int64_t  num,
cairo_int64_t  den 
)

◆ _cairo_int64_to_int128()

cairo_int128_t _cairo_int64_to_int128 ( cairo_int64_t  i)

◆ _cairo_int64x64_128_mul()

cairo_int128_t _cairo_int64x64_128_mul ( cairo_int64_t  a,
cairo_int64_t  b 
)

◆ _cairo_int_96by64_32x64_divrem()

cairo_quorem64_t _cairo_int_96by64_32x64_divrem ( cairo_int128_t  num,
cairo_int64_t  den 
)

◆ _cairo_uint128_add()

cairo_uint128_t _cairo_uint128_add ( cairo_uint128_t  a,
cairo_uint128_t  b 
)

◆ _cairo_uint128_divrem()

cairo_uquorem128_t _cairo_uint128_divrem ( cairo_uint128_t  num,
cairo_uint128_t  den 
)

◆ _cairo_uint128_eq()

int _cairo_uint128_eq ( cairo_uint128_t  a,
cairo_uint128_t  b 
)

Definition at line 585 of file cairo-wideint.c.

References _cairo_uint64_eq.

Referenced by ns3::int64x64_t::Udiv().

◆ _cairo_uint128_lsl()

cairo_uint128_t _cairo_uint128_lsl ( cairo_uint128_t  a,
int  shift 
)

◆ _cairo_uint128_lt()

int _cairo_uint128_lt ( cairo_uint128_t  a,
cairo_uint128_t  b 
)

◆ _cairo_uint128_mul()

cairo_uint128_t _cairo_uint128_mul ( cairo_uint128_t  a,
cairo_uint128_t  b 
)

Definition at line 500 of file cairo-wideint.c.

References _cairo_uint64_add, _cairo_uint64_mul, and _cairo_uint64x64_128_mul().

◆ _cairo_uint128_negate()

cairo_uint128_t _cairo_uint128_negate ( cairo_uint128_t  a)

Definition at line 631 of file cairo-wideint.c.

References _cairo_uint128_add(), _cairo_uint32_to_uint128(), and _cairo_uint64_not.

Referenced by ns3::output_sign().

◆ _cairo_uint128_not()

cairo_uint128_t _cairo_uint128_not ( cairo_uint128_t  a)

Definition at line 639 of file cairo-wideint.c.

References _cairo_uint64_not.

◆ _cairo_uint128_rsa()

cairo_uint128_t _cairo_uint128_rsa ( cairo_int128_t  a,
int  shift 
)

◆ _cairo_uint128_rsl()

cairo_uint128_t _cairo_uint128_rsl ( cairo_uint128_t  a,
int  shift 
)

◆ _cairo_uint128_sub()

cairo_uint128_t _cairo_uint128_sub ( cairo_uint128_t  a,
cairo_uint128_t  b 
)

Definition at line 397 of file cairo-wideint.c.

References _cairo_uint32_to_uint64, _cairo_uint64_gt, and _cairo_uint64_sub.

Referenced by _cairo_uint128_divrem().

◆ _cairo_uint32_to_uint128()

cairo_uint128_t _cairo_uint32_to_uint128 ( uint32_t  i)

◆ _cairo_uint64_divrem()

cairo_uquorem64_t _cairo_uint64_divrem ( cairo_uint64_t  num,
cairo_uint64_t  den 
)

◆ _cairo_uint64_to_uint128()

cairo_uint128_t _cairo_uint64_to_uint128 ( cairo_uint64_t  i)

Definition at line 365 of file cairo-wideint.c.

References _cairo_uint32_to_uint64.

Referenced by ns3::int64x64_t::Umul().

◆ _cairo_uint64x64_128_mul()

cairo_uint128_t _cairo_uint64x64_128_mul ( cairo_uint64_t  a,
cairo_uint64_t  b 
)

◆ _cairo_uint_96by64_32x64_divrem()

cairo_uquorem64_t _cairo_uint_96by64_32x64_divrem ( cairo_uint128_t  num,
cairo_uint64_t  den 
)

_cairo_uint_96by64_32x64_divrem:

Compute a 32 bit quotient and 64 bit remainder of a 96 bit unsigned dividend and 64 bit divisor. If the quotient doesn't fit into 32 bits then the returned remainder is equal to the divisor, and the quotient is the largest representable 64 bit integer. It is an error to call this function with the high 32 bits of ‘num’ being non-zero.

Definition at line 682 of file cairo-wideint.c.

References _cairo_uint128_rsl(), _cairo_uint128_to_uint32, _cairo_uint128_to_uint64, _cairo_uint32_to_uint64, _cairo_uint32s_to_uint64, _cairo_uint32x32_64_mul, _cairo_uint64_add, _cairo_uint64_divrem(), _cairo_uint64_ge, _cairo_uint64_lt, _cairo_uint64_sub, _cairo_uint64_to_uint32, cairo_uquorem64_t::quo, cairo_uquorem64_t::rem, uint64_hi32, and sample-rng-plot::x.

Referenced by _cairo_int_96by64_32x64_divrem().

Variable Documentation

◆ cairo_impl128

const char* cairo_impl128 = "cairo_uint64_t"

Definition at line 342 of file cairo-wideint.c.

Referenced by ns3::int64x64::test::Int64x64ImplTestCase::DoRun().

◆ cairo_impl64

const char* cairo_impl64 = "uint64_t"

Definition at line 44 of file cairo-wideint.c.

Referenced by ns3::int64x64::test::Int64x64ImplTestCase::DoRun().