Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to fix crash on truffleruby #561

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions ext/pg_text_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ static ID s_id_utc;
static ID s_id_getlocal;
static ID s_id_BigDecimal;

static VALUE s_IPAddr;
static VALUE s_vmasks4;
static VALUE s_vmasks6;
static VALUE s_nan, s_pos_inf, s_neg_inf;
static VALUE s_IPAddr = Qnil;
static VALUE s_vmasks4 = Qnil;
static VALUE s_vmasks6 = Qnil;
static VALUE s_nan = Qnil, s_pos_inf = Qnil, s_neg_inf = Qnil;
static int use_ipaddr_alloc;
static ID s_id_lshift;
static ID s_id_add;
Expand Down Expand Up @@ -939,8 +939,8 @@ static VALUE
init_pg_text_decoder_inet(VALUE rb_mPG_TextDecoder)
{
rb_require("ipaddr");
s_IPAddr = rb_funcall(rb_cObject, rb_intern("const_get"), 1, rb_str_new2("IPAddr"));
rb_global_variable(&s_IPAddr);
s_IPAddr = rb_funcall(rb_cObject, rb_intern("const_get"), 1, rb_str_new2("IPAddr"));
s_ivar_family = rb_intern("@family");
s_ivar_addr = rb_intern("@addr");
s_ivar_mask_addr = rb_intern("@mask_addr");
Expand All @@ -950,10 +950,10 @@ init_pg_text_decoder_inet(VALUE rb_mPG_TextDecoder)

use_ipaddr_alloc = RTEST(rb_eval_string("IPAddr.new.instance_variables.sort == [:@addr, :@family, :@mask_addr]"));

s_vmasks4 = rb_eval_string("a = [0]*33; a[0] = 0; a[32] = 0xffffffff; 31.downto(1){|i| a[i] = a[i+1] - (1 << (31 - i))}; a.freeze");
rb_global_variable(&s_vmasks4);
s_vmasks6 = rb_eval_string("a = [0]*129; a[0] = 0; a[128] = 0xffffffffffffffffffffffffffffffff; 127.downto(1){|i| a[i] = a[i+1] - (1 << (127 - i))}; a.freeze");
s_vmasks4 = rb_eval_string("a = [0]*33; a[0] = 0; a[32] = 0xffffffff; 31.downto(1){|i| a[i] = a[i+1] - (1 << (31 - i))}; a.freeze");
rb_global_variable(&s_vmasks6);
s_vmasks6 = rb_eval_string("a = [0]*129; a[0] = 0; a[128] = 0xffffffffffffffffffffffffffffffff; 127.downto(1){|i| a[i] = a[i+1] - (1 << (127 - i))}; a.freeze");

/* dummy = rb_define_class_under( rb_mPG_TextDecoder, "Inet", rb_cPG_SimpleDecoder ); */
pg_define_coder( "Inet", pg_text_dec_inet, rb_cPG_SimpleDecoder, rb_mPG_TextDecoder);
Expand All @@ -970,12 +970,12 @@ init_pg_text_decoder(void)
s_id_utc = rb_intern("utc");
s_id_getlocal = rb_intern("getlocal");

s_nan = rb_eval_string("0.0/0.0");
rb_global_variable(&s_nan);
s_pos_inf = rb_eval_string("1.0/0.0");
s_nan = rb_eval_string("0.0/0.0");
rb_global_variable(&s_pos_inf);
s_neg_inf = rb_eval_string("-1.0/0.0");
s_pos_inf = rb_eval_string("1.0/0.0");
rb_global_variable(&s_neg_inf);
s_neg_inf = rb_eval_string("-1.0/0.0");

/* This module encapsulates all decoder classes with text input format */
rb_mPG_TextDecoder = rb_define_module_under( rb_mPG, "TextDecoder" );
Expand Down
Loading