Skip to content

Commit e258899

Browse files
committed
Ensure builtin binaries are aligned to ibf_header
Since IBF result string size should be multiple of 4, this should not increase the binary size actually.
1 parent b5ac483 commit e258899

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

template/builtin_binary.inc.tmpl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,24 @@
55
% unless ARGV.include?('--cross=yes')
66
% ary = RubyVM.enum_for(:each_builtin).to_a
77
% ary.each{|feature, iseq|
8+
% bin = iseq.to_binary
89

9-
static const unsigned char <%= feature %>_bin[] = {
10-
% iseq \
11-
% . to_binary \
10+
static const union {
11+
unsigned char binary[<%= bin.bytesize %>];
12+
uint32_t align_as_ibf_header;
13+
} <%= feature %>_builtin = {
14+
.binary = {
15+
% bin \
1216
% . each_byte \
1317
% . each_slice(12) {|a|
14-
<%= a.map{ '0x%02x,' % _1 }.join(' ') %>
18+
<%= a.map{ '0x%02x,' % _1 }.join(' ') %>
1519
% }
20+
}
1621
};
1722
% }
1823

1924
#define BUILTIN_BIN(feature) \
20-
{ #feature, feature ## _bin, sizeof(feature ## _bin), }
25+
{ #feature, feature ## _builtin.binary, sizeof(feature ## _builtin.binary), }
2126
static const struct builtin_binary builtin_binary[] = {
2227
% ary.each{|feature, |
2328
BUILTIN_BIN(<%= feature %>),

0 commit comments

Comments
 (0)