From 7618907cad93430e5bb626706d4fe48b9b2ad2e9 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 16 Oct 2016 16:32:02 +0000 Subject: [PATCH] runtime: use i64 for watchdog timeout, not i32. --- artiq/compiler/transforms/artiq_ir_generator.py | 2 +- artiq/compiler/transforms/llvm_ir_generator.py | 2 +- artiq/runtime.rs/libksupport/Cargo.lock | 1 + artiq/runtime.rs/libksupport/lib.rs | 7 +++++-- artiq/test/libartiq_support/artiq_time.c | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index 0c753e984..330ff0ecf 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -821,7 +821,7 @@ class ARTIQIRGenerator(algorithm.Visitor): timeout = self.visit(context_expr_node.args[0]) timeout_ms = self.append(ir.Arith(ast.Mult(loc=None), timeout, ir.Constant(1000, builtins.TFloat()))) - timeout_ms_int = self.append(ir.Coerce(timeout_ms, builtins.TInt32())) + timeout_ms_int = self.append(ir.Coerce(timeout_ms, builtins.TInt64())) watchdog_id = self.append(ir.Builtin("watchdog_set", [timeout_ms_int], builtins.TInt32())) diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index 1e5dfcde3..371d6ca29 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -356,7 +356,7 @@ class LLVMIRGenerator: elif name == "now": llty = lli64 elif name == "watchdog_set": - llty = ll.FunctionType(lli32, [lli32]) + llty = ll.FunctionType(lli32, [lli64]) elif name == "watchdog_clear": llty = ll.FunctionType(llvoid, [lli32]) else: diff --git a/artiq/runtime.rs/libksupport/Cargo.lock b/artiq/runtime.rs/libksupport/Cargo.lock index 042a9a750..da7d2b081 100644 --- a/artiq/runtime.rs/libksupport/Cargo.lock +++ b/artiq/runtime.rs/libksupport/Cargo.lock @@ -1,3 +1,4 @@ [root] name = "ksupport" version = "0.0.0" + diff --git a/artiq/runtime.rs/libksupport/lib.rs b/artiq/runtime.rs/libksupport/lib.rs index 4163482ab..5b12c360e 100644 --- a/artiq/runtime.rs/libksupport/lib.rs +++ b/artiq/runtime.rs/libksupport/lib.rs @@ -142,8 +142,11 @@ pub extern fn __artiq_terminate(exception: *const kernel_proto::Exception, loop {} } -extern fn watchdog_set(ms: i32) -> usize { - // FIXME: fix ms +extern fn watchdog_set(ms: i64) -> usize { + if ms < 0 { + artiq_raise!("ValueError", "cannot set a watchdog with a negative timeout") + } + send(&WatchdogSetRequest { ms: ms as u64 }); recv!(&WatchdogSetReply { id } => id) } diff --git a/artiq/test/libartiq_support/artiq_time.c b/artiq/test/libartiq_support/artiq_time.c index f60e46e47..07c81c9ac 100644 --- a/artiq/test/libartiq_support/artiq_time.c +++ b/artiq/test/libartiq_support/artiq_time.c @@ -3,7 +3,7 @@ int64_t now = 0; -int watchdog_set(int ms) +int watchdog_set(long long ms) { printf("watchdog_set %d\n", ms); return ms;