~ubuntu-branches/debian/sid/lvm2/sid

« back to all changes in this revision

Viewing changes to lib/misc/lvm-percent.h

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2014-08-19 15:37:06 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20140819153706-i1gaio8lg534dara
Tags: 2.02.109-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#define _LVM_PERCENT_H
17
17
#include <stdint.h>
18
18
 
19
 
/*
20
 
 * A fixed-point representation of percent values. One percent equals to
21
 
 * PERCENT_1 as defined below. Values that are not multiples of PERCENT_1
22
 
 * represent fractions, with precision of 1/1000000 of a percent. See
23
 
 * percent_to_float for a conversion to a floating-point representation.
24
 
 *
25
 
 * You should always use make_percent when building percent_t values. The
26
 
 * implementation of make_percent is biased towards the middle: it ensures that
27
 
 * the result is PERCENT_0 or PERCENT_100 if and only if this is the actual
28
 
 * value -- it never rounds any intermediate value (> 0 or < 100) to either 0
29
 
 * or 100.
30
 
 */
31
 
typedef int32_t percent_t;
32
 
 
33
19
typedef enum {
34
20
        SIGN_NONE = 0,
35
21
        SIGN_PLUS = 1,
45
31
        PERCENT_ORIGIN
46
32
} percent_type_t;
47
33
 
48
 
typedef enum {
49
 
        PERCENT_0 = 0,
50
 
        PERCENT_1 = 1000000,
51
 
        PERCENT_100 = 100 * PERCENT_1,
52
 
        PERCENT_INVALID = -1,
53
 
        PERCENT_MERGE_FAILED = -2
54
 
} percent_range_t;
55
 
 
56
 
float percent_to_float(percent_t v);
57
 
percent_t make_percent(uint64_t numerator, uint64_t denominator);
 
34
#define LVM_PERCENT_MERGE_FAILED DM_PERCENT_FAILED
58
35
 
59
36
uint32_t percent_of_extents(uint32_t percents, uint32_t count, int roundup);
60
37