diff --git a/ChangeLog b/ChangeLog index b0dd1b15e4..c40e751330 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Wed Sep 3 21:31:59 2008 Tanaka Akira + + * transcode_data.h (WORDINDEX_SHIFT_BITS): defined. + (WORDINDEX2INFO): defined. + (INFO2WORDINDEX): defined. + + * tool/transcode-tblgen.rb: use WORDINDEX2INFO. + + * transcode.c: use INFO2WORDINDEX. + Wed Sep 3 21:19:51 2008 Kazuhiro NISHIYAMA * golf_prelude.rb: suppress warning when goruby -v. diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb index cbeccc35ec..75b88b0083 100644 --- a/tool/transcode-tblgen.rb +++ b/tool/transcode-tblgen.rb @@ -365,13 +365,13 @@ class ActionMap size = words_code.length words_code.insert_at_last(infos.length, - "\#define #{infos_name} (sizeof(unsigned int)*#{size})\n" + + "\#define #{infos_name} WORDINDEX2INFO(#{size})\n" + format_infos(infos) + "\n") end size = words_code.length words_code.insert_at_last(NUM_ELEM_BYTELOOKUP, - "\#define #{name} (sizeof(unsigned int)*#{size})\n" + + "\#define #{name} WORDINDEX2INFO(#{size})\n" + <<"End" + "\n") #{offsets_name}, #{infos_name}, diff --git a/transcode.c b/transcode.c index c404b0de02..aa89f12a8e 100644 --- a/transcode.c +++ b/transcode.c @@ -492,7 +492,7 @@ transcode_restartable0(const unsigned char **in_pos, unsigned char **out_pos, } #define BYTE_ADDR(index) (tr->byte_array + (index)) -#define WORD_ADDR(index) (tr->word_array + (index)/sizeof(*tr->word_array)) +#define WORD_ADDR(index) (tr->word_array + INFO2WORDINDEX(index)) #define BL_BASE(bl) BYTE_ADDR(BYTE_LOOKUP_BASE(WORD_ADDR(bl))) #define BL_INFO(bl) WORD_ADDR(BYTE_LOOKUP_INFO(WORD_ADDR(bl))) #define BL_MIN_BYTE(bl) (BL_BASE(bl)[0]) diff --git a/transcode_data.h b/transcode_data.h index 1ceb0cf473..6081aec81d 100644 --- a/transcode_data.h +++ b/transcode_data.h @@ -14,6 +14,9 @@ #ifndef RUBY_TRANSCODE_DATA_H #define RUBY_TRANSCODE_DATA_H 1 +#define WORDINDEX_SHIFT_BITS 2 +#define WORDINDEX2INFO(widx) ((widx) << WORDINDEX_SHIFT_BITS) +#define INFO2WORDINDEX(info) ((info) >> WORDINDEX_SHIFT_BITS) #define BYTE_LOOKUP_BASE(bl) ((bl)[0]) #define BYTE_LOOKUP_INFO(bl) ((bl)[1])