2015-04-16 20:06:57 +08:00
|
|
|
// This file is part of libfringe, a low-level green threading library.
|
2016-03-22 15:25:23 +08:00
|
|
|
// 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-04-16 22:03:13 +08:00
|
|
|
#![cfg(target_os = "linux")]
|
2015-02-03 03:17:23 +08:00
|
|
|
#![feature(asm, test)]
|
2015-01-14 14:01:43 +08:00
|
|
|
extern crate test;
|
|
|
|
|
2015-04-17 00:50:15 +08:00
|
|
|
#[cfg(target_arch = "x86_64")]
|
2015-01-14 14:01:43 +08:00
|
|
|
#[bench]
|
2016-07-16 09:22:41 +08:00
|
|
|
fn syscall(b: &mut test::Bencher) {
|
2015-01-14 14:01:43 +08:00
|
|
|
b.iter(|| unsafe {
|
|
|
|
asm!("movq $$102, %rax\n\
|
|
|
|
syscall"
|
|
|
|
:
|
|
|
|
:
|
|
|
|
: "rax", "rcx"
|
|
|
|
: "volatile");
|
|
|
|
});
|
|
|
|
}
|
2015-04-17 00:50:15 +08:00
|
|
|
|
|
|
|
#[cfg(target_arch = "x86")]
|
|
|
|
#[bench]
|
2016-07-16 09:22:41 +08:00
|
|
|
fn syscall(b: &mut test::Bencher) {
|
2015-04-17 00:50:15 +08:00
|
|
|
b.iter(|| unsafe {
|
|
|
|
asm!("mov $$24, %eax\n\
|
|
|
|
int $$0x80"
|
|
|
|
:
|
|
|
|
:
|
|
|
|
: "eax"
|
|
|
|
: "volatile");
|
|
|
|
});
|
|
|
|
}
|