Skip to content

Commit e18d34f

Browse files
authored
Merge pull request #180 from ryankurte/fix/heap-feature
Allow heap feature to be disabled.
2 parents c50113d + 9997226 commit e18d34f

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ledger_device_sdk/Cargo.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_device_sdk"
3-
version = "1.14.0"
3+
version = "1.14.1"
44
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
55
edition = "2021"
66
license.workspace = true
@@ -21,13 +21,11 @@ rand_core = { version = "0.6.3", default_features = false }
2121
zeroize = { version = "1.6.0", default_features = false }
2222
numtoa = "0.2.4"
2323
const-zero = "0.1.1"
24-
25-
[target.'cfg(target_os="nanos")'.dependencies]
26-
ledger_secure_sdk_sys = {path = "../ledger_secure_sdk_sys", version = "1.4.3"}
27-
28-
[target.'cfg(not(target_os="nanos"))'.dependencies]
29-
ledger_secure_sdk_sys = {path = "../ledger_secure_sdk_sys", version = "1.4.3", features = ["heap"]}
24+
ledger_secure_sdk_sys = { path = "../ledger_secure_sdk_sys", version = "1.4.4" }
3025

3126
[features]
3227
speculos = []
3328
ccid = []
29+
heap = [ "ledger_secure_sdk_sys/heap" ]
30+
31+
default = [ "heap" ]

ledger_secure_sdk_sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_secure_sdk_sys"
3-
version = "1.4.3"
3+
version = "1.4.4"
44
authors = ["yhql", "agrojean-ledger"]
55
edition = "2021"
66
license.workspace = true

ledger_secure_sdk_sys/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![allow(non_snake_case)]
55

66
use core::ffi::c_void;
7-
#[cfg(feature = "heap")]
7+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
88
use core::mem::MaybeUninit;
99

1010
pub mod buttons;
@@ -35,22 +35,22 @@ pub fn pic_rs_mut<T>(x: &mut T) -> &mut T {
3535
unsafe { &mut *ptr }
3636
}
3737

38-
#[cfg(feature = "heap")]
38+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
3939
use critical_section::RawRestoreState;
40-
#[cfg(feature = "heap")]
40+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
4141
use embedded_alloc::Heap;
4242

43-
#[cfg(feature = "heap")]
43+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
4444
#[global_allocator]
4545
static HEAP: Heap = Heap::empty();
4646

47-
#[cfg(feature = "heap")]
47+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
4848
struct CriticalSection;
49-
#[cfg(feature = "heap")]
49+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
5050
critical_section::set_impl!(CriticalSection);
5151

5252
/// Default empty implementation as we don't have concurrency.
53-
#[cfg(feature = "heap")]
53+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
5454
unsafe impl critical_section::Impl for CriticalSection {
5555
unsafe fn acquire() -> RawRestoreState {}
5656
unsafe fn release(_restore_state: RawRestoreState) {}
@@ -61,15 +61,15 @@ unsafe impl critical_section::Impl for CriticalSection {
6161
/// The heap is stored in the stack, and has a fixed size.
6262
/// This method is called just before [sample_main].
6363
#[no_mangle]
64-
#[cfg(feature = "heap")]
64+
#[cfg(all(feature = "heap", not(target_os = "nanos")))]
6565
extern "C" fn heap_init() {
6666
const HEAP_SIZE: usize = 8192;
6767
static mut HEAP_MEM: [MaybeUninit<u8>; HEAP_SIZE] = [MaybeUninit::uninit(); HEAP_SIZE];
6868
unsafe { HEAP.init(HEAP_MEM.as_ptr() as usize, HEAP_SIZE) }
6969
}
7070

7171
#[no_mangle]
72-
#[cfg(not(feature = "heap"))]
72+
#[cfg(any(not(feature = "heap"), target_os = "nanos"))]
7373
extern "C" fn heap_init() {}
7474

7575
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

0 commit comments

Comments
 (0)