summaryrefslogtreecommitdiffstats
path: root/src/common/utils.c
blob: 7e4caa50fbdf0f27337bb2a8fa494cd39528a8e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "utils.h"

int cmp_uuid(uuid_t *first, uuid_t *second)
{
	if (first->hi == second->hi) {
		if (first->low == second->low) {
			return 0;
		} else if (first->low < second->low) {
			return -1;
		} else {
			return 1;
		}
	} else if (first->hi < second->hi) {
		return -1;
	} else {
		return 1;
	}
}

fpi1_t add(fpi1_t a, fpi1_t b)
{
	return a + b;
}

fpi1_t sub(fpi1_t a, fpi1_t b)
{
	return a - b;
}

fpi1_t mul(fpi1_t a, fpi1_t b)
{
	return (fpi1_t)(((long)a * (long)b) / 100);
}

fpi1_t div(fpi1_t a, fpi1_t b)
{
	return (fpi1_t)(((long)a * 10) / ((long)b * 10));
}