summaryrefslogtreecommitdiff
path: root/devel/got/files/openbsd-compat/util.h
blob: d985406bdee6087b8e6053c3c217c13c63ada181 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef _OPENBSD_COMPAT_UTIL_H_
#define _OPENBSD_COMPAT_UTIL_H_

#include <libutil.h>

/*
 * fmt_scaled(3) specific flags.
 */
#define FMT_SCALED_STRSIZE	7	/* minus sign, 4 digits, suffix, null byte */

#define fmt_scaled(number, result) ({					\
	int64_t num = number;						\
	int r = humanize_number(result,					\
	    FMT_SCALED_STRSIZE - (num < 0 ? 0 : 1),			\
	    num, "", HN_AUTOSCALE, HN_NOSPACE | HN_B);			\
	r == -1 ? -1 : 0;						\
})

#endif