summaryrefslogtreecommitdiffhomepage
path: root/src/internal/mdso_object_impl.h
blob: 539a77d82920d8de435975630bb888a8d172f26b (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
40
41
42
43
44
45
46
47
/****************************************************************/
/*  mdso: midipix dso scavenger                                 */
/*  Copyright (C) 2015--2024  SysDeer Technologies, LLC         */
/*  Released under GPLv2 and GPLv3; see COPYING.MDSO.           */
/****************************************************************/

#include <stdint.h>

static inline void mdso_obj_write_short(unsigned char * ch, uint16_t val)
{
	ch[0] = val;
	ch[1] = val >> 8;
}

static inline void mdso_obj_write_long(unsigned char * ch, uint32_t val)
{
	ch[0] = val;
	ch[1] = val >> 8;
	ch[2] = val >> 16;
	ch[3] = val >> 24;
}

static inline void mdso_obj_write_quad(unsigned char * ch, uint64_t val)
{
	ch[0] = val;
	ch[1] = val >> 8;
	ch[2] = val >> 16;
	ch[3] = val >> 24;
	ch[4] = val >> 32;
	ch[5] = val >> 40;
	ch[6] = val >> 48;
	ch[7] = val >> 56;
}

static inline void mdso_obj_write_dec(unsigned char * ch, uint64_t dec)
{
	int      digits;
	uint64_t val;

	*ch = '0';

	for (digits=0,val=dec; val; digits++)
		val /= 10;

	for (val=dec; val; val/=10)
		ch[--digits] = (val % 10) + '0';
}