1 /* compress-debug.c - compress debug sections
2 Copyright 2010 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
26 #include "compress-debug.h"
32 /* Initialize the compression engine. */
40 static struct z_stream_s strm;
45 deflateInit (&strm, Z_DEFAULT_COMPRESSION);
47 #endif /* HAVE_ZLIB_H */
50 /* Stream the contents of a frag to the compression engine. Output
51 from the engine goes into the current frag on the obstack. */
54 compress_data (struct z_stream_s *strm ATTRIBUTE_UNUSED,
55 const char **next_in ATTRIBUTE_UNUSED,
56 int *avail_in ATTRIBUTE_UNUSED,
57 char **next_out ATTRIBUTE_UNUSED,
58 int *avail_out ATTRIBUTE_UNUSED)
66 strm->next_in = (Bytef *) (*next_in);
67 strm->avail_in = *avail_in;
68 strm->next_out = (Bytef *) (*next_out);
69 strm->avail_out = *avail_out;
71 x = deflate (strm, Z_NO_FLUSH);
75 out_size = *avail_out - strm->avail_out;
76 *next_in = (char *) (strm->next_in);
77 *avail_in = strm->avail_in;
78 *next_out = (char *) (strm->next_out);
79 *avail_out = strm->avail_out;
82 #endif /* HAVE_ZLIB_H */
85 /* Finish the compression and consume the remaining compressed output.
86 Returns -1 for error, 0 when done, 1 when more output buffer is
90 compress_finish (struct z_stream_s *strm ATTRIBUTE_UNUSED,
91 char **next_out ATTRIBUTE_UNUSED,
92 int *avail_out ATTRIBUTE_UNUSED,
93 int *out_size ATTRIBUTE_UNUSED)
101 strm->next_out = (Bytef *) (*next_out);
102 strm->avail_out = *avail_out;
104 x = deflate (strm, Z_FINISH);
106 *out_size = *avail_out - strm->avail_out;
107 *next_out = (char *) (strm->next_out);
108 *avail_out = strm->avail_out;
110 if (x == Z_STREAM_END)
115 if (strm->avail_out != 0)
118 #endif /* HAVE_ZLIB_H */