Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libvcodex/Vcdelta/vcdelta.h
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2003-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* *
19
***********************************************************************/
20
#ifndef _VCDELTA_H
21
#define _VCDELTA_H 1
22
23
/* Types and functions related to delta compression as defined by
24
** the IETF RFC3284 Proposed Standard.
25
**
26
** Written by Kiem-Phong Vo
27
*/
28
29
/* bits in the delta indicator byte */
30
#define VCD_DATACOMPRESS (1<<0) /* compressed unmatched data */
31
#define VCD_INSTCOMPRESS (1<<1) /* compressed instructions */
32
#define VCD_ADDRCOMPRESS (1<<2) /* compressed COPY addrs */
33
34
/* delta instruction types */
35
#define VCD_NOOP 0
36
#define VCD_ADD 1 /* data immediately follow */
37
#define VCD_RUN 2 /* a run of a single byte */
38
#define VCD_COPY 3 /* copy data from some earlier address */
39
#define VCD_BYTE 4 /* Vcinst_t.mode is the byte encoded */
40
41
/* Address modes are limited to 16 (VCD_ADDR). Of these, VCD_SELF
42
and VCD_HERE are reserved. The remaining modes are s+n < 16 where
43
s*256 is the size of "same address" cache and n is the size of the
44
"near address" cache.
45
*/
46
#define VCD_ADDR 16 /* the maximum number of address modes */
47
#define VCD_SELF 0 /* COPY addr is coded as itself */
48
#define VCD_HERE 1 /* COPY addr is offset from current pos */
49
50
/* buffer size requirement for encoding/decoding code tables */
51
#define VCD_TBLSIZE (6*256 + 64)
52
53
typedef struct _vcdinst_s Vcdinst_t; /* instruction type */
54
typedef struct _vcdcode_s Vcdcode_t; /* a pair of insts */
55
typedef struct _vcdtable_s Vcdtable_t; /* entire code table */
56
57
struct _vcdinst_s
58
{ Vcchar_t type; /* COPY, RUN, ADD, NOOP, BYTE */
59
Vcchar_t size; /* if 0, size coded separately */
60
Vcchar_t mode; /* address mode for COPY */
61
};
62
63
struct _vcdcode_s
64
{ Vcdinst_t inst1;
65
Vcdinst_t inst2;
66
};
67
68
struct _vcdtable_s
69
{ Vcchar_t s_near; /* size of near address cache */
70
Vcchar_t s_same; /* size of same address cache */
71
Vcdcode_t code[256]; /* codes -> instructions */
72
};
73
74
_BEGIN_EXTERNS_
75
76
#if _BLD_vcodex && defined(__EXPORT__)
77
#define extern __EXPORT__
78
#endif
79
80
extern ssize_t vcdputtable _ARG_((Vcdtable_t*, Void_t*, size_t));
81
extern int vcdgettable _ARG_((Vcdtable_t*, Void_t*, size_t));
82
83
#undef extern
84
85
_END_EXTERNS_
86
87
#endif /*_VCDELTA_H*/
88
89