Skip to content

Commit 57e0f37

Browse files
committed
fixed header size declaration (noreturn is possible)
1 parent 0cd2388 commit 57e0f37

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

ext/zstds_ext/dictionary.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "zstds_ext/buffer.h"
1010
#include "zstds_ext/error.h"
1111
#include "zstds_ext/gvl.h"
12-
#include "zstds_ext/macro.h"
1312
#include "zstds_ext/option.h"
1413

1514
// -- initialization --
@@ -153,22 +152,23 @@ VALUE zstds_ext_get_dictionary_buffer_id(VALUE ZSTDS_EXT_UNUSED(self), VALUE buf
153152
return UINT2NUM(id);
154153
}
155154

156-
VALUE zstds_ext_get_dictionary_header_size(VALUE ZSTDS_EXT_UNUSED(self), VALUE buffer)
157-
{
158155
#if defined(HAVE_ZDICT_HEADER_SIZE)
156+
VALUE zstds_ext_get_dictionary_header_size(VALUE self, VALUE buffer)
157+
{
159158
zstds_result_t result = ZDICT_getDictHeaderSize(RSTRING_PTR(buffer), RSTRING_LEN(buffer));
160159
if (ZDICT_isError(result)) {
161160
zstds_ext_raise_error(zstds_ext_get_error(ZSTD_getErrorCode(result)));
162161
}
163162

164163
return SIZET2NUM(result);
164+
}
165165

166166
#else
167+
ZSTDS_EXT_NORETURN VALUE zstds_ext_get_dictionary_header_size(VALUE self, VALUE buffer)
168+
{
167169
zstds_ext_raise_error(ZSTDS_EXT_ERROR_NOT_IMPLEMENTED);
168-
169-
return SIZET2NUM(0);
170+
};
170171
#endif
171-
}
172172

173173
// -- exports --
174174

ext/zstds_ext/dictionary.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66

77
#include "ruby.h"
88

9+
#include "zstds_ext/macro.h"
10+
911
#define ZSTDS_EXT_DEFAULT_DICTIONARY_CAPACITY (1 << 17); // 128 KB
1012

1113
VALUE zstds_ext_train_dictionary_buffer(VALUE self, VALUE samples, VALUE options);
1214
VALUE zstds_ext_get_dictionary_buffer_id(VALUE self, VALUE buffer);
1315

16+
#if defined(HAVE_ZDICT_HEADER_SIZE)
17+
VALUE zstds_ext_get_dictionary_header_size(VALUE self, VALUE buffer);
18+
#else
19+
ZSTDS_EXT_NORETURN VALUE zstds_ext_get_dictionary_header_size(VALUE self, VALUE buffer);
20+
#endif
21+
1422
void zstds_ext_dictionary_exports(VALUE root_module);
1523

1624
#endif // ZSTDS_EXT_DICTIONARY_H

ext/zstds_ext/macro.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@
1010
#define ZSTDS_EXT_UNUSED(x) x
1111
#endif
1212

13+
#if defined(__GNUC__)
14+
#define ZSTDS_EXT_NORETURN __attribute__((__noreturn__))
15+
#else
16+
#define ZSTDS_EXT_NORETURN
17+
#endif
18+
1319
#endif // ZSTDS_EXT_MACRO_H

0 commit comments

Comments
 (0)