Update code from OSX merge to be consistent with the rest of the code

Remove some dead code whilst I was here too :P
This commit is contained in:
Ginger Bill
2017-02-01 20:59:14 +00:00
parent c6133587d1
commit 205f4664f8
15 changed files with 162 additions and 249 deletions
+2
View File
@@ -11,6 +11,8 @@
main :: proc() {
i: int;
fmt.println("Hellope!");
x: [dynamic]f64;
defer free(x);
append(^x, 2_000_000.500_000, 3, 5, 7);
+6 -44
View File
@@ -1,6 +1,7 @@
#import "os.odin";
#import "mem.odin";
#import "utf8.odin";
#import "types.odin";
DEFAULT_BUFFER_SIZE :: 1<<12;
@@ -100,7 +101,6 @@ fprint_type :: proc(fd: os.Handle, info: ^Type_Info) {
os.write(fd, buf.data[:buf.length]);
}
buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) {
if ti == nil {
return;
@@ -197,7 +197,7 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) {
buffer_write_string(buf, field.name);
buffer_write_string(buf, ": ");
buffer_write_type(buf, field.type_info);
buffer_write_byte(buf, ';');
buffer_write_byte(buf, ',');
}
buffer_write_string(buf, "}");
@@ -207,7 +207,7 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) {
buffer_write_string(buf, field.name);
buffer_write_string(buf, ": ");
buffer_write_type(buf, field.type_info);
buffer_write_byte(buf, ';');
buffer_write_byte(buf, ',');
}
buffer_write_string(buf, "}");
@@ -217,7 +217,7 @@ buffer_write_type :: proc(buf: ^Buffer, ti: ^Type_Info) {
buffer_write_string(buf, field.name);
buffer_write_string(buf, ": ");
buffer_write_type(buf, field.type_info);
buffer_write_byte(buf, ';');
buffer_write_byte(buf, ',');
}
buffer_write_string(buf, "}");
@@ -235,7 +235,7 @@ bprint :: proc(buf: ^Buffer, args: ...any) -> int {
prev_string := false;
for arg, i in args {
is_string := arg.data != nil && is_type_string(arg.type_info);
is_string := arg.data != nil && types.is_string(arg.type_info);
if i > 0 && !is_string && !prev_string {
buffer_write_byte(buf, ' ');
}
@@ -279,44 +279,6 @@ sprintf :: proc(buf: []byte, fmt: string, args: ...any) -> string {
}
is_type_string :: proc(info: ^Type_Info) -> bool {
using Type_Info;
if info == nil {
return false;
}
match type i in type_info_base(info) {
case String:
return true;
}
return false;
}
is_type_integer :: proc(info: ^Type_Info) -> bool {
using Type_Info;
if info == nil {
return false;
}
match type i in type_info_base(info) {
case Integer:
return true;
}
return false;
}
is_type_float :: proc(info: ^Type_Info) -> bool {
using Type_Info;
if info == nil {
return false;
}
match type i in type_info_base(info) {
case Float:
return true;
}
return false;
}
parse_int :: proc(s: string, offset: int) -> (int, int, bool) {
@@ -697,7 +659,7 @@ fmt_enum :: proc(fi: ^Fmt_Info, v: any, verb: rune) {
case f64: f = cast(f64)v;
}
if is_type_integer(e.base) {
if types.is_string(e.base) {
for it, idx in e.values {
if it.i == i {
buffer_write_string(fi.buf, e.names[idx]);
+10 -10
View File
@@ -49,17 +49,17 @@ O_CLOEXEC :: 0x80000;
#foreign_system_library libc "c";
unix_open :: proc(path: ^u8, mode: int, perm: u32) -> Handle #foreign libc "open";
unix_close :: proc(handle: Handle) #foreign libc "close";
unix_read :: proc(handle: Handle, buffer: rawptr, count: int) -> int #foreign libc "read";
unix_write :: proc(handle: Handle, buffer: rawptr, count: int) -> int #foreign libc "write";
unix_gettid :: proc() -> u64 #foreign libc "gettid";
unix_open :: proc(path: ^u8, mode: int, perm: u32) -> Handle #foreign libc "open";
unix_close :: proc(handle: Handle) #foreign libc "close";
unix_read :: proc(handle: Handle, buffer: rawptr, count: int) -> int #foreign libc "read";
unix_write :: proc(handle: Handle, buffer: rawptr, count: int) -> int #foreign libc "write";
unix_gettid :: proc() -> u64 #foreign libc "gettid";
unix_malloc :: proc(size: int) -> rawptr #foreign libc "malloc";
unix_free :: proc(ptr: rawptr) #foreign libc "free";
unix_realloc :: proc(ptr: rawptr, size: int) -> rawptr #foreign libc "realloc";
unix_malloc :: proc(size: int) -> rawptr #foreign libc "malloc";
unix_free :: proc(ptr: rawptr) #foreign libc "free";
unix_realloc :: proc(ptr: rawptr, size: int) -> rawptr #foreign libc "realloc";
unix_exit :: proc(status: int) #foreign libc "exit";
unix_exit :: proc(status: int) #foreign libc "exit";
@@ -108,7 +108,7 @@ seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
// NOTE(bill): Uses startup to initialize it
stdin: Handle = 0; // get_std_handle(win32.STD_INPUT_HANDLE);
stdin: Handle = 0; // get_std_handle(win32.STD_INPUT_HANDLE);
stdout: Handle = 1; // get_std_handle(win32.STD_OUTPUT_HANDLE);
stderr: Handle = 2; // get_std_handle(win32.STD_ERROR_HANDLE);
+1 -1
View File
@@ -22,7 +22,7 @@ typedef struct BuildContext {
String const WIN32_SEPARATOR_STRING = {cast(u8 *)"\\", 1};
String const NIX_SEPARATOR_STRING = {cast(u8 *)"/", 1};
#if defined(WINDOWS)
#if defined(GB_SYSTEM_WINDOWS)
String odin_root_dir(void) {
String path = global_module_path;
Array(wchar_t) path_buf;
+5 -12
View File
@@ -225,9 +225,6 @@ i64 check_distance_between_types(Checker *c, Operand *operand, Type *type) {
return -1;
}
#ifndef _MAX
#define _MAX(x, y) ((x) > (y) ? (x) : (y))
#endif
bool check_is_assignable_to_with_score(Checker *c, Operand *operand, Type *type, i64 *score_) {
i64 score = 0;
@@ -235,8 +232,7 @@ bool check_is_assignable_to_with_score(Checker *c, Operand *operand, Type *type,
bool ok = distance >= 0;
if (ok) {
// TODO(bill): A decent score function
// score = max(1000000 - distance*distance, 0);
score = _MAX(1000000 - distance*distance, 0);
score = gb_max(1000000 - distance*distance, 0);
}
if (score_) *score_ = score;
return ok;
@@ -1008,10 +1004,6 @@ void check_identifier(Checker *c, Operand *o, AstNode *n, Type *named_type, Type
o->mode = Addressing_Value;
break;
case Entity_ImplicitValue:
o->mode = Addressing_Value;
break;
default:
compiler_error("Compiler error: Unknown EntityKind");
break;
@@ -2567,9 +2559,6 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h
case Entity_Nil:
operand->mode = Addressing_Value;
break;
case Entity_ImplicitValue:
operand->mode = Addressing_Value;
break;
}
operand->type = entity->type;
@@ -5105,6 +5094,10 @@ gbString write_expr_to_string(gbString str, AstNode *node) {
str = string_append_token(str, *i);
case_end;
case_ast_node(i, Implicit, node);
str = string_append_token(str, *i);
case_end;
case_ast_node(bl, BasicLit, node);
str = string_append_token(str, *bl);
case_end;
+1 -6
View File
@@ -723,8 +723,7 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
}
}
skip_expr:
; // again, declaring a variable immediately after a label... weird.
skip_expr:; // NOTE(zhiayang): again, declaring a variable immediately after a label... weird.
AstNode *lhs[2] = {rs->value, rs->index};
Type * rhs[2] = {val, idx};
@@ -1209,10 +1208,6 @@ void check_stmt_internal(Checker *c, AstNode *node, u32 flags) {
error(us->token, "`using` cannot be applied to a procedure");
break;
case Entity_ImplicitValue:
error(us->token, "`using` cannot be applied to an implicit value");
break;
case Entity_Nil:
error(us->token, "`using` cannot be applied to `nil`");
break;
+102 -67
View File
@@ -1,6 +1,108 @@
#include "exact_value.c"
#include "entity.c"
typedef enum ExprKind {
Expr_Expr,
Expr_Stmt,
} ExprKind;
// Statements and Declarations
typedef enum StmtFlag {
Stmt_BreakAllowed = 1<<0,
Stmt_ContinueAllowed = 1<<1,
Stmt_FallthroughAllowed = 1<<2,
Stmt_GiveAllowed = 1<<3,
} StmtFlag;
typedef struct BuiltinProc {
String name;
isize arg_count;
bool variadic;
ExprKind kind;
} BuiltinProc;
typedef enum BuiltinProcId {
BuiltinProc_Invalid,
BuiltinProc_new,
BuiltinProc_new_slice,
BuiltinProc_free,
BuiltinProc_reserve,
BuiltinProc_append,
BuiltinProc_size_of,
BuiltinProc_size_of_val,
BuiltinProc_align_of,
BuiltinProc_align_of_val,
BuiltinProc_offset_of,
BuiltinProc_offset_of_val,
BuiltinProc_type_of_val,
BuiltinProc_type_info,
BuiltinProc_type_info_of_val,
BuiltinProc_compile_assert,
BuiltinProc_assert,
BuiltinProc_panic,
BuiltinProc_copy,
// BuiltinProc_append,
BuiltinProc_swizzle,
// BuiltinProc_ptr_offset,
// BuiltinProc_ptr_sub,
BuiltinProc_slice_ptr,
BuiltinProc_min,
BuiltinProc_max,
BuiltinProc_abs,
BuiltinProc_clamp,
BuiltinProc_Count,
} BuiltinProcId;
gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = {
{STR_LIT(""), 0, false, Expr_Stmt},
{STR_LIT("new"), 1, false, Expr_Expr},
{STR_LIT("new_slice"), 2, false, Expr_Expr},
{STR_LIT("free"), 1, false, Expr_Stmt},
{STR_LIT("reserve"), 2, false, Expr_Stmt},
{STR_LIT("append"), 1, true, Expr_Expr},
{STR_LIT("size_of"), 1, false, Expr_Expr},
{STR_LIT("size_of_val"), 1, false, Expr_Expr},
{STR_LIT("align_of"), 1, false, Expr_Expr},
{STR_LIT("align_of_val"), 1, false, Expr_Expr},
{STR_LIT("offset_of"), 2, false, Expr_Expr},
{STR_LIT("offset_of_val"), 1, false, Expr_Expr},
{STR_LIT("type_of_val"), 1, false, Expr_Expr},
{STR_LIT("type_info"), 1, false, Expr_Expr},
{STR_LIT("type_info_of_val"), 1, false, Expr_Expr},
{STR_LIT("compile_assert"), 1, false, Expr_Stmt},
{STR_LIT("assert"), 1, false, Expr_Stmt},
{STR_LIT("panic"), 1, false, Expr_Stmt},
{STR_LIT("copy"), 2, false, Expr_Expr},
// {STR_LIT("append"), 2, false, Expr_Expr},
{STR_LIT("swizzle"), 1, true, Expr_Expr},
// {STR_LIT("ptr_offset"), 2, false, Expr_Expr},
// {STR_LIT("ptr_sub"), 2, false, Expr_Expr},
{STR_LIT("slice_ptr"), 2, false, Expr_Expr},
{STR_LIT("min"), 2, false, Expr_Expr},
{STR_LIT("max"), 2, false, Expr_Expr},
{STR_LIT("abs"), 1, false, Expr_Expr},
{STR_LIT("clamp"), 3, false, Expr_Expr},
};
typedef enum AddressingMode {
Addressing_Invalid,
@@ -105,73 +207,6 @@ typedef struct Scope {
} Scope;
gb_global Scope *universal_scope = NULL;
typedef enum ExprKind {
Expr_Expr,
Expr_Stmt,
} ExprKind;
// Statements and Declarations
typedef enum StmtFlag {
Stmt_BreakAllowed = 1<<0,
Stmt_ContinueAllowed = 1<<1,
Stmt_FallthroughAllowed = 1<<2,
Stmt_GiveAllowed = 1<<3,
} StmtFlag;
typedef struct BuiltinProc {
String name;
isize arg_count;
bool variadic;
ExprKind kind;
} BuiltinProc;
gb_global BuiltinProc builtin_procs[BuiltinProc_Count] = {
{STR_LIT(""), 0, false, Expr_Stmt},
{STR_LIT("new"), 1, false, Expr_Expr},
{STR_LIT("new_slice"), 2, false, Expr_Expr},
{STR_LIT("free"), 1, false, Expr_Stmt},
{STR_LIT("reserve"), 2, false, Expr_Stmt},
{STR_LIT("append"), 1, true, Expr_Expr},
{STR_LIT("size_of"), 1, false, Expr_Expr},
{STR_LIT("size_of_val"), 1, false, Expr_Expr},
{STR_LIT("align_of"), 1, false, Expr_Expr},
{STR_LIT("align_of_val"), 1, false, Expr_Expr},
{STR_LIT("offset_of"), 2, false, Expr_Expr},
{STR_LIT("offset_of_val"), 1, false, Expr_Expr},
{STR_LIT("type_of_val"), 1, false, Expr_Expr},
{STR_LIT("type_info"), 1, false, Expr_Expr},
{STR_LIT("type_info_of_val"), 1, false, Expr_Expr},
{STR_LIT("compile_assert"), 1, false, Expr_Stmt},
{STR_LIT("assert"), 1, false, Expr_Stmt},
{STR_LIT("panic"), 1, false, Expr_Stmt},
{STR_LIT("copy"), 2, false, Expr_Expr},
// {STR_LIT("append"), 2, false, Expr_Expr},
{STR_LIT("swizzle"), 1, true, Expr_Expr},
// {STR_LIT("ptr_offset"), 2, false, Expr_Expr},
// {STR_LIT("ptr_sub"), 2, false, Expr_Expr},
{STR_LIT("slice_ptr"), 2, false, Expr_Expr},
{STR_LIT("min"), 2, false, Expr_Expr},
{STR_LIT("max"), 2, false, Expr_Expr},
{STR_LIT("abs"), 1, false, Expr_Expr},
{STR_LIT("clamp"), 3, false, Expr_Expr},
};
typedef struct ImplicitValueInfo {
String name;
String backing_name;
Type * type;
} ImplicitValueInfo;
// NOTE(bill): This is initialized later
gb_global ImplicitValueInfo implicit_value_infos[ImplicitValue_Count] = {0};
+2 -73
View File
@@ -2,63 +2,6 @@ typedef struct Scope Scope;
typedef struct Checker Checker;
typedef struct Type Type;
// typedef enum BuiltinProcId BuiltinProcId;
// typedef enum ImplicitValueId ImplicitValueId;
typedef enum BuiltinProcId {
BuiltinProc_Invalid,
BuiltinProc_new,
BuiltinProc_new_slice,
BuiltinProc_free,
BuiltinProc_reserve,
BuiltinProc_append,
BuiltinProc_size_of,
BuiltinProc_size_of_val,
BuiltinProc_align_of,
BuiltinProc_align_of_val,
BuiltinProc_offset_of,
BuiltinProc_offset_of_val,
BuiltinProc_type_of_val,
BuiltinProc_type_info,
BuiltinProc_type_info_of_val,
BuiltinProc_compile_assert,
BuiltinProc_assert,
BuiltinProc_panic,
BuiltinProc_copy,
// BuiltinProc_append,
BuiltinProc_swizzle,
// BuiltinProc_ptr_offset,
// BuiltinProc_ptr_sub,
BuiltinProc_slice_ptr,
BuiltinProc_min,
BuiltinProc_max,
BuiltinProc_abs,
BuiltinProc_clamp,
BuiltinProc_Count,
} BuiltinProcId;
typedef enum ImplicitValueId {
ImplicitValue_Invalid,
ImplicitValue_context,
ImplicitValue_Count,
} ImplicitValueId;
#define ENTITY_KINDS \
@@ -71,7 +14,6 @@ typedef enum ImplicitValueId {
ENTITY_KIND(ImportName) \
ENTITY_KIND(LibraryName) \
ENTITY_KIND(Nil) \
ENTITY_KIND(ImplicitValue) \
ENTITY_KIND(Count)
typedef enum EntityKind {
@@ -136,7 +78,7 @@ struct Entity {
OverloadKind overload_kind;
} Procedure;
struct {
BuiltinProcId id;
i32 id;
} Builtin;
struct {
String path;
@@ -150,11 +92,6 @@ struct Entity {
bool used;
} LibraryName;
i32 Nil;
struct {
// TODO(bill): Should this be a user-level construct rather than compiler-level?
ImplicitValueId id;
Entity * backing;
} ImplicitValue;
};
};
@@ -229,7 +166,7 @@ Entity *make_entity_procedure(gbAllocator a, Scope *scope, Token token, Type *si
return entity;
}
Entity *make_entity_builtin(gbAllocator a, Scope *scope, Token token, Type *type, BuiltinProcId id) {
Entity *make_entity_builtin(gbAllocator a, Scope *scope, Token token, Type *type, i32 id) {
Entity *entity = alloc_entity(a, Entity_Builtin, scope, token, type);
entity->Builtin.id = id;
return entity;
@@ -258,14 +195,6 @@ Entity *make_entity_nil(gbAllocator a, String name, Type *type) {
return entity;
}
Entity *make_entity_implicit_value(gbAllocator a, String name, Type *type, ImplicitValueId id) {
Token token = make_token_ident(name);
Entity *entity = alloc_entity(a, Entity_ImplicitValue, NULL, token, type);
entity->ImplicitValue.id = id;
return entity;
}
Entity *make_entity_dummy_variable(gbAllocator a, Scope *scope, Token token) {
token.string = str_lit("_");
return make_entity_variable(a, scope, token, NULL, false);
+14 -14
View File
@@ -1,4 +1,4 @@
/* gb.h - v0.26d - Ginger Bill's C Helper Library - public domain
/* gb.h - v0.27 - Ginger Bill's C Helper Library - public domain
- no warranty implied; use at your own risk
This is a single header file with a bunch of useful stuff
@@ -298,7 +298,9 @@ extern "C" {
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#ifndef _IOSC11_SOURCE
#define _IOSC11_SOURCE
#endif
#include <stdlib.h> // NOTE(bill): malloc on linux
#include <sys/mman.h>
#if !defined(GB_SYSTEM_OSX)
@@ -312,18 +314,18 @@ extern "C" {
#endif
#if defined(GB_SYSTEM_OSX)
#include <mach/mach.h>
#include <mach/mach_init.h>
#include <mach/mach_time.h>
#include <mach/thread_act.h>
#include <mach/thread_policy.h>
#include <sys/sysctl.h>
#include <copyfile.h>
#include <mach/clock.h>
#include <mach/mach.h>
#include <mach/mach_init.h>
#include <mach/mach_time.h>
#include <mach/thread_act.h>
#include <mach/thread_policy.h>
#include <sys/sysctl.h>
#include <copyfile.h>
#include <mach/clock.h>
#endif
#if defined(GB_SYSTEM_UNIX)
#include <semaphore.h>
#include <semaphore.h>
#endif
@@ -4822,8 +4824,6 @@ GB_ALLOCATOR_PROC(gb_heap_allocator_proc) {
#else
// TODO(bill): *nix version that's decent
case gbAllocation_Alloc: {
// ptr = aligned_alloc(alignment, size);
posix_memalign(&ptr, alignment, size);
if (flags & gbAllocatorFlag_ClearToZero) {
@@ -4832,7 +4832,7 @@ GB_ALLOCATOR_PROC(gb_heap_allocator_proc) {
} break;
case gbAllocation_Free: {
// free(old_memory);
free(old_memory);
} break;
case gbAllocation_Resize: {
@@ -4929,7 +4929,7 @@ isize gb_affinity_thread_count_for_core(gbAffinity *a, isize core) {
void gb_affinity_init(gbAffinity *a) {
usize count, count_size = gb_size_of(count);
a->is_accurate = false;
a->is_accurate = false;
a->thread_count = 1;
a->core_count = 1;
a->threads_per_core = 1;
-2
View File
@@ -2591,8 +2591,6 @@ irValue *ir_build_single_expr(irProcedure *proc, AstNode *expr, TypeAndValue *tv
return NULL;
} else if (e->kind == Entity_Nil) {
return ir_make_value_nil(proc->module->allocator, tv->type);
} else if (e->kind == Entity_ImplicitValue) {
GB_PANIC("Illegal use of implicit value");
}
irValue **found = map_ir_value_get(&proc->module->values, hash_pointer(e));
+3 -4
View File
@@ -17,7 +17,6 @@ extern "C" {
// #include "vm.c"
#if defined(GB_SYSTEM_WINDOWS)
// NOTE(bill): `name` is used in debugging and profiling modes
i32 system_exec_command_line_app(char *name, bool is_silent, char *fmt, ...) {
STARTUPINFOW start_info = {gb_size_of(STARTUPINFOW)};
@@ -73,8 +72,9 @@ i32 system_exec_command_line_app(char *name, bool is_silent, char *fmt, ...) {
va_start(va, fmt);
cmd_len = gb_snprintf_va(cmd_line, gb_size_of(cmd_line), fmt, va);
va_end(va);
cmd = make_string(cast(u8 *)&cmd_line, cmd_len-1);
exit_code = system(cmd.text);
exit_code = system(&cmd_line[0]);
// pid_t pid = fork();
// int status = 0;
@@ -266,7 +266,7 @@ int main(int argc, char **argv) {
return exit_code;
}
#if 0
#if 1
timings_start_section(&timings, str_lit("llvm-llc"));
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html
exit_code = system_exec_command_line_app("llvm-llc", false,
@@ -329,7 +329,6 @@ int main(int argc, char **argv) {
#endif
#endif
return 0;
}
+5
View File
@@ -3230,8 +3230,13 @@ AstNode *parse_stmt(AstFile *f) {
}
if (e->kind == AstNode_Ident) {
return make_using_stmt(f, token, node);
} else if (e->kind == AstNode_Implicit) {
syntax_error(token, "Illegal use of `using` statement with implicit value `%.*s`", LIT(e->Implicit.string));
return make_bad_stmt(f, token, f->curr_token);
}
} break;
}
syntax_error(token, "Illegal use of `using` statement");
+7 -13
View File
@@ -15,6 +15,8 @@ typedef struct String {
} String;
// NOTE(bill): used for printf style arguments
#define LIT(x) ((int)(x).len), (x).text
#define STR_LIT(c_str) {cast(u8 *)c_str, gb_size_of(c_str)-1}
#define str_lit(c_str) (String){cast(u8 *)c_str, gb_size_of(c_str)-1}
typedef struct String16 {
@@ -46,7 +48,6 @@ gb_inline String make_string_c(char *text) {
return make_string(cast(u8 *)cast(void *)text, gb_strlen(text));
}
#define str_lit(c_str) (String){cast(u8 *)c_str, gb_size_of(c_str)-1}
@@ -174,32 +175,25 @@ bool string_contains_char(String s, u8 c) {
#if defined(GB_SYSTEM_WINDOWS)
int convert_multibyte_to_widechar(char* multibyte_input, int input_length, wchar_t* output, int output_size)
{
int convert_multibyte_to_widechar(char *multibyte_input, int input_length, wchar_t *output, int output_size) {
return MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, multibyte_input, input_length, output, output_size);
}
int convert_widechar_to_multibyte(wchar_t* widechar_input, int input_length, char* output, int output_size)
{
int convert_widechar_to_multibyte(wchar_t *widechar_input, int input_length, char *output, int output_size) {
return WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, widechar_input, input_length, output, output_size, NULL, NULL);
}
}
#elif defined(GB_SYSTEM_UNIX) || defined(GB_SYSTEM_OSX)
#include <iconv.h>
int convert_multibyte_to_widechar(char* multibyte_input, int input_length, wchar_t* output, int output_size)
{
int convert_multibyte_to_widechar(char *multibyte_input, int input_length, wchar_t *output, int output_size) {
iconv_t conv = iconv_open("WCHAR_T", "UTF-8");
size_t result = iconv(conv, (char**) &multibyte_input, &input_length, (char**) &output, &output_size);
size_t result = iconv(conv, cast(char **)&multibyte_input, &input_length, cast(char **)&output, &output_size);
iconv_close(conv);
return (int) result;
}
int convert_widechar_to_multibyte(wchar_t* widechar_input, int input_length, char* output, int output_size)
{
int convert_widechar_to_multibyte(wchar_t* widechar_input, int input_length, char* output, int output_size) {
iconv_t conv = iconv_open("UTF-8", "WCHAR_T");
size_t result = iconv(conv, (char**) &widechar_input, &input_length, (char**) &output, &output_size);
iconv_close(conv);
+2
View File
@@ -27,7 +27,9 @@ u64 win32_time_stamp__freq(void) {
return win32_perf_count_freq.QuadPart;
}
#elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX)
#include <time.h>
u64 unix_time_stamp_time_now(void) {
+2 -3
View File
@@ -192,7 +192,6 @@ void selection_add_index(Selection *s, isize index) {
#define STR_LIT(x) {cast(u8 *)(x), gb_size_of(x)-1}
gb_global Type basic_types[] = {
{Type_Basic, {Basic_Invalid, 0, 0, STR_LIT("invalid type")}},
{Type_Basic, {Basic_bool, BasicFlag_Boolean, 1, STR_LIT("bool")}},
@@ -1348,7 +1347,7 @@ void type_path_pop(TypePath *tp) {
i64 type_size_of(BaseTypeSizes s, gbAllocator allocator, Type *t);
i64 type_align_of(BaseTypeSizes s, gbAllocator allocator, Type *t);
i64 type_offset_of(BaseTypeSizes s, gbAllocator allocator, Type *t, isize index);
i64 type_offset_of(BaseTypeSizes s, gbAllocator allocator, Type *t, i32 index);
i64 type_size_of_internal (BaseTypeSizes s, gbAllocator allocator, Type *t, TypePath *path);
i64 type_align_of_internal(BaseTypeSizes s, gbAllocator allocator, Type *t, TypePath *path);
@@ -1735,7 +1734,7 @@ i64 type_size_of_internal(BaseTypeSizes s, gbAllocator allocator, Type *t, TypeP
return s.word_size;
}
i64 type_offset_of(BaseTypeSizes s, gbAllocator allocator, Type *t, isize index) {
i64 type_offset_of(BaseTypeSizes s, gbAllocator allocator, Type *t, i32 index) {
t = base_type(t);
if (t->kind == Type_Record && t->Record.kind == TypeRecord_Struct) {
type_set_offsets(s, allocator, t);