blob: 3a961b9777c88aeed66e50352993fae3528c5894 (
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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
/**CFile****************************************************************
FileName [xsatMemory.h]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [xSAT - A SAT solver written in C.
Read the license file for more info.]
Synopsis [Memory management implementation.]
Author [Bruno Schmitt <boschmitt@inf.ufrgs.br>]
Affiliation [UC Berkeley / UFRGS]
Date [Ver. 1.0. Started - November 10, 2016.]
Revision []
***********************************************************************/
#ifndef ABC__sat__xSAT__xsatMemory_h
#define ABC__sat__xSAT__xsatMemory_h
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "misc/util/abc_global.h"
#include "xsatClause.h"
ABC_NAMESPACE_HEADER_START
////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
typedef struct xSAT_Mem_t_ xSAT_Mem_t;
struct xSAT_Mem_t_
{
uint32_t nSize;
uint32_t nCap;
uint32_t nWasted;
uint32_t * pData;
};
////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline xSAT_Clause_t * xSAT_MemClauseHand( xSAT_Mem_t * p, int h )
{
return h != UINT32_MAX ? ( xSAT_Clause_t * )( p->pData + h ) : NULL;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void xSAT_MemGrow( xSAT_Mem_t * p, uint32_t nCap )
{
if ( p->nCap >= nCap )
return;
uint32_t nPrevCap = p->nCap;
while (p->nCap < nCap)
{
uint32_t delta = ((p->nCap >> 1) + (p->nCap >> 3) + 2) & ~1;
p->nCap += delta;
assert(p->nCap >= nPrevCap);
}
assert(p->nCap > 0);
p->pData = ABC_REALLOC(uint32_t, p->pData, p->nCap);
}
/**Function*************************************************************
Synopsis [Allocating vector.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline xSAT_Mem_t * xSAT_MemAlloc( int nCap )
{
xSAT_Mem_t * p;
p = ABC_CALLOC( xSAT_Mem_t, 1 );
if (nCap <= 0)
nCap = 1024*1024;
xSAT_MemGrow(p, nCap);
return p;
}
/**Function*************************************************************
Synopsis [Resetting vector.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void xSAT_MemRestart( xSAT_Mem_t * p )
{
p->nSize = 0;
p->nWasted = 0;
}
/**Function*************************************************************
Synopsis [Freeing vector.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void xSAT_MemFree( xSAT_Mem_t * p )
{
ABC_FREE( p->pData );
ABC_FREE( p );
}
/**Function*************************************************************
Synopsis [Creates new clause.]
Description [The resulting clause is fully initialized.]
SideEffects []
SeeAlso []
***********************************************************************/
static inline uint32_t xSAT_MemAppend( xSAT_Mem_t * p, int nSize )
{
assert(nSize > 0);
xSAT_MemGrow(p, p->nSize + nSize);
uint32_t nPrevSize = p->nSize;
p->nSize += nSize;
assert(p->nSize > nPrevSize);
return nPrevSize;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline uint32_t xSAT_MemCRef( xSAT_Mem_t * p, uint32_t * pC )
{
return ( uint32_t )( pC - &(p->pData[0]) );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline uint32_t xSAT_MemCap( xSAT_Mem_t * p )
{
return p->nCap;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline uint32_t xSAT_MemWastedCap( xSAT_Mem_t * p )
{
return p->nWasted;
}
ABC_NAMESPACE_HEADER_END
#endif
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
|