85: fix master r=japaric a=japaric

closes #80

Co-authored-by: Ferdia McKeogh <chocol4te@users.noreply.github.com>
Co-authored-by: Jorge Aparicio <jorge@japaric.io>
This commit is contained in:
bors[bot] 2018-08-24 14:36:59 +00:00
commit 62a232f5c6
45 changed files with 56 additions and 111 deletions

View file

@ -7,44 +7,21 @@ matrix:
- env: TARGET=thumbv6m-none-eabi
rust: nightly
addons:
apt:
sources:
- debian-sid
packages:
- binutils-arm-none-eabi
- env: TARGET=thumbv7m-none-eabi
rust: nightly
addons:
apt:
sources:
- debian-sid
packages:
- binutils-arm-none-eabi
- env: TARGET=thumbv7em-none-eabi
rust: nightly
addons:
apt:
sources:
- debian-sid
packages:
- binutils-arm-none-eabi
- env: TARGET=thumbv7em-none-eabihf
rust: nightly
addons:
apt:
sources:
- debian-sid
packages:
- binutils-arm-none-eabi
before_install: set -e
install:
- bash ci/install.sh
- export PATH="$PATH:$PWD/gcc/bin"
script:
- bash ci/script.sh

View file

@ -1,5 +0,0 @@
[dependencies.core]
stage = 0
[dependencies.compiler_builtins]
stage = 1

View file

@ -4,6 +4,10 @@ main() {
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
rustup target add $TARGET
fi
mkdir gcc
curl -L https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2?revision=bc2c96c0-14b5-4bb4-9f18-bceb4050fee7?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,7-2018-q2-update | tar --strip-components=1 -C gcc -xj
}
main

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,7 +1,6 @@
//! A showcase of the `app!` macro syntax
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;
@ -60,7 +59,7 @@ mod main {
pub fn idle(t: &mut Threshold, mut r: ::idle::Resources) -> ! {
loop {
*r.OWNED != *r.OWNED;
*r.OWNED = !*r.OWNED;
if *r.OWNED {
if r.SHARED.claim(t, |shared, _| *shared) {

View file

@ -1,14 +1,13 @@
//! Working with resources in a generic fashion
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;
extern crate stm32f103xx;
use rtfm::{app, Resource, Threshold};
use stm32f103xx::{SPI1, GPIOA};
use stm32f103xx::{GPIOA, SPI1};
app! {
device: stm32f103xx,

View file

@ -1,7 +1,6 @@
//! Demonstrates initialization of resources in `init`.
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -4,7 +4,6 @@
//! letters in the comments: A, then B, then C, etc.
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;
@ -60,7 +59,13 @@ fn idle() -> ! {
}
#[allow(non_snake_case)]
fn exti0(t: &mut Threshold, EXTI0::Resources { mut LOW, mut HIGH }: EXTI0::Resources) {
fn exti0(
t: &mut Threshold,
EXTI0::Resources {
LOW: mut low,
HIGH: mut high,
}: EXTI0::Resources,
) {
// Because this task has a priority of 1 the preemption threshold `t` also
// starts at 1
@ -71,7 +76,7 @@ fn exti0(t: &mut Threshold, EXTI0::Resources { mut LOW, mut HIGH }: EXTI0::Resou
rtfm::set_pending(Interrupt::EXTI1); // ~> exti1
// A claim creates a critical section
LOW.claim_mut(t, |_low, t| {
low.claim_mut(t, |_low, t| {
// This claim increases the preemption threshold to 2
//
// 2 is just high enough to not race with task `exti1` for access to the
@ -92,7 +97,7 @@ fn exti0(t: &mut Threshold, EXTI0::Resources { mut LOW, mut HIGH }: EXTI0::Resou
rtfm::bkpt();
// Claims can be nested
HIGH.claim_mut(t, |_high, _| {
high.claim_mut(t, |_high, _| {
// This claim increases the preemption threshold to 3
// Now `exti2` can't preempt this task

View file

@ -1,7 +1,6 @@
//! An application with one task
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m;

View file

@ -1,7 +1,6 @@
//! Two tasks running at *different* priorities with access to the same resource
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,7 +1,6 @@
//! Safe creation of `&'static mut` references
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,7 +1,6 @@
//! Two tasks running at the *same* priority with access to the same resource
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,8 +1,6 @@
//! Minimal example with zero tasks
#![deny(unsafe_code)]
#![deny(warnings)]
// IMPORTANT always include this feature gate
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm; // IMPORTANT always do this rename

View file

@ -11,10 +11,10 @@ version = "0.3.1"
[dependencies]
failure = "0.1.1"
proc-macro2 = "0.3.6"
quote = "0.5.1"
rtfm-syntax = "0.3.0"
syn = "0.13.1"
proc-macro2 = "0.4.6"
quote = "0.6.3"
rtfm-syntax = "0.3.4"
syn = "0.14.2"
[lib]
proc-macro = true

View file

@ -61,7 +61,7 @@ pub fn app(app: check::App) -> Result<App> {
tasks: app.tasks
.into_iter()
.map(|(k, v)| {
let v = ::check::task(k.as_ref(), v)?;
let v = ::check::task(&k.to_string(), v)?;
Ok((k, v))
})

View file

@ -1,6 +1,5 @@
//! Procedural macros of the `cortex-m-rtfm` crate
// #![deny(warnings)]
#![feature(proc_macro)]
#![recursion_limit = "128"]
#[macro_use]

View file

@ -1,15 +1,14 @@
use proc_macro2::Span;
use quote::Tokens;
use proc_macro2::{TokenStream, Span};
use syn::{Ident, LitStr};
use analyze::Ownerships;
use check::{App, Kind};
fn krate() -> Ident {
Ident::from("rtfm")
Ident::new("rtfm", Span::call_site())
}
pub fn app(app: &App, ownerships: &Ownerships) -> Tokens {
pub fn app(app: &App, ownerships: &Ownerships) -> TokenStream {
let mut root = vec![];
let mut main = vec![quote!(#![allow(path_statements)])];
@ -28,7 +27,7 @@ pub fn app(app: &App, ownerships: &Ownerships) -> Tokens {
quote!(#(#root)*)
}
fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<TokenStream>, root: &mut Vec<TokenStream>) {
let krate = krate();
let mut mod_items = vec![];
@ -54,7 +53,7 @@ fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<Tokens>, root: &mut V
let super_ = if needs_reexport {
None
} else {
Some(Ident::from("super"))
Some(Ident::new("super", Span::call_site()))
};
let mut rexprs = vec![];
let mut rfields = vec![];
@ -70,7 +69,7 @@ fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<Tokens>, root: &mut V
pub #name: &'static mut #ty,
});
let _name = Ident::from(format!("_{}", name.as_ref()));
let _name = Ident::new(&name.to_string(), Span::call_site());
rexprs.push(if resource.expr.is_some() {
quote! {
#name: &mut #super_::#_name,
@ -86,7 +85,7 @@ fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<Tokens>, root: &mut V
});
rexprs.push(quote! {
#name: ::idle::#name { _0: core::marker::PhantomData },
#name: ::idle::#name { _0: ::core::marker::PhantomData },
});
}
}
@ -136,7 +135,7 @@ fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<Tokens>, root: &mut V
continue;
}
let _name = Ident::from(format!("_{}", name.as_ref()));
let _name = Ident::new(&name.to_string(), Span::call_site());
let resource = app.resources
.get(name)
.expect(&format!("BUG: resource {} has no definition", name));
@ -150,7 +149,7 @@ fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<Tokens>, root: &mut V
mod_items.push(quote! {
#[allow(non_camel_case_types)]
pub struct #name { _0: core::marker::PhantomData<*const ()> }
pub struct #name { _0: ::core::marker::PhantomData<*const ()> }
});
root.push(quote! {
@ -224,7 +223,7 @@ fn idle(app: &App, ownerships: &Ownerships, main: &mut Vec<Tokens>, root: &mut V
});
}
fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
fn init(app: &App, main: &mut Vec<TokenStream>, root: &mut Vec<TokenStream>) {
let device = &app.device;
let krate = krate();
@ -263,7 +262,7 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
&mut #name
},));
} else {
let _name = Ident::from(format!("_{}", name.as_ref()));
let _name = Ident::new(&name.to_string(), Span::call_site());
lifetime = Some(quote!('a));
fields.push(quote! {
@ -310,7 +309,7 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
let mut fields = vec![];
for (name, resource) in late_resources {
let _name = Ident::from(format!("_{}", name.as_ref()));
let _name = Ident::new(&name.to_string(), Span::call_site());
let ty = &resource.ty;
@ -415,11 +414,11 @@ fn init(app: &App, main: &mut Vec<Tokens>, root: &mut Vec<Tokens>) {
});
}
fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<TokenStream>) {
let krate = krate();
for name in ownerships.keys() {
let _name = Ident::from(format!("_{}", name.as_ref()));
let _name = Ident::new(&name.to_string(), Span::call_site());
// Declare the static that holds the resource
let resource = app.resources
@ -442,7 +441,7 @@ fn resources(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
}
}
fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>, main: &mut Vec<Tokens>) {
fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<TokenStream>, main: &mut Vec<TokenStream>) {
let device = &app.device;
let krate = krate();
@ -456,7 +455,7 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>, main: &mut
if has_resources {
for rname in &task.resources {
let ceiling = ownerships[rname].ceiling();
let _rname = Ident::from(format!("_{}", rname.as_ref()));
let _rname = Ident::new(&rname.to_string(), Span::call_site());
let resource = app.resources
.get(rname)
.expect(&format!("BUG: resource {} has no definition", rname));
@ -594,8 +593,8 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>, main: &mut
}
let path = &task.path;
let _tname = Ident::from(format!("_{}", tname));
let export_name = LitStr::new(tname.as_ref(), Span::call_site());
let _tname = Ident::new(&tname.to_string(), Span::call_site());
let export_name = LitStr::new(&tname.to_string(), Span::call_site());
root.push(quote! {
#[allow(non_snake_case)]
#[allow(unsafe_code)]

View file

@ -3,8 +3,6 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! // IMPORTANT always include this feature gate
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm; // IMPORTANT always do this rename

View file

@ -3,7 +3,6 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m;

View file

@ -3,7 +3,6 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm;

View file

@ -3,7 +3,6 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm;

View file

@ -6,14 +6,13 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm;
//! extern crate stm32f103xx;
//!
//! use stm32f103xx::Interrupt;
//! use rtfm::{app, Resource, Threshold};
//! use stm32f103xx::Interrupt;
//!
//! app! {
//! device: stm32f103xx,
@ -64,7 +63,10 @@
//! #[allow(non_snake_case)]
//! fn exti0(
//! t: &mut Threshold,
//! EXTI0::Resources { mut LOW, mut HIGH }: EXTI0::Resources,
//! EXTI0::Resources {
//! LOW: mut low,
//! HIGH: mut high,
//! }: EXTI0::Resources,
//! ) {
//! // Because this task has a priority of 1 the preemption threshold `t` also
//! // starts at 1
@ -76,7 +78,7 @@
//! rtfm::set_pending(Interrupt::EXTI1); // ~> exti1
//!
//! // A claim creates a critical section
//! LOW.claim_mut(t, |_low, t| {
//! low.claim_mut(t, |_low, t| {
//! // This claim increases the preemption threshold to 2
//! //
//! // 2 is just high enough to not race with task `exti1` for access to the
@ -97,7 +99,7 @@
//! rtfm::bkpt();
//!
//! // Claims can be nested
//! HIGH.claim_mut(t, |_high, _| {
//! high.claim_mut(t, |_high, _| {
//! // This claim increases the preemption threshold to 3
//!
//! // Now `exti2` can't preempt this task

View file

@ -3,7 +3,6 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm;

View file

@ -3,7 +3,6 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm;

View file

@ -3,14 +3,13 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm;
//! extern crate stm32f103xx;
//!
//! use rtfm::{app, Resource, Threshold};
//! use stm32f103xx::{SPI1, GPIOA};
//! use stm32f103xx::{GPIOA, SPI1};
//!
//! app! {
//! device: stm32f103xx,

View file

@ -3,7 +3,6 @@
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![feature(proc_macro)]
//! #![no_std]
//!
//! extern crate cortex_m_rtfm as rtfm;
@ -62,7 +61,7 @@
//!
//! pub fn idle(t: &mut Threshold, mut r: ::idle::Resources) -> ! {
//! loop {
//! *r.OWNED != *r.OWNED;
//! *r.OWNED = !*r.OWNED;
//!
//! if *r.OWNED {
//! if r.SHARED.claim(t, |shared, _| *shared) {

View file

@ -79,7 +79,6 @@
//! [rtfm]: http://www.diva-portal.org/smash/get/diva2:1005680/FULLTEXT01.pdf
#![deny(missing_docs)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m;

View file

@ -1,7 +1,6 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(const_fn)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,5 +1,4 @@
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,5 +1,4 @@
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,7 +1,6 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(const_fn)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;
@ -8,8 +7,9 @@ extern crate stm32f103xx;
use rtfm::app;
app! { //~ error attempt to subtract with overflow
//~^ error constant evaluation error
app! { //~ error referenced constant has errors
//~^ error could not evaluate constant
//~| error constant evaluation error
device: stm32f103xx,
tasks: {

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;
@ -8,8 +7,9 @@ extern crate stm32f103xx;
use rtfm::app;
app! { //~ error attempt to subtract with overflow
//~^ error constant evaluation error
app! { //~ error referenced constant has errors
//~^ error could not evaluate constant
//~| error constant evaluation error
device: stm32f103xx,
tasks: {

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,7 +1,6 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(const_fn)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;
@ -47,7 +46,7 @@ fn exti0(_t: &mut Threshold, r: EXTI0::Resources) {
// ERROR resource proxies are not `Send`able across tasks
is_send(&r.SHARED);
//~^ error the trait bound `*const (): core::marker::Send` is not satisfied
//~^ error `*const ()` cannot be sent between threads safely
}
fn exti1(_t: &mut Threshold, _r: EXTI1::Resources) {

View file

@ -1,7 +1,6 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(const_fn)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;

View file

@ -1,7 +1,6 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(const_fn)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;
@ -9,7 +8,7 @@ extern crate stm32f103xx;
use rtfm::{app, Threshold};
app! { //~ error bound `*const (): core::marker::Send` is not satisfied
app! { //~ error `*const ()` cannot be sent between threads safely
device: stm32f103xx,
resources: {

View file

@ -1,6 +1,5 @@
#![deny(unsafe_code)]
#![deny(warnings)]
#![feature(proc_macro)]
#![no_std]
extern crate cortex_m_rtfm as rtfm;