Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/dsslib/ip_t/iv.h
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2000-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
* Glenn Fowler <[email protected]> *
18
* Phong Vo <[email protected]> *
19
* *
20
***********************************************************************/
21
#pragma prototyped
22
23
#ifndef _IV_H
24
#define _IV_H 1
25
26
/* Library for handling intervals of arbitrary sized unsigned integer points.
27
**
28
** ivset(iv, lo, hi, data): specifies an interval [lo,hi]
29
** associated with the given "data".
30
** ivget(iv, pt): find the data currently associated with "pt".
31
** ivdel(iv, lo, hi): deletes the specified interval [lo,hi].
32
**
33
** Written by Kiem-Phong Vo and Glenn Fowler.
34
*/
35
36
#include <fv.h>
37
38
#define IV_VERSION 20111001L
39
40
#define IV_OPEN 1
41
#define IV_CLOSE 2
42
43
/* types related to the interval handle */
44
typedef unsigned char* Ivpoint_t; /* interval point */
45
typedef struct Iv_s Iv_t; /* handle structure */
46
typedef struct Ivdisc_s Ivdisc_t; /* interval discipline */
47
typedef struct Ivmeth_s Ivmeth_t; /* interval method */
48
typedef struct Ivseg_s Ivseg_t; /* a segment of data */
49
50
typedef void (*Ivfree_f)(Iv_t*, void*);
51
52
struct Ivseg_s
53
{
54
unsigned char* lo;
55
unsigned char* hi;
56
void* data;
57
#ifdef _IV_SEG_PRIVATE_
58
_IV_SEG_PRIVATE_
59
#endif
60
};
61
62
struct Ivdisc_s
63
{
64
uint32_t version; /* api version */
65
void* unmatched; /* data for unmatched addresses */
66
Error_f errorf; /* error handling function */
67
Ivfree_f freef; /* for each Ivseg_t.data on ivclose() */
68
};
69
70
struct Ivmeth_s
71
{
72
const char* name;
73
const char* description;
74
const char* options;
75
unsigned char* (*getf)(Iv_t*, unsigned char*);
76
int (*setf)(Iv_t*, unsigned char*, unsigned char*, void*);
77
int (*delf)(Iv_t*, unsigned char*, unsigned char*);
78
Ivseg_t* (*segf)(Iv_t*, unsigned char*);
79
int (*eventf)(Iv_t*, int, void*);
80
};
81
82
struct Iv_s
83
{
84
Ivmeth_t* meth;
85
Ivdisc_t* disc;
86
void* data;
87
unsigned char* unit;
88
unsigned char* r1;
89
unsigned char* r2;
90
int size;
91
};
92
93
#define ivinit(p) (memset(p,0,sizeof(*(p))),(p)->version=IV_VERSION)
94
95
#define ivset(iv,lo,hi,dt) (*(iv)->meth->setf)((iv),(lo),(hi),(dt))
96
#define ivget(iv,pt) (*(iv)->meth->getf)((iv),(pt))
97
#define ivdel(iv,lo,hi) (*(iv)->meth->delf)((iv),(lo),(hi))
98
#define ivseg(iv,pt) (*(iv)->meth->segf)((iv),(pt))
99
100
_BEGIN_EXTERNS_
101
102
extern Ivmeth_t* ivmeth(const char*);
103
extern Iv_t* ivopen(Ivdisc_t*, Ivmeth_t*, int, const char*);
104
extern int ivclose(Iv_t*);
105
extern int ivstr(Iv_t*, const char*, char**, unsigned char*, unsigned char*);
106
extern char* ivfmt(Iv_t*, const unsigned char*, int);
107
108
_END_EXTERNS_
109
110
#if _BLD_iv || _BLD_ip_t || _PACKAGE_astsa
111
112
#define IVLIB(m) Ivmeth_t* Iv##m = &_##Iv##m;
113
114
#else
115
116
#if defined(__EXPORT__)
117
#define IVLIB(m) Ivmethod_t* Iv##m = &_##Iv##m; extern __EXPORT__ Ivmethod_t* vcodex_lib(const char* path) { return Iv##m; }
118
#else
119
#define IVLIB(m) Ivmethod_t* Iv##m = &_##Iv##m; extern Ivmethod_t* iv_lib(const char* path) { return Iv##m; }
120
#endif
121
122
#endif
123
124
#endif /* _IV_H */
125
126