368 Commits

Author SHA1 Message Date
Emil Fresk
7e3ab44ff8 Release v0.6.1 2021-03-02 15:05:05 +01:00
Emil Fresk
4499eda03d
Merge pull request #192 from AfoHT/updategenericarray
Update generic-array and as-slice to security patched versions
2021-03-02 15:01:02 +01:00
Henrik Tjäder
c464710c81 Update as-slice to patched version 2021-03-02 14:52:59 +01:00
Henrik Tjäder
47906b7981 Changes to version 0.14.4 of generic-array
Resolves RUSTSEC-2020-0145
2021-03-02 14:15:44 +01:00
Emil Fresk
7586332e3d Remove travis 2021-02-08 08:57:46 +01:00
Emil Fresk
b107f928b6 Fmt 2021-02-08 08:54:59 +01:00
Emil Fresk
97af6fe8ea
Merge pull request #159 from rjsberry/box-forget
Implement Box::forget for the singleton pool
2021-02-08 08:49:49 +01:00
Emil Fresk
4afa223fbe
Merge pull request #189 from nickray/ga-14
Bump generic-array to v0.14.2 (MSRV remains the same)
v0.6.0
2021-02-03 09:36:14 +01:00
nicolas-solokeys
d60b0e2c39 Bump generic-array to v0.14.2 (MSRV remains the same) 2021-02-02 20:57:33 +01:00
Emil Fresk
ae7ce354a8
Merge pull request #188 from AfoHT/ghafix
Remove GHA ci-failure job
2021-01-20 09:37:14 +01:00
Henrik Tjäder
8c513b7fc1 Remove GHA ci-failure job 2021-01-19 20:43:54 +01:00
Emil Fresk
868aebfbad
Merge pull request #187 from Lotterleben/indexDoc
IndexMap, IndexSet: hint to FnvIndex...: Extend explanation, add examples & links
2020-12-17 16:13:54 +01:00
Emil Fresk
fdd7b48ef5
Merge pull request #186 from AfoHT/gha
First GitHub Actions test
2020-12-17 16:13:00 +01:00
Lotte Steenbrink
61b85596cf IndexMap, IndexSet: hint to FnvIndex... in the docs, copy examples to Fnv... docs, add direct links 2020-12-16 10:23:01 +01:00
Henrik Tjäder
430a8d4379 Limit tests to one thread 2020-12-10 17:54:52 +00:00
Henrik Tjäder
2862779617 First GitHub Actions test 2020-12-10 17:54:52 +00:00
Emil Fresk
71188c3202
Merge pull request #185 from AfoHT/cargofmt
Cargo format
2020-12-03 20:50:48 +01:00
Henrik Tjäder
e1177dfd5b Run cargo fmt 2020-12-03 19:23:44 +00:00
Emil Fresk
70687d8ace
Merge pull request #182 from almusil/expose_len_for_consumer_producer
Queue: Expose len and capacity for Consumer and Producer
2020-11-30 15:55:04 +01:00
Ales Musil
5823e4785a Queue: Expose len and capacity for Consumer and Producer
It is usefull to know in advance the space that is
occupied by the items in queue.
2020-11-03 11:29:17 +01:00
bors[bot]
9ff3a5fa89
Merge #178
178: Version bump dependency 'as-slice' -> 0.1.4 r=korken89 a=ToddG

This fixes the issue I was having targeting AVR.

See: https://github.com/japaric/heapless/issues/177#issuecomment-697341580

## REPRO

```
(base) ~/temp/break/abc $ cargo build
    Updating crates.io index
   Compiling compiler_builtins v0.1.35
   Compiling core v0.0.0 (/home/todd/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling typenum v1.12.0
   Compiling version_check v0.9.2
   Compiling byteorder v1.3.4
   Compiling heapless v0.5.6 (/home/todd/temp/heapless)
   Compiling generic-array v0.14.4
   Compiling rustc-std-workspace-core v1.99.0 (/home/todd/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling stable_deref_trait v1.2.0
   Compiling hash32 v0.1.1
   Compiling generic-array v0.12.3
   Compiling generic-array v0.13.2
   Compiling as-slice v0.1.4
   Compiling abc v0.1.0 (/home/todd/temp/break/abc)
    Finished dev [unoptimized + debuginfo] target(s) in 26.46s
```

Co-authored-by: Todd Greenwood <pub+github@zwrob.com>
2020-09-23 13:01:31 +00:00
Todd Greenwood
b97a1762b3 Version bump dependency 'as-slice' -> 0.1.4 2020-09-23 05:51:43 -07:00
bors[bot]
bd3c938379
Merge #175
175: Preparing v0.5.6 release r=korken89 a=korken89



Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
v0.5.6
2020-09-22 18:51:06 +00:00
Emil Fresk
77f31428b5 Preparing v0.5.6 release 2020-09-18 15:32:26 +02:00
bors[bot]
7685445020
Merge #170
170: Buffer methods for Vec and as_mut_vec for String r=japaric a=samlich

This adds `set_len` to `Vec`, identical to the `std` version, with the documentation copied from `std`. This is useful for using it as a buffer by writing to the uninitialized portion and then setting the length to include those bytes.

It also adds `as_mut_vec` to `String` (also from `std`), which enables using `String` as a buffer in the same manner.

Co-authored-by: samlich <1349989+samlich@users.noreply.github.com>
2020-07-31 18:31:44 +00:00
samlich
90d652464a
String: add as_mut_vec 2020-07-29 21:29:05 +00:00
samlich
d9955a2599
Vec: add set_len 2020-07-24 12:25:54 +00:00
bors[bot]
4bb5df514f
Merge #161 #162
161: readme: add instructions for tests r=korken89 a=andresv

It took me some time to figure out which features must be used for tests. So this pull request removes some friction.

162: histbuf: replace slow modulo operations r=korken89 a=andresv

STM32G081 Cortex-M0 64MHz
thumbv6m-none-eabi
Rust 1.43.1

RTFM application where data from ADC channels is added to `HistoryBuffers`:
```Rust
// this is shared with DMA
static mut ADC_DATA: [u16; 6] = [0; 6];
...
// this interrupt fires when DMA has finished sequencing all ADC channels
#[task(binds = DMA_CHANNEL1, resources = [pa9, adc_data, hist0, hist1, hist2, hist3, hist4, hist5])]
fn adc_data_ready(ctx: adc_data_ready::Context) {
    let dma = unsafe { &(*stm32::DMA::ptr()) };
    // transfer complete flag clear
    dma.ifcr.write(|w| w.ctcif1().set_bit());

    ctx.resources.pa9.set_high().unwrap();
    
    ctx.resources.hist0.write(ctx.resources.adc_data[0]);
    ctx.resources.hist1.write(ctx.resources.adc_data[1]);
    ctx.resources.hist2.write(ctx.resources.adc_data[2]);
    ctx.resources.hist3.write(ctx.resources.adc_data[3]);
    ctx.resources.hist4.write(ctx.resources.adc_data[4]);
    ctx.resources.hist5.write(ctx.resources.adc_data[5]);
    
    ctx.resources.pa9.set_low().unwrap();
}
```

Time is measured from `PA9` pin using logic analyzer.
```
[profile.release]
opt-level = "s"
codegen-units = 1
debug = true
lto = true
```

- before `27.6 us`
- with fix `4.4 us`


```
[profile.release]
opt-level = 2
codegen-units = 1
debug = true
lto = true
```

- before `25.9 us`
- with fix `2.9 us`

Co-authored-by: Andres Vahter <andres.vahter@gmail.com>
2020-05-12 14:02:34 +00:00
Andres Vahter
c6e4f59640 histbuf: fix style 2020-05-09 21:32:55 +03:00
Andres Vahter
f5a26c04c4 histbuf: replace slow modulo operatins
on cortex m0  `%` is extremely costly
2020-05-09 20:05:19 +03:00
Andres Vahter
cfe596bd3e readme: add instructions for tests 2020-05-09 19:46:06 +03:00
Richard Berry
16db51d62b Implement Box::forget for the singleton pool 2020-05-06 18:13:50 +01:00
bors[bot]
ab9f2515a7
Merge #154
154: indexmap: expose PowerOfTwo, Bucket and Pos r=japaric a=willem66745

This change allows the create custom structs based on `IndexMap` with size arguments outside
the heapless crate itself.

For example:
```rust
use heapless::consts::*;
use heapless::{ArrayLength, Bucket, FnvIndexMap, Pos, PowerOfTwo};

struct CustomMap<S>
where
    S: ArrayLength<Bucket<u8, u16>> + ArrayLength<Option<Pos>> + PowerOfTwo,
{
    map: FnvIndexMap<u8, u16, S>,
}

impl<S> CustomMap<S>
where
    S: ArrayLength<Bucket<u8, u16>> + ArrayLength<Option<Pos>> + PowerOfTwo,
{
    fn new() -> CustomMap<S> {
        CustomMap {
            map: FnvIndexMap::<_, _, S>::new(),
        }
    }
}

fn main() {
    let mut bla = CustomMap::<U8>::new();

    bla.map.insert(8, 16).unwrap();
}
```

I can imagine that exposing these types is not preferable, but at least it would help for my usecase. Or is there a way where exposing these types is not needed?

Co-authored-by: Willem <willem66745@gmail.com>
2020-05-04 20:34:00 +00:00
bors[bot]
b265330c67
Merge #149
149: Make Producer<..., SingleCore> Send, like Consumer r=japaric a=BryanKadzban

I assume there's no reason that only multi-core Producers are marked
Send, while Consumers are not (they're pretty symmetrical).

(Context: I'm trying to use an SPSC queue on a single cortex-m0 MCU.
So I can guarantee that a SingleCore queue is safe because there is no
other core it could possibly be shared with.  The RTFM framework adds
an assert_send on the producer, since it's shared between init and an
SPI receiver interrupt.  It also adds an assert_send on the Consumer,
since it's shared between init and the I2C transmit interrupt, but that one
works since Consumer has this extra C type in the impl already.)

Co-authored-by: Bryan Kadzban <github@kadzban.net>
2020-05-04 20:20:59 +00:00
bors[bot]
82064d0e6e
Merge #157
157: Preparing for v0.5.5 r=korken89 a=korken89

Prepared v0.5.5 to release the latest accepted PRs

Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
v0.5.5
2020-05-04 18:59:58 +00:00
Emil Fresk
357360e1e8 Preparing for v0.5.5 2020-05-04 20:59:35 +02:00
bors[bot]
417e26617e
Merge #153
153: x86_64: "practically" thread-safe  Pool r=korken89 a=japaric

### Summary / motivation

this PR makes `Pool` `Sync` on x86_64 with the main goal of being able to test `no_std` code that uses `Pool` (e.g. via the singleton `pool!` macro) on x86_64 (as it's not straight forward to run tests on embedded devices, and even less to CI those tests).

### Details

this PR reduces the chance of Pool running into the ABA problem (which corrupts the underlying lock-free stack) by using 32-bit version tags (search term: IBM ABA-prevention tags). Version tags do not 100% prevent the ABA problem but make it almost impossible to run into it in practice (the bigger the tag, in bits, the less the chance of running into ABA). See module level docs for details and limitations.

As this does not eliminate ABA with 100% certainty perhaps it should live behind a Cargo feature?

It seems to me that hazard pointers may be able to completely get rid of ABA but implementing those, AFAICT, require Thread Local Storage (`#[thread_local]`) which is not supported in `no_std` code.

r? @korken89 

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2020-05-04 18:51:01 +00:00
Jorge Aparicio
ebedb559c0 1.36.0 compatibility 2020-05-04 20:45:52 +02:00
bors[bot]
a28dac7087
Merge #143
143: Implement core::fmt::Write for heapless::Vec<u8, N> r=korken89 a=ijl

I didn't see a mention of this in issues or previous pull requests, but I expect it's in scope?

Co-authored-by: ijl <ijl@mailbox.org>
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
2020-05-04 09:19:32 +00:00
Emil Fresk
373abf1d96
Fixing test 2020-05-04 11:18:50 +02:00
Emil Fresk
99ea5f123e
Merge branch 'master' into write 2020-05-04 11:10:52 +02:00
Jorge Aparicio
ea0c189a62 x86: put Sync impl behind a Cargo feature 2020-05-03 17:18:22 +02:00
Jorge Aparicio
af877b4418 fix warnings 2020-05-03 17:18:11 +02:00
Jorge Aparicio
e4c8f1f75b x86_64: "practically" thread-safe Pool 2020-05-03 17:18:11 +02:00
bors[bot]
da154963e2
Merge #155
155: Extend ARMv7-R `Pool` support to the bare-metal `armebv7r-` targets r=japaric a=rjsberry

Extends support for singleton `Pool`s to include the `armebv7r-none-eabi` and `armebv7r-none-eabihf` targets.

Co-authored-by: Richard Berry <rjsberry@pm.me>
2020-05-03 14:11:53 +00:00
bors[bot]
b470e26fd0
Merge #156
156: Add optional ufmt impls r=japaric a=dbrgn

By enabling the `ufmt-impl` feature, `uWrite` impls are provided for `String<N>` and `Vec<u8, N>`.

Co-authored-by: Danilo Bargen <mail@dbrgn.ch>
2020-05-03 14:07:10 +00:00
Danilo Bargen
92d1a399e8 Add optional ufmt impls 2020-05-03 13:29:59 +02:00
bors[bot]
75bcd7e496
Merge #152
152: Implement Vec::starts_with and Vec::ends_with r=korken89 a=dbrgn

Implementation mostly copied from `std`.

The logic should be covered by documentation tests, so no separate unit tests were added.

Co-authored-by: Danilo Bargen <mail@dbrgn.ch>
2020-05-03 06:56:57 +00:00
Richard Berry
8bcf9d8970 Extend ARMv7-R Pool support to the bare-metal armebv7r- targets 2020-04-30 20:13:18 +01:00
Danilo Bargen
5e32bf7244 Implement Vec::starts_with and Vec::ends_with 2020-04-30 13:58:00 +02:00