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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#ifndef NFTABLES_GMPUTIL_H
#define NFTABLES_GMPUTIL_H
#include <config.h>
#ifdef HAVE_LIBGMP
#include <gmp.h>
#else
#include <mini-gmp.h>
#include <stdarg.h>
#include <stdio.h>
/* mini-gmp doesn't come with gmp_vfprintf, so we use our own minimal variant */
extern int mpz_vfprintf(FILE *fp, const char *format, va_list args);
#define gmp_vfprintf mpz_vfprintf
#endif
#include <inttypes.h>
#include <asm/byteorder.h>
enum mpz_word_order {
MPZ_MSWF = 1,
MPZ_LSWF = -1,
};
#ifdef __LITTLE_ENDIAN_BITFIELD
#define MPZ_HWO MPZ_LSWF
#elif defined(__BIG_ENDIAN_BITFIELD)
#define MPZ_HWO MPZ_MSWF
#else
#error "byteorder undefined"
#endif
enum mpz_byte_order {
MPZ_BIG_ENDIAN = 1,
MPZ_HOST_ENDIAN = 0,
MPZ_LITTLE_ENDIAN = -1,
};
extern void mpz_bitmask(mpz_t rop, unsigned int width);
extern void mpz_init_bitmask(mpz_t rop, unsigned int width);
extern void mpz_prefixmask(mpz_t rop, unsigned int width, unsigned int prefix_len);
extern void mpz_lshift_ui(mpz_t rop, unsigned int n);
extern void mpz_rshift_ui(mpz_t rop, unsigned int n);
extern uint64_t mpz_get_uint64(const mpz_t op);
extern uint32_t mpz_get_uint32(const mpz_t op);
extern uint16_t mpz_get_uint16(const mpz_t op);
extern uint8_t mpz_get_uint8(const mpz_t op);
extern uint32_t mpz_get_be32(const mpz_t op);
extern uint16_t mpz_get_be16(const mpz_t op);
enum byteorder;
extern void *__mpz_export_data(void *data, const mpz_t op,
enum byteorder byteorder, unsigned int len);
extern void __mpz_import_data(mpz_t rop, const void *data,
enum byteorder byteorder, unsigned int len);
extern void __mpz_switch_byteorder(mpz_t rop, unsigned int len);
#include <assert.h>
#include <datatype.h>
#define mpz_export_data(data, op, byteorder, len) \
{ \
assert(len > 0); \
__mpz_export_data(data, op, byteorder, len); \
}
#define mpz_import_data(rop, data, byteorder, len) \
{ \
assert(len > 0); \
__mpz_import_data(rop, data, byteorder, len); \
}
#define mpz_switch_byteorder(rop, len) \
{ \
assert(len > 0); \
__mpz_switch_byteorder(rop, len); \
}
#endif /* NFTABLES_GMPUTIL_H */
|