}
}
- if (!o->unit_base) {
+ if (o->unit_base == N2S_NONE) {
if (td_ioengine_flagged(td, FIO_BIT_BASED))
- o->unit_base = 1;
+ o->unit_base = N2S_BITPERSEC;
else
- o->unit_base = 8;
+ o->unit_base = N2S_BYTEPERSEC;
}
#ifndef FIO_HAVE_ANY_FALLOCATE
* @maxlen: max number of digits in the output string (not counting prefix and units, but counting .)
* @base: multiplier for num (e.g., if num represents Ki, use 1024)
* @pow2: select unit prefix - 0=power-of-10 decimal SI, nonzero=power-of-2 binary IEC
- * @units: select units - N2S_* macros defined in num2str.h
+ * @units: select units - N2S_* constants defined in num2str.h
* @returns a malloc'd buffer containing "number[<unit prefix>][<units>]"
*/
-char *num2str(uint64_t num, int maxlen, int base, int pow2, int units)
+char *num2str(uint64_t num, int maxlen, int base, int pow2, enum n2s_unit units)
{
const char *sistr[] = { "", "k", "M", "G", "T", "P" };
const char *iecstr[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
base /= thousand[!!pow2];
switch (units) {
+ case N2S_NONE:
+ break;
case N2S_PERSEC:
unit_index = 1;
break;
#include <inttypes.h>
-#define N2S_NONE 0
-#define N2S_BITPERSEC 1 /* match unit_base for bit rates */
-#define N2S_PERSEC 2
-#define N2S_BIT 3
-#define N2S_BYTE 4
-#define N2S_BYTEPERSEC 8 /* match unit_base for byte rates */
-
-extern char *num2str(uint64_t, int, int, int, int);
+enum n2s_unit {
+ N2S_NONE = 0,
+ N2S_BITPERSEC = 1,
+ N2S_PERSEC = 2,
+ N2S_BIT = 3,
+ N2S_BYTE = 4,
+ N2S_BYTEPERSEC = 8,
+};
+
+extern char *num2str(uint64_t, int, int, int, enum n2s_unit);
#endif