aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-09-02 15:51:48 +0100
committerGinger Bill <bill@gingerbill.org>2016-09-02 15:51:48 +0100
commite1a6775661d1ef57b84effa9b4c567c030b87556 (patch)
tree47de7c1dee8b691d750c1b35833194c8b0fe8d8a /examples
parent25e9b9bc87a5b4fa14fc7d47ca3077849ee5648d (diff)
Runtime assert
Diffstat (limited to 'examples')
-rw-r--r--examples/demo.odin3
-rw-r--r--examples/runtime.odin31
2 files changed, 15 insertions, 19 deletions
diff --git a/examples/demo.odin b/examples/demo.odin
index 4d2344185..79cd9643b 100644
--- a/examples/demo.odin
+++ b/examples/demo.odin
@@ -3,17 +3,16 @@
#load "game.odin"
main :: proc() {
-
print_int(min(1, 2)); nl()
print_int(max(1, 2)); nl()
print_int(abs(-1337)); nl()
a, b, c := 1, 2, -1337
+
print_int(min(a, b)); nl()
print_int(max(a, b)); nl()
print_int(abs(c) as int); nl()
-
nl()
/*
Vec3 :: type struct { x, y, z: f32 }
diff --git a/examples/runtime.odin b/examples/runtime.odin
index a512a9b8e..7a76a3bff 100644
--- a/examples/runtime.odin
+++ b/examples/runtime.odin
@@ -36,7 +36,7 @@ memory_copy :: proc(dst, src: rawptr, n: int) #inline {
}
v128b :: type {4}u32
- static_assert(align_of(v128b) == 16)
+ assert(align_of(v128b) == 16)
d, s: ^byte = dst, src
@@ -236,10 +236,6 @@ __string_eq :: proc(a, b: string) -> bool {
return memory_compare(^a[0], ^b[0], len(a)) == 0
}
-__string_ne :: proc(a, b : string) -> bool #inline {
- return !__string_eq(a, b)
-}
-
__string_cmp :: proc(a, b : string) -> int {
min_len := len(a)
if len(b) < min_len {
@@ -263,6 +259,7 @@ __string_cmp :: proc(a, b : string) -> int {
return 0
}
+__string_ne :: proc(a, b : string) -> bool #inline { return !__string_eq(a, b) }
__string_lt :: proc(a, b : string) -> bool #inline { return __string_cmp(a, b) < 0 }
__string_gt :: proc(a, b : string) -> bool #inline { return __string_cmp(a, b) > 0 }
__string_le :: proc(a, b : string) -> bool #inline { return __string_cmp(a, b) <= 0 }
@@ -291,9 +288,9 @@ Allocator :: type struct {
Context :: type struct {
- thread_id: i32
+ thread_id: int
- user_index: i32
+ user_index: int
user_data: rawptr
allocator: Allocator
@@ -350,11 +347,7 @@ default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment:
return null
}
- if new_size < old_size {
- new_size = old_size
- }
-
- if old_size == new_size {
+ if new_size == old_size {
return old_memory
}
@@ -362,11 +355,8 @@ default_resize_align :: proc(old_memory: rawptr, old_size, new_size, alignment:
if new_memory == null {
return null
}
- min_size := old_size;
- if min_size > new_size {
- min_size = new_size;
- }
- memory_copy(new_memory, old_memory, min_size);
+
+ memory_copy(new_memory, old_memory, min(old_size, new_size));
dealloc(old_memory)
return new_memory
}
@@ -399,3 +389,10 @@ __default_allocator :: proc() -> Allocator {
}
}
+
+
+
+__assert :: proc(msg: string) {
+ file_write(file_get_standard(File_Standard.ERROR), msg as []byte)
+ debug_trap()
+}