-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "no_std_test" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["Stephen Chung"] | ||
description = "no-std test application" | ||
|
||
[dependencies] | ||
ahash = { path = "../", default_features = false } | ||
wee_alloc = { version = "0.4.5", default_features = false } | ||
|
||
[profile.dev] | ||
panic = "abort" | ||
|
||
[profile.release] | ||
opt-level = "z" # optimize for size | ||
debug = false | ||
rpath = false | ||
debug-assertions = false | ||
codegen-units = 1 | ||
panic = "abort" | ||
|
||
[profile.unix] | ||
inherits = "release" | ||
lto = true | ||
|
||
[profile.windows] | ||
inherits = "release" | ||
|
||
[profile.macos] | ||
inherits = "release" | ||
lto = "fat" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! This is a bare-bones `no-std` application that hashes a value and | ||
//! uses the hash value as the return value. | ||
#![no_std] | ||
#![feature(alloc_error_handler, start, core_intrinsics, lang_items, link_cfg)] | ||
|
||
#[global_allocator] | ||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; | ||
|
||
use core::hash::{Hash, Hasher}; | ||
|
||
// NB: Rust needs a CRT runtime on Windows MSVC. | ||
#[cfg(all(windows, target_env = "msvc"))] | ||
#[link(name = "msvcrt")] | ||
#[link(name = "libcmt")] | ||
extern "C" {} | ||
|
||
#[start] | ||
fn main(_argc: isize, _argv: *const *const u8) -> isize { | ||
let mut h: ahash::AHasher = Default::default(); | ||
42_i32.hash(&mut h); | ||
return h.finish() as isize; | ||
} | ||
|
||
|
||
#[alloc_error_handler] | ||
fn foo(_: core::alloc::Layout) -> ! { | ||
core::intrinsics::abort(); | ||
} | ||
|
||
#[panic_handler] | ||
#[lang = "panic_impl"] | ||
fn rust_begin_panic(_: &core::panic::PanicInfo) -> ! { | ||
core::intrinsics::abort(); | ||
} | ||
|
||
#[no_mangle] | ||
extern "C" fn _rust_eh_personality() {} | ||
|
||
#[no_mangle] | ||
extern "C" fn rust_eh_personality() {} | ||
|
||
#[no_mangle] | ||
extern "C" fn rust_eh_register_frames() {} | ||
|
||
#[no_mangle] | ||
extern "C" fn rust_eh_unregister_frames() {} | ||
|
||
#[no_mangle] | ||
extern "C" fn _Unwind_Resume() {} |