mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-23 02:09:38 +00:00
Merge branch 'master' into windows-llvm-13.0.0
This commit is contained in:
1786
core/math/linalg/glsl/linalg_glsl.odin
Normal file
1786
core/math/linalg/glsl/linalg_glsl.odin
Normal file
File diff suppressed because it is too large
Load Diff
63
core/math/linalg/glsl/linalg_glsl_math.odin
Normal file
63
core/math/linalg/glsl/linalg_glsl_math.odin
Normal file
@@ -0,0 +1,63 @@
|
||||
package math_linalg_glsl
|
||||
|
||||
import "core:math"
|
||||
|
||||
cos_f32 :: proc "c" (x: f32) -> f32 { return math.cos(x) }
|
||||
sin_f32 :: proc "c" (x: f32) -> f32 { return math.sin(x) }
|
||||
tan_f32 :: proc "c" (x: f32) -> f32 { return math.tan(x) }
|
||||
acos_f32 :: proc "c" (x: f32) -> f32 { return math.acos(x) }
|
||||
asin_f32 :: proc "c" (x: f32) -> f32 { return math.asin(x) }
|
||||
atan_f32 :: proc "c" (x: f32) -> f32 { return math.atan(x) }
|
||||
atan2_f32 :: proc "c" (y, x: f32) -> f32 { return math.atan2(y, x) }
|
||||
cosh_f32 :: proc "c" (x: f32) -> f32 { return math.cosh(x) }
|
||||
sinh_f32 :: proc "c" (x: f32) -> f32 { return math.sinh(x) }
|
||||
tanh_f32 :: proc "c" (x: f32) -> f32 { return math.tanh(x) }
|
||||
acosh_f32 :: proc "c" (x: f32) -> f32 { return math.acosh(x) }
|
||||
asinh_f32 :: proc "c" (x: f32) -> f32 { return math.asinh(x) }
|
||||
atanh_f32 :: proc "c" (x: f32) -> f32 { return math.atanh(x) }
|
||||
sqrt_f32 :: proc "c" (x: f32) -> f32 { return math.sqrt(x) }
|
||||
inversesqrt_f32 :: proc "c" (x: f32) -> f32 { return 1.0/math.sqrt(x) }
|
||||
pow_f32 :: proc "c" (x, y: f32) -> f32 { return math.pow(x, y) }
|
||||
exp_f32 :: proc "c" (x: f32) -> f32 { return math.exp(x) }
|
||||
log_f32 :: proc "c" (x: f32) -> f32 { return math.ln(x) }
|
||||
exp2_f32 :: proc "c" (x: f32) -> f32 { return math.pow(f32(2), x) }
|
||||
sign_f32 :: proc "c" (x: f32) -> f32 { return math.sign(x) }
|
||||
floor_f32 :: proc "c" (x: f32) -> f32 { return math.floor(x) }
|
||||
ceil_f32 :: proc "c" (x: f32) -> f32 { return math.ceil(x) }
|
||||
mod_f32 :: proc "c" (x, y: f32) -> f32 { return math.mod(x, y) }
|
||||
fract_f32 :: proc "c" (x: f32) -> f32 {
|
||||
if x >= 0 {
|
||||
return x - math.trunc(x)
|
||||
}
|
||||
return math.trunc(-x) + x
|
||||
}
|
||||
|
||||
cos_f64 :: proc "c" (x: f64) -> f64 { return math.cos(x) }
|
||||
sin_f64 :: proc "c" (x: f64) -> f64 { return math.sin(x) }
|
||||
tan_f64 :: proc "c" (x: f64) -> f64 { return math.tan(x) }
|
||||
acos_f64 :: proc "c" (x: f64) -> f64 { return math.acos(x) }
|
||||
asin_f64 :: proc "c" (x: f64) -> f64 { return math.asin(x) }
|
||||
atan_f64 :: proc "c" (x: f64) -> f64 { return math.atan(x) }
|
||||
atan2_f64 :: proc "c" (y, x: f64) -> f64 { return math.atan2(y, x) }
|
||||
cosh_f64 :: proc "c" (x: f64) -> f64 { return math.cosh(x) }
|
||||
sinh_f64 :: proc "c" (x: f64) -> f64 { return math.sinh(x) }
|
||||
tanh_f64 :: proc "c" (x: f64) -> f64 { return math.tanh(x) }
|
||||
acosh_f64 :: proc "c" (x: f64) -> f64 { return math.acosh(x) }
|
||||
asinh_f64 :: proc "c" (x: f64) -> f64 { return math.asinh(x) }
|
||||
atanh_f64 :: proc "c" (x: f64) -> f64 { return math.atanh(x) }
|
||||
sqrt_f64 :: proc "c" (x: f64) -> f64 { return math.sqrt(x) }
|
||||
inversesqrt_f64 :: proc "c" (x: f64) -> f64 { return 1.0/math.sqrt(x) }
|
||||
pow_f64 :: proc "c" (x, y: f64) -> f64 { return math.pow(x, y) }
|
||||
exp_f64 :: proc "c" (x: f64) -> f64 { return math.exp(x) }
|
||||
log_f64 :: proc "c" (x: f64) -> f64 { return math.ln(x) }
|
||||
exp2_f64 :: proc "c" (x: f64) -> f64 { return math.pow(f64(2), x) }
|
||||
sign_f64 :: proc "c" (x: f64) -> f64 { return math.sign(x) }
|
||||
floor_f64 :: proc "c" (x: f64) -> f64 { return math.floor(x) }
|
||||
ceil_f64 :: proc "c" (x: f64) -> f64 { return math.ceil(x) }
|
||||
mod_f64 :: proc "c" (x, y: f64) -> f64 { return math.mod(x, y) }
|
||||
fract_f64 :: proc "c" (x: f64) -> f64 {
|
||||
if x >= 0 {
|
||||
return x - math.trunc(x)
|
||||
}
|
||||
return math.trunc(-x) + x
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ package runtime
|
||||
import "core:intrinsics"
|
||||
|
||||
@(private)
|
||||
RUNTIME_LINKAGE :: "strong" when ODIN_USE_SEPARATE_MODULES else "internal"
|
||||
RUNTIME_LINKAGE :: "strong" when (ODIN_USE_SEPARATE_MODULES || ODIN_BUILD_MODE == "dynamic") else "internal"
|
||||
|
||||
@(private)
|
||||
byte_slice :: #force_inline proc "contextless" (data: rawptr, len: int) -> []byte #no_bounds_check {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package runtime
|
||||
|
||||
when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" {
|
||||
@(link_name="memset", require)
|
||||
when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" || ODIN_NO_CRT {
|
||||
@(link_name="memset", linkage="strong", require)
|
||||
memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
|
||||
if ptr != nil && len != 0 {
|
||||
b := byte(val)
|
||||
@@ -13,7 +13,7 @@ when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" {
|
||||
return ptr
|
||||
}
|
||||
|
||||
@(link_name="memmove", require)
|
||||
@(link_name="memmove", linkage="strong", require)
|
||||
memmove :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
|
||||
if dst != src {
|
||||
d, s := ([^]byte)(dst), ([^]byte)(src)
|
||||
@@ -25,32 +25,7 @@ when ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64" {
|
||||
return dst
|
||||
|
||||
}
|
||||
} else when ODIN_NO_CRT {
|
||||
@(link_name="memset", linkage=RUNTIME_LINKAGE, require)
|
||||
memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
|
||||
if ptr != nil && len != 0 {
|
||||
b := byte(val)
|
||||
p := ([^]byte)(ptr)
|
||||
for i in 0..<len {
|
||||
p[i] = b
|
||||
}
|
||||
}
|
||||
return ptr
|
||||
}
|
||||
|
||||
@(link_name="memmove", linkage=RUNTIME_LINKAGE, require)
|
||||
memmove :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
|
||||
if dst != src {
|
||||
d, s := ([^]byte)(dst), ([^]byte)(src)
|
||||
d_end, s_end := d[len:], s[len:]
|
||||
for i := len-1; i >= 0; i -= 1 {
|
||||
d[i] = s[i]
|
||||
}
|
||||
}
|
||||
return dst
|
||||
|
||||
}
|
||||
@(link_name="memcpy", linkage=RUNTIME_LINKAGE, require)
|
||||
@(link_name="memcpy", linkage="strong", require)
|
||||
memcpy :: proc "c" (dst, src: rawptr, len: int) -> rawptr {
|
||||
if dst != src {
|
||||
d, s := ([^]byte)(dst), ([^]byte)(src)
|
||||
|
||||
@@ -29,6 +29,7 @@ import big "core:math/big"
|
||||
import bits "core:math/bits"
|
||||
import fixed "core:math/fixed"
|
||||
import linalg "core:math/linalg"
|
||||
import glm "core:math/linalg/glsl"
|
||||
import rand "core:math/rand"
|
||||
import mem "core:mem"
|
||||
import ast "core:odin/ast"
|
||||
@@ -84,6 +85,7 @@ _ :: big
|
||||
_ :: bits
|
||||
_ :: fixed
|
||||
_ :: linalg
|
||||
_ :: glm
|
||||
_ :: rand
|
||||
_ :: mem
|
||||
_ :: ast
|
||||
|
||||
@@ -166,6 +166,7 @@ struct BuildContext {
|
||||
String ODIN_VENDOR; // compiler vendor
|
||||
String ODIN_VERSION; // compiler version
|
||||
String ODIN_ROOT; // Odin ROOT
|
||||
String ODIN_BUILD_MODE;
|
||||
bool ODIN_DEBUG; // Odin in debug mode
|
||||
bool ODIN_DISABLE_ASSERT; // Whether the default 'assert' et al is disabled in code or not
|
||||
bool ODIN_DEFAULT_TO_NIL_ALLOCATOR; // Whether the default allocator is a "nil" allocator or not (i.e. it does nothing)
|
||||
@@ -815,6 +816,24 @@ void init_build_context(TargetMetrics *cross_target) {
|
||||
bc->ODIN_VENDOR = str_lit("odin");
|
||||
bc->ODIN_VERSION = ODIN_VERSION;
|
||||
bc->ODIN_ROOT = odin_root_dir();
|
||||
switch (bc->build_mode) {
|
||||
default:
|
||||
case BuildMode_Executable:
|
||||
bc->ODIN_BUILD_MODE = str_lit("executable");
|
||||
break;
|
||||
case BuildMode_DynamicLibrary:
|
||||
bc->ODIN_BUILD_MODE = str_lit("dynamic");
|
||||
break;
|
||||
case BuildMode_Object:
|
||||
bc->ODIN_BUILD_MODE = str_lit("object");
|
||||
break;
|
||||
case BuildMode_Assembly:
|
||||
bc->ODIN_BUILD_MODE = str_lit("assembly");
|
||||
break;
|
||||
case BuildMode_LLVM_IR:
|
||||
bc->ODIN_BUILD_MODE = str_lit("llvm-ir");
|
||||
break;
|
||||
}
|
||||
|
||||
bc->copy_file_contents = true;
|
||||
|
||||
|
||||
@@ -778,6 +778,8 @@ void init_universal(void) {
|
||||
add_global_string_constant("ODIN_VENDOR", bc->ODIN_VENDOR);
|
||||
add_global_string_constant("ODIN_VERSION", bc->ODIN_VERSION);
|
||||
add_global_string_constant("ODIN_ROOT", bc->ODIN_ROOT);
|
||||
|
||||
add_global_string_constant("ODIN_BUILD_MODE", bc->ODIN_BUILD_MODE);
|
||||
add_global_bool_constant("ODIN_DEBUG", bc->ODIN_DEBUG);
|
||||
add_global_bool_constant("ODIN_DISABLE_ASSERT", bc->ODIN_DISABLE_ASSERT);
|
||||
add_global_bool_constant("ODIN_DEFAULT_TO_NIL_ALLOCATOR", bc->ODIN_DEFAULT_TO_NIL_ALLOCATOR);
|
||||
|
||||
@@ -1168,7 +1168,7 @@ lbValue lb_emit_array_ep(lbProcedure *p, lbValue s, lbValue index) {
|
||||
Type *t = s.type;
|
||||
GB_ASSERT_MSG(is_type_pointer(t), "%s", type_to_string(t));
|
||||
Type *st = base_type(type_deref(t));
|
||||
GB_ASSERT_MSG(is_type_array(st) || is_type_enumerated_array(st), "%s", type_to_string(st));
|
||||
GB_ASSERT_MSG(is_type_array(st) || is_type_enumerated_array(st) || is_type_matrix(st), "%s", type_to_string(st));
|
||||
GB_ASSERT_MSG(is_type_integer(core_type(index.type)), "%s", type_to_string(index.type));
|
||||
|
||||
LLVMValueRef indices[2] = {};
|
||||
@@ -1186,7 +1186,7 @@ lbValue lb_emit_array_epi(lbProcedure *p, lbValue s, isize index) {
|
||||
Type *t = s.type;
|
||||
GB_ASSERT(is_type_pointer(t));
|
||||
Type *st = base_type(type_deref(t));
|
||||
GB_ASSERT_MSG(is_type_array(st) || is_type_enumerated_array(st), "%s", type_to_string(st));
|
||||
GB_ASSERT_MSG(is_type_array(st) || is_type_enumerated_array(st) || is_type_matrix(st), "%s", type_to_string(st));
|
||||
|
||||
GB_ASSERT(0 <= index);
|
||||
Type *ptr = base_array_type(st);
|
||||
|
||||
@@ -1185,7 +1185,7 @@ bool parse_build_flags(Array<String> args) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (str == "dll" || str == "shared") {
|
||||
if (str == "dll" || str == "shared" || str == "dynamic") {
|
||||
build_context.build_mode = BuildMode_DynamicLibrary;
|
||||
} else if (str == "obj" || str == "object") {
|
||||
build_context.build_mode = BuildMode_Object;
|
||||
|
||||
Reference in New Issue
Block a user