mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-28 18:30:06 +00:00
Require @(init) and @(fini) to be proc "contextless" ()
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
package math_big
|
||||
|
||||
import "base:intrinsics"
|
||||
import "base:runtime"
|
||||
import rnd "core:math/rand"
|
||||
|
||||
/*
|
||||
@@ -778,22 +779,23 @@ int_from_bytes_little_python :: proc(a: ^Int, buf: []u8, signed := false, alloca
|
||||
INT_ONE, INT_ZERO, INT_MINUS_ONE, INT_INF, INT_MINUS_INF, INT_NAN := &Int{}, &Int{}, &Int{}, &Int{}, &Int{}, &Int{}
|
||||
|
||||
@(init, private)
|
||||
_init_constants :: proc() {
|
||||
_init_constants :: proc "contextless" () {
|
||||
initialize_constants()
|
||||
}
|
||||
|
||||
initialize_constants :: proc() -> (res: int) {
|
||||
internal_set( INT_ZERO, 0); INT_ZERO.flags = {.Immutable}
|
||||
internal_set( INT_ONE, 1); INT_ONE.flags = {.Immutable}
|
||||
internal_set(INT_MINUS_ONE, -1); INT_MINUS_ONE.flags = {.Immutable}
|
||||
initialize_constants :: proc "contextless" () -> (res: int) {
|
||||
context = runtime.default_context()
|
||||
internal_int_set_from_integer( INT_ZERO, 0); INT_ZERO.flags = {.Immutable}
|
||||
internal_int_set_from_integer( INT_ONE, 1); INT_ONE.flags = {.Immutable}
|
||||
internal_int_set_from_integer(INT_MINUS_ONE, -1); INT_MINUS_ONE.flags = {.Immutable}
|
||||
|
||||
/*
|
||||
We set these special values to -1 or 1 so they don't get mistake for zero accidentally.
|
||||
This allows for shortcut tests of is_zero as .used == 0.
|
||||
*/
|
||||
internal_set( INT_NAN, 1); INT_NAN.flags = {.Immutable, .NaN}
|
||||
internal_set( INT_INF, 1); INT_INF.flags = {.Immutable, .Inf}
|
||||
internal_set(INT_MINUS_INF, -1); INT_MINUS_INF.flags = {.Immutable, .Inf}
|
||||
internal_int_set_from_integer( INT_NAN, 1); INT_NAN.flags = {.Immutable, .NaN}
|
||||
internal_int_set_from_integer( INT_INF, 1); INT_INF.flags = {.Immutable, .Inf}
|
||||
internal_int_set_from_integer(INT_MINUS_INF, -1); INT_MINUS_INF.flags = {.Immutable, .Inf}
|
||||
|
||||
return _DEFAULT_MUL_KARATSUBA_CUTOFF
|
||||
}
|
||||
|
||||
@@ -27,10 +27,11 @@
|
||||
|
||||
package math_big
|
||||
|
||||
import "core:mem"
|
||||
import "base:intrinsics"
|
||||
import rnd "core:math/rand"
|
||||
import "base:builtin"
|
||||
import "base:intrinsics"
|
||||
import "base:runtime"
|
||||
import "core:mem"
|
||||
import rnd "core:math/rand"
|
||||
|
||||
/*
|
||||
Low-level addition, unsigned. Handbook of Applied Cryptography, algorithm 14.7.
|
||||
@@ -2885,12 +2886,12 @@ internal_clear_if_uninitialized_multi :: proc(args: ..^Int, allocator := context
|
||||
}
|
||||
internal_clear_if_uninitialized :: proc {internal_clear_if_uninitialized_single, internal_clear_if_uninitialized_multi, }
|
||||
|
||||
internal_error_if_immutable_single :: proc(arg: ^Int) -> (err: Error) {
|
||||
internal_error_if_immutable_single :: proc "contextless" (arg: ^Int) -> (err: Error) {
|
||||
if arg != nil && .Immutable in arg.flags { return .Assignment_To_Immutable }
|
||||
return nil
|
||||
}
|
||||
|
||||
internal_error_if_immutable_multi :: proc(args: ..^Int) -> (err: Error) {
|
||||
internal_error_if_immutable_multi :: proc "contextless" (args: ..^Int) -> (err: Error) {
|
||||
for i in args {
|
||||
if i != nil && .Immutable in i.flags { return .Assignment_To_Immutable }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user