Skip to content

Commit e55d24c

Browse files
committed
Edition 2018 cleanups
1 parent 71a1c6c commit e55d24c

File tree

22 files changed

+92
-101
lines changed

22 files changed

+92
-101
lines changed

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ license = "Apache-2.0/MIT"
77
homepage = "https://github.com/edef1c/libfringe"
88
repository = "https://github.com/edef1c/libfringe"
99
documentation = "https://edef1c.github.io/libfringe"
10+
edition = "2018"
1011

1112
[target.'cfg(unix)'.dependencies]
1213
libc = "0.2.14"
@@ -16,10 +17,11 @@ optional = true
1617
version = "1.0.0"
1718

1819
[target.'cfg(unix)'.dev-dependencies]
19-
packed_simd = "0.3.3"
20+
packed_simd = { version = "0.3.4", package = "packed_simd_2" }
2021

2122
[features]
22-
default = ["alloc", "valgrind"]
23+
default = [ "std" ]
24+
std = [ "alloc" ]
2325
alloc = []
2426
valgrind = ["valgrind_request"]
2527

benches/generator.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// http://opensource.org/licenses/MIT>, at your option. This file may not be
66
// copied, modified, or distributed except according to those terms.
77
#![feature(test)]
8-
extern crate fringe;
9-
extern crate test;
108

119
use fringe::{Generator, OsStack};
1210

benches/syscall.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
// http://opensource.org/licenses/MIT>, at your option. This file may not be
66
// copied, modified, or distributed except according to those terms.
77
#![cfg(target_os = "linux")]
8-
#![feature(asm, test)]
9-
extern crate test;
8+
#![feature(llvm_asm, test)]
109

1110
#[cfg(target_arch = "x86_64")]
1211
#[bench]
1312
fn syscall(b: &mut test::Bencher) {
1413
b.iter(|| unsafe {
15-
asm!("movq $$102, %rax\n\
14+
llvm_asm!("movq $$102, %rax\n\
1615
syscall"
1716
:
1817
:
@@ -25,7 +24,7 @@ fn syscall(b: &mut test::Bencher) {
2524
#[bench]
2625
fn syscall(b: &mut test::Bencher) {
2726
b.iter(|| unsafe {
28-
asm!("mov $$24, %eax\n\
27+
llvm_asm!("mov $$24, %eax\n\
2928
int $$0x80"
3029
:
3130
:

rustfmt.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
merge_imports = true
12
newline_style = "Unix"
2-
tab_spaces = 2
3+
tab_spaces = 2

src/arch/aarch64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
// * The 1st init trampoline tells the unwinder to restore x29 and x30
4747
// from the stack frame at x29 (in the parent stack), thus continuing
4848
// unwinding at the swap call site instead of falling off the end of context stack.
49+
4950
use core::mem;
5051
use stack::Stack;
5152

src/arch/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
pub use self::imp::*;
1010

11-
#[allow(unused_attributes)] // rust-lang/rust#35584
1211
#[cfg_attr(target_arch = "x86", path = "x86.rs")]
1312
#[cfg_attr(target_arch = "x86_64", path = "x86_64.rs")]
1413
#[cfg_attr(target_arch = "aarch64", path = "aarch64.rs")]
@@ -17,11 +16,12 @@ mod imp;
1716

1817
#[cfg(test)]
1918
mod tests {
20-
extern crate packed_simd;
2119
extern crate test;
2220

23-
use arch::{self, StackPointer};
24-
use OsStack;
21+
use crate::{
22+
arch::{self, StackPointer},
23+
OsStack,
24+
};
2525

2626
#[test]
2727
fn context() {

src/arch/or1k.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
// * The 1st init trampoline tells the unwinder to restore r2 and r9
4242
// from the stack frame at r2 (in the parent stack), thus continuing
4343
// unwinding at the swap call site instead of falling off the end of context stack.
44+
45+
use crate::stack::Stack;
4446
use core::mem;
45-
use stack::Stack;
4647

4748
pub const STACK_ALIGNMENT: usize = 4;
4849

src/arch/x86.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
// * The 1st init trampoline tells the unwinder to restore %ebp and its return
4242
// address from the stack frame at %ebp (in the parent stack), thus continuing
4343
// unwinding at the swap call site instead of falling off the end of context stack.
44+
45+
use crate::stack::Stack;
4446
use core::mem;
45-
use stack::Stack;
4647

4748
pub const STACK_ALIGNMENT: usize = 16;
4849

src/arch/x86_64.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@
4646
// * The 1st init trampoline tells the unwinder to restore %rbp and its return
4747
// address from the stack frame at %rbp (in the parent stack), thus continuing
4848
// unwinding at the swap call site instead of falling off the end of context stack.
49-
use core::mem;
50-
use stack::Stack;
49+
50+
use crate::stack::Stack;
51+
use core::mem::MaybeUninit;
5152

5253
pub const STACK_ALIGNMENT: usize = 16;
5354

@@ -56,13 +57,13 @@ pub const STACK_ALIGNMENT: usize = 16;
5657
pub struct StackPointer(*mut usize);
5758

5859
pub unsafe fn init(
59-
stack: &Stack,
60+
stack: &dyn Stack,
6061
f: unsafe extern "C" fn(usize, StackPointer) -> !,
6162
) -> StackPointer {
6263
#[cfg(not(target_vendor = "apple"))]
6364
#[naked]
6465
unsafe extern "C" fn trampoline_1() {
65-
asm!(
66+
llvm_asm!(
6667
r#"
6768
# gdb has a hardcoded check that rejects backtraces where frame addresses
6869
# do not monotonically decrease. It is turned off if the function is called
@@ -102,7 +103,7 @@ pub unsafe fn init(
102103
#[cfg(target_vendor = "apple")]
103104
#[naked]
104105
unsafe extern "C" fn trampoline_1() {
105-
asm!(
106+
llvm_asm!(
106107
r#"
107108
# Identical to the above, except avoids .local/.size that aren't available on Mach-O.
108109
__morestack:
@@ -117,7 +118,7 @@ pub unsafe fn init(
117118

118119
#[naked]
119120
unsafe extern "C" fn trampoline_2() {
120-
asm!(
121+
llvm_asm!(
121122
r#"
122123
# Set up the second part of our DWARF CFI.
123124
# When unwinding the frame corresponding to this function, a DWARF unwinder
@@ -175,20 +176,20 @@ pub unsafe fn init(
175176
pub unsafe fn swap(
176177
arg: usize,
177178
new_sp: StackPointer,
178-
new_stack: Option<&Stack>,
179+
new_stack: Option<&dyn Stack>,
179180
) -> (usize, StackPointer) {
180181
// Address of the topmost CFA stack slot.
181-
let mut dummy: usize = mem::uninitialized();
182+
let mut dummy: MaybeUninit<usize> = MaybeUninit::uninit();
182183
let new_cfa = if let Some(new_stack) = new_stack {
183184
(new_stack.base() as *mut usize).offset(-4)
184185
} else {
185186
// Just pass a dummy pointer if we aren't linking the stack
186-
&mut dummy
187+
dummy.as_mut_ptr()
187188
};
188189

189-
let ret: usize;
190-
let ret_sp: *mut usize;
191-
asm!(
190+
let mut ret: usize;
191+
let mut ret_sp: *mut usize;
192+
llvm_asm!(
192193
r#"
193194
# Push the return address
194195
leaq 0f(%rip), %rax

src/debug/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
55
// http://opensource.org/licenses/MIT>, at your option. This file may not be
66
// copied, modified, or distributed except according to those terms.
7+
78
pub use self::imp::*;
89

910
#[cfg(feature = "valgrind")]
@@ -12,12 +13,14 @@ mod imp;
1213

1314
#[cfg(not(feature = "valgrind"))]
1415
mod imp {
15-
use stack;
16+
use crate::stack::Stack;
17+
1618
#[derive(Debug)]
1719
pub struct StackId;
20+
1821
/// No-op since no valgrind
1922
impl StackId {
20-
pub fn register<Stack: stack::Stack>(_stack: &Stack) -> StackId {
23+
pub fn register<S: Stack>(_stack: &S) -> StackId {
2124
StackId
2225
}
2326
}

0 commit comments

Comments
 (0)