Fix warning and directory restructure.

This commit is contained in:
Gav
2018-02-08 14:29:30 +01:00
parent ac5a750f45
commit 4582038b3d
145 changed files with 129 additions and 123 deletions
-23
View File
@@ -1,23 +0,0 @@
[package]
name = "pwasm-alloc"
version = "0.1.0"
authors = ["Nikolay Volf <nikvolf@gmail.com>"]
license = "MIT/Apache-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/pwasm-std"
homepage = "https://github.com/paritytech/pwasm-std"
documentation = "https://paritytech.github.io/pwasm-std/pwasm_std/"
description = "Parity WebAssembly standard library internal allocator"
keywords = ["wasm", "parity", "webassembly", "blockchain"]
categories = ["no-std", "embedded"]
build = "build.rs"
[dependencies]
pwasm-libc = { path = "../pwasm-libc", version = "0.1" }
[build-dependencies]
rustc_version = "0.2"
[features]
strict = []
nightly = []
-12
View File
@@ -1,12 +0,0 @@
# pwasm-libc
Parity WASM contracts standard library libc bindings
[Documentation](https://paritytech.github.io/pwasm-std/pwasm_alloc/)
# License
`pwasm_alloc` is primarily distributed under the terms of both the MIT
license and the Apache License (Version 2.0), at your choice.
See LICENSE-APACHE, and LICENSE-MIT for details.
-14
View File
@@ -1,14 +0,0 @@
//! Set a nightly feature
extern crate rustc_version;
use rustc_version::{version, version_meta, Channel};
fn main() {
// Assert we haven't travelled back in time
assert!(version().unwrap().major >= 1);
// Set cfg flags depending on release channel
if let Channel::Nightly = version_meta().unwrap().channel {
println!("cargo:rustc-cfg=feature=\"nightly\"");
}
}
-36
View File
@@ -1,36 +0,0 @@
#![warn(missing_docs)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![no_std]
#![crate_type = "rlib"]
#![cfg_attr(feature = "nightly", feature(global_allocator))]
#![cfg_attr(feature = "nightly", feature(alloc))]
#![cfg_attr(feature = "nightly", feature(allocator_api))]
//! Custom allocator crate for wasm
/// Wasm allocator
pub struct WasmAllocator;
#[cfg(feature = "nightly")]
#[global_allocator]
static ALLOCATOR: WasmAllocator = WasmAllocator;
#[cfg(feature = "nightly")]
mod __impl {
extern crate alloc;
extern crate pwasm_libc;
use self::alloc::heap::{Alloc, Layout, AllocErr};
use super::WasmAllocator;
unsafe impl<'a> Alloc for &'a WasmAllocator {
unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
Ok(pwasm_libc::malloc(layout.size()))
}
unsafe fn dealloc(&mut self, ptr: *mut u8, _layout: Layout) {
pwasm_libc::free(ptr)
}
}
}