From 3d2fd471b61ed8aaa762f11a2654dd5a501de895 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 25 Jul 2020 19:20:47 +0300 Subject: [PATCH] ci: prepare for enabling compilation with g++ again --- vlib/builtin/map.v | 16 ++++++++++------ vlib/v/gen/cgen.v | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/vlib/builtin/map.v b/vlib/builtin/map.v index c80b003d8f..896c3c2e38 100644 --- a/vlib/builtin/map.v +++ b/vlib/builtin/map.v @@ -124,8 +124,9 @@ fn (mut d DenseArray) push(key string, value voidptr) u32 { if d.cap == d.len { d.cap += d.cap >> 3 unsafe { - d.keys = &string(v_realloc(d.keys, sizeof(string) * d.cap)) - d.values = v_realloc(d.values, u32(d.value_bytes) * d.cap) + x := v_realloc(byteptr(d.keys), sizeof(string) * d.cap) + d.keys = &string(x) + d.values = v_realloc(byteptr(d.values), u32(d.value_bytes) * d.cap) } } push_index := d.len @@ -174,8 +175,9 @@ fn (mut d DenseArray) zeros_to_end() { d.len = count d.cap = if count < 8 { u32(8) } else { count } unsafe { - d.keys = &string(v_realloc(d.keys, sizeof(string) * d.cap)) - d.values = v_realloc(d.values, u32(d.value_bytes) * d.cap) + x := v_realloc(byteptr(d.keys), sizeof(string) * d.cap) + d.keys = &string(x) + d.values = v_realloc(byteptr(d.values), u32(d.value_bytes) * d.cap) } } @@ -280,7 +282,8 @@ fn (mut m map) ensure_extra_metas(probe_count u32) { m.extra_metas += extra_metas_inc mem_size := (m.cap + 2 + m.extra_metas) unsafe { - m.metas = &u32(v_realloc(m.metas, sizeof(u32) * mem_size)) + x := v_realloc(byteptr(m.metas), sizeof(u32) * mem_size) + m.metas = &u32(x) C.memset(m.metas + mem_size - extra_metas_inc, 0, sizeof(u32) * extra_metas_inc) } // Should almost never happen @@ -342,7 +345,8 @@ fn (mut m map) expand() { fn (mut m map) rehash() { meta_bytes := sizeof(u32) * (m.cap + 2 + m.extra_metas) unsafe { - m.metas = &u32(v_realloc(m.metas, meta_bytes)) + x := v_realloc(byteptr(m.metas), meta_bytes) + m.metas = &u32(x) C.memset(m.metas, 0, meta_bytes) } for i := u32(0); i < m.key_values.len; i++ { diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index cf1f13bd75..ae647abaad 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -16,7 +16,7 @@ const ( c_reserved = ['delete', 'exit', 'link', 'unix', 'error', 'calloc', 'malloc', 'free', 'panic', 'auto', 'char', 'default', 'do', 'double', 'extern', 'float', 'inline', 'int', 'long', 'register', 'restrict', 'short', 'signed', 'sizeof', 'static', 'switch', 'typedef', 'union', 'unsigned', 'void', - 'volatile', 'while', 'new', 'namespace', 'class', 'typename'] + 'volatile', 'while', 'new', 'namespace', 'class', 'typename', 'export'] // same order as in token.Kind cmp_str = ['eq', 'ne', 'gt', 'lt', 'ge', 'le'] // when operands are switched