mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
safe arithmetic: disable on windows
This commit is contained in:
parent
73816b8e5a
commit
38af3d344a
@ -27,9 +27,11 @@
|
||||
to non-refs.")
|
||||
(register copy (λ [&Long] Long))
|
||||
|
||||
(register safe-add (λ [Long Long (Ref Long)] Bool))
|
||||
(register safe-sub (λ [Long Long (Ref Long)] Bool))
|
||||
(register safe-mul (λ [Long Long (Ref Long)] Bool))
|
||||
(not-on-windows ; this seems to generate invalid code on some windows machines
|
||||
(register safe-add (λ [Long Long (Ref Long)] Bool))
|
||||
(register safe-sub (λ [Long Long (Ref Long)] Bool))
|
||||
(register safe-mul (λ [Long Long (Ref Long)] Bool))
|
||||
)
|
||||
|
||||
(register abs (λ [Long] Long))
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
(system-include "carp_safe_int.h")
|
||||
|
||||
(defmodule Int
|
||||
(doc safe-add "Performs an addition and checks whether it overflowed.")
|
||||
(register safe-add (λ [Int Int (Ref Int)] Bool))
|
||||
(doc safe-sub "Performs an substraction and checks whether it overflowed.")
|
||||
(register safe-sub (λ [Int Int (Ref Int)] Bool))
|
||||
(doc safe-mul "Performs an multiplication and checks whether it overflowed.")
|
||||
(register safe-mul (λ [Int Int (Ref Int)] Bool))
|
||||
(not-on-windows ; this seems to generate invalid code on some windows machines
|
||||
(doc safe-add "Performs an addition and checks whether it overflowed.")
|
||||
(register safe-add (λ [Int Int (Ref Int)] Bool))
|
||||
(doc safe-sub "Performs an substraction and checks whether it overflowed.")
|
||||
(register safe-sub (λ [Int Int (Ref Int)] Bool))
|
||||
(doc safe-mul "Performs an multiplication and checks whether it overflowed.")
|
||||
(register safe-mul (λ [Int Int (Ref Int)] Bool))
|
||||
)
|
||||
)
|
||||
|
@ -10,6 +10,7 @@ Long Long__MUL_(Long x, Long y) {
|
||||
Long Long__DIV_(Long x, Long y) {
|
||||
return x / y;
|
||||
}
|
||||
#ifndef _WIN32
|
||||
bool Long_safe_MINUS_add(Long x, Long y, Long* res) {
|
||||
return __builtin_add_overflow(x, y, res);
|
||||
}
|
||||
@ -19,6 +20,7 @@ bool Long_safe_MINUS_sub(Long x, Long y, Long* res) {
|
||||
bool Long_safe_MINUS_mul(Long x, Long y, Long* res) {
|
||||
return __builtin_mul_overflow(x, y, res);
|
||||
}
|
||||
#endif
|
||||
bool Long__EQ_(Long x, Long y) {
|
||||
return x == y;
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#ifndef _WIN32
|
||||
bool Int_safe_MINUS_add(int x, int y, int* res) {
|
||||
return __builtin_add_overflow(x, y, res);
|
||||
}
|
||||
@ -7,3 +8,4 @@ bool Int_safe_MINUS_sub(int x, int y, int* res) {
|
||||
bool Int_safe_MINUS_mul(int x, int y, int* res) {
|
||||
return __builtin_mul_overflow(x, y, res);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user