Composite operations on unsigned long integers for non-i386 architectures. More...
#include <linux/types.h>
Go to the source code of this file.
Defines | |
#define | ul_shl_div(num, SHF, den) ((__u32) ((((__u64) ((__u32)(num))) << (SHF)) / (__u32)(den))) |
Computes '(num << SHF) / den' as unsigned long (32 bits). | |
#define | ul_mul_div(x, num, den) ((__u32) (((__u64) (x)) * (num) / (__u32)(den))) |
Computes '(x * num) / den' as unsigned long (32 bits). | |
#define | ul_mul_shr(x, y, SHF) ((__u32) ((((__u64) (x)) * (y)) >> (SHF))) |
Computes '(x * y) >> SHF' as unsigned long (32 bits). | |
#define | ul_shl_ceil(num, SHF, den) |
Computes 'ceil((num << SHF) / den)' as unsigned long (32 bits). |
Composite operations on unsigned long integers for non-i386 architectures.
Definition in file qos_ul_other.h.
#define ul_mul_div | ( | x, | |||
num, | |||||
den | ) | ((__u32) (((__u64) (x)) * (num) / (__u32)(den))) |
Computes '(x * num) / den' as unsigned long (32 bits).
Computation is carried on with intermediate result (x * num) on 64 bits.
x | an unsigned long integer (32 bits) | |
num | an unsigned long integer (32 bits) | |
den | an unsigned long integer (32 bits) |
Definition at line 56 of file qos_ul_other.h.
#define ul_mul_shr | ( | x, | |||
y, | |||||
SHF | ) | ((__u32) ((((__u64) (x)) * (y)) >> (SHF))) |
Computes '(x * y) >> SHF' as unsigned long (32 bits).
The computation is carried on with intermediate result (x*y) on 64 bits.
This macro is useful for multiplying two integers where one of them represents a real in fixed precision with SHF decimal bits (i.e. 1.0 is represented as 1ul<<SHF).
x | an unsigned long integer (32 bits) | |
y | an unsigned long integer (32 bits) | |
SHF | a macro which evaluates to an integer within 1 and 31 |
Definition at line 84 of file qos_ul_other.h.
#define ul_shl_ceil | ( | num, | |||
SHF, | |||||
den | ) |
({ \ __u64 _n = (__u64) (num); \ __u32 _d = (__u32) (den); \ __u32 _r = (__u32) ( ( (_n << (SHF)) + _d - 1) / _d ); \ _r; \ })
Computes 'ceil((num << SHF) / den)' as unsigned long (32 bits).
This macro makes the same computation as ul_shl_div, but the result is rounded up to the next value, if it cannot be precisely represented.
Definition at line 93 of file qos_ul_other.h.
#define ul_shl_div | ( | num, | |||
SHF, | |||||
den | ) | ((__u32) ((((__u64) ((__u32)(num))) << (SHF)) / (__u32)(den))) |
Computes '(num << SHF) / den' as unsigned long (32 bits).
Computation is carried on with intermediate result (num << SHF) on 64 bits. This macro is useful for representing the result of the division num/dev as a real in fixed precision with SHF decimal bits (i.e. 1.0 is represented as 1ul<<SHF).
num | an unsigned long integer (32 bits) | |
SHF | a macro which evaluates to an integer within 1 and 31 | |
den | an unsigned long integer (32 bits) |
Definition at line 30 of file qos_ul_other.h.