Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / rst / rstzip3 / rstzip_v2 / rstzip2if.H
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: rstzip2if.H
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23// ========== Copyright Header Begin ==========================================
24//
25// OpenSPARC T2 Processor File: rstzip2if.H
26// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
27// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
28//
29// The above named program is free software; you can redistribute it and/or
30// modify it under the terms of the GNU General Public
31// License version 2 as published by the Free Software Foundation.
32//
33// The above named program is distributed in the hope that it will be
34// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
35// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36// General Public License for more details.
37//
38// You should have received a copy of the GNU General Public
39// License along with this work; if not, write to the Free Software
40// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
41//
42// ========== Copyright Header End ============================================
43#ifndef _RSTZIP2IF_H
44#define _RSTZIP2IF_H
45
46// ==== Programming Notes ====
47//
48// All programs using these routines must be linked with
49// /import/archperf/lib/32/librstzip2.a
50// /import/shade/v6/beta-2.0.0-32/lib/libspix_sparc.a
51// and
52// /import/archperf/local/lib/32/libz.a
53// or their respective 64bit versions.
54//
55// See
56// /import/archperf/pkgs/rstzip2-2.00/rstzip2.C
57// for an example of using this library.
58
59#include "rstf/rstf.h"
60
61#ifdef __cplusplus
62
63class RstzipIF; // Defined in rstzipif.H
64
65// C++ rstzip2 (de)compression class.
66
67class Rstzip2if {
68 public:
69 Rstzip2if();
70
71 ~Rstzip2if();
72
73 // ==== Compression example ====
74 //
75 // rstzip->openRstzip(outfile, BUFFERSIZE, gzip, stats, numcpus);
76 // while (nrecs > 0) {
77 // rstzip->compress(rstbuf, nrecs);
78 // nrecs = fread(rstbuf, sizeof(rstf_unionT), BUFFERSIZE, infp);
79 // }
80 // rstzip->closeRstzip();
81
82 // ==== Decompression example ====
83 //
84 // rstzip->openRstunzip(infile, BUFFERSIZE, gzip, stats);
85 // nrecs = rstzip->decompress(rstbuf, BUFFERSIZE);
86 // while (nrecs > 0) {
87 // fwrite(rstbuf, sizeof(rstf_unionT), nrecs, outfp);
88 // nrecs = rstzip->decompress(rstbuf, BUFFERSIZE);
89 // }
90 // rstzip->closeRstunzip();
91
92 // ==== Version routines ====
93
94 // DESCRIPTION
95 // Returns integers corresponding to the major and minor versions of the
96 // compressor library.
97 int getMajorVersion();
98 int getMinorVersion();
99
100 // ==== Compression routines ====
101
102 // DESCRIPTION
103 // Opens the file pointed to by 'outfile' and associates the Rstzip2if
104 // object with it.
105 //
106 // The argument 'buffersize' specifies the memory allocation size
107 // (in number of RST records) for the compressor's internal buffers.
108 // This argument must be greater then or equal to the largest
109 // 'nrecs' parameter that will be passed to passed to compress().
110 //
111 // The argument 'gzip' indicates whether the output should be gzip
112 // compressed in addition to rstzip2 compressed.
113 // gzip = 1 Gzip the output.
114 // gzip = 0 Do not gzip the output.
115 //
116 // The argument 'stats' indicates whether compression statistics should
117 // be printed to stderr after compression ends.
118 // stats = 1 Print compression stats
119 // stats = 0 Do no print compression stats.
120 //
121 // The argument 'numcpus' indicates whether the input trace is a
122 // multi-processor trace or not.
123 // numcpus = 1 Input is a uni-processor trace. Use this for compressing
124 // RST traces from versions 1.09 and below.
125 // numcpus = 0 (or anything other than 1) Input is an MP trace. Use
126 // this for compressing RST traces from versions 1.10 and
127 // above.
128 //
129 // RETURN VALUES
130 // None.
131 int openRstzip(const char* outfile, int buffersize, int gzip, int stats, int numcpus);
132
133 // DESCRIPTION
134 // Compresses exactly 'nrecs' RST records from 'rstbuf', and writes
135 // the compressed data to the file opened by openRstzip().
136 //
137 // The argument 'nrecs' must be less than or equal to the
138 // 'buffersize' passed to openRstzip(); otherwise, an error will be
139 // reported and the program will exit.
140 //
141 // RETURN VALUES
142 // The number of RST records compressed is returned; this value
143 // should be equal to 'nrecs'.
144 int compress(rstf_unionT* rstbuf, int nrecs);
145
146 // DESCRIPTION
147 // Flushes all internal compression buffers, writes compression statistics
148 // to the file footer, and closes the file opened by openRstzip(). This
149 // function must be called before exiting the program; otherwise, the end of
150 // the compressed file will be corrupt.
151 //
152 // RETURN VALUES
153 // None.
154 void closeRstzip();
155
156 // ==== Decompression routines ====
157
158 // DESCRIPTION
159 // Opens the file pointed to by 'infile' and associates the Rstzip2if
160 // object with it.
161 //
162 // The argument 'buffersize' specifies the memory allocation size
163 // (in number of RST records) for the compressor's internal buffers.
164 // This argument must be greater then or equal to the largest
165 // 'nrecs' parameter that will be passed to passed to decompress().
166 //
167 // The argument 'gzip' indicates whether the input should be gzip
168 // decompressed in addition to rstzip2 decompressed.
169 // gzip = 1 Gunzip the input.
170 // gzip = 0 Do not gunzip the input.
171 //
172 // The argument 'stats' indicates whether compression statistics should
173 // be printed to stderr after decompression ends.
174 // stats = 1 Print compression stats
175 // stats = 0 Do no print compression stats
176 //
177 // RETURN VALUES
178 // None.
179 int openRstunzip(const char* infile, int buffersize, int gzip, int stats);
180
181 // DESCRIPTION
182 // Decompresses up to 'nrecs' records from the file opened by
183 // openRstunzip(), and writes the decompressed records into 'rstbuf'.
184 //
185 // The argument 'nrecs' must be less than or equal to the
186 // 'buffersize' passed to openRstunzip(); otherwise, an error will be
187 // reported and the program will exit.
188 //
189 // RETURN VALUES
190 // The number of RST records decompressed is returned; this value
191 // should be equal to 'nrecs'.
192 int decompress(rstf_unionT* rstbuf, int nrecs);
193
194 // DESCRIPTION
195 // Flushes all internal decompression buffers, reads and compares
196 // the decompression statistics with the file footer, and closes the
197 // file opened by openRstunzip(). This function must be called
198 // before exiting the program; otherwise, the end of the
199 // decompressed file will be incomplete and possibly corrupt.
200 //
201 // RETURN VALUES
202 // None.
203 void closeRstunzip();
204
205 protected:
206 RstzipIF* rstzip;
207}; // Rstzip2if
208
209#else // __cplusplus
210
211 // Dummy C struct type.
212 typedef struct Rstzip2if Rstzip2if;
213
214#endif // __cplusplus
215
216#if 0
217
218// C wrapper prototypes.
219
220#ifdef __cplusplus
221extern "C" {
222#endif
223
224 // ==== Compression example ====
225 //
226 // rstzip = rz2_openRstzip(outfile, BUFFERSIZE, gzip, stats, numcpus);
227 // while (nrecs > 0) {
228 // rz2_compress(rstzip, rstbuf, nrecs);
229 // nrecs = fread(rstbuf, sizeof(rstf_unionT), BUFFERSIZE, infp);
230 // }
231 // rz2_closeRstzip(rstzip);
232
233 // ==== Decompression example ====
234 //
235 // rstzip = rz2_openRstunzip(infile, BUFFERSIZE, gzip, stats);
236 // nrecs = rz2_decompress(rstzip, rstbuf, BUFFERSIZE);
237 // while (nrecs > 0) {
238 // fwrite(rstbuf, sizeof(rstf_unionT), nrecs, outfp);
239 // nrecs = rz2_decompress(rstzip, rstbuf, BUFFERSIZE);
240 // }
241 // rz2_closeRstunzip(rstzip);
242
243 // ==== Version routines ====
244
245 // DESCRIPTION
246 // Returns integers corresponding to the major and minor versions of the
247 // compressor library.
248 int rz2_getMajorVersion(Rstzip2if* rstzip);
249 int rz2_getMinorVersion(Rstzip2if* rstzip);
250
251 // ==== Compression routines ====
252
253 // DESCRIPTION
254 // Opens the file pointed to by 'outfile' associates the Rstzip2if
255 // object with it.
256 //
257 // The argument 'buffersize' specifies the memory allocation size
258 // (in number of RST records) for the compressor's internal buffers.
259 // This argument must be greater then or equal to the largest
260 // 'nrecs' parameter that will be passed to passed to rz2_compress().
261 //
262 // The argument 'gzip' indicates whether the output should be gzip
263 // compressed in addition to rstzip2 compressed.
264 // gzip = 1 Gzip the output.
265 // gzip = 0 Do not gzip the output.
266 //
267 // The argument 'stats' indicates whether compression statistics should
268 // be printed to stderr after compression ends.
269 // stats = 1 Print compression stats
270 // stats = 0 Do no print compression stats.
271 //
272 // The argument 'numcpus' indicates whether the input trace is a
273 // multi-processor trace or not.
274 // numcpus = 1 Input is a uni-processor trace. Use this for compressing
275 // RST traces from versions 1.09 and below.
276 // numcpus = 0 (or anything other than 1) Input is an MP trace. Use
277 // this for compressing RST traces from versions 1.10 and
278 // above.
279 //
280 // RETURN VALUES
281 // A pointer to the allocated Rstzip2if object is returned.
282 Rstzip2if* rz2_openRstzip(const char* outfile, int buffersize, int gzip, int stats, int numcpus);
283
284 // DESCRIPTION
285 // Compresses exactly 'nrecs' RST records from 'rstbuf', and writes
286 // the compressed data to the file opened by rz2_openRstzip().
287 //
288 // The argument 'rstzip' must point to an Rstzip2if object
289 // previously allocated by calling rz2_openRstzip().
290 //
291 // The argument 'nrecs' must be less than or equal to the
292 // 'buffersize' passed to rz2_openRstzip(); otherwise, an error will be
293 // reported and the program will exit.
294 //
295 // RETURN VALUES
296 // The number of RST records compressed is returned; this value
297 // should be equal to 'nrecs'.
298 int rz2_compress(Rstzip2if* rstzip, rstf_unionT* rstbuf, int nrecs);
299
300 // DESCRIPTION
301 // Flushes all internal compression buffers, writes compression statistics
302 // to the file footer, and closes the file opened by rz2_openRstzip(). This
303 // function must be called before exiting the program; otherwise, the end of
304 // the compressed file will be corrupt.
305 //
306 // RETURN VALUES
307 // None.
308 void rz2_closeRstzip(Rstzip2if* rstzip);
309
310 // ==== Decompression routines ====
311
312 // DESCRIPTION
313 // Opens the file pointed to by 'infile' and associates the Rstzip2if
314 // object with it.
315 //
316 // The argument 'buffersize' specifies the memory allocation size
317 // (in number of RST records) for the compressor's internal buffers.
318 // This argument must be greater then or equal to the largest
319 // 'nrecs' parameter that will be passed to passed to decompress().
320 //
321 // The argument 'gzip' indicates whether the input should be gzip
322 // decompressed in addition to rstzip2 decompressed.
323 // gzip = 1 Gunzip the input.
324 // gzip = 0 Do not gunzip the input.
325 //
326 // The argument 'stats' indicates whether compression statistics should
327 // be printed to stderr after decompression ends.
328 // stats = 1 Print compression stats
329 // stats = 0 Do no print compression stats
330 //
331 // RETURN VALUES
332 // A pointer to the allocated Rstzip2if object is returned.
333 Rstzip2if* rz2_openRstunzip(const char* infile, int buffersize, int gzip, int stats);
334
335 // DESCRIPTION
336 // Decompresses up to 'nrecs' records from the file opened by
337 // rz2_openRstunzip(), and writes the decompressed records into 'rstbuf'.
338 //
339 // The argument 'nrecs' must be less than or equal to the
340 // 'buffersize' passed to rz2_openRstunzip(); otherwise, an error will be
341 // reported and the program will exit.
342 //
343 // RETURN VALUES
344 // The number of RST records decompressed is returned; this value
345 // should be equal to 'nrecs'.
346 int rz2_decompress(Rstzip2if* rstzip, rstf_unionT* rstbuf, int nrecs);
347
348 // DESCRIPTION
349 // Flushes all internal decompression buffers, reads and compares
350 // the decompression statistics with the file footer, and closes the
351 // file opened by rz2_openRstunzip(). This function must be called
352 // before exiting the program; otherwise, the end of the
353 // decompressed file will be incomplete and possibly corrupt.
354 //
355 // RETURN VALUES
356 // None.
357 void rz2_closeRstunzip(Rstzip2if* rstzip);
358
359#ifdef __cplusplus
360}
361#endif
362
363#endif
364
365#endif // _RSTZIP2IF_H