diff --git a/Cargo.lock b/Cargo.lock index e05958928..af20cbf09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,25 @@ dependencies = [ "scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "arr_macro" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arr_macro_impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "arr_macro_impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "arrayvec" version = "0.4.11" @@ -1011,6 +1030,7 @@ dependencies = [ name = "rustpython-vm" version = "0.1.0" dependencies = [ + "arr_macro 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1855,6 +1875,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" +"checksum arr_macro 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d262b83f2f573121554ad6e764cd444303df85d86e5fcebc81903ddcf8dd3a97" +"checksum arr_macro_impl 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8decbe97ffec939e44228d91e5d0829ceb1616c6ed0984c09df164b1e7ebaafc" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum ascii-canvas 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b385d69402821a1c254533a011a312531cbcc0e3e24f19bbb4747a5a2daf37e2" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" diff --git a/vm/Cargo.toml b/vm/Cargo.toml index d4913b782..6ffc8c378 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -63,6 +63,7 @@ bitflags = "1.1" libc = "0.2" nix = "0.14.1" wtf8 = "0.0.3" +arr_macro = "0.1.2" flame = { version = "0.2", optional = true } flamer = { version = "0.3", optional = true } diff --git a/vm/src/stdlib/signal.rs b/vm/src/stdlib/signal.rs index d519c66dd..bf31c16e2 100644 --- a/vm/src/stdlib/signal.rs +++ b/vm/src/stdlib/signal.rs @@ -6,30 +6,14 @@ use std::sync::atomic::{AtomicBool, Ordering}; use num_traits::cast::ToPrimitive; +use arr_macro::arr; use nix::sys::signal; use nix::unistd::alarm as sig_alarm; -// Signal triggers -// TODO: 64 -const NSIG: usize = 15; +const NSIG: usize = 64; -static mut TRIGGERS: [AtomicBool; NSIG] = [ - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), - AtomicBool::new(false), -]; +// We cannot use the NSIG const in the arr macro. This will fail compilation if NSIG is different. +static mut TRIGGERS: [AtomicBool; NSIG] = arr![AtomicBool::new(false); 64]; extern "C" fn run_signal(signum: i32) { unsafe {