Commit graph

1031 commits

Author SHA1 Message Date
Jorge Aparicio
aa7eec0299 check task priority at compile time
before we were checking the priority at runtime. The compile time error message
when the priority is too high is kind of awful though.
2019-04-16 23:04:24 +02:00
bors[bot]
8da925647e Merge #162
162: v0.4.2 r=TeXitoi a=japaric

this PR prepares a new release

r? @korken89 || @TeXitoi 

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-27 01:27:16 +00:00
Jorge Aparicio
3310f507c0 v0.4.2 2019-02-27 00:56:56 +01:00
bors[bot]
692876649c Merge #161
161: (ru) binds r=japaric a=japaric

resubmitting PR #160 

Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2019-02-26 23:28:02 +00:00
Andrey Zgarbul
028d5325ae (ru) binds 2019-02-27 00:27:05 +01:00
bors[bot]
6d1d84980a Merge #158
158: implement RFC #128: #[interrupt(binds = ..)] r=korken89 a=japaric

closes #128 

r? @korken89 or @TeXitoi 

suggestions for tests are welcome! (2 of the 3 tests I added hit bugs in my implementation)

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-26 22:26:52 +00:00
Jorge Aparicio
8eccef7d9c refactor: make binds harder to misuse 2019-02-26 23:25:16 +01:00
Jorge Aparicio
2fd6ae69d1 binds can only appear once in the argument list 2019-02-26 23:22:34 +01:00
Jorge Aparicio
e167af01f0 document the binds feature
cc @burrbull
2019-02-26 23:22:34 +01:00
Jorge Aparicio
11f795aaf6 add binds example and make it work 2019-02-26 23:22:34 +01:00
Jorge Aparicio
a233808280 fix warnings in cpass test 2019-02-26 23:22:34 +01:00
Jorge Aparicio
72f0cc505a make cfail test actually fail 2019-02-26 23:22:34 +01:00
Jorge Aparicio
c749979c45 add some tests 2019-02-26 23:22:34 +01:00
Jorge Aparicio
d0f33add0a add binds argument to the interrupt and exception attributes 2019-02-26 23:22:31 +01:00
bors[bot]
bbdc3221f6 Merge #159
159: reject duplicate arguments in #[interrupt] and #[exception] r=TeXitoi a=japaric

This program was being accepted:

``` rust
#[task(
    capacity = 1,
    capacity = 2,
    priority = 1,
    priority = 2,
)]
fn foo() {}
```

now it will trigger a compiler error

r? @korken89 || @TeXitoi 

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-24 16:42:33 +00:00
Jorge Aparicio
73529ea650 reject duplicate arguments in #[interrupt] and #[exception]
This program was being accepted:

``` rust
 #[task(
    capacity = 1,
    capacity = 2,
    priority = 1,
    priority = 2,
)]
fn foo() {}
```

now it will trigger a compiler error
2019-02-23 22:35:29 +01:00
bors[bot]
6b61cd2e3f Merge #153
153: add "nightly" feature; replace hint::unreachable_unchecked with a panic r=korken89 a=japaric

this implements the action plan described in #149

to give you a sense of the overhead of this change: it has increased the binary
size of some of our examples by up to 10% but this is mainly from pulling in a
panic handler that does formatting

r? @korken89

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-23 19:37:29 +00:00
Jorge Aparicio
c6f9b2c0aa fix ci 2019-02-23 20:35:54 +01:00
bors[bot]
43c2ffbdcf Merge #154
154: add Duration.as_cycles r=japaric a=japaric

cc @oni303

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-19 16:15:38 +00:00
Jorge Aparicio
3973b420ec add Duration.as_cycles 2019-02-19 17:14:34 +01:00
Jorge Aparicio
28ee83dfdd turn all potential UB into panics 2019-02-19 13:13:16 +01:00
Jorge Aparicio
fe70817653 ci: report the size of built examples 2019-02-19 13:13:16 +01:00
Jorge Aparicio
16821c8315 document the nightly feature 2019-02-19 13:13:16 +01:00
Jorge Aparicio
c8df71adf0 ci: test the nightly feature 2019-02-19 13:13:13 +01:00
Jorge Aparicio
88078e7770 add "nightly" feature 2019-02-19 12:37:25 +01:00
bors[bot]
c91b14bcd4 Merge #151
151: make builds reproducible r=japaric a=japaric

This is a rebased and augmented version of #132. With this PR both dev and release builds that do not use the owned-singleton stuff become reproducible. (I haven't really bothered to make owned-singleton reproducible since [lifo] is way more ergonomic than [alloc-singleton] and will eventually make its way into heapless).

[lifo]: https://github.com/japaric/lifo
[alloc-singleton]: https://crates.io/crates/alloc-singleton

Thanks @hugwijst for doing the bulk of the work!

closes #132

Co-authored-by: Hugo van der Wijst <hvanderwijst@tesla.com>
Co-authored-by: Hugo van der Wijst <hugo@wij.st>
Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-15 23:39:28 +00:00
Jorge Aparicio
e5e54ee8f1 rebase fix 2019-02-16 00:28:12 +01:00
Jorge Aparicio
7ce052be37 cargo fmt 2019-02-16 00:26:07 +01:00
Jorge Aparicio
2b8e743f35 make debug builds reproducible 2019-02-16 00:25:48 +01:00
Hugo van der Wijst
cf05dc2c4b Temporarily disable checking for reproducibility of debug builds. 2019-02-16 00:23:01 +01:00
Hugo van der Wijst
577d188f72 Make generated names stable when sorting. 2019-02-16 00:23:01 +01:00
Hugo van der Wijst
a654d13eef Seed RNG with package name and prepend string to full random name. 2019-02-16 00:23:01 +01:00
Hugo van der Wijst
82c533cbf4 Fix thumbv6 build. 2019-02-16 00:23:01 +01:00
Hugo van der Wijst
be8a5e89b8 Make identifiers deterministic. 2019-02-16 00:23:01 +01:00
Hugo van der Wijst
4f193df0ef Speed up CI significantly. 2019-02-16 00:22:22 +01:00
Hugo van der Wijst
2f89688ca9 Make builds reproducible
This is done by using `BTreeMap`s and `BTreeSet`s to get deterministic
ordering.

Also updated the CI job to check reproducibility of all examples.
2019-02-16 00:22:22 +01:00
Jorge Aparicio
fdba26525c fancier redirect page 2019-02-14 21:57:43 +01:00
Jorge Aparicio
92fd6bf856 set a redirect from book/ to book/en/
closes #148
2019-02-14 21:46:17 +01:00
Jorge Aparicio
c37f414a83 update link to documentation in the README 2019-02-14 21:42:51 +01:00
Jorge Aparicio
197d5264c4 update documentation link in crate metadata 2019-02-14 21:41:24 +01:00
bors[bot]
87c69b68af Merge #145
145: fix non_camel_case_types warnings r=japaric a=japaric

closes #144

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-13 14:38:20 +00:00
Jorge Aparicio
5f7e831d27 fix non_camel_case_types warnings 2019-02-13 15:37:24 +01:00
bors[bot]
ecdc008fb1 Merge #142
142: (ru) late resources r=japaric a=burrbull

According to 1e9058cab2

Co-authored-by: Zgarbul Andrey <zgarbul.andrey@gmail.com>
2019-02-12 17:30:26 +00:00
Jorge Aparicio
aadd00c068 bump macros version 2019-02-12 17:29:50 +01:00
Jorge Aparicio
4742da94e7 changelog: note that new syntax is documented in the book 2019-02-12 17:28:16 +01:00
Zgarbul Andrey
3a03fd06d8
(ru) late resources
According to 1e9058cab2
2019-02-12 19:12:08 +03:00
bors[bot]
ed6460f6dc Merge #140
140: fix soundness issue: forbid early returns in init r=japaric a=japaric

TL;DR

1. v0.4.1 will be published once this PR lands

2. v0.4.0 will be yanked once v0.4.1 is out

3. v0.4.1 will reject code that contains early returns in `init` *and* contains
   late resources. Yes, this is a breaking change but such code is unsound /
   has undefined behavior.

4. as of v0.4.1 users are encouraged to use `fn init() -> init::LateResources`
   instead of `fn init()` when they make use of late resources.

---

This PR fixes a soundness issue reported by @RalfJung. Basically, early
returning from `init` leaves *late resources* (runtime initialized statics)
uninitialized, and this produces undefined behavior as tasks rely on those
statics being initialized. The example below showcases a program that runs into
this soundness issue.

``` rust
 #[rtfm::app(device = lm3s6965)]
const APP: () = {
    // this is actually `static mut UNINITIALIZED: MaybeUninit<bool> = ..`
    static mut UNINITIALIZED: bool = ();

    #[init]
    fn init() {
        // early return
        return;

        // this is translated into `UNINITIALIZED.set(true)`
        UNINITIALIZED = true; // the DSL forces you to write this at the end
    }

    #[interrupt(resources = [UNINITIALIZED])]
    fn UART0() {
        // `resources.UNINITIALIZED` is basically `UNINITIALIZED.get_mut()`

        if resources.UNINITIALIZED {
            // undefined behavior
        }
    }
};
```

The fix consists of two parts. The first part is producing a compiler error
whenever the `app` procedural macro finds a `return` expression in `init`. This
covers most cases, except for macros (e.g. `ret!()` expands into `return`) which
cannot be instrospected by procedural macros. This fix is technically a
breaking change (though unlikely to affect real code out there) but as per our
SemVer policy (which follows rust-lang/rust's) we are allowed to make breaking
changes to fix soundness bugs.

The second part of the fix consists of extending the `init` syntax to let the
user return the initial values of late resources in a struct. Namely, `fn() ->
init::LateResources` will become a valid signature for `init` (we allowed this
signature back in v0.3.x). Thus the problematic code shown above can be
rewritten as:

``` rust
 #[rtfm::app(device = lm3s6965)]
const APP: () = {
    static mut UNINITIALIZED: bool = ();

    #[init]
    fn init() -> init::LateResources {
        // rejected by the compiler
        // return; //~ ERROR expected `init::LateResources`, found `()`

        // initialize late resources
        init::LateResources {
            UNINITIALIZED: true,
        }
    }

    #[interrupt(resources = [UNINITIALIZED])]
    fn UART0() {
        if resources.UNINITIALIZED {
            // OK
        }
    }
};
```

Attempting to early return without giving the initial values for late resources
will produce a compiler error.

~~Additionally, we'll emit warnings if the `init: fn()` signature is used to
encourage users to switch to the alternative `init: fn() -> init::LateResources`
signature.~~ Turns out we can't do this on stable. Bummer.

The book and examples have been updated to make use of `init::LateResources`.

In the next minor version release we'll reject `fn init()` if late resources
are declared. `fn init() -> init::LateResources` will become the only way to
initialize late resources.

This PR also prepares release v0.4.1. Once that version is published the unsound
version v0.4.0 will be yanked.


Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2019-02-12 14:28:42 +00:00
Jorge Aparicio
519d7ca056 update CHANGELOG with alt init syntax 2019-02-12 15:27:08 +01:00
Jorge Aparicio
1e9058cab2 (en) update the text related to late resources
cc @burrbull
2019-02-12 15:13:41 +01:00
Jorge Aparicio
89c922079e update examples and tests 2019-02-12 15:08:46 +01:00