summaryrefslogtreecommitdiff
path: root/c_src/util.h
blob: 30e7a64323a27fd40092ec6ca9f3e78e3d7649f1 (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
48
49
50
51
52
53
/*
 * Copyright (c) 2016, NORDUnet A/S.
 * See LICENSE for licensing information.
 */

#ifndef UTIL_H
#define UTIL_H

#define DEBUG_CACHE 0
#define DEBUG_WRITE 0
#define DEBUG_READ 0
#define DEBUG_REBUILD 0
#define DEBUG_PORT 0

#define dprintf(category,args) do { if (DEBUG_ ## category) { fprintf args; } } while (0)
#define dprinthex(category,data,size) do { if (DEBUG_ ## category) { print_hex(data, size); } } while (0)

/* HTONLL() is a macro on Darwin. */
#ifndef HTONLL
#define HTONLL(x) htobe64(x)
#endif

/* NTOHLL() is a macro on Darwin. */
#ifndef NTOHLL
#define NTOHLL(x) be64toh(x)
#endif

void
set_error(char **error, const char * __restrict, ...) __attribute__ ((__format__ (__printf__, 2, 3)));

uint64_t
calc_padding(uint64_t offset, uint64_t alignment);

void
print_entry(node_object node);

void
print_hex(const void *data, int length);

uint64_t
read_be64(const void *ptr);

uint32_t
read_be32(const void *ptr);

uint16_t
read_be16(const void *ptr);

#endif

/* Local Variables: */
/* c-file-style: "BSD" */
/* End: */