2015-07-21 11:36:45 +08:00
|
|
|
// This file is part of libfringe, a low-level green threading library.
|
2016-07-18 02:12:56 +08:00
|
|
|
// Copyright (c) Ben Segall <talchas@gmail.com>
|
|
|
|
// Copyright (c) edef <edef@edef.eu>
|
2016-08-21 05:45:01 +08:00
|
|
|
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
|
|
|
|
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
|
|
|
|
// http://opensource.org/licenses/MIT>, at your option. This file may not be
|
|
|
|
// copied, modified, or distributed except according to those terms.
|
2015-07-21 11:36:45 +08:00
|
|
|
#![cfg(target_os = "linux")]
|
|
|
|
#![feature(test)]
|
|
|
|
#![feature(thread_local)]
|
|
|
|
#![feature(asm)]
|
|
|
|
extern crate fringe;
|
|
|
|
extern crate test;
|
2016-08-09 21:59:35 +08:00
|
|
|
use fringe::{OsStack, Generator};
|
2015-07-21 11:36:45 +08:00
|
|
|
use test::black_box;
|
|
|
|
|
|
|
|
const FE_DIVBYZERO: i32 = 0x4;
|
|
|
|
extern {
|
|
|
|
fn feenableexcept(except: i32) -> i32;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[ignore]
|
|
|
|
fn fpe() {
|
2016-08-09 21:59:35 +08:00
|
|
|
let stack = OsStack::new(0).unwrap();
|
2016-08-12 05:04:40 +08:00
|
|
|
let mut gen = Generator::new(stack, move |yielder, ()| {
|
2016-08-09 21:59:35 +08:00
|
|
|
yielder.generate(1.0 / black_box(0.0));
|
|
|
|
});
|
2015-07-21 11:36:45 +08:00
|
|
|
|
2016-08-09 21:59:35 +08:00
|
|
|
unsafe { feenableexcept(FE_DIVBYZERO); }
|
2016-08-12 05:04:40 +08:00
|
|
|
println!("{:?}", gen.resume(()));
|
2015-07-21 11:36:45 +08:00
|
|
|
}
|