qos_ul_other.h File Reference

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).

Detailed Description

Composite operations on unsigned long integers for non-i386 architectures.

Definition in file qos_ul_other.h.


Define Documentation

#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.

Parameters:
x an unsigned long integer (32 bits)
num an unsigned long integer (32 bits)
den an unsigned long integer (32 bits)
Returns:
the result as an unsigned long integer (32 bits)
Note:
No overflow check is made after the division.
Todo:
Investigate on volatiles, that do not allow optimizations. They should not be required, but without them bw2Q(), which uses ul_mul_shr, outputs zero instead of the correct value.

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).

Parameters:
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
Returns:
the result as an unsigned long integer (32 bits)
Note:
No overflow check is made after the shift.
Todo:
Investigate on volatiles, that do not allow optimizations. They should not be required, but without them bw2Q(), which uses ul_mul_shr, outputs zero instead of the correct value.

Definition at line 84 of file qos_ul_other.h.

#define ul_shl_ceil ( num,
SHF,
den   ) 
Value:
({                      \
      __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).

Parameters:
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)
Returns:
the result as an unsigned long integer (32 bits)
Note:
No overflow check is made after the division.
Todo:
Investigate on volatiles, that do not allow optimizations. They should not be required, but without them bw2Q(), which uses ul_mul_shr, outputs zero instead of the correct value.

Definition at line 30 of file qos_ul_other.h.

Generated on Mon Aug 2 22:39:17 2010 for qosres by  doxygen 1.6.3