Skip to content

Commit 7b48fd4

Browse files
committed
have no-stdlib be the optional feature rather than asking people to turn on the stdlib
1 parent 5ca5a9e commit 7b48fd4

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "alloc-no-stdlib"
33
description = "A dynamic allocator that may be used with or without the stdlib. This allows a package with nostd to allocate memory dynamically and be used either with a custom allocator, items on the stack, or by a package that wishes to simply use Box<>. It also provides options to use calloc or a mutable global variable for pre-zeroed memory"
4-
version = "1.1.0"
4+
version = "1.2.0"
55
authors = ["Daniel Reiter Horn <[email protected]>"]
66
documentation = "https://raw.githubusercontent.com/dropbox/rust-alloc-no-stdlib/master/tests/lib.rs"
77
homepage = "https://github.com/dropbox/rust-alloc-no-stdlib"
@@ -15,4 +15,4 @@ name = "example"
1515

1616
[features]
1717
unsafe = []
18-
stdlib = []
18+
no-stdlib = []

src/bin/example.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use core::ops;
66
mod heap_alloc;
77

88
pub use heap_alloc::HeapAllocator;
9-
#[cfg(feature="stdlib")]
9+
#[cfg(not(feature="no-stdlib"))]
1010
use alloc_no_stdlib::HeapPrealloc;
1111
mod tests;
1212
extern {
@@ -27,11 +27,11 @@ use alloc_no_stdlib::StackAllocator;
2727
use alloc_no_stdlib::bzero;
2828
declare_stack_allocator_struct!(CallocAllocatedFreelist4, 4, calloc);
2929
declare_stack_allocator_struct!(StackAllocatedFreelist16, 16, stack);
30-
#[cfg(not(feature="stdlib"))]
30+
#[cfg(feature="no-stdlib")]
3131
fn show_heap_prealloc() {
3232

3333
}
34-
#[cfg(feature="stdlib")]
34+
#[cfg(not(feature="no-stdlib"))]
3535
fn show_heap_prealloc() {
3636
let mut zero_global_buffer = define_allocator_memory_pool!(4, u8, [0; 1024 * 1024 * 20], heap);
3737

src/heap_alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(feature="stdlib")]
1+
#![cfg(not(feature="no-stdlib"))]
22
use std;
33

44

src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![no_std]
22

3-
#[cfg(feature="stdlib")]
3+
#[cfg(not(feature="no-stdlib"))]
44
#[macro_use]
55
extern crate std;
66
mod allocated_memory;
@@ -16,14 +16,12 @@ pub use allocated_stack_memory::AllocatedStackMemory;
1616
pub use stack_allocator::Allocator;
1717
pub use stack_allocator::StackAllocator;
1818
mod heap_alloc;
19-
#[cfg(feature="stdlib")]
19+
#[cfg(not(feature="no-stdlib"))]
2020
pub use heap_alloc::HeapAlloc;
21-
#[cfg(feature="stdlib")]
21+
#[cfg(not(feature="no-stdlib"))]
2222
pub use heap_alloc::HeapPrealloc;
23-
#[cfg(all(feature="stdlib", feature="unsafe"))]
23+
#[cfg(all(not(feature="no-stdlib"), feature="unsafe"))]
2424
pub use heap_alloc::HeapAllocUninitialized;
25-
//#[cfg(all(feature="stdlib", feature="unsafe"))]
26-
//pub use heap_alloc::StdAllocUninitialized;
2725
use core::default::Default;
2826
pub fn bzero<T : Default> (data : &mut [T]) {
2927
for iter in data.iter_mut() {

tests/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use core::ops;
1212
use alloc_no_stdlib::{Allocator, SliceWrapperMut, SliceWrapper,
1313
StackAllocator, AllocatedStackMemory, uninitialized, bzero};
1414

15-
#[cfg(feature="stdlib")]
15+
#[cfg(not(feature="no-stdlib"))]
1616
use alloc_no_stdlib::{HeapPrealloc, HeapAlloc};
1717

18-
#[cfg(all(feature="stdlib", feature="unsafe"))]
18+
#[cfg(all(not(feature="no-stdlib"),feature="unsafe"))]
1919
use alloc_no_stdlib::{HeapAllocUninitialized};
2020

2121
declare_stack_allocator_struct!(CallocAllocatedFreelist4096, 4096, calloc);
@@ -136,7 +136,7 @@ fn uninitialized_stack_pool_free_null() {
136136

137137
}
138138
#[test]
139-
#[cfg(all(feature="stdlib",feature="unsafe"))]
139+
#[cfg(all(feature="unsafe",not(feature="no-stdlib")))]
140140
fn uninitialized_heap_pool_test() {
141141
{
142142
let mut heap_global_buffer = unsafe{HeapPrealloc::<u8>::new_uninitialized_memory_pool(6 * 1024 * 1024)};
@@ -335,7 +335,7 @@ fn stack_pool_free_null() {
335335

336336
}
337337
#[test]
338-
#[cfg(feature="stdlib")]
338+
#[cfg(not(feature="no-stdlib"))]
339339
fn heap_pool_test() {
340340
{
341341
let mut heap_global_buffer = define_allocator_memory_pool!(4096, u8, [0; 6 * 1024 * 1024], heap);

0 commit comments

Comments
 (0)