blob: baae9f5f090af3f2059d6c5da57f231c94b7b9ff (
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
54
55
56
57
|
#ifndef PAIR_H
#define PAIR_H
#include "util.h"
/* This header contains struct definitions of some pairs. */
/* I probably should have named the fields by numbers, such as x1, x2,
etc, so that we can recursively declare these structs by macros.
But it is not worth the trouble to rewrite this I guess. */
typedef NUM pair1;
struct pair2_s { NUM x; NUM y; };
typedef struct pair2_s pair2;
struct pair3_s { NUM x; NUM y; NUM z; };
typedef struct pair3_s pair3;
struct pair4_s { NUM x; NUM y; NUM z; NUM u; };
typedef struct pair4_s pair4;
struct pair5_s { NUM x; NUM y; NUM z; NUM u; NUM v; };
typedef struct pair5_s pair5;
struct pair6_s { NUM x; NUM y; NUM z; NUM u; NUM v; NUM w; };
typedef struct pair6_s pair6;
#define COPY_PAIR1(DEST, SOUR) do { \
DEST.x = SOUR.y; \
} while (0)
#define COPY_PAIR2(DEST, SOUR) do { \
COPY_PAIR1(DEST, SOUR); \
DEST.y = SOUR.z; \
} while (0)
#define COPY_PAIR3(DEST, SOUR) do { \
COPY_PAIR2(DEST, SOUR); \
DEST.z = SOUR.u; \
} while (0)
#define COPY_PAIR4(DEST, SOUR) do { \
COPY_PAIR3(DEST, SOUR); \
DEST.u = SOUR.v; \
} while (0)
#define COPY_PAIR5(DEST, SOUR) do { \
COPY_PAIR4(DEST, SOUR); \
DEST.v = SOUR.w; \
} while (0)
#endif
|