-
Notifications
You must be signed in to change notification settings - Fork 92
/
common.h
46 lines (36 loc) · 910 Bytes
/
common.h
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
// SPDX-License-Identifier: GPL-3.0-only
/*
* Copyright (c) 2023 Dengfeng Liu <[email protected]>
*/
#ifndef XFRPC_COMMON_H
#define XFRPC_COMMON_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <assert.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include <event2/listener.h>
#include <event2/util.h>
#include <event2/event.h>
#include <event2/dns.h>
#include <event2/event_struct.h>
#include "uthash.h"
// Type definitions
typedef unsigned short ushort;
typedef uint64_t msg_size_t;
// Memory management macros
#define SAFE_FREE(m) do { \
if (m) { \
free(m); \
m = NULL; \
} \
} while(0)
// Network byte order conversion functions
uint64_t ntoh64(const uint64_t input);
uint64_t hton64(const uint64_t input);
// Message size conversion macros
#define msg_ntoh(l) ntoh64(l)
#define msg_hton(b) hton64(b)
#endif //XFRPC_COMMON_H