diff --git a/.gitignore b/.gitignore index e3b4068f..b3c01d63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ /build/ /thirdparty/ .DS_Store +Cargo.lock +target +.cargo +*.o +*.bin +*.lst +autom4te.cache diff --git a/.travis.yml b/.travis.yml index fc8eebb7..64ea98d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,26 @@ language: rust +rust: nightly before_install: - sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded - sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/terry_guo-gcc-arm-embedded-precise.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0" install: - sudo apt-get install gcc-arm-none-eabi - - (mkdir -p ./thirdparty/rust) - - (cd ./thirdparty/rust; wget -O rust.tar.gz https://github.com/rust-lang/rust/tarball/`rustc --version|awk '{sub(/\\(/, "", $3); print $3}'`; tar -zx --strip-components=1 -f rust.tar.gz) script: - - rake build_all test + - ./configure --host=arm-none-eabi + - cargo build --target=$TARGET --verbose --features $PLATFORM +after_script: + - cargo test --lib --verbose + - (cd ./platformtree; cargo build --verbose; cargo test --verbose) + - (cd ./macro_platformtree; cargo build --verbose; cargo test --verbose) env: matrix: - PLATFORM=lpc17xx + TARGET=thumbv7m-none-eabi + - PLATFORM=k20 + TARGET=thumbv7em-none-eabi - PLATFORM=stm32f4 + TARGET=thumbv7em-none-eabi - PLATFORM=stm32l1 - - PLATFORM=k20 + TARGET=thumbv7m-none-eabi - PLATFORM=tiva_c + TARGET=thumbv7em-none-eabi diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..383cb839 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,95 @@ +[package] +name = "zinc" +version = "0.1.0" +authors = ["Zinc Developers "] +build = "build.rs" + +[lib] +name = "zinc" +crate-type = ["lib"] + +[features] +lpc17xx = [] +stm32f4 = [] +stm32l1 = [] +k20 = [] +tiva_c = [] + +[target.thumbv7m-none-eabi.dependencies.core] +git = "https://github.com/hackndev/rust-libcore" + +[target.thumbv7em-none-eabi.dependencies.core] +git = "https://github.com/hackndev/rust-libcore" + +[dependencies.ioreg] +path = "./ioreg" + +[dependencies.rlibc] +git = "https://github.com/mcoffin/rlibc" +branch = "zinc" + +[dev-dependencies.platformtree] +path = "./platformtree" + +[dev-dependencies.macro_platformtree] +path = "./macro_platformtree" + +[[example]] +name = "nothing" +path = "examples/app_nothing.rs" + +[[example]] +name = "blink" +path = "examples/app_blink.rs" + +[[example]] +name = "blink_k20" +path = "examples/app_blink_k20.rs" + +[[example]] +name = "blink_k20_isr" +path = "examples/app_blink_k20_isr.rs" + +[[example]] +name = "blink_pt" +path = "examples/app_blink_pt.rs" + +[[example]] +name = "blink_stm32f4" +path = "examples/app_blink_stm32f4.rs" + +[[example]] +name = "blink_stm32l1" +path = "examples/app_blink_stm32l1.rs" + +[[example]] +name = "blink_tiva_c" +path = "examples/app_blink_tiva_c.rs" + +[[example]] +name = "bluenrg_stm32l1" +path = "examples/app_bluenrg_stm32l1.rs" + +[[example]] +name = "dht22" +path = "examples/app_dht22.rs" + +[[example]] +name = "empty" +path = "examples/app_empty.rs" + +[[example]] +name = "lcd_tiva_c" +path = "examples/app_lcd_tiva_c.rs" + +[[example]] +name = "uart" +path = "examples/app_uart.rs" + +[[example]] +name = "uart_tiva_c" +path = "examples/app_uart_tiva_c.rs" + +[[example]] +name = "uart_stm32l1" +path = "examples/app_uart_stm32l1.rs" diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..3273ab61 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,39 @@ +STRIP=@STRIP@ +OBJCOPY=@OBJCOPY@ +OBJDUMP=@OBJDUMP@ + +CARGO_ROOT=@srcdir@ + +PLATFORM=@PLATFORM@ +TARGET=@TARGET@ + +$(if $(value EXAMPLE_NAME),, \ + $(error EXAMPLE_NAME must be set)) + +# Output directory +OUT_DIR=$(CARGO_ROOT)/target/$(TARGET)/release +EXAMPLE_DIR=$(OUT_DIR)/examples + +BIN_FILE=$(EXAMPLE_DIR)/$(EXAMPLE_NAME).bin +LST_FILE=$(EXAMPLE_DIR)/$(EXAMPLE_NAME).lst +EXAMPLE_FILE=$(EXAMPLE_DIR)/$(EXAMPLE_NAME) + +.PHONY: build clean listing $(EXAMPLE_FILE) + +build: $(BIN_FILE) + +clean: + cargo clean + +listing: $(LST_FILE) + +# Target is PHONY so cargo can deal with dependencies +$(EXAMPLE_FILE): + cd $(CARGO_ROOT) + cargo build --example $(EXAMPLE_NAME) --release --target=$(TARGET) --verbose --features $(PLATFORM) + +$(BIN_FILE): $(EXAMPLE_FILE) + $(OBJCOPY) -O binary $< $@ + +$(LST_FILE): $(EXAMPLE_FILE) + $(OBJDUMP) -D $< > $@ diff --git a/README.md b/README.md index eef50d49..599de2eb 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,23 @@ Zinc is distributed under Apache-2.0, see LICENSE for more details. ## Usage -Get a gcc cross-toolchain for arm and configure `TOOLCHAIN` and `RUNTIME_LIB` in -Rakefile header as appropriate. `RUNTIME_LIB` should be either libgcc or -libcompiler-rt ar archive, compiled for appropriate architecture. +### Environment Setup -To build an application from apps/ use the following rake command: +Get a gcc cross-toolchain for arm and make sure it is accessible. + +### Examples + +First, generate a `Makefile` and `.cargo/config` with `configure` so cargo +can find your toolchain. Your toolchain triple is probably `arm-none-eabi` +```` +./configure PLATFORM= --host= +```` + +To build an application from examples/ use the following command after having +run `configure`: ``` -rake PLATFORM= build_all # or build_ +EXAMPLE_NAME= make build ``` + +Ouput will go to `target//release/examples`. diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 11d71ae2..00000000 --- a/Rakefile +++ /dev/null @@ -1,181 +0,0 @@ -load 'support/rake.rb' - -TOOLCHAIN = 'arm-none-eabi-' -RUSTC = 'rustc' - -Context.create(__FILE__, ENV['PLATFORM']) - -provide_stdlibs - -# collect-all task for tests -desc "Run tests" -task :test - -# external dependencies -compile_rust :shiny_crate, { - source: 'thirdparty/shiny/src/lib.rs'.in_root, - produce: 'thirdparty/shiny/src/lib.rs'.in_root.as_rlib.in_build, - out_dir: true, - build_for: :host, -} - -compile_rust :hamcrest_crate, { - source: 'thirdparty/hamcrest-rust/src/hamcrest/lib.rs'.in_root, - produce: 'thirdparty/hamcrest-rust/src/hamcrest/lib.rs'.in_root.as_rlib.in_build, - out_dir: true, - build_for: :host, - do_not_collect_rust_deps: true, -} - -# cross-compiled librlibc -compile_rust :rlibc_crate, { - source: 'thirdparty/librlibc/src/lib.rs'.in_root, - produce: 'thirdparty/librlibc/src/lib.rs'.in_root.as_rlib.in_build, - out_dir: true, - recompile_on: :triple, -} - -# cross-compiled libcore -compile_rust :core_crate, { - source: 'thirdparty/libcore/lib.rs'.in_root, - produce: 'thirdparty/libcore/lib.rs'.in_root.as_rlib.in_build, - out_dir: true, - recompile_on: :triple, -} - -# ioreg -compile_rust :ioreg_crate, { - source: 'ioreg/ioreg.rs'.in_source, - produce: 'ioreg/ioreg.rs'.in_source.as_dylib.in_build, - out_dir: true, - build_for: :host, -} - -rust_tests :ioreg_test, { - source: 'ioreg/test.rs'.in_source, - deps: [:core_crate, :ioreg_crate, :shiny_crate], - produce: 'ioreg_test'.in_build, -} - -# zinc crate -compile_rust :zinc_crate, { - source: 'zinc/lib.rs'.in_source, - deps: [:core_crate, :rlibc_crate, :ioreg_crate], - produce: 'zinc/lib.rs'.in_source.as_rlib.in_build, - out_dir: true, - recompile_on: [:triple, :platform], -} - -# zinc isr crate -compile_rust :zinc_isr, { - source: 'zinc/hal/isr.rs'.in_source, - deps: :core_crate, - produce: 'isr.o'.in_intermediate, - recompile_on: [:triple], -} - -# zinc scheduler assembly -# TODO(farcaller): broken until implemented in PT. -# compile_c :zinc_isr_sched, { -# source: 'hal/cortex_m3/sched.S'.in_source, -# produce: 'isr_sched.o'.in_intermediate, -# recompile_on: [:triple], -# } - -# platform tree -compile_rust :platformtree_crate, { - source: 'platformtree/platformtree.rs'.in_source, - produce: 'platformtree/platformtree.rs'.in_source.as_rlib.in_build, - out_dir: true, - build_for: :host, - optimize: 0, -} - -rust_tests :platformtree_test, { - source: 'platformtree/platformtree.rs'.in_source, - deps: :hamcrest_crate, - produce: 'platformtree_test'.in_build, -} - -# zinc test -rust_tests :zinc_test, { - source: 'zinc/lib.rs'.in_source, - deps: [:core_crate, :ioreg_crate, :hamcrest_crate, :shiny_crate], - produce: 'zinc_test'.in_build, - recompile_on: [:platform], - build_for: :host, -} - -# macros -compile_rust :macro_platformtree, { - source: 'macro/platformtree.rs'.in_source, - deps: [:platformtree_crate], - produce: 'macro/platformtree.rs'.in_source.as_dylib.in_build, - out_dir: true, - build_for: :host, - optimize: 0, -} - -desc "Build API documentation" -task build_docs: [:build_docs_html] - -task build_docs_html: [] do |t| - ['src/zinc/lib.rs', 'src/platformtree/platformtree.rs', 'src/ioreg/ioreg.rs'].each do |f| - build = Context.instance.build_dir - sh ("rustdoc -w html -o #{build}/doc -L #{build} " \ - + f + ' ' + :config_flags.in_env.join(' ')) - end -end - -app_tasks = Context.instance.applications.map do |a| - compile_rust "app_#{a}".to_sym, { - source: "apps/app_#{a}.rs".in_root, - deps: [ - :zinc_crate, - :core_crate, - :macro_platformtree, - ], - produce: "app_#{a}.o".in_intermediate(a), - recompile_on: [:triple, :platform], - } - - link_binary "app_#{a}_elf".to_sym, { - script: 'layout.ld'.in_platform, - deps: ["app_#{a}".to_sym, :zinc_isr], - # TODO(farcaller): broken until implemented in PT. - # (features.include?(:multitasking) ? [:zinc_isr_sched] : []), - produce: "app_#{a}.elf".in_build, - } - - t_bin = make_binary "app_#{a}_bin".to_sym, { - source: "app_#{a}.elf".in_build, - produce: "app_#{a}.bin".in_build, - } - - t_lst = listing "app_#{a}_lst".to_sym, { - source: "app_#{a}.elf".in_build, - produce: "app_#{a}.lst".in_build, - } - - t_size = report_size "app_#{a}_size".to_sym, { - source: "app_#{a}.elf".in_build, - } - - desc "Build application #{a}" - task "build_#{a}".to_sym => [t_bin.name, t_lst.name, t_size.name] -end - -desc "Build all applications" -case ENV['PLATFORM'] -when 'k20' - task :build_all => [:build_blink_k20, :build_blink_k20_isr] -when 'stm32f4' - task :build_all => [:build_blink_stm32f4] -when 'stm32l1' - task :build_all => [:build_blink_stm32l1, :build_usart_stm32l1, - :build_bluenrg_stm32l1] -when 'lpc17xx' - task :build_all => [:build_empty, :build_blink, :build_uart, :build_dht22] -when 'tiva_c' - task :build_all => [:build_blink_tiva_c, :build_uart_tiva_c, :build_lcd_tiva_c] -end diff --git a/apps/app_usart_stm32l1.rs b/apps/app_usart_stm32l1.rs deleted file mode 100644 index 44966197..00000000 --- a/apps/app_usart_stm32l1.rs +++ /dev/null @@ -1,42 +0,0 @@ -#![feature(plugin, no_std, core)] -#![crate_type="staticlib"] -#![no_std] -#![plugin(macro_platformtree)] - -extern crate core; -extern crate zinc; - -#[no_mangle] -pub unsafe fn main() { - use zinc::drivers::chario::CharIO; - use zinc::hal; - use zinc::hal::pin::Gpio; - use zinc::hal::stm32l1::{init, pin, usart}; - - zinc::hal::mem_init::init_stack(); - zinc::hal::mem_init::init_data(); - - let sys_clock = init::ClockConfig::new_default(); - sys_clock.setup(); - - let _pin_tx = pin::Pin::new(pin::Port::PortA, 2, - pin::Mode::AltFunction( - pin::AltMode::AfUsart1_Usart2_Usart3, - pin::OutputType::OutPushPull, - pin::Speed::VeryLow), - pin::PullType::PullNone); - - let led1 = pin::Pin::new(pin::Port::PortA, 5, - pin::Mode::GpioOut(pin::OutputType::OutPushPull, pin::Speed::VeryLow), - pin::PullType::PullNone); - - led1.set_low(); - - let uart = usart::Usart::new(usart::UsartPeripheral::Usart2, 38400, usart::WordLen::WordLen8bits, - hal::uart::Parity::Disabled, usart::StopBit::StopBit1bit, &sys_clock); - uart.puts("Hello, world\n"); - - led1.set_high(); - - loop {} -} diff --git a/architectures.yml b/architectures.yml deleted file mode 100644 index 460cc2cf..00000000 --- a/architectures.yml +++ /dev/null @@ -1,8 +0,0 @@ -cortex_m3: - arch: armv7-m - cpu: cortex-m3 - target: thumbv7m-none-eabi -cortex_m4: - arch: armv7e-m - cpu: cortex-m4 - target: thumbv7em-none-eabi diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..d27e6dbe --- /dev/null +++ b/build.rs @@ -0,0 +1,46 @@ +use std::ascii::AsciiExt; +use std::env; +use std::fs; +use std::io; +use std::path::Path; + +fn get_platform() -> Option { + let features = env::vars().filter(|&(ref key, _)| key.starts_with("CARGO_FEATURE_")); + match features.last() { + Some((feature_var, _)) => Some( + feature_var.trim_left_matches("CARGO_FEATURE_") + .to_string().to_ascii_lowercase()), + None => None, + } +} + +fn copy_linker_scripts, Q: AsRef>(target: P, out_path: Q) -> io::Result<()> { + // Try copying the linker scripts + let target_dir = Path::new("src/hal").join(target); + let out_dir: &Path = out_path.as_ref(); + try!(fs::copy("src/hal/layout_common.ld", out_dir.join("layout_common.ld"))); + try!(fs::copy(target_dir.join("iomem.ld"), out_dir.join("iomem.ld"))); + try!(fs::copy(target_dir.join("layout.ld"), out_dir.join("layout.ld"))); + + Ok(()) +} + +fn main() { + let platform = match get_platform() { + Some(p) => p, + None => { + return; + }, + }; + // Get output directory for cargo for zinc crate + let out_dir = env::var("OUT_DIR").unwrap(); + + // Move linker scripts to cargo output dir + match copy_linker_scripts(&platform, &out_dir) { + Ok(_) => {}, + Err(e) => panic!("Failed to copy linker scripts: {}", e) + } + + // Make sure that the output dir is passed to linker + println!("cargo:rustc-link-search=native={}", out_dir); +} diff --git a/cargo_config.in b/cargo_config.in new file mode 100644 index 00000000..93f74356 --- /dev/null +++ b/cargo_config.in @@ -0,0 +1,3 @@ +[target.@TARGET@] +linker = "@CC@" +ar = "@AR@" diff --git a/configure b/configure new file mode 100755 index 00000000..d725d889 --- /dev/null +++ b/configure @@ -0,0 +1,3323 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for zinc 0.1. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='zinc' +PACKAGE_TARNAME='zinc' +PACKAGE_VERSION='0.1' +PACKAGE_STRING='zinc 0.1' +PACKAGE_BUGREPORT='' +PACKAGE_URL='' + +ac_subst_vars='LTLIBOBJS +LIBOBJS +TARGET +PLATFORM +CC +AR +OBJDUMP +OBJCOPY +STRIP +GCC +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +' + ac_precious_vars='build_alias +host_alias +target_alias +PLATFORM' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures zinc 0.1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/zinc] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of zinc 0.1:";; + esac + cat <<\_ACEOF + +Some influential environment variables: + PLATFORM Platform for which to build + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +zinc configure 0.1 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by zinc $as_me 0.1, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +cross_compiling=yes + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_GCC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$GCC"; then + ac_cv_prog_GCC="$GCC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_GCC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +GCC=$ac_cv_prog_GCC +if test -n "$GCC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GCC" >&5 +$as_echo "$GCC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_GCC"; then + ac_ct_GCC=$GCC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_GCC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_GCC"; then + ac_cv_prog_ac_ct_GCC="$ac_ct_GCC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_GCC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_GCC=$ac_cv_prog_ac_ct_GCC +if test -n "$ac_ct_GCC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_GCC" >&5 +$as_echo "$ac_ct_GCC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_GCC" = x; then + GCC=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + GCC=$ac_ct_GCC + fi +else + GCC="$ac_cv_prog_GCC" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. +set dummy ${ac_tool_prefix}objcopy; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJCOPY+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJCOPY"; then + ac_cv_prog_OBJCOPY="$OBJCOPY" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJCOPY="${ac_tool_prefix}objcopy" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJCOPY=$ac_cv_prog_OBJCOPY +if test -n "$OBJCOPY"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJCOPY" >&5 +$as_echo "$OBJCOPY" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJCOPY"; then + ac_ct_OBJCOPY=$OBJCOPY + # Extract the first word of "objcopy", so it can be a program name with args. +set dummy objcopy; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJCOPY+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJCOPY"; then + ac_cv_prog_ac_ct_OBJCOPY="$ac_ct_OBJCOPY" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJCOPY="objcopy" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJCOPY=$ac_cv_prog_ac_ct_OBJCOPY +if test -n "$ac_ct_OBJCOPY"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJCOPY" >&5 +$as_echo "$ac_ct_OBJCOPY" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJCOPY" = x; then + OBJCOPY=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJCOPY=$ac_ct_OBJCOPY + fi +else + OBJCOPY="$ac_cv_prog_OBJCOPY" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + + +CC=$GCC + + + + +case $PLATFORM in +lpc17xx | stm32l1) + platform_target=thumbv7m-none-eabi + ;; +stm32f4 | k20 | tiva_c) + platform_target=thumbv7em-none-eabi + ;; +*) + as_fn_error $? "Unknown platform $PLATFORM" "$LINENO" 5 + ;; +esac + +TARGET=$platform_target + + +ac_config_files="$ac_config_files Makefile" + +ac_config_files="$ac_config_files .cargo/config:cargo_config.in" + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by zinc $as_me 0.1, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +zinc config.status 0.1 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + ".cargo/config") CONFIG_FILES="$CONFIG_FILES .cargo/config:cargo_config.in" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + + +eval set X " :F $CONFIG_FILES " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..4eb57e2f --- /dev/null +++ b/configure.ac @@ -0,0 +1,32 @@ +AC_INIT(zinc, 0.1) + +cross_compiling=yes + +AC_CHECK_TOOL(GCC, gcc, :) +AC_CHECK_TOOL(STRIP, strip, :) +AC_CHECK_TOOL(OBJCOPY, objcopy, :) +AC_CHECK_TOOL(OBJDUMP, objdump, :) +AC_CHECK_TOOL(AR, ar, :) + +AC_SUBST(CC, $GCC) + +AC_ARG_VAR(PLATFORM, [Platform for which to build]) + +case $PLATFORM in +lpc17xx | stm32l1) + platform_target=thumbv7m-none-eabi + ;; +stm32f4 | k20 | tiva_c) + platform_target=thumbv7em-none-eabi + ;; +*) + AC_MSG_ERROR([Unknown platform $PLATFORM]) + ;; +esac + +AC_SUBST(TARGET, $platform_target) + +AC_CONFIG_FILES([Makefile]) +AC_CONFIG_FILES([.cargo/config:cargo_config.in]) + +AC_OUTPUT diff --git a/examples/app_blink.rs b/examples/app_blink.rs new file mode 100644 index 00000000..1f084bf3 --- /dev/null +++ b/examples/app_blink.rs @@ -0,0 +1,37 @@ +#![feature(no_std, core, start)] +#![no_std] + +extern crate core; +extern crate zinc; + +use zinc::hal::timer::Timer; +use zinc::hal::lpc17xx::{pin, timer}; +use zinc::hal::pin::GpioDirection; +use zinc::hal::pin::Gpio; +use core::option::Option::Some; + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} + +pub fn main() { + zinc::hal::mem_init::init_stack(); + zinc::hal::mem_init::init_data(); + + // P1.20 => LED-2 (mbed LPC1768) + let led2 = pin::Pin::new( + pin::Port::Port1, 21, + pin::Function::Gpio, + Some(GpioDirection::Out)); + + let timer = timer::Timer::new(timer::TimerPeripheral::Timer0, 25, 4); + + loop { + led2.set_high(); + timer.wait_ms(10); + led2.set_low(); + timer.wait_ms(10); + } +} diff --git a/apps/app_blink_k20.rs b/examples/app_blink_k20.rs similarity index 82% rename from apps/app_blink_k20.rs rename to examples/app_blink_k20.rs index 7bc492d2..841907f7 100644 --- a/apps/app_blink_k20.rs +++ b/examples/app_blink_k20.rs @@ -1,7 +1,5 @@ -#![feature(plugin, no_std, core)] -#![crate_type="staticlib"] +#![feature(no_std, core, start)] #![no_std] -#![plugin(macro_platformtree)] extern crate core; extern crate zinc; @@ -26,10 +24,7 @@ pub fn wait(ticks: u32) { } } -#[no_mangle] -#[allow(unused_variables)] -#[allow(dead_code)] -pub unsafe fn main() { +pub fn main() { zinc::hal::mem_init::init_stack(); zinc::hal::mem_init::init_data(); watchdog::init(watchdog::State::Disabled); @@ -46,3 +41,9 @@ pub unsafe fn main() { wait(10); } } + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} diff --git a/apps/app_blink_k20_isr.rs b/examples/app_blink_k20_isr.rs similarity index 72% rename from apps/app_blink_k20_isr.rs rename to examples/app_blink_k20_isr.rs index b6371401..483a9c5f 100644 --- a/apps/app_blink_k20_isr.rs +++ b/examples/app_blink_k20_isr.rs @@ -1,8 +1,5 @@ -#![feature(plugin, no_std, core)] -#![feature(asm)] -#![crate_type="staticlib"] +#![feature(no_std, core, start)] #![no_std] -#![plugin(macro_platformtree)] extern crate core; extern crate zinc; @@ -21,15 +18,13 @@ static mut global_on: u32 = 0; #[allow(dead_code)] #[no_mangle] pub unsafe extern fn isr_systick() { - i += 1; - if i > 100 { - i = 0; - global_on = !global_on; - } + i += 1; + if i > 100 { + i = 0; + global_on = !global_on; + } } -#[no_mangle] -#[allow(dead_code)] pub fn main() { zinc::hal::mem_init::init_stack(); zinc::hal::mem_init::init_data(); @@ -44,10 +39,16 @@ pub fn main() { loop { let on: bool = unsafe { volatile_load(&global_on as *const u32) == 0 }; - match on { - true => led1.set_high(), - false => led1.set_low(), - } - wfi(); + match on { + true => led1.set_high(), + false => led1.set_low(), + } + wfi(); } } + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} diff --git a/apps/app_blink.rs b/examples/app_blink_pt.rs similarity index 87% rename from apps/app_blink.rs rename to examples/app_blink_pt.rs index f94042cb..41ce60a7 100644 --- a/apps/app_blink.rs +++ b/examples/app_blink_pt.rs @@ -1,11 +1,9 @@ -#![feature(plugin, no_std, core)] -#![crate_type="staticlib"] +#![feature(plugin, no_std, core, start)] #![no_std] #![plugin(macro_platformtree)] extern crate core; extern crate zinc; -#[macro_use] #[no_link] extern crate macro_platformtree; platformtree!( lpc17xx@mcu { diff --git a/apps/app_blink_stm32f4.rs b/examples/app_blink_stm32f4.rs similarity index 70% rename from apps/app_blink_stm32f4.rs rename to examples/app_blink_stm32f4.rs index 0c6f01cb..60cbc982 100644 --- a/apps/app_blink_stm32f4.rs +++ b/examples/app_blink_stm32f4.rs @@ -1,17 +1,19 @@ -#![feature(plugin, no_std, core)] -#![crate_type="staticlib"] +#![feature(no_std, core, start)] #![no_std] -#![plugin(macro_platformtree)] extern crate core; extern crate zinc; -#[no_mangle] -#[allow(unused_variables)] -#[allow(dead_code)] -pub unsafe fn main() { - use zinc::hal::timer::Timer; - use zinc::hal::stm32f4::{pin, timer}; +use zinc::hal::timer::Timer; +use zinc::hal::stm32f4::{pin, timer}; + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} + +pub fn main() { zinc::hal::mem_init::init_stack(); zinc::hal::mem_init::init_data(); diff --git a/apps/app_blink_stm32l1.rs b/examples/app_blink_stm32l1.rs similarity index 76% rename from apps/app_blink_stm32l1.rs rename to examples/app_blink_stm32l1.rs index 3dbb92d1..8277dead 100644 --- a/apps/app_blink_stm32l1.rs +++ b/examples/app_blink_stm32l1.rs @@ -1,12 +1,15 @@ -#![feature(plugin, no_std, core)] -#![crate_type="staticlib"] +#![feature(no_std, core, start)] #![no_std] -#![plugin(macro_platformtree)] extern crate core; extern crate zinc; -#[no_mangle] +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} + pub unsafe fn main() { use core::option::Option; use zinc::hal::pin::Gpio; @@ -25,8 +28,8 @@ pub unsafe fn main() { sys_clock.setup(); let led1 = pin::Pin::new(pin::Port::PortA, 5, - pin::Mode::GpioOut(pin::OutputType::OutPushPull, pin::Speed::VeryLow), - pin::PullType::PullNone); + pin::Mode::GpioOut(pin::OutputType::OutPushPull, pin::Speed::VeryLow), + pin::PullType::PullNone); // TODO(kvark): why doesn't "sys_clock.get_apb1_frequency()" work better? let timer_clock = sys_clock.source.frequency(); diff --git a/apps/app_blink_tiva_c.rs b/examples/app_blink_tiva_c.rs similarity index 100% rename from apps/app_blink_tiva_c.rs rename to examples/app_blink_tiva_c.rs diff --git a/apps/app_bluenrg_stm32l1.rs b/examples/app_bluenrg_stm32l1.rs similarity index 97% rename from apps/app_bluenrg_stm32l1.rs rename to examples/app_bluenrg_stm32l1.rs index 487e5473..68b6f3b9 100644 --- a/apps/app_bluenrg_stm32l1.rs +++ b/examples/app_bluenrg_stm32l1.rs @@ -1,7 +1,5 @@ -#![feature(plugin, no_std, core)] -#![crate_type="staticlib"] +#![feature(no_std, core, start)] #![no_std] -#![plugin(macro_platformtree)] //! Sample application for BlueNRG communication over SPI in X-NUCLEO-IDB04A1 //! extension board for NUCLEO-L152RE @@ -16,6 +14,12 @@ mod std { pub use core::fmt; } +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} + //TODO(kvark): temporary `u8 -> str` conversion until #235 is resolved fn map_byte(s: u8) -> (&'static str, &'static str) { fn map_hex(h: u8) -> &'static str { @@ -42,7 +46,6 @@ fn map_byte(s: u8) -> (&'static str, &'static str) { (map_hex(s>>4), map_hex(s&0xF)) } -#[no_mangle] pub unsafe fn main() { use core::fmt::Write; use core::result::Result; diff --git a/apps/app_dht22.rs b/examples/app_dht22.rs similarity index 100% rename from apps/app_dht22.rs rename to examples/app_dht22.rs diff --git a/apps/app_empty.rs b/examples/app_empty.rs similarity index 100% rename from apps/app_empty.rs rename to examples/app_empty.rs diff --git a/apps/app_lcd_tiva_c.rs b/examples/app_lcd_tiva_c.rs similarity index 100% rename from apps/app_lcd_tiva_c.rs rename to examples/app_lcd_tiva_c.rs diff --git a/examples/app_nothing.rs b/examples/app_nothing.rs new file mode 100644 index 00000000..05abd6ff --- /dev/null +++ b/examples/app_nothing.rs @@ -0,0 +1,13 @@ +#![feature(no_std, core, start)] +#![no_std] + +extern crate zinc; + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} + +pub fn main() { +} diff --git a/apps/app_uart.rs b/examples/app_uart.rs similarity index 96% rename from apps/app_uart.rs rename to examples/app_uart.rs index a9703205..ccda42fa 100644 --- a/apps/app_uart.rs +++ b/examples/app_uart.rs @@ -1,4 +1,4 @@ -#![feature(plugin, no_std, core)] +#![feature(start, plugin, no_std, core)] #![crate_type="staticlib"] #![no_std] #![plugin(macro_platformtree)] diff --git a/apps/app_uart_tiva_c.rs b/examples/app_uart_tiva_c.rs similarity index 100% rename from apps/app_uart_tiva_c.rs rename to examples/app_uart_tiva_c.rs diff --git a/examples/app_usart_stm32l1.rs b/examples/app_usart_stm32l1.rs new file mode 100644 index 00000000..63afdde3 --- /dev/null +++ b/examples/app_usart_stm32l1.rs @@ -0,0 +1,45 @@ +#![feature(no_std, core, start)] +#![no_std] + +extern crate core; +extern crate zinc; + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + main(); + 0 +} + +pub unsafe fn main() { + use zinc::drivers::chario::CharIO; + use zinc::hal; + use zinc::hal::pin::Gpio; + use zinc::hal::stm32l1::{init, pin, usart}; + + zinc::hal::mem_init::init_stack(); + zinc::hal::mem_init::init_data(); + + let sys_clock = init::ClockConfig::new_default(); + sys_clock.setup(); + + let _pin_tx = pin::Pin::new(pin::Port::PortA, 2, + pin::Mode::AltFunction( + pin::AltMode::AfUsart1_Usart2_Usart3, + pin::OutputType::OutPushPull, + pin::Speed::VeryLow), + pin::PullType::PullNone); + + let led1 = pin::Pin::new(pin::Port::PortA, 5, + pin::Mode::GpioOut(pin::OutputType::OutPushPull, pin::Speed::VeryLow), + pin::PullType::PullNone); + + led1.set_low(); + + let uart = usart::Usart::new(usart::UsartPeripheral::Usart2, 38400, usart::WordLen::WordLen8bits, + hal::uart::Parity::Disabled, usart::StopBit::StopBit1bit, &sys_clock); + uart.puts("Hello, world\n"); + + led1.set_high(); + + loop {} +} diff --git a/apps/old_app_mbed_lcd.rs b/examples/old_app_mbed_lcd.rs similarity index 100% rename from apps/old_app_mbed_lcd.rs rename to examples/old_app_mbed_lcd.rs diff --git a/apps/old_app_sched.rs b/examples/old_app_sched.rs similarity index 100% rename from apps/old_app_sched.rs rename to examples/old_app_sched.rs diff --git a/apps/old_app_systick.rs b/examples/old_app_systick.rs similarity index 100% rename from apps/old_app_systick.rs rename to examples/old_app_systick.rs diff --git a/ioreg/Cargo.toml b/ioreg/Cargo.toml new file mode 100644 index 00000000..e13cc3a3 --- /dev/null +++ b/ioreg/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "ioreg" +version = "0.1.0" +authors = ["Zinc Developers "] + +[lib] +name = "ioreg" +plugin = true diff --git a/src/ioreg/builder/accessors.rs b/ioreg/src/builder/accessors.rs similarity index 65% rename from src/ioreg/builder/accessors.rs rename to ioreg/src/builder/accessors.rs index 2428dde7..7e61b611 100644 --- a/src/ioreg/builder/accessors.rs +++ b/ioreg/src/builder/accessors.rs @@ -124,83 +124,100 @@ fn build_get_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg) fn build_field_set_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, field: &node::Field) - -> P + -> P { + let reg_ty = cx.ty_ident(DUMMY_SP, utils::path_ident(cx, path)); let fn_name = - cx.ident_of((String::from_str("set_")+field.name.node.as_slice()).as_slice()); + cx.ident_of((String::from_str("set_")+field.name.node.as_str()).as_str()); let field_ty: P = cx.ty_path(utils::field_type_path(cx, path, reg, field)); let setter_ty = utils::setter_name(cx, path); if field.count.node == 1 { - quote_method!(cx, - #[allow(dead_code, missing_docs)] - pub fn $fn_name<'a>(&'a self, new_value: $field_ty) -> $setter_ty<'a> { - let mut setter: $setter_ty = $setter_ty::new(self); - setter.$fn_name(new_value); - setter + utils::unwrap_impl_item(quote_item!(cx, + impl $reg_ty { + #[allow(dead_code, missing_docs)] + pub fn $fn_name<'a>(&'a self, new_value: $field_ty) -> $setter_ty<'a> { + let mut setter: $setter_ty = $setter_ty::new(self); + setter.$fn_name(new_value); + setter + } } - ) + ).unwrap()) } else { - quote_method!(cx, - #[allow(dead_code, missing_docs)] - pub fn $fn_name<'a>(&'a self, idx: usize, new_value: $field_ty) -> $setter_ty<'a> { - let mut setter: $setter_ty = $setter_ty::new(self); - setter.$fn_name(idx, new_value); - setter + utils::unwrap_impl_item(quote_item!(cx, + impl $reg_ty { + #[allow(dead_code, missing_docs)] + pub fn $fn_name<'a>(&'a self, idx: usize, new_value: $field_ty) -> $setter_ty<'a> { + let mut setter: $setter_ty = $setter_ty::new(self); + setter.$fn_name(idx, new_value); + setter + } } - ) + ).unwrap()) } } fn build_field_get_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, field: &node::Field) - -> P + -> P { - let fn_name = cx.ident_of(field.name.node.as_slice()); - let field_ty: P = - cx.ty_path(utils::field_type_path(cx, path, reg, field)); - let getter_ty = utils::getter_name(cx, path); - if field.count.node == 1 { - quote_method!(cx, - #[allow(dead_code, missing_docs)] - pub fn $fn_name(&self) -> $field_ty { - $getter_ty::new(self).$fn_name() + let reg_ty = cx.ty_ident(DUMMY_SP, utils::path_ident(cx, path)); + utils::unwrap_impl_item({ + let fn_name = cx.ident_of(field.name.node.as_str()); + let field_ty: P = + cx.ty_path(utils::field_type_path(cx, path, reg, field)); + let getter_ty = utils::getter_name(cx, path); + if field.count.node == 1 { + quote_item!(cx, + impl $reg_ty { + #[allow(dead_code, missing_docs)] + pub fn $fn_name(&self) -> $field_ty { + $getter_ty::new(self).$fn_name() + } + } + ).unwrap() + } else { + quote_item!(cx, + impl $reg_ty { + #[allow(dead_code, missing_docs)] + pub fn $fn_name(&self, idx: usize) -> $field_ty { + $getter_ty::new(self).$fn_name(idx) + } + } + ).unwrap() } - ) - } else { - quote_method!(cx, - #[allow(dead_code, missing_docs)] - pub fn $fn_name(&self, idx: usize) -> $field_ty { - $getter_ty::new(self).$fn_name(idx) - } - ) - } + }) } fn build_field_clear_fn(cx: &ExtCtxt, path: &Vec, _reg: &node::Reg, field: &node::Field) - -> P + -> P { + let reg_ty = cx.ty_ident(DUMMY_SP, utils::path_ident(cx, path)); let fn_name = - cx.ident_of((String::from_str("clear_")+field.name.node.as_slice()).as_slice()); + cx.ident_of((String::from_str("clear_")+field.name.node.as_str()).as_str()); let setter_ty = utils::setter_name(cx, path); - if field.count.node == 1 { - quote_method!(cx, - #[allow(dead_code, missing_docs)] - pub fn $fn_name<'a>(&'a self) -> $setter_ty<'a> { - let mut setter: $setter_ty = $setter_ty::new(self); - setter.$fn_name(); - setter + utils::unwrap_impl_item(if field.count.node == 1 { + quote_item!(cx, + impl $reg_ty { + #[allow(dead_code, missing_docs)] + pub fn $fn_name<'a>(&'a self) -> $setter_ty<'a> { + let mut setter: $setter_ty = $setter_ty::new(self); + setter.$fn_name(); + setter + } } - ) + ).unwrap() } else { - quote_method!(cx, - #[allow(dead_code, missing_docs)] - pub fn $fn_name<'a>(&'a self, idx: usize) -> $setter_ty<'a> { - let mut setter: $setter_ty = $setter_ty::new(self); - setter.$fn_name(idx); - setter + quote_item!(cx, + impl $reg_ty { + #[allow(dead_code, missing_docs)] + pub fn $fn_name<'a>(&'a self, idx: usize) -> $setter_ty<'a> { + let mut setter: $setter_ty = $setter_ty::new(self); + setter.$fn_name(idx); + setter + } } - ) - } + ).unwrap() + }) } diff --git a/src/ioreg/builder/getter.rs b/ioreg/src/builder/getter.rs similarity index 64% rename from src/ioreg/builder/getter.rs rename to ioreg/src/builder/getter.rs index c2d97a68..c6a26252 100644 --- a/src/ioreg/builder/getter.rs +++ b/ioreg/src/builder/getter.rs @@ -76,6 +76,7 @@ fn build_type(cx: &ExtCtxt, path: &Vec, let item = quote_item!(cx, $doc_attr + #[derive(Clone)] #[allow(non_camel_case_types)] pub struct $name { value: $packed_ty, @@ -86,25 +87,28 @@ fn build_type(cx: &ExtCtxt, path: &Vec, P(item) } -fn build_new(cx: &ExtCtxt, path: &Vec) -> P { +fn build_new(cx: &ExtCtxt, path: &Vec) -> P { let reg_ty: P = cx.ty_ident(DUMMY_SP, utils::path_ident(cx, path)); + let getter_ident = utils::getter_name(cx, path); let getter_ty: P = cx.ty_ident(DUMMY_SP, - utils::getter_name(cx, path)); + getter_ident); let item = quote_item!(cx, - #[doc = "Create a getter reflecting the current value of the given register."] - pub fn new(reg: & $reg_ty) -> $getter_ty { - $getter_ty { - value: reg.value.get(), + impl $getter_ty { + #[doc = "Create a getter reflecting the current value of the given register."] + pub fn new(reg: & $reg_ty) -> $getter_ty { + $getter_ident { + value: reg.value.get(), + } } } - ); - item.unwrap() + ).unwrap(); + utils::unwrap_impl_item(item) } /// Given an `Expr` of the given register's primitive type, return /// an `Expr` of the field type -fn from_primitive(cx: &ExtCtxt, reg: &node::Reg, +fn from_primitive(cx: &ExtCtxt, path: &Vec, _: &node::Reg, field: &node::Field, prim: P) -> P { match field.ty.node { @@ -112,28 +116,49 @@ fn from_primitive(cx: &ExtCtxt, reg: &node::Reg, node::FieldType::BoolField => cx.expr_binary(DUMMY_SP, ast::BiNe, prim, utils::expr_int(cx, 0)), - node::FieldType::EnumField {..} => { - let from = match reg.ty { - node::RegType::RegPrim(ref width,_) => - match width { - &node::RegWidth::Reg32 => "from_u32", - &node::RegWidth::Reg16 => "from_u16", - &node::RegWidth::Reg8 => "from_u8", - }, - _ => panic!("Can't convert group register to primitive type"), + node::FieldType::EnumField {opt_name: _, variants: ref vars} => { + let mut arms: Vec = Vec::new(); + for v in vars.iter() { + let mut name = path.clone(); + name.push(field.name.node.clone()); + let enum_ident = cx.ident_of(name.connect("_").as_str()); + let val_ident = cx.ident_of(v.name.node.as_str()); + let body = cx.expr_path( + cx.path(DUMMY_SP, vec!(enum_ident, val_ident))); + let val: u64 = v.value.node; + let lit = cx.expr_lit( + DUMMY_SP, + ast::LitInt(val, ast::UnsuffixedIntLit(ast::Plus))); + let arm = ast::Arm { + attrs: vec!(), + pats: vec!( + P(ast::Pat { + id: ast::DUMMY_NODE_ID, + span: DUMMY_SP, + node: ast::PatLit(lit), + }) + ), + guard: None, + body: cx.expr_some(DUMMY_SP, body), + }; + arms.push(arm); + } + let wild_arm = ast::Arm { + attrs: vec!(), + pats: vec!(cx.pat_wild(DUMMY_SP)), + guard: None, + body: cx.expr_none(DUMMY_SP), }; + arms.push(wild_arm); + let opt_expr = cx.expr_match( + DUMMY_SP, + prim, + arms); cx.expr_method_call( DUMMY_SP, - cx.expr_call_global( - DUMMY_SP, - vec!(cx.ident_of("core"), - cx.ident_of("num"), - cx.ident_of(from)), - vec!(prim) - ), + opt_expr, cx.ident_of("unwrap"), - Vec::new() - ) + Vec::new()) }, } } @@ -142,19 +167,21 @@ fn build_impl(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, fields: &Vec) -> P { let getter_ty = utils::getter_name(cx, path); let new = build_new(cx, path); - let getters: Vec> = + let getters: Vec> = FromIterator::from_iter( fields.iter() .map(|field| build_field_get_fn(cx, path, reg, field))); let packed_ty = utils::reg_primitive_type(cx, reg) .expect("Unexpected non-primitive register"); - let get_raw: P = quote_method!(cx, - #[doc = "Get the raw value of the register."] - pub fn raw(&self) -> $packed_ty { - self.value + let get_raw: P = utils::unwrap_impl_item(quote_item!(cx, + impl $getter_ty { + #[doc = "Get the raw value of the register."] + pub fn raw(&self) -> $packed_ty { + self.value + } } - ); + ).unwrap()); let it = quote_item!(cx, #[allow(dead_code)] @@ -164,14 +191,16 @@ fn build_impl(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, $get_raw } ); - it.unwrap() + let mut item: ast::Item = it.unwrap().deref().clone(); + item.span = reg.name.span; + P(item) } /// Build a getter for a field fn build_field_get_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, - field: &node::Field) -> P + field: &node::Field) -> P { - let fn_name = cx.ident_of(field.name.node.as_slice()); + let fn_name = cx.ident_of(field.name.node.as_str()); let field_ty: P = cx.ty_path(utils::field_type_path(cx, path, reg, field)); let mask = utils::mask(cx, field); @@ -187,24 +216,28 @@ fn build_field_get_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, if field.count.node == 1 { let shift = utils::shift(cx, None, field); let value = from_primitive( - cx, reg, field, + cx, path, reg, field, quote_expr!(cx, (self.value >> $shift) & $mask)); - quote_method!(cx, - $doc_attr - pub fn $fn_name(&self) -> $field_ty { - $value + utils::unwrap_impl_item(quote_item!(cx, + impl X { + $doc_attr + pub fn $fn_name(&self) -> $field_ty { + $value + } } - ) + ).unwrap()) } else { let shift = utils::shift(cx, Some(quote_expr!(cx, idx)), field); let value = from_primitive( - cx, reg, field, + cx, path, reg, field, quote_expr!(cx, (self.value >> $shift) & $mask)); - quote_method!(cx, - $doc_attr - pub fn $fn_name(&self, idx: usize) -> $field_ty { - $value + utils::unwrap_impl_item(quote_item!(cx, + impl X { + $doc_attr + pub fn $fn_name(&self, idx: usize) -> $field_ty { + $value + } } - ) + ).unwrap()) } } diff --git a/src/ioreg/builder/mod.rs b/ioreg/src/builder/mod.rs similarity index 100% rename from src/ioreg/builder/mod.rs rename to ioreg/src/builder/mod.rs diff --git a/src/ioreg/builder/register.rs b/ioreg/src/builder/register.rs similarity index 97% rename from src/ioreg/builder/register.rs rename to ioreg/src/builder/register.rs index 5b4681fd..3e59c6a8 100644 --- a/src/ioreg/builder/register.rs +++ b/ioreg/src/builder/register.rs @@ -73,7 +73,6 @@ fn build_field_type(cx: &ExtCtxt, path: &Vec, variants.iter().map(|v| P(build_enum_variant(cx, v)))), }; let attrs: Vec = vec!( - utils::list_attribute(cx, "derive", vec!("FromPrimitive")), utils::list_attribute(cx, "allow", vec!("dead_code", "non_camel_case_types", @@ -115,6 +114,7 @@ fn build_reg_struct(cx: &ExtCtxt, path: &Vec, let ty_name = utils::path_ident(cx, path); let item = quote_item!(cx, $doc_attr + #[derive(Clone)] #[allow(non_camel_case_types)] pub struct $ty_name { value: VolatileCell<$packed_ty>, @@ -140,7 +140,7 @@ fn build_enum_variant(cx: &ExtCtxt, variant: &node::Variant) respan( mk_sp(variant.name.span.lo, variant.value.span.hi), ast::Variant_ { - name: cx.ident_of(variant.name.node.as_slice()), + name: cx.ident_of(variant.name.node.as_str()), attrs: vec!(doc_attr), kind: ast::TupleVariantKind(Vec::new()), id: ast::DUMMY_NODE_ID, diff --git a/src/ioreg/builder/setter.rs b/ioreg/src/builder/setter.rs similarity index 70% rename from src/ioreg/builder/setter.rs rename to ioreg/src/builder/setter.rs index 15747fe7..bdb70008 100644 --- a/src/ioreg/builder/setter.rs +++ b/ioreg/src/builder/setter.rs @@ -90,28 +90,28 @@ fn build_type(cx: &ExtCtxt, path: &Vec, } fn build_new<'a>(cx: &'a ExtCtxt, path: &Vec) - -> P { + -> P { let reg_ty: P = cx.ty_ident(DUMMY_SP, utils::path_ident(cx, path)); - let setter_ty: P = cx.ty_ident(DUMMY_SP, - utils::setter_name(cx, path)); - let item = quote_item!(cx, - #[doc="Create a new updater"] - pub fn new(reg: &'a $reg_ty) -> $setter_ty { - $setter_ty { - value: 0, - mask: 0, - reg: reg, + let setter_ident = utils::setter_name(cx, path); + utils::unwrap_impl_item(quote_item!(cx, + impl<'a> $setter_ident<'a> { + #[doc="Create a new updater"] + pub fn new(reg: &'a $reg_ty) -> $setter_ident<'a> { + $setter_ident { + value: 0, + mask: 0, + reg: reg, + } } - }); - item.unwrap() + } + ).unwrap()) } fn build_drop(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, fields: &Vec) -> P { - let setter_ty: P = cx.ty_ident(DUMMY_SP, - utils::setter_name(cx, path)); + let setter_ident = utils::setter_name(cx, path); let unpacked_ty = utils::reg_primitive_type(cx, reg) .expect("Unexpected non-primitive register"); @@ -137,9 +137,8 @@ fn build_drop(cx: &ExtCtxt, path: &Vec, }; let item = quote_item!(cx, - #[unsafe_destructor] #[doc = "This performs the register update"] - impl<'a> Drop for $setter_ty<'a> { + impl<'a> Drop for $setter_ident<'a> { fn drop(&mut self) { let clear_mask: $unpacked_ty = $clear as $unpacked_ty; if self.mask != 0 { @@ -152,40 +151,38 @@ fn build_drop(cx: &ExtCtxt, path: &Vec, item.unwrap() } -fn build_done(cx: &ExtCtxt) -> P -{ - quote_method!(cx, - #[doc="Commit changes to register. This is to allow chains of `set_*` \ - invocations to be used as a statement."] - pub fn done(self) {} - ) +fn build_done(ctx: &ExtCtxt, path: &Vec) -> P { + let setter_ident = utils::setter_name(ctx, path); + utils::unwrap_impl_item(quote_item!(ctx, + impl<'a> $setter_ident<'a> { + #[doc = "Commit changes to register. Allows for chaining of set"] + pub fn done(self) {} + } + ).unwrap()) } fn build_impl(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, fields: &Vec) -> P { let new = build_new(cx, path); - let setter_ty: P = cx.ty_ident( - DUMMY_SP, - utils::setter_name(cx, path)); - let methods: Vec> = + let setter_ident = utils::setter_name(cx, path); + let methods: Vec> = FromIterator::from_iter( fields.iter() .filter_map(|field| build_field_fn(cx, path, reg, field))); - let done: P = build_done(cx); - let impl_ = quote_item!(cx, + let done = build_done(cx, path); + quote_item!(cx, #[allow(dead_code)] - impl<'a> $setter_ty<'a> { + impl<'a> $setter_ident<'a> { $new $methods $done } - ); - impl_.unwrap() + ).unwrap() } fn build_field_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, - field: &node::Field) -> Option> + field: &node::Field) -> Option> { match field.access { node::Access::ReadOnly => None, @@ -196,13 +193,13 @@ fn build_field_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, /// Build a setter for a field fn build_field_set_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, - field: &node::Field) -> P + field: &node::Field) -> P { let setter_ty = utils::setter_name(cx, path); let unpacked_ty = utils::reg_primitive_type(cx, reg) .expect("Unexpected non-primitive register"); let fn_name = - cx.ident_of((String::from_str("set_")+field.name.node.as_slice()).as_slice()); + cx.ident_of((String::from_str("set_")+field.name.node.as_str()).as_str()); let field_ty: P = cx.ty_path(utils::field_type_path(cx, path, reg, field)); let mask = utils::mask(cx, field); @@ -218,35 +215,40 @@ fn build_field_set_fn(cx: &ExtCtxt, path: &Vec, reg: &node::Reg, if field.count.node == 1 { let shift = utils::shift(cx, None, field); - quote_method!(cx, - $doc_attr - pub fn $fn_name<'b>(&'b mut self, new_value: $field_ty) - -> &'b mut $setter_ty<'a> { - self.value |= (self.value & ! $mask) | ((new_value as $unpacked_ty) & $mask) << $shift; - self.mask |= $mask << $shift; - self + utils::unwrap_impl_item(quote_item!(cx, + impl<'a> $setter_ty<'a> { + $doc_attr + pub fn $fn_name<'b>(&'b mut self, + new_value: $field_ty) -> &'b mut $setter_ty<'a> { + self.value |= (self.value & ! $mask) | ((new_value as $unpacked_ty) & $mask) << $shift; + self.mask |= $mask << $shift; + self + } } - ) + ).unwrap()) } else { let shift = utils::shift(cx, Some(quote_expr!(cx, idx)), field); - quote_method!(cx, - $doc_attr - pub fn $fn_name<'b>(&'b mut self, idx: usize, new_value: $field_ty) - -> &'b mut $setter_ty<'a> { - self.value |= (self.value & ! $mask) | ((new_value as $unpacked_ty) & $mask) << $shift; - self.mask |= $mask << $shift; - self + utils::unwrap_impl_item(quote_item!(cx, + impl<'a> $setter_ty<'a> { + $doc_attr + pub fn $fn_name<'b>(&'b mut self, + idx: usize, + new_value: $field_ty) -> &'b mut $setter_ty<'a> { + self.value |= (self.value & ! $mask) | ((new_value as $unpacked_ty) & $mask) << $shift; + self.mask |= $mask << $shift; + self + } } - ) + ).unwrap()) } } fn build_field_clear_fn(cx: &ExtCtxt, path: &Vec, - _: &node::Reg, field: &node::Field) -> P + _: &node::Reg, field: &node::Field) -> P { let setter_ty = utils::setter_name(cx, path); let fn_name = - cx.ident_of((String::from_str("clear_")+field.name.node.as_slice()).as_slice()); + cx.ident_of((String::from_str("clear_")+field.name.node.as_str()).as_str()); let mask = utils::mask(cx, field); let field_doc = match field.docstring { @@ -260,23 +262,27 @@ fn build_field_clear_fn(cx: &ExtCtxt, path: &Vec, if field.count.node == 1 { let shift = utils::shift(cx, None, field); - quote_method!(cx, - $doc_attr - pub fn $fn_name<'b>(&'b mut self) -> &'b mut $setter_ty<'a> { - self.value |= $mask << $shift; - self.mask |= $mask << $shift; - self + utils::unwrap_impl_item(quote_item!(cx, + impl<'a> $setter_ty<'a> { + $doc_attr + pub fn $fn_name<'b>(&'b mut self) -> &'b mut $setter_ty<'a> { + self.value |= $mask << $shift; + self.mask |= $mask << $shift; + self + } } - ) + ).unwrap()) } else { let shift = utils::shift(cx, Some(quote_expr!(cx, idx)), field); - quote_method!(cx, - $doc_attr - pub fn $fn_name<'b>(&'b mut self, idx: usize) -> &'b mut $setter_ty<'a> { - self.value |= $mask << $shift; - self.mask |= $mask << $shift; - self + utils::unwrap_impl_item(quote_item!(cx, + impl<'a> $setter_ty<'a> { + $doc_attr + pub fn $fn_name<'b>(&'b mut self, idx: usize) -> &'b mut $setter_ty<'a> { + self.value |= $mask << $shift; + self.mask |= $mask << $shift; + self + } } - ) + ).unwrap()) } } diff --git a/src/ioreg/builder/union.rs b/ioreg/src/builder/union.rs similarity index 85% rename from src/ioreg/builder/union.rs rename to ioreg/src/builder/union.rs index a19df6f1..5a2f6851 100644 --- a/src/ioreg/builder/union.rs +++ b/ioreg/src/builder/union.rs @@ -87,7 +87,7 @@ impl<'a> BuildUnionTypes<'a> { } fn expr_u64(cx: &ExtCtxt, n: u64) -> P { - cx.expr_lit(DUMMY_SP, ast::LitInt(n as u64, ast::UnsignedIntLit(ast::TyUs(false)))) + cx.expr_lit(DUMMY_SP, ast::LitInt(n as u64, ast::UnsignedIntLit(ast::TyUs))) } /// Returns the type of the field representing the given register @@ -128,7 +128,7 @@ impl<'a> BuildUnionTypes<'a> { dummy_spanned( ast::StructField_ { kind: ast::NamedField( - self.cx.ident_of(reg.name.node.as_slice()), + self.cx.ident_of(reg.name.node.as_str()), ast::Public), id: ast::DUMMY_NODE_ID, ty: reg_struct_type(self.cx, &field_path, reg), @@ -154,7 +154,7 @@ impl<'a> BuildUnionTypes<'a> { dummy_spanned( ast::StructField_ { kind: ast::NamedField( - self.cx.ident_of(format!("_pad{}", index).as_slice()), + self.cx.ident_of(format!("_pad{}", index).as_str()), ast::Inherited), id: ast::DUMMY_NODE_ID, ty: ty, @@ -171,6 +171,7 @@ impl<'a> BuildUnionTypes<'a> { let name = utils::path_ident(self.cx, path); // Registers are already sorted by parser let mut regs = regs.clone(); + let mut regs2 = regs.clone(); let padded_regs = PaddedRegsIterator::new(&mut regs); let fields = padded_regs.enumerate().map(|(n,r)| self.build_pad_or_reg(path, r, n)); @@ -198,7 +199,33 @@ impl<'a> BuildUnionTypes<'a> { vis: ast::Public, span: reg.name.span, }); + let mut full_size: u64 = 0; + //FIXME(mcoffin) - We're making this iterator twice + let padded_regs2 = PaddedRegsIterator::new(&mut regs2); + padded_regs2.enumerate().map(|(_, rp)| { + full_size += match rp { + RegOrPadding::Reg(reg) => reg.ty.size(), + RegOrPadding::Pad(s) => s, + }; + }).count(); + let clone_impl = quote_item!(self.cx, + impl ::core::clone::Clone for $name { + fn clone(&self) -> Self { + let mut next: $name = unsafe { + ::core::mem::uninitialized() + }; + unsafe { + let next_ptr: *mut $name = &mut next; + ::core::intrinsics::copy( + ::core::mem::transmute(self), + next_ptr, + $full_size as usize); + return next; + } + } + } + ).unwrap(); let copy_impl = quote_item!(self.cx, impl ::core::marker::Copy for $name {}).unwrap(); - vec!(struct_item, copy_impl) + vec!(struct_item, clone_impl, copy_impl) } } diff --git a/src/ioreg/builder/utils.rs b/ioreg/src/builder/utils.rs similarity index 91% rename from src/ioreg/builder/utils.rs rename to ioreg/src/builder/utils.rs index d01483bb..a7ef798e 100644 --- a/src/ioreg/builder/utils.rs +++ b/ioreg/src/builder/utils.rs @@ -33,7 +33,7 @@ pub fn expr_int(cx: &ExtCtxt, n: i64) -> P { /// The name of the structure representing a register pub fn path_ident(cx: &ExtCtxt, path: &Vec) -> ast::Ident { - cx.ident_of(path.clone().connect("_").as_slice()) + cx.ident_of(path.clone().connect("_").as_str()) } @@ -97,17 +97,26 @@ pub fn field_type_path(cx: &ExtCtxt, path: &Vec, node::FieldType::EnumField { ref opt_name, ..} => { match opt_name { &Some(ref name) => - cx.path_ident(span, cx.ident_of(name.as_slice())), + cx.path_ident(span, cx.ident_of(name.as_str())), &None => { let mut name = path.clone(); name.push(field.name.node.clone()); - cx.path_ident(span, cx.ident_of(name.connect("_").as_slice())) + cx.path_ident(span, cx.ident_of(name.connect("_").as_str())) } } }, } } +pub fn unwrap_impl_item(item: P) -> P { + match item.node { + ast::ItemImpl(_, _, _, _, _, ref items) => { + items.clone().pop().expect("ImplItem not found") + }, + _ => panic!("Tried to unwrap ImplItem from Non-Impl") + } +} + /// Build an expression for the mask of a field pub fn mask(cx: &ExtCtxt, field: &node::Field) -> P { expr_int(cx, ((1 << field.width as u64) - 1)) @@ -142,5 +151,5 @@ pub fn getter_name(cx: &ExtCtxt, path: &Vec) -> ast::Ident { } pub fn intern_string(cx: &ExtCtxt, s: String) -> token::InternedString { - token::get_ident(cx.ident_of(s.as_slice())) + token::get_ident(cx.ident_of(s.as_str())) } diff --git a/src/ioreg/ioreg.rs b/ioreg/src/lib.rs similarity index 99% rename from src/ioreg/ioreg.rs rename to ioreg/src/lib.rs index 6bf1f51a..7f63425a 100644 --- a/src/ioreg/ioreg.rs +++ b/ioreg/src/lib.rs @@ -328,8 +328,7 @@ N => NAME */ #![feature(quote, plugin_registrar, rustc_private, collections, core)] -#![crate_name="ioreg"] -#![crate_type="dylib"] +#![feature(convert)] extern crate rustc; extern crate syntax; @@ -360,7 +359,7 @@ pub fn macro_ioregs(cx: &mut ExtCtxt, _: Span, tts: &[ast::TokenTree]) MacItems::new(items) }, None => { - panic!(); + panic!("Parsing failed"); } } } diff --git a/src/ioreg/node.rs b/ioreg/src/node.rs similarity index 100% rename from src/ioreg/node.rs rename to ioreg/src/node.rs diff --git a/src/ioreg/parser.rs b/ioreg/src/parser.rs similarity index 97% rename from src/ioreg/parser.rs rename to ioreg/src/parser.rs index f6c5aeef..edd39b31 100644 --- a/src/ioreg/parser.rs +++ b/ioreg/src/parser.rs @@ -143,11 +143,11 @@ impl<'a> Parser<'a> { self.sess.span_diagnostic.span_err( r1.name.span, format!("The byte range of register ({} to {})", - r1.offset, r1.last_byte()).as_slice()); + r1.offset, r1.last_byte()).as_str()); self.sess.span_diagnostic.span_err( r2.name.span, format!("overlaps with the range of this register ({} to {})", - r2.offset, r2.last_byte()).as_slice()); + r2.offset, r2.last_byte()).as_str()); failed = true; } } @@ -216,10 +216,10 @@ impl<'a> Parser<'a> { for (f1,f2) in fields.iter().zip(fields.iter().skip(1)) { if f2.low_bit <= f1.high_bit() { self.sess.span_diagnostic.span_err( - f1.bit_range_span, "The bit range of this field,".as_slice()); + f1.bit_range_span, "The bit range of this field,"); self.sess.span_diagnostic.span_err( f2.bit_range_span, - "overlaps with the bit range of this field".as_slice()); + "overlaps with the bit range of this field"); return None; } } @@ -230,7 +230,7 @@ impl<'a> Parser<'a> { self.sess.span_diagnostic.span_err( name.span, format!("Width of fields ({} bits) exceeds access size of register ({} bits)", - last_bit+1, 8*width.size()).as_slice()); + last_bit+1, 8*width.size()).as_str()); return None; }, _ => {} @@ -345,7 +345,7 @@ impl<'a> Parser<'a> { self.sess.span_diagnostic.span_err( mk_sp(bits_span.lo, self.last_span.hi), format!("Bit width ({}) not divisible by count ({})", - w, count.node).as_slice()); + w, count.node).as_str()); return None; } }, @@ -506,7 +506,7 @@ impl<'a> Parser<'a> { } } let string = docs.connect("\n"); - let string = string.as_slice().trim(); + let string = string.as_str().trim(); if !string.is_empty() { Some(respan(self.last_span, self.cx.ident_of(string))) } else { @@ -568,7 +568,7 @@ impl<'a> Parser<'a> { } fn error(&self, m: String) { - self.sess.span_diagnostic.span_err(self.span, m.as_slice()); + self.sess.span_diagnostic.span_err(self.span, m.as_str()); } /// Bumps a token. diff --git a/ioreg/tests/test.rs b/ioreg/tests/test.rs new file mode 100644 index 00000000..b5d482e4 --- /dev/null +++ b/ioreg/tests/test.rs @@ -0,0 +1,284 @@ +// Zinc, the bare metal stack for rust. +// Copyright 2014 Ben Gamari +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! Tests for ioreg! syntax extension + +#![feature(core, plugin)] +#![plugin(ioreg)] + +extern crate core; + +#[path="../../src/util/volatile_cell.rs"] mod volatile_cell; + +#[cfg(test)] +mod test { + use std::mem::{transmute, zeroed}; + use volatile_cell::VolatileCell; + + fn get_value<'a, T>(v: &'a T, offset: usize) -> u32 { + unsafe { + let ptr: *const u32 = transmute(v); + *(ptr.offset(offset as isize)) + } + } + + fn zeroed_safe() -> T { + unsafe { + return zeroed(); + } + } + + ioregs!(BASIC_TEST = { + 0x0 => reg32 reg1 { + 0 => field1, + 1..3 => field2, + 16..24 => field3, + 25 => field4: set_to_clear, + } + 0x4 => reg32 reg2 { + 0 => field1, + } + 0x8 => reg32 wo_reg { + 0..15 => field1: wo, + 16..31 => field2: wo, + } + }); + + #[test] + fn round_trip_simple_field_values_1() { + let test: BASIC_TEST = zeroed_safe(); + + test.reg1.set_field1(true); + assert_eq!(test.reg1.field1(), true); + assert_eq!(get_value(&test, 0), 1); + assert_eq!(get_value(&test, 1), 0); + } + + #[test] + fn round_trip_simple_field_values_2() { + let test: BASIC_TEST = zeroed_safe(); + + test.reg1.set_field3(0xde); + assert_eq!(test.reg1.field3(), 0xde); + assert_eq!(get_value(&test, 0), 0xde<<16); + } + + #[test] + fn set_set_to_clear_fields() { + let test: BASIC_TEST = zeroed_safe(); + + test.reg1.clear_field4(); + assert_eq!(get_value(&test, 0), 1<<25); + } + + #[test] + fn no_read_writeonly_registers() { + let test: BASIC_TEST = zeroed_safe(); + + test.wo_reg.set_field1(0xdead); + assert_eq!(get_value(&test, 2), 0xdead); + test.wo_reg.set_field2(0xdead); + assert_eq!(get_value(&test, 2), 0xdead<<16); + } + + /* + describe!( + before_each { + let test: BASIC_TEST = zeroed_safe(); + } + + it "can round_trip simple field values 1" { + test.reg1.set_field1(true); + assert_eq!(test.reg1.field1(), true); + assert_eq!(get_value(&test, 0), 1); + assert_eq!(get_value(&test, 1), 0); + } + + it "can round trip simple field values 2" { + test.reg1.set_field3(0xde); + assert_eq!(test.reg1.field3(), 0xde); + assert_eq!(get_value(&test, 0), 0xde<<16); + } + + it "sets set_to_clear fields" { + test.reg1.clear_field4(); + assert_eq!(get_value(&test, 0), 1<<25); + } + + it "does not read from writeonly registers" { + test.wo_reg.set_field1(0xdead); + assert_eq!(get_value(&test, 2), 0xdead); + test.wo_reg.set_field2(0xdead); + assert_eq!(get_value(&test, 2), 0xdead<<16); + } + ); + */ + + ioregs!(GROUP_TEST = { + 0x0 => group regs[5] { + 0x0 => reg32 reg1 { + 0..31 => field1 + } + 0x4 => reg32 reg2 { + 0..31 => field2 + } + } + }); + + #[test] + fn sets_groups_correctly() { + let test: GROUP_TEST = zeroed_safe(); + test.regs[0].reg1.set_field1(0xdeadbeef); + assert_eq!(test.regs[0].reg1.field1(), 0xdeadbeef); + assert_eq!(get_value(&test, 0), 0xdeadbeef); + for i in 1..10 { + assert_eq!(get_value(&test, i), 0); + } + + test.regs[2].reg2.set_field2(0xfeedbeef); + assert_eq!(test.regs[2].reg2.field2(), 0xfeedbeef); + assert_eq!(get_value(&test, 5), 0xfeedbeef); + } + + /* + describe!( + before_each { + let test: GROUP_TEST = zeroed_safe(); + } + + it "sets groups correctly" { + test.regs[0].reg1.set_field1(0xdeadbeef); + assert_eq!(test.regs[0].reg1.field1(), 0xdeadbeef); + assert_eq!(get_value(&test, 0), 0xdeadbeef); + for i in range(1, 10) { + assert_eq!(get_value(&test, i), 0); + } + + test.regs[2].reg2.set_field2(0xfeedbeef); + assert_eq!(test.regs[2].reg2.field2(), 0xfeedbeef); + assert_eq!(get_value(&test, 5), 0xfeedbeef); + } + ); + */ + + ioregs!(FIELD_ARRAY_TEST = { + 0x0 => reg32 reg1 { + 0..31 => field[16] + } + }); + + #[test] + fn sets_field_arrays_correctly() { + let test: FIELD_ARRAY_TEST = zeroed_safe(); + test.reg1.set_field(0, 1); + assert_eq!(test.reg1.field(0), 1); + assert_eq!(get_value(&test, 0), 0x1); + + test.reg1.set_field(4, 3); + assert_eq!(test.reg1.field(4), 3); + assert_eq!(get_value(&test, 0), 0x1 | 0x3<<8); + } + + /* + describe!( + before_each { + let test: FIELD_ARRAY_TEST = zeroed_safe(); + } + + it "sets field arrays correctly" { + test.reg1.set_field(0, 1); + assert_eq!(test.reg1.field(0), 1); + assert_eq!(get_value(&test, 0), 0x1); + + test.reg1.set_field(4, 3); + assert_eq!(test.reg1.field(4), 3); + assert_eq!(get_value(&test, 0), 0x1 | 0x3<<8); + } + ); + */ + + ioregs!(GAP_TEST = { + 0x0 => reg32 reg1 { + 0..31 => field, + } + 0x10 => reg32 reg2 { + 0..31 => field, + } + 0x14 => reg32 reg3 { + 0..31 => field, + } + 0x20 => reg32 reg4 { + 0..31 => field, + } + }); + + #[test] + fn has_zero_base_offset() { + let test: GAP_TEST = zeroed_safe(); + let base = &test as *const GAP_TEST; + let addr = &test.reg1 as *const GAP_TEST_reg1; + assert_eq!(addr as usize - base as usize, 0x0); + } + + #[test] + fn computes_first_gap() { + let test: GAP_TEST = zeroed_safe(); + let base = &test as *const GAP_TEST; + let addr = &test.reg2 as *const GAP_TEST_reg2; + assert_eq!(addr as usize - base as usize, 0x10); + } + + #[test] + fn computes_second_gap() { + let test: GAP_TEST = zeroed_safe(); + let base = &test as *const GAP_TEST; + let addr = &test.reg4 as *const GAP_TEST_reg4; + assert_eq!(addr as usize - base as usize, 0x20); + } + + /* + describe!( + before_each { + let test: GAP_TEST = zeroed_safe(); + let base = &test as *const GAP_TEST; + } + it "has zero base offset" { + let addr = &test.reg1 as *const GAP_TEST_reg1; + assert_eq!(addr as usize - base as usize, 0x0); + } + it "computes the correct first gap" { + let addr = &test.reg2 as *const GAP_TEST_reg2; + assert_eq!(addr as usize - base as usize, 0x10); + } + it "computes the correct second gap" { + let addr = &test.reg4 as *const GAP_TEST_reg4; + assert_eq!(addr as usize - base as usize, 0x20); + } + ); + */ + + ioregs!(MULTI_TEST = { + 0x100 => reg32 reg1[8] { + 0..31 => field[32], + } + }); + + #[test] + fn multi_ok() { + let test: MULTI_TEST = zeroed_safe(); + test.reg1[0].set_field(0, true); + assert_eq!(test.reg1[0].field(0), true); + } +} diff --git a/macro_platformtree/Cargo.toml b/macro_platformtree/Cargo.toml new file mode 100644 index 00000000..e1a8d5b6 --- /dev/null +++ b/macro_platformtree/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "macro_platformtree" +version = "0.1.0" +authors = ["Zinc Developers "] + +[lib] +name = "macro_platformtree" +plugin = true + +[dependencies.platformtree] +path = "../platformtree" diff --git a/src/macro/platformtree.rs b/macro_platformtree/src/lib.rs similarity index 87% rename from src/macro/platformtree.rs rename to macro_platformtree/src/lib.rs index 0339bc4c..3493ef5f 100644 --- a/src/macro/platformtree.rs +++ b/macro_platformtree/src/lib.rs @@ -13,10 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(core, rustc_private, plugin_registrar, quote)] -#![crate_name="macro_platformtree"] -#![crate_type="dylib"] - +#![feature(rustc_private, plugin_registrar, quote, convert)] extern crate platformtree; extern crate rustc; @@ -53,7 +50,7 @@ pub fn macro_platformtree(cx: &mut ExtCtxt, _: Span, tts: &[ast::TokenTree]) -> Box { let pt = Parser::new(cx, tts).parse_platformtree(); let items = Builder::build(cx, pt.unwrap()) - .expect(format!("Unexpected failure on {}", line!()).as_slice()) + .expect(format!("Unexpected failure on {}", line!()).as_str()) .emit_items(cx); MacItems::new(items) } @@ -72,7 +69,7 @@ pub fn macro_platformtree_verbose(cx: &mut ExtCtxt, sp: Span, fn macro_zinc_task(cx: &mut ExtCtxt, _: Span, _: &ast::MetaItem, it: P) -> P { match it.node { - ast::ItemFn(ref decl, style, abi, _, ref block) => { + ast::ItemFn(ref decl, style, constness, abi, _, ref block) => { let istr = syntax::parse::token::get_ident(it.ident); let fn_name = &*istr; let ty_params = platformtree::builder::meta_args::get_ty_params_for_task(cx, fn_name); @@ -80,9 +77,9 @@ fn macro_zinc_task(cx: &mut ExtCtxt, _: Span, _: &ast::MetaItem, let params = ty_params.iter().map(|ty| { cx.typaram( DUMMY_SP, - cx.ident_of(ty.to_tyhash().as_slice()), + cx.ident_of(ty.to_tyhash().as_str()), OwnedSlice::from_vec(vec!(cx.typarambound( - cx.path(DUMMY_SP, ty.as_slice().split("::").map(|t| cx.ident_of(t)).collect())))), + cx.path(DUMMY_SP, ty.as_str().split("::").map(|t| cx.ident_of(t)).collect())))), None) }).collect(); @@ -92,10 +89,10 @@ fn macro_zinc_task(cx: &mut ExtCtxt, _: Span, _: &ast::MetaItem, cx.path_all( DUMMY_SP, false, - ["pt".to_string(), fn_name.to_string() + "_args"].iter().map(|t| cx.ident_of(t.as_slice())).collect(), + ["pt".to_string(), fn_name.to_string() + "_args"].iter().map(|t| cx.ident_of(t.as_str())).collect(), vec!(), ty_params.iter().map(|ty| { - cx.ty_path(cx.path_ident(DUMMY_SP, cx.ident_of(ty.to_tyhash().as_slice()))) + cx.ty_path(cx.path_ident(DUMMY_SP, cx.ident_of(ty.to_tyhash().as_str()))) }).collect(), vec!())), None, @@ -113,7 +110,7 @@ fn macro_zinc_task(cx: &mut ExtCtxt, _: Span, _: &ast::MetaItem, predicates: vec!(), } }; - let new_node = ast::ItemFn(new_decl, style, abi, new_generics, block.clone()); + let new_node = ast::ItemFn(new_decl, style, constness, abi, new_generics, block.clone()); P(ast::Item {node: new_node, ..it.deref().clone() }) }, diff --git a/platforms.yml b/platforms.yml deleted file mode 100644 index 92ad4bcc..00000000 --- a/platforms.yml +++ /dev/null @@ -1,12 +0,0 @@ -lpc17xx: - arch: cortex_m3 - features: - - mcu_has_spi -stm32f4: - arch: cortex_m4 -stm32l1: - arch: cortex_m3 -k20: - arch: cortex_m4 -tiva_c: - arch: cortex_m4 diff --git a/platformtree/Cargo.toml b/platformtree/Cargo.toml new file mode 100644 index 00000000..169e8009 --- /dev/null +++ b/platformtree/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "platformtree" +version = "0.1.0" +authors = ["Zinc Developers "] + +[lib] +name = "platformtree" +plugin = true + +[dev-dependencies.hamcrest] +git = "https://github.com/carllerche/hamcrest-rust.git" diff --git a/src/platformtree/builder/mcu.rs b/platformtree/src/builder/mcu.rs similarity index 93% rename from src/platformtree/builder/mcu.rs rename to platformtree/src/builder/mcu.rs index c44e923d..62c0b85a 100644 --- a/src/platformtree/builder/mcu.rs +++ b/platformtree/src/builder/mcu.rs @@ -25,7 +25,7 @@ use super::Builder; pub fn attach(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { match node.name { Some(ref name) => { - match name.as_slice() { + match name.as_str() { "lpc17xx" => lpc17xx_pt::attach(builder, cx, node.clone()), // "tiva_c" => tiva_c_pt::attach(builder, cx, node.clone()), _ => node.materializer.set(Some(fail_build_mcu as fn(&mut Builder, &mut ExtCtxt, Rc))), @@ -38,7 +38,7 @@ pub fn attach(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { pub fn fail_build_mcu(_: &mut Builder, cx: &mut ExtCtxt, node: Rc) { match node.name { Some(ref name) => cx.parse_sess().span_diagnostic.span_err( - node.name_span, format!("unknown mcu `{}`", name).as_slice()), + node.name_span, format!("unknown mcu `{}`", name).as_str()), None => cx.parse_sess().span_diagnostic.span_err( node.name_span, "`mcu` node must have a name"), } diff --git a/src/platformtree/builder/meta_args.rs b/platformtree/src/builder/meta_args.rs similarity index 96% rename from src/platformtree/builder/meta_args.rs rename to platformtree/src/builder/meta_args.rs index 8dec5ce8..13332075 100644 --- a/src/platformtree/builder/meta_args.rs +++ b/platformtree/src/builder/meta_args.rs @@ -41,7 +41,7 @@ impl ToTyHash for String { /// args: a vector of type parameters pub fn set_ty_params_for_task(cx: &mut ExtCtxt, task: &str, args: Vec) { let ty_params = args.iter().map(|arg| { - cx.meta_word(DUMMY_SP, intern_and_get_ident(arg.as_slice())) + cx.meta_word(DUMMY_SP, intern_and_get_ident(arg.as_str())) }).collect(); let newmi = cx.meta_list(DUMMY_SP, intern_and_get_ident(task), ty_params); @@ -112,7 +112,7 @@ fn get_task(tasks: &Vec>, task: &str) -> Vec { // fn get_task(cx: &ExtCtxt, task: &str) -> Option { // get_args(cx).and_then(|args| { // for a in args.iter() { -// if a.task_name.as_slice() == task { +// if a.task_name.as_str() == task { // return Some(a.clone()); // } // } @@ -154,6 +154,6 @@ fn get_task(tasks: &Vec>, task: &str) -> Vec { // extra_ty_params: args, // }; // let enc = json::encode(&ma); -// let istr = intern_and_get_ident(enc.as_slice()); +// let istr = intern_and_get_ident(enc.as_str()); // box(GC) respan(DUMMY_SP, ast::MetaWord(istr)) // } diff --git a/src/platformtree/builder/mod.rs b/platformtree/src/builder/mod.rs similarity index 93% rename from src/platformtree/builder/mod.rs rename to platformtree/src/builder/mod.rs index 8f7ecc2b..fc1d7cc3 100644 --- a/src/platformtree/builder/mod.rs +++ b/platformtree/src/builder/mod.rs @@ -170,7 +170,19 @@ impl Builder { InternedString::new("allow"), vec!(unused_variables)); let allow_noncamel = cx.attribute(DUMMY_SP, allow); - self.item_fn(cx, DUMMY_SP, "main", &[allow_noncamel], body) + self.item_fn(cx, DUMMY_SP, "platformtree_main", &[allow_noncamel], body) + } + + fn emit_start(&self, cx: &ExtCtxt) -> P { + quote_item!(cx, + #[start] + fn start(_: isize, _: *const *const u8) -> isize { + unsafe { + platformtree_main(); + } + 0 + } + ).unwrap() } fn emit_morestack(&self, cx: &ExtCtxt) -> P { @@ -195,9 +207,9 @@ impl Builder { vec!(allow_noncamel), self.type_items.clone()); if self.type_items.len() > 1 { - vec!(pt_mod_item, self.emit_main(cx), self.emit_morestack(cx)) + vec!(pt_mod_item, self.emit_main(cx), self.emit_start(cx), self.emit_morestack(cx)) } else { - vec!(self.emit_main(cx), self.emit_morestack(cx)) + vec!(self.emit_main(cx), self.emit_start(cx), self.emit_morestack(cx)) } } @@ -216,6 +228,7 @@ impl Builder { node: ast::ItemFn( cx.fn_decl(Vec::new(), cx.ty(DUMMY_SP, ast::Ty_::TyTup(Vec::new()))), ast::Unsafety::Unsafe, + ast::Constness::NotConst, abi::Rust, // TODO(farcaller): should this be abi::C? empty_generics(), body), diff --git a/src/platformtree/builder/os.rs b/platformtree/src/builder/os.rs similarity index 92% rename from src/platformtree/builder/os.rs rename to platformtree/src/builder/os.rs index c6431078..ae0d776d 100644 --- a/src/platformtree/builder/os.rs +++ b/platformtree/src/builder/os.rs @@ -45,7 +45,7 @@ pub fn attach(builder: &mut Builder, _: &mut ExtCtxt, node: Rc) { for (_, ref attr) in args_node.attributes.borrow().iter() { match attr.value { node::RefValue(ref refname) => { - let refnode = builder.pt.get_by_name(refname.as_slice()).unwrap(); + let refnode = builder.pt.get_by_name(refname.as_str()).unwrap(); add_node_dependency(&task_node, &refnode); }, _ => (), @@ -79,9 +79,9 @@ fn build_single_task(builder: &mut Builder, cx: &mut ExtCtxt, let call_expr = cx.expr_call_ident( node.get_attr("loop").value_span, - cx.ident_of(loop_fn.as_slice()), + cx.ident_of(loop_fn.as_str()), args); - let loop_stmt = quote_stmt!(&*cx, loop { $call_expr; } ); + let loop_stmt = quote_stmt!(&*cx, loop { $call_expr; } ).unwrap(); builder.add_main_statement(loop_stmt); }, None => (), @@ -102,7 +102,7 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt, all_keys.sort(); for k in all_keys.iter() { - let v = &(*node_attr)[*k]; + let v = &(*node_attr)[k]; let (ty, val) = match v.value { node::IntValue(i) => @@ -113,7 +113,7 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt, quote_expr!(&*cx, $b)), node::StrValue(ref string) => { let static_lifetime = cx.lifetime(DUMMY_SP, intern("'static")); - let val_slice = string.as_slice(); + let val_slice = string.as_str(); (cx.ty_rptr( DUMMY_SP, cx.ty_ident(DUMMY_SP, cx.ident_of("str")), @@ -121,11 +121,11 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt, ast::MutImmutable), quote_expr!(&*cx, $val_slice)) }, node::RefValue(ref rname) => { - let refnode = builder.pt.get_by_name(rname.as_slice()).unwrap(); + let refnode = builder.pt.get_by_name(rname.as_str()).unwrap(); let reftype = refnode.type_name().unwrap(); let refparams = refnode.type_params(); for param in refparams.iter() { - if !param.as_slice().starts_with("'") { + if !param.as_str().starts_with("'") { ty_params.insert(param.clone()); } } @@ -133,12 +133,12 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt, let a_lifetime = cx.lifetime(DUMMY_SP, intern("'a")); (cx.ty_rptr( DUMMY_SP, - cx.ty_path(type_name_as_path(cx, reftype.as_slice(), refparams)), + cx.ty_path(type_name_as_path(cx, reftype.as_str(), refparams)), Some(a_lifetime), ast::MutImmutable), quote_expr!(&*cx, &$val_slice)) }, }; - let name_ident = cx.ident_of(k.as_slice()); + let name_ident = cx.ident_of(k.as_str()); let sf = ast::StructField_ { kind: ast::NamedField(name_ident, ast::Public), id: ast::DUMMY_NODE_ID, @@ -150,13 +150,13 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt, expr_fields.push(cx.field_imm(DUMMY_SP, name_ident, val)); } - let name_ident = cx.ident_of(format!("{}_args", struct_name).as_slice()); + let name_ident = cx.ident_of(format!("{}_args", struct_name).as_str()); let mut collected_params = vec!(); let mut ty_params_vec = vec!(); for ty in ty_params.iter() { let typaram = cx.typaram( DUMMY_SP, - cx.ident_of(ty.to_tyhash().as_slice()), + cx.ident_of(ty.to_tyhash().as_str()), OwnedSlice::from_vec(vec!( ast::RegionTyParamBound(cx.lifetime(DUMMY_SP, intern("'a"))) )), @@ -165,7 +165,7 @@ fn build_args(builder: &mut Builder, cx: &mut ExtCtxt, ty_params_vec.push(ty.clone()); } - set_ty_params_for_task(cx, struct_name.as_slice(), ty_params_vec); + set_ty_params_for_task(cx, struct_name.as_str(), ty_params_vec); let struct_item = P(ast::Item { ident: name_ident, attrs: vec!(), @@ -197,12 +197,12 @@ fn type_name_as_path(cx: &ExtCtxt, ty: &str, params: Vec) -> ast::Path { let mut lifetimes = vec!(); let mut types = vec!(); for p in params.iter() { - let slice = p.as_slice(); + let slice = p.as_str(); if slice.starts_with("'") { let lifetime = cx.lifetime(DUMMY_SP, intern(slice)); lifetimes.push(lifetime); } else { - let path = cx.ty_path(type_name_as_path(cx, p.to_tyhash().as_slice(), vec!())); + let path = cx.ty_path(type_name_as_path(cx, p.to_tyhash().as_str(), vec!())); types.push(path); } } diff --git a/src/platformtree/platformtree.rs b/platformtree/src/lib.rs similarity index 79% rename from src/platformtree/platformtree.rs rename to platformtree/src/lib.rs index dea21080..4c5b525d 100644 --- a/src/platformtree/platformtree.rs +++ b/platformtree/src/lib.rs @@ -15,10 +15,7 @@ //! Platform tree operations crate -#![feature(quote, rustc_private, collections, core, alloc, unicode, hash)] - -#![crate_name="platformtree"] -#![crate_type="rlib"] +#![feature(quote, rustc_private, collections, alloc, hash, convert)] // extern crate regex; extern crate syntax; @@ -28,9 +25,9 @@ pub mod builder; pub mod node; pub mod parser; -#[path="../zinc/hal/lpc17xx/platformtree.rs"] mod lpc17xx_pt; +#[path="../../src/hal/lpc17xx/platformtree.rs"] mod lpc17xx_pt; // #[path="../zinc/hal/tiva_c/platformtree.rs"] mod tiva_c_pt; -#[path="../zinc/drivers/drivers_pt.rs"] mod drivers_pt; +#[path="../../src/drivers/drivers_pt.rs"] mod drivers_pt; #[cfg(test)] mod test_helpers; #[cfg(test)] mod parser_test; diff --git a/src/platformtree/node.rs b/platformtree/src/node.rs similarity index 96% rename from src/platformtree/node.rs rename to platformtree/src/node.rs index d81a0edb..3845c9e6 100644 --- a/src/platformtree/node.rs +++ b/platformtree/src/node.rs @@ -41,7 +41,7 @@ pub enum AttributeValue { /// /// Used in Node::expect_attributes to provide the expected type of the /// attribute. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum AttributeType { IntAttribute, BoolAttribute, @@ -264,12 +264,12 @@ impl Node { Some(ref parent) => parent.clone().upgrade().unwrap().full_path() + "::", None => "".to_string(), }; - pp + self.path.as_slice() + pp + self.path.as_str() } /// Returns attribute by name or panic!()s. pub fn get_attr(&self, key: &str) -> Rc { - let ref attr = (*self.attributes.borrow())[key.to_string()]; + let ref attr = (*self.attributes.borrow())[&key.to_string()]; attr.clone() } @@ -319,7 +319,7 @@ impl Node { None => { cx.parse_sess().span_diagnostic.span_err(self.name_span, format!("required string attribute `{}` is missing", key) - .as_slice()); + .as_str()); None } } @@ -335,7 +335,7 @@ impl Node { None => { cx.parse_sess().span_diagnostic.span_err(self.name_span, format!("required integer attribute `{}` is missing", key) - .as_slice()); + .as_str()); None } } @@ -351,7 +351,7 @@ impl Node { None => { cx.parse_sess().span_diagnostic.span_err(self.name_span, format!("required boolean attribute `{}` is missing", key) - .as_slice()); + .as_str()); None } } @@ -367,7 +367,7 @@ impl Node { None => { cx.parse_sess().span_diagnostic.span_err(self.name_span, format!("required ref attribute `{}` is missing", key) - .as_slice()); + .as_str()); None } } @@ -426,11 +426,11 @@ impl Node { pub fn expect_subnodes(&self, cx: &ExtCtxt, expectations: &[&str]) -> bool { let mut ok = true; for sub in self.subnodes().iter() { - if !expectations.contains(&sub.path.as_slice()) { + if !expectations.contains(&sub.path.as_str()) { ok = false; cx.parse_sess().span_diagnostic.span_err(sub.path_span, format!("unknown subnode `{}` in node `{}`", - sub.path, self.path).as_slice()); + sub.path, self.path).as_str()); } } ok @@ -456,7 +456,7 @@ impl PartialEq for Node { impl fmt::Display for Node { fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> { - fmt.write_str(format!("", self.full_path()).as_slice()) + fmt.write_str(format!("", self.full_path()).as_str()) .or_else(|_| { panic!() }) } } @@ -505,10 +505,10 @@ impl PlatformTree { pub fn expect_subnodes(&self, cx: &ExtCtxt, expectations: &[&str]) -> bool { let mut ok = true; for (path, sub) in self.nodes.iter() { - if !expectations.contains(&path.as_slice()) { + if !expectations.contains(&path.as_str()) { ok = false; cx.parse_sess().span_diagnostic.span_err(sub.path_span, - format!("unknown root node `{}`", path).as_slice()); + format!("unknown root node `{}`", path).as_str()); } } ok diff --git a/src/platformtree/parser.rs b/platformtree/src/parser.rs similarity index 97% rename from src/platformtree/parser.rs rename to platformtree/src/parser.rs index 7e3df8f4..7cb359c3 100644 --- a/src/platformtree/parser.rs +++ b/platformtree/src/parser.rs @@ -78,8 +78,8 @@ impl<'a> Parser<'a> { if nodes.contains_key(&path) { failed = true; self.sess.span_diagnostic.span_err(node.path_span, - format!("duplicate node definition `{}`", path).as_slice()); - let old_node: &Rc = &nodes[path]; + format!("duplicate node definition `{}`", path).as_str()); + let old_node: &Rc = &nodes[&path]; self.sess.span_diagnostic.span_err(old_node.path_span, "previously defined here"); } else { @@ -118,10 +118,10 @@ impl<'a> Parser<'a> { Some(ref name) => { if map.contains_key(name) { self.sess.span_diagnostic.span_err(n.name_span, format!( - "duplicate `{}` definition", name).as_slice()); + "duplicate `{}` definition", name).as_str()); self.sess.span_diagnostic.span_warn( - (*map)[*name].upgrade().unwrap().name_span, + (*map)[name].upgrade().unwrap().name_span, "previously defined here"); return false; } else { @@ -318,7 +318,7 @@ impl<'a> Parser<'a> { self.span = node.path_span; self.error(format!("duplicate node definition `{}`", path)); - let old_node: Rc = subnodes.as_map()[path].upgrade().unwrap(); + let old_node: Rc = subnodes.as_map()[&path].upgrade().unwrap(); self.span = old_node.path_span.clone(); self.error("previously defined here".to_string()); return None; @@ -390,7 +390,7 @@ impl<'a> Parser<'a> { } fn error(&self, m: String) { - self.sess.span_diagnostic.span_err(self.span, m.as_slice()); + self.sess.span_diagnostic.span_err(self.span, m.as_str()); } /// Bumps a token. diff --git a/src/platformtree/parser_test.rs b/platformtree/src/parser_test.rs similarity index 100% rename from src/platformtree/parser_test.rs rename to platformtree/src/parser_test.rs diff --git a/src/platformtree/test_helpers.rs b/platformtree/src/test_helpers.rs similarity index 91% rename from src/platformtree/test_helpers.rs rename to platformtree/src/test_helpers.rs index 1366b0da..77e551e4 100644 --- a/src/platformtree/test_helpers.rs +++ b/platformtree/src/test_helpers.rs @@ -14,16 +14,17 @@ // limitations under the License. use std::rc::Rc; +use std::string::ToString; use syntax::ast; use syntax::codemap::MacroBang; use syntax::codemap::{CodeMap, Span, mk_sp, BytePos, ExpnInfo, NameAndSpan}; use syntax::codemap; -use syntax::diagnostic::mk_handler; -use syntax::diagnostic::{Emitter, RenderSpan, Level, mk_span_handler}; +use syntax::diagnostic::Handler; +use syntax::diagnostic::{Emitter, RenderSpan, Level, SpanHandler}; use syntax::ext::base::ExtCtxt; use syntax::ext::expand::ExpansionConfig; use syntax::ext::quote::rt::ExtParseUtils; -use syntax::parse::new_parse_sess_special_handler; +use syntax::parse::ParseSess; use syntax::print::pprust; use builder::Builder; @@ -68,13 +69,15 @@ pub fn with_parsed_tts(src: &str, block: F) let mut failed = false; let failptr = &mut failed as *mut bool; let ce = Box::new(CustomEmmiter::new(failptr)); - let sh = mk_span_handler(mk_handler(false, ce), CodeMap::new()); - let parse_sess = new_parse_sess_special_handler(sh); + let h = Handler::with_emitter(false, ce); + let sh = SpanHandler::new(h, CodeMap::new()); + let parse_sess = ParseSess::with_span_handler(sh); let cfg = Vec::new(); let ecfg = ExpansionConfig { crate_name: ("test").parse().unwrap(), features: None, recursion_limit: 10, + trace_mac: true, }; let mut cx = ExtCtxt::new(&parse_sess, cfg, ecfg); cx.bt_push(ExpnInfo { @@ -82,6 +85,7 @@ pub fn with_parsed_tts(src: &str, block: F) callee: NameAndSpan { name: "platformtree".to_string(), format: MacroBang, + allow_internal_unstable: true, span: None, }, }); diff --git a/src/zinc/drivers/bluenrg.rs b/src/drivers/bluenrg.rs similarity index 99% rename from src/zinc/drivers/bluenrg.rs rename to src/drivers/bluenrg.rs index cdba902d..d51b9c84 100644 --- a/src/zinc/drivers/bluenrg.rs +++ b/src/drivers/bluenrg.rs @@ -31,7 +31,7 @@ enum Control { /// Spi error codes. #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Error { /// Device is sleeping. Sleeping, diff --git a/src/zinc/drivers/chario.rs b/src/drivers/chario.rs similarity index 96% rename from src/zinc/drivers/chario.rs rename to src/drivers/chario.rs index 5ab4cfd3..0bfc3ca4 100644 --- a/src/zinc/drivers/chario.rs +++ b/src/drivers/chario.rs @@ -15,9 +15,8 @@ //! Generic char output trait. -use core::str::{Str, StrExt}; use core::slice::SliceExt; -use core::iter::range; +use core::convert::AsRef; use core::mem::zeroed; @@ -33,8 +32,8 @@ pub trait CharIO { /// Outputs a string. fn puts(&self, s: &str) { - let chars : &[u8] = s.as_slice().as_bytes(); - for i in range(0, s.len()) { + let chars : &[u8] = s.as_ref(); + for i in 0 .. chars.len() { let c : char = chars[i] as char; self.putc(c); } @@ -71,7 +70,7 @@ pub mod test { use drivers::chario::CharIO; - #[derive(Copy)] + #[derive(Clone, Copy)] pub struct TestCharIOData { last_char: char, putc_calls: usize, diff --git a/src/zinc/drivers/dht22.rs b/src/drivers/dht22.rs similarity index 96% rename from src/zinc/drivers/dht22.rs rename to src/drivers/dht22.rs index e8c93a41..02143909 100644 --- a/src/zinc/drivers/dht22.rs +++ b/src/drivers/dht22.rs @@ -15,7 +15,6 @@ //! Driver for DHT22. -use core::iter::range; use core::option::Option::{self, Some, None}; use hal::pin::Gpio; @@ -34,7 +33,7 @@ pub struct DHT22<'a, T:'a, P:'a> { /// Measurement data from the DHT22. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Measurements { pub humidity: f32, pub temperature: f32, @@ -66,7 +65,7 @@ impl<'a, T: Timer, P: Gpio> DHT22<'a, T, P> { return None } - for _ in range(0usize, 40) { + for _ in 0..40 { if !self.wait_while(Low, 80) { return None } @@ -117,7 +116,7 @@ impl<'a, T: Timer, P: Gpio> DHT22<'a, T, P> { } fn wait_while(&self, level: GpioLevel, timeout: usize) -> bool { - for _ in range(0, timeout / 10) { + for _ in 0..(timeout / 10) { self.timer.wait_us(10); if self.gpio.level() != level { return true; diff --git a/src/zinc/drivers/dht22_pt.rs b/src/drivers/dht22_pt.rs similarity index 95% rename from src/zinc/drivers/dht22_pt.rs rename to src/drivers/dht22_pt.rs index b08f769f..469449d1 100644 --- a/src/zinc/drivers/dht22_pt.rs +++ b/src/drivers/dht22_pt.rs @@ -24,17 +24,17 @@ pub fn attach(builder: &mut Builder, _: &mut ExtCtxt, node: Rc) { node.mutator.set(Some(mutate_pin as fn(&mut Builder, &mut ExtCtxt, Rc))); let pin_node_name = node.get_ref_attr("pin").unwrap(); - let pin_node = builder.pt().get_by_name(pin_node_name.as_slice()).unwrap(); + let pin_node = builder.pt().get_by_name(pin_node_name.as_str()).unwrap(); add_node_dependency(&node, &pin_node); let timer_node_name = node.get_ref_attr("timer").unwrap(); - let timer_node = builder.pt().get_by_name(timer_node_name.as_slice()).unwrap(); + let timer_node = builder.pt().get_by_name(timer_node_name.as_str()).unwrap(); add_node_dependency(&node, &timer_node); } fn mutate_pin(builder: &mut Builder, _: &mut ExtCtxt, node: Rc) { let pin_node_name = node.get_ref_attr("pin").unwrap(); - let pin_node = builder.pt().get_by_name(pin_node_name.as_slice()).unwrap(); + let pin_node = builder.pt().get_by_name(pin_node_name.as_str()).unwrap(); pin_node.attributes.borrow_mut().insert("direction".to_string(), Rc::new(node::Attribute::new_nosp(node::StrValue("out".to_string())))); } @@ -64,7 +64,7 @@ fn build_dht22(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { let st = quote_stmt!(&*cx, let $name = zinc::drivers::dht22::DHT22::new(&$timer, &$pin); - ); + ).unwrap(); builder.add_main_statement(st); } diff --git a/src/zinc/drivers/drivers_pt.rs b/src/drivers/drivers_pt.rs similarity index 97% rename from src/zinc/drivers/drivers_pt.rs rename to src/drivers/drivers_pt.rs index 85feb5f0..04014a9f 100644 --- a/src/zinc/drivers/drivers_pt.rs +++ b/src/drivers/drivers_pt.rs @@ -26,7 +26,7 @@ pub fn attach(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { for sub in node.subnodes().iter() { add_node_dependency(&node, sub); - match sub.path.as_slice() { + match sub.path.as_str() { "dht22" => dht22_pt::attach(builder, cx, sub.clone()), _ => (), } diff --git a/src/zinc/drivers/lcd/c12332.rs b/src/drivers/lcd/c12332.rs similarity index 98% rename from src/zinc/drivers/lcd/c12332.rs rename to src/drivers/lcd/c12332.rs index 4c56f414..2dbef6af 100644 --- a/src/zinc/drivers/lcd/c12332.rs +++ b/src/drivers/lcd/c12332.rs @@ -26,7 +26,6 @@ might be an issue for any other peripheral sharing the same SPI bus. use core::cell; use core::slice::SliceExt; use core::mem::zeroed; -use core::iter::range; use super::font_small_7; use super::LCD; @@ -164,8 +163,8 @@ impl<'a, S: Spi, T: Timer, P: Gpio> C12332<'a, S, T, P> { // zeichen = &self.font[]; // start of char bitmap let w = zeichen[0]; // width of actual char // construct the char into the buffer - for j in range(0, vert) { - for i in range(0, hor) { + for j in 0..vert { + for i in 0..hor { let z: u8 = zeichen[(bpl * i + ((j & 0xF8) >> 3)+1) as usize]; let b: u8 = 1 << ((j & 0x07) as usize); if ( z & b ) == 0x00 { @@ -229,7 +228,7 @@ impl<'a, S: Spi, T: Timer, P: Gpio> LCD for C12332<'a, S, T, P> { } fn clear(&self) { - for i in range(0usize, 512) { + for i in 0 .. 512 { self.videobuf[i].set(0); } } diff --git a/src/zinc/drivers/lcd/font_small_7.rs b/src/drivers/lcd/font_small_7.rs similarity index 100% rename from src/zinc/drivers/lcd/font_small_7.rs rename to src/drivers/lcd/font_small_7.rs diff --git a/src/zinc/drivers/lcd/hd44780u.rs b/src/drivers/lcd/hd44780u.rs similarity index 99% rename from src/zinc/drivers/lcd/hd44780u.rs rename to src/drivers/lcd/hd44780u.rs index 28af0920..9bf8144f 100644 --- a/src/zinc/drivers/lcd/hd44780u.rs +++ b/src/drivers/lcd/hd44780u.rs @@ -35,7 +35,7 @@ pub struct Hd44780u<'a> { /// The controller supports writing in either direction to accomodate various /// languages. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum MoveDir { /// Cursor moves right after write Right, @@ -44,7 +44,7 @@ pub enum MoveDir { } /// The controller supports 5x8 and 5x10 dot fonts depending on the LCD used. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Font { /// Use 5x8 dot matrix font Font5x8, diff --git a/src/zinc/drivers/lcd/ili9341.rs b/src/drivers/lcd/ili9341.rs similarity index 98% rename from src/zinc/drivers/lcd/ili9341.rs rename to src/drivers/lcd/ili9341.rs index 3bc55bcc..9ad4d0e8 100644 --- a/src/zinc/drivers/lcd/ili9341.rs +++ b/src/drivers/lcd/ili9341.rs @@ -15,8 +15,6 @@ //! Driver for the ILI9341 LCD. -use core::iter::range; - use super::LCD; use drivers::chario::CharIO; use hal::timer::Timer; @@ -83,7 +81,7 @@ impl<'a, S: Spi, T: Timer, P: Gpio> ILI9341<'a, S, T, P> { let mut data: [u8; 3] = [0, 0, 0]; let id: [u8; 3] = [0x00, 0x93, 0x41]; - for i in range(0, 3) { + for i in 0 .. 3 { data[i] = self.read_register(0xd3, (i+1) as u8); if data[i] != id[i] { return false; @@ -278,7 +276,7 @@ impl<'a, S: Spi, T: Timer, P: Gpio> ILI9341<'a, S, T, P> { self.dc.set_high(); self.cs.set_low(); - for _ in range(0usize, 38400) { + for _ in 0..38400 { self.spi.transfer(0); self.spi.transfer(0); self.spi.transfer(0); diff --git a/src/zinc/drivers/lcd/mod.rs b/src/drivers/lcd/mod.rs similarity index 95% rename from src/zinc/drivers/lcd/mod.rs rename to src/drivers/lcd/mod.rs index 3d437def..f6ea8b0a 100644 --- a/src/zinc/drivers/lcd/mod.rs +++ b/src/drivers/lcd/mod.rs @@ -15,7 +15,7 @@ //! Drivers for TFT LCDs. -use core::iter::{range, range_inclusive}; +use core::iter::range_inclusive; use drivers::chario::CharIO; @@ -43,9 +43,9 @@ pub trait LCD : CharIO { /// Draws a line from xy0 to xy1. fn line(&self, x0_b: u32, y0_b: u32, x1: u32, y1: u32, color: u16) { - let (mut x0, mut y0) = (x0_b, y0_b); + let (mut x0, mut y0) = (x0_b as i32, y0_b as i32); - let (dx, dy) = ((x1-x0) as i32, (y1-y0) as i32); + let (dx, dy) = ((x1 as i32) - (x0), (y1 as i32) - (y0)); let dx_sym: i32 = if dx > 0 { @@ -67,30 +67,30 @@ pub trait LCD : CharIO { if dx >= dy { let mut di = dy_x2 - dx; - while x0 != x1 { - self.pixel(x0, y0, color); - x0 += dx_sym as u32; + while x0 as u32 != x1 { + self.pixel(x0 as u32, y0 as u32, color); + x0 += dx_sym; if di < 0 { di += dy_x2; } else { di += dy_x2 - dx_x2; - y0 += dy_sym as u32; + y0 += dy_sym; } } - self.pixel(x0, y0, color); + self.pixel(x0 as u32, y0 as u32, color); } else { let mut di = dx_x2 - dy; - while y0 != y1 { - self.pixel(x0, y0, color); - y0 += dy_sym as u32; + while y0 as u32 != y1 { + self.pixel(x0 as u32, y0 as u32, color); + y0 += dy_sym; if di < 0 { di += dx_x2; } else { di += dx_x2 - dy_x2; - x0 += dx_sym as u32; + x0 += dx_sym; } } - self.pixel(x0, y0, color); + self.pixel(x0 as u32, y0 as u32, color); } } @@ -147,8 +147,8 @@ pub trait LCD : CharIO { /// Draws an image from a buffer. fn image(&self, width: u32, height: u32, data: &[u16]) { - for x in range(0, width) { - for y in range(0, height) { + for x in 0..width { + for y in 0..height { self.pixel(x, y, data[(x+y*width) as usize]); } } @@ -158,9 +158,9 @@ pub trait LCD : CharIO { #[cfg(test)] mod test { use core::mem::zeroed; - use core::iter::{Range, range}; use core::cell::Cell; use core::ops::Fn; + use core::ops::Range; use drivers::chario::CharIO; use drivers::lcd::LCD; @@ -196,7 +196,7 @@ mod test { fn coords(&self, x: usize, y: usize) -> (u32, u32) { (x as u32, y as u32) } - fn axis(&self) -> Range { range(0, 16) } + fn axis(&self) -> Range { 0..16 } fn for_each(&self, block: F) where F: Fn((u32, u32), u16) { for x in self.axis() { diff --git a/src/zinc/drivers/mod.rs b/src/drivers/mod.rs similarity index 100% rename from src/zinc/drivers/mod.rs rename to src/drivers/mod.rs diff --git a/src/zinc/hal/cortex_common/irq.rs b/src/hal/cortex_common/irq.rs similarity index 100% rename from src/zinc/hal/cortex_common/irq.rs rename to src/hal/cortex_common/irq.rs diff --git a/src/zinc/hal/cortex_common/mod.rs b/src/hal/cortex_common/mod.rs similarity index 100% rename from src/zinc/hal/cortex_common/mod.rs rename to src/hal/cortex_common/mod.rs diff --git a/src/zinc/hal/cortex_common/mpu.rs b/src/hal/cortex_common/mpu.rs similarity index 100% rename from src/zinc/hal/cortex_common/mpu.rs rename to src/hal/cortex_common/mpu.rs diff --git a/src/zinc/hal/cortex_common/nvic.rs b/src/hal/cortex_common/nvic.rs similarity index 100% rename from src/zinc/hal/cortex_common/nvic.rs rename to src/hal/cortex_common/nvic.rs diff --git a/src/zinc/hal/cortex_common/scb.rs b/src/hal/cortex_common/scb.rs similarity index 100% rename from src/zinc/hal/cortex_common/scb.rs rename to src/hal/cortex_common/scb.rs diff --git a/src/zinc/hal/cortex_common/systick.rs b/src/hal/cortex_common/systick.rs similarity index 100% rename from src/zinc/hal/cortex_common/systick.rs rename to src/hal/cortex_common/systick.rs diff --git a/src/zinc/hal/cortex_m0/lock.rs b/src/hal/cortex_m0/lock.rs similarity index 100% rename from src/zinc/hal/cortex_m0/lock.rs rename to src/hal/cortex_m0/lock.rs diff --git a/src/zinc/hal/cortex_m0/mod.rs b/src/hal/cortex_m0/mod.rs similarity index 100% rename from src/zinc/hal/cortex_m0/mod.rs rename to src/hal/cortex_m0/mod.rs diff --git a/src/zinc/hal/cortex_m3/isr.rs b/src/hal/cortex_m3/isr.rs similarity index 100% rename from src/zinc/hal/cortex_m3/isr.rs rename to src/hal/cortex_m3/isr.rs index df13ee46..c653b733 100644 --- a/src/zinc/hal/cortex_m3/isr.rs +++ b/src/hal/cortex_m3/isr.rs @@ -17,8 +17,8 @@ use core::option::Option; use core::option::Option::{Some, None}; extern { - fn __STACK_BASE(); fn main(); + fn __STACK_BASE(); fn isr_nmi(); fn isr_hardfault(); diff --git a/src/zinc/hal/cortex_m3/lock.rs b/src/hal/cortex_m3/lock.rs similarity index 100% rename from src/zinc/hal/cortex_m3/lock.rs rename to src/hal/cortex_m3/lock.rs diff --git a/src/zinc/hal/cortex_m3/mod.rs b/src/hal/cortex_m3/mod.rs similarity index 100% rename from src/zinc/hal/cortex_m3/mod.rs rename to src/hal/cortex_m3/mod.rs diff --git a/src/zinc/hal/cortex_m3/sched.S b/src/hal/cortex_m3/sched.S similarity index 100% rename from src/zinc/hal/cortex_m3/sched.S rename to src/hal/cortex_m3/sched.S diff --git a/src/zinc/hal/cortex_m3/sched.rs b/src/hal/cortex_m3/sched.rs similarity index 100% rename from src/zinc/hal/cortex_m3/sched.rs rename to src/hal/cortex_m3/sched.rs diff --git a/src/zinc/hal/cortex_m4/mod.rs b/src/hal/cortex_m4/mod.rs similarity index 100% rename from src/zinc/hal/cortex_m4/mod.rs rename to src/hal/cortex_m4/mod.rs diff --git a/src/zinc/hal/isr.rs b/src/hal/isr.rs similarity index 80% rename from src/zinc/hal/isr.rs rename to src/hal/isr.rs index c667b2fd..0864baa3 100644 --- a/src/zinc/hal/isr.rs +++ b/src/hal/isr.rs @@ -16,23 +16,15 @@ //! This file is not part of zinc crate, it is linked separately, alongside the //! ISRs for the platform. -#![feature(core, asm, lang_items, no_std)] -#![crate_name="isr"] -#![crate_type="staticlib"] -#![no_std] - -extern crate core; +#![allow(missing_docs)] #[path="cortex_m3/isr.rs"] pub mod isr_cortex_m3; -#[cfg(mcu_lpc17xx)] +#[cfg(feature = "lpc17xx")] #[path="lpc17xx/isr.rs"] pub mod isr_lpc17xx; -#[cfg(mcu_k20)] +#[cfg(feature = "k20")] #[path="k20/isr.rs"] pub mod isr_k20; -#[cfg(mcu_tiva_c)] +#[cfg(feature = "tiva_c")] #[path="tiva_c/isr.rs"] pub mod isr_tiva_c; - - -#[path="../util/lang_items.rs"] mod lang_items; diff --git a/src/zinc/hal/k20/iomem.ld b/src/hal/k20/iomem.ld similarity index 100% rename from src/zinc/hal/k20/iomem.ld rename to src/hal/k20/iomem.ld diff --git a/src/zinc/hal/k20/isr.rs b/src/hal/k20/isr.rs similarity index 99% rename from src/zinc/hal/k20/isr.rs rename to src/hal/k20/isr.rs index 77a45b92..03b1619d 100644 --- a/src/zinc/hal/k20/isr.rs +++ b/src/hal/k20/isr.rs @@ -14,6 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! ISR Data for k20 + use core::option::Option::{self, Some, None}; extern { diff --git a/src/zinc/hal/k20/layout.ld b/src/hal/k20/layout.ld similarity index 98% rename from src/zinc/hal/k20/layout.ld rename to src/hal/k20/layout.ld index 06a08726..611be181 100644 --- a/src/zinc/hal/k20/layout.ld +++ b/src/hal/k20/layout.ld @@ -3,7 +3,7 @@ __STACK_BASE = 0x20001FFF; _data_load = LOADADDR(.data); -INCLUDE ./src/zinc/hal/k20/iomem.ld +INCLUDE iomem.ld ENTRY(main) diff --git a/src/zinc/hal/k20/mod.rs b/src/hal/k20/mod.rs similarity index 100% rename from src/zinc/hal/k20/mod.rs rename to src/hal/k20/mod.rs diff --git a/src/zinc/hal/k20/pin.rs b/src/hal/k20/pin.rs similarity index 98% rename from src/zinc/hal/k20/pin.rs rename to src/hal/k20/pin.rs index d980e2ee..f8aa847e 100644 --- a/src/zinc/hal/k20/pin.rs +++ b/src/hal/k20/pin.rs @@ -33,7 +33,7 @@ use self::SlewRate::*; /// A pin. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Pin { pub port: Port, pub pin: u8, @@ -41,6 +41,7 @@ pub struct Pin { /// Available port names. #[allow(missing_docs)] +#[derive(Clone)] pub enum Port { PortA = 1, PortB = 2, @@ -52,7 +53,7 @@ pub enum Port { impl Copy for Port {} /// Pin functions (GPIO or up to seven additional functions). -#[derive(PartialEq)] +#[derive(PartialEq, Clone)] #[allow(missing_docs)] pub enum Function { Analog = 0, @@ -69,7 +70,7 @@ impl Copy for Function {} /// Pull-up/-down configuration. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum PullConf { PullNone = 0, PullUp = 1, @@ -78,7 +79,7 @@ pub enum PullConf { /// Pin output driver strength. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum DriveStrength { DriveStrengthHigh = 0, DriveStrengthLow = 1, @@ -86,7 +87,7 @@ pub enum DriveStrength { /// Pin output drive slew rate. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum SlewRate { SlewFast = 0, SlewSlow = 1, diff --git a/src/zinc/hal/k20/sim.rs b/src/hal/k20/sim.rs similarity index 100% rename from src/zinc/hal/k20/sim.rs rename to src/hal/k20/sim.rs diff --git a/src/zinc/hal/k20/uart.rs b/src/hal/k20/uart.rs similarity index 99% rename from src/zinc/hal/k20/uart.rs rename to src/hal/k20/uart.rs index a4b7f930..fffc2c6c 100644 --- a/src/zinc/hal/k20/uart.rs +++ b/src/hal/k20/uart.rs @@ -29,7 +29,7 @@ use self::UARTPeripheral::*; /// Available UART peripherals. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum UARTPeripheral { UART0, UART1, @@ -37,14 +37,14 @@ pub enum UARTPeripheral { } /// Structure describing a UART instance. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct UART { reg: &'static reg::UART, } /// Stop bits configuration. /// K20 UART only supports one stop bit. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum StopBit { /// Single stop bit. StopBit1bit = 0, diff --git a/src/zinc/hal/k20/watchdog.rs b/src/hal/k20/watchdog.rs similarity index 99% rename from src/zinc/hal/k20/watchdog.rs rename to src/hal/k20/watchdog.rs index 1b7c1d5f..146ae878 100644 --- a/src/zinc/hal/k20/watchdog.rs +++ b/src/hal/k20/watchdog.rs @@ -21,7 +21,7 @@ use util::support::nop; /// Watchdog state #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum State { Disabled, Enabled, diff --git a/src/zinc/hal/layout_common.ld b/src/hal/layout_common.ld similarity index 94% rename from src/zinc/hal/layout_common.ld rename to src/hal/layout_common.ld index b61258c7..75b8451d 100644 --- a/src/zinc/hal/layout_common.ld +++ b/src/hal/layout_common.ld @@ -1,3 +1,6 @@ +__aeabi_unwind_cpp_pr0 = abort; +__aeabi_unwind_cpp_pr1 = abort; + SECTIONS { .vector : ALIGN(4) diff --git a/src/zinc/hal/lpc17xx/iomem.ld b/src/hal/lpc17xx/iomem.ld similarity index 100% rename from src/zinc/hal/lpc17xx/iomem.ld rename to src/hal/lpc17xx/iomem.ld diff --git a/src/zinc/hal/lpc17xx/isr.rs b/src/hal/lpc17xx/isr.rs similarity index 99% rename from src/zinc/hal/lpc17xx/isr.rs rename to src/hal/lpc17xx/isr.rs index b3b1338b..011120d4 100644 --- a/src/zinc/hal/lpc17xx/isr.rs +++ b/src/hal/lpc17xx/isr.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! ISR Data for k20 + use core::option::Option::{self, Some}; extern { diff --git a/src/zinc/hal/lpc17xx/layout.ld b/src/hal/lpc17xx/layout.ld similarity index 79% rename from src/zinc/hal/lpc17xx/layout.ld rename to src/hal/lpc17xx/layout.ld index 10cf317a..d261dec2 100644 --- a/src/zinc/hal/lpc17xx/layout.ld +++ b/src/hal/lpc17xx/layout.ld @@ -1,11 +1,11 @@ __STACK_BASE = 0x10002000; +INCLUDE iomem.ld + isr_reserved_1 = 0 - (__STACK_BASE + main + 1 + isr_nmi + 1 + isr_hardfault + 1); _data_load = LOADADDR(.data); -INCLUDE ./src/zinc/hal/lpc17xx/iomem.ld - ENTRY(main) MEMORY @@ -16,4 +16,4 @@ MEMORY REGION_ALIAS("vectors", rom); -INCLUDE ./src/zinc/hal/layout_common.ld +INCLUDE layout_common.ld diff --git a/src/zinc/hal/lpc17xx/mod.rs b/src/hal/lpc17xx/mod.rs similarity index 100% rename from src/zinc/hal/lpc17xx/mod.rs rename to src/hal/lpc17xx/mod.rs diff --git a/src/zinc/hal/lpc17xx/peripheral_clock.rs b/src/hal/lpc17xx/peripheral_clock.rs similarity index 98% rename from src/zinc/hal/lpc17xx/peripheral_clock.rs rename to src/hal/lpc17xx/peripheral_clock.rs index 259241a7..c93519cf 100644 --- a/src/zinc/hal/lpc17xx/peripheral_clock.rs +++ b/src/hal/lpc17xx/peripheral_clock.rs @@ -24,13 +24,13 @@ use core::intrinsics::abort; use super::system_clock::system_clock; use self::PeripheralClock::*; use self::PeripheralDivisor::*; -use core::marker::Copy; #[path="../../util/ioreg.rs"] #[macro_use] mod ioreg; /// Configures the state of peripheral clock. #[allow(missing_docs)] +#[derive(Clone, Copy)] pub enum PeripheralClock { // reserved = 0, TIM0Clock = 1, @@ -66,11 +66,9 @@ pub enum PeripheralClock { USBClock = 31, } -impl Copy for PeripheralClock {} - /// Configures the divisor of peripheral clock based on core clock. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum PeripheralDivisor { WDTDivisor = 0, TIMER0Divisor = 2, diff --git a/src/zinc/hal/lpc17xx/pin.rs b/src/hal/lpc17xx/pin.rs similarity index 98% rename from src/zinc/hal/lpc17xx/pin.rs rename to src/hal/lpc17xx/pin.rs index f5dd6467..2c9b9da7 100644 --- a/src/zinc/hal/lpc17xx/pin.rs +++ b/src/hal/lpc17xx/pin.rs @@ -22,7 +22,6 @@ on the package. use core::intrinsics::abort; use core::option::Option; -use core::marker::Copy; use self::Port::*; @@ -31,7 +30,7 @@ use self::Port::*; /// Available port names. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Port { Port0, Port1, @@ -41,7 +40,7 @@ pub enum Port { } /// Pin functions (GPIO or up to three additional functions). -#[derive(PartialEq)] +#[derive(PartialEq, Clone, Copy)] #[allow(missing_docs)] pub enum Function { Gpio = 0, @@ -50,10 +49,8 @@ pub enum Function { AltFunction3 = 3, } -impl Copy for Function {} - /// Structure to describe the location of a pin -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Pin { /// Port the pin is attached to port: Port, diff --git a/src/zinc/hal/lpc17xx/pin_pt.rs b/src/hal/lpc17xx/pin_pt.rs similarity index 92% rename from src/zinc/hal/lpc17xx/pin_pt.rs rename to src/hal/lpc17xx/pin_pt.rs index 300ecbf7..087a63e2 100644 --- a/src/zinc/hal/lpc17xx/pin_pt.rs +++ b/src/hal/lpc17xx/pin_pt.rs @@ -40,12 +40,12 @@ pub fn verify(_: &mut Builder, cx: &mut ExtCtxt, node: Rc) { fn build_pin(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { let port_node = node.parent.clone().unwrap().upgrade().unwrap(); let ref port_path = port_node.path; - let port_str = format!("Port{}", match port_path.as_slice().parse::().unwrap() { + let port_str = format!("Port{}", match port_path.as_str().parse::().unwrap() { 0...4 => port_path, other => { cx.parse_sess().span_diagnostic.span_err(port_node.path_span, format!("unknown port `{}`, allowed values: 0...4", - other).as_slice()); + other).as_str()); return; } }); @@ -60,26 +60,26 @@ fn build_pin(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { let direction_str = if node.get_string_attr("function").is_some() { "core::option::Option::None" } else { - match node.get_string_attr("direction").unwrap().as_slice() { + match node.get_string_attr("direction").unwrap().as_str() { "out" => "core::option::Option::Some(zinc::hal::pin::Out)", "in" => "core::option::Option::Some(zinc::hal::pin::In)", other => { let attr = node.get_attr("direction"); cx.parse_sess().span_diagnostic.span_err(attr.value_span, format!("unknown direction `{}`, allowed values: `in`, `out`", - other).as_slice()); + other).as_str()); return; } } }; let direction = TokenString(direction_str.to_string()); - let pin_str = match node.path.as_slice().parse::().unwrap() { + let pin_str = match node.path.as_str().parse::().unwrap() { 0...31 => &node.path, other => { cx.parse_sess().span_diagnostic.span_err(node.path_span, format!("unknown pin `{}`, allowed values: 0...31", - other).as_slice()); + other).as_str()); return; } }; @@ -88,15 +88,15 @@ fn build_pin(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { let function_str = match node.get_string_attr("function") { None => "Gpio".to_string(), Some(fun) => { - let pins = &port_def[*port_path]; - let maybe_pin_index: usize = node.path.as_slice().parse().unwrap(); + let pins = &port_def[port_path]; + let maybe_pin_index: usize = node.path.as_str().parse().unwrap(); let maybe_pin: &Option = pins.get(maybe_pin_index).unwrap(); match maybe_pin { &None => { cx.parse_sess().span_diagnostic.span_err( node.get_attr("function").value_span, format!("unknown pin function `{}`, only GPIO avaliable on this pin", - fun).as_slice()); + fun).as_str()); return; } &Some(ref pin_funcs) => { @@ -107,7 +107,7 @@ fn build_pin(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { cx.parse_sess().span_diagnostic.span_err( node.get_attr("function").value_span, format!("unknown pin function `{}`, allowed functions: {}", - fun, avaliable.connect(", ")).as_slice()); + fun, avaliable.connect(", ")).as_str()); return; }, Some(func_idx) => { @@ -131,7 +131,7 @@ fn build_pin(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { $pin, zinc::hal::lpc17xx::pin::Function::$function, $direction); - ); + ).unwrap(); builder.add_main_statement(st); } diff --git a/src/zinc/hal/lpc17xx/pinmap.rs b/src/hal/lpc17xx/pinmap.rs similarity index 100% rename from src/zinc/hal/lpc17xx/pinmap.rs rename to src/hal/lpc17xx/pinmap.rs diff --git a/src/zinc/hal/lpc17xx/pinmap.rs.rb b/src/hal/lpc17xx/pinmap.rs.rb similarity index 100% rename from src/zinc/hal/lpc17xx/pinmap.rs.rb rename to src/hal/lpc17xx/pinmap.rs.rb diff --git a/src/zinc/hal/lpc17xx/platformtree.rs b/src/hal/lpc17xx/platformtree.rs similarity index 97% rename from src/zinc/hal/lpc17xx/platformtree.rs rename to src/hal/lpc17xx/platformtree.rs index 6de4e61c..73b930cd 100644 --- a/src/zinc/hal/lpc17xx/platformtree.rs +++ b/src/hal/lpc17xx/platformtree.rs @@ -31,7 +31,7 @@ pub fn attach(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { for sub in node.subnodes().iter() { add_node_dependency(&node, sub); - match sub.path.as_slice() { + match sub.path.as_str() { "clock" => system_clock_pt::attach(builder, cx, sub.clone()), "timer" => timer_pt::attach(builder, cx, sub.clone()), "uart" => uart_pt::attach(builder, cx, sub.clone()), @@ -116,16 +116,16 @@ mod test { } }", |cx, failed, pt| { let items = Builder::build(cx, pt) - .expect(format!("Unexpected failure on {}", line!()).as_slice()) + .expect(format!("Unexpected failure on {}", line!()).as_str()) .emit_items(cx); assert!(unsafe{*failed} == false); - assert!(items.len() == 3); + assert!(items.len() == 4); assert_equal_items(items[1].deref(), " #[no_mangle] #[allow(unused_variables)] - pub unsafe fn main() -> () { + pub unsafe fn platformtree_main() -> () { zinc::hal::mem_init::init_stack(); zinc::hal::mem_init::init_data(); { diff --git a/src/zinc/hal/lpc17xx/ssp.rs b/src/hal/lpc17xx/ssp.rs similarity index 100% rename from src/zinc/hal/lpc17xx/ssp.rs rename to src/hal/lpc17xx/ssp.rs diff --git a/src/zinc/hal/lpc17xx/system_clock.rs b/src/hal/lpc17xx/system_clock.rs similarity index 98% rename from src/zinc/hal/lpc17xx/system_clock.rs rename to src/hal/lpc17xx/system_clock.rs index ccf640cb..9d3bf2b6 100644 --- a/src/zinc/hal/lpc17xx/system_clock.rs +++ b/src/hal/lpc17xx/system_clock.rs @@ -28,7 +28,7 @@ use core::option::Option::{self, Some, None}; #[macro_use] mod wait_for; /// PLL clock source. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum ClockSource { /// Internal resonator, 4MHz. Internal, @@ -46,7 +46,7 @@ pub enum ClockSource { /// Fcco = (2 * m * Fin) / n /// Fcpu = Fcco / divisor /// ``` -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct PLL0 { /// PLL multiplier. pub m: u8, @@ -57,7 +57,7 @@ pub struct PLL0 { } /// MCU clock configuration. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Clock { /// Clocking source. pub source: ClockSource, diff --git a/src/zinc/hal/lpc17xx/system_clock_pt.rs b/src/hal/lpc17xx/system_clock_pt.rs similarity index 97% rename from src/zinc/hal/lpc17xx/system_clock_pt.rs rename to src/hal/lpc17xx/system_clock_pt.rs index 407b5ba4..3e10303b 100644 --- a/src/zinc/hal/lpc17xx/system_clock_pt.rs +++ b/src/hal/lpc17xx/system_clock_pt.rs @@ -32,7 +32,7 @@ fn build_clock(builder: &mut Builder, cx: &mut ExtCtxt, let source = node.get_string_attr("source").unwrap(); let source_freq: usize; - let clock_source = TokenString(match source.as_slice() { + let clock_source = TokenString(match source.as_str() { "internal-oscillator" => { source_freq = 4_000_000; "system_clock::Internal".to_string() @@ -56,7 +56,7 @@ fn build_clock(builder: &mut Builder, cx: &mut ExtCtxt, source_freq = 0; cx.span_err( node.get_attr("source").value_span, - format!("unknown oscillator value `{}`", other).as_slice()); + format!("unknown oscillator value `{}`", other).as_str()); "BAD".to_string() }, }); diff --git a/src/zinc/hal/lpc17xx/timer.rs b/src/hal/lpc17xx/timer.rs similarity index 97% rename from src/zinc/hal/lpc17xx/timer.rs rename to src/hal/lpc17xx/timer.rs index 8e15c671..dd316ce4 100644 --- a/src/zinc/hal/lpc17xx/timer.rs +++ b/src/hal/lpc17xx/timer.rs @@ -28,7 +28,7 @@ use self::TimerPeripheral::*; /// Available timer peripherals. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum TimerPeripheral { Timer0, Timer1, @@ -37,7 +37,7 @@ pub enum TimerPeripheral { } /// Configuration for timer. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct TimerConf { /// Peripheral to use. pub timer: TimerPeripheral, @@ -48,7 +48,7 @@ pub struct TimerConf { } /// Struct describing a timer instance. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Timer { reg: &'static reg::TIMER, } diff --git a/src/zinc/hal/lpc17xx/timer_pt.rs b/src/hal/lpc17xx/timer_pt.rs similarity index 96% rename from src/zinc/hal/lpc17xx/timer_pt.rs rename to src/hal/lpc17xx/timer_pt.rs index c4a6a152..1e342894 100644 --- a/src/zinc/hal/lpc17xx/timer_pt.rs +++ b/src/hal/lpc17xx/timer_pt.rs @@ -46,7 +46,7 @@ fn build_timer(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { } let name = TokenString(node.name.clone().unwrap()); - let timer_index: usize = node.path.as_slice().parse().unwrap(); + let timer_index: usize = node.path.as_str().parse().unwrap(); let counter: u32 = node.get_int_attr("counter").unwrap() as u32; let divisor: u8 = node.get_int_attr("divisor").unwrap() as u8; @@ -56,7 +56,7 @@ fn build_timer(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { other => { cx.parse_sess().span_diagnostic.span_err(node.path_span, format!("unknown timer index `{}`, allowed indexes: 0, 1, 2, 3", - other).as_slice()); + other).as_str()); return } }; @@ -66,7 +66,7 @@ fn build_timer(builder: &mut Builder, cx: &mut ExtCtxt, node: Rc) { let st = quote_stmt!(&*cx, let $name = zinc::hal::lpc17xx::timer::Timer::new( $timer_name, $counter, $divisor); - ); + ).unwrap(); builder.add_main_statement(st); } diff --git a/src/zinc/hal/lpc17xx/uart.rs b/src/hal/lpc17xx/uart.rs similarity index 98% rename from src/zinc/hal/lpc17xx/uart.rs rename to src/hal/lpc17xx/uart.rs index 41a27a5b..efeda6ad 100644 --- a/src/zinc/hal/lpc17xx/uart.rs +++ b/src/hal/lpc17xx/uart.rs @@ -21,7 +21,6 @@ than other UARTs in MCU). */ use core::intrinsics::abort; -use core::marker::Copy; use hal::lpc17xx::peripheral_clock::PeripheralClock; use hal::lpc17xx::peripheral_clock::PeripheralClock::UART0Clock; @@ -40,6 +39,7 @@ use self::UARTPeripheral::*; /// Available UART peripherals. #[allow(missing_docs)] +#[derive(Clone, Copy)] pub enum UARTPeripheral { UART0, UART2, @@ -48,7 +48,7 @@ pub enum UARTPeripheral { /// UART word length. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum WordLen { WordLen5bits = 0b00, WordLen6bits = 0b01, @@ -71,7 +71,7 @@ impl WordLen { } /// Stop bits configuration. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum StopBit { /// Single stop bit. StopBit1bit = 0b0_00, @@ -129,7 +129,7 @@ enum FIFOTriggerLevel { } /// Structure describing a UART instance. -#[derive(Copy)] +#[derive(Clone)] pub struct UART { reg: &'static reg::UART, clock: PeripheralClock, @@ -153,8 +153,6 @@ impl UARTPeripheral { } } -impl Copy for UARTPeripheral {} - impl UART { /// Create ans setup a UART. pub fn new(peripheral: UARTPeripheral, baudrate: u32, word_len: u8, diff --git a/src/zinc/hal/lpc17xx/uart_pt.rs b/src/hal/lpc17xx/uart_pt.rs similarity index 85% rename from src/zinc/hal/lpc17xx/uart_pt.rs rename to src/hal/lpc17xx/uart_pt.rs index 75683874..7e5dad5a 100644 --- a/src/zinc/hal/lpc17xx/uart_pt.rs +++ b/src/hal/lpc17xx/uart_pt.rs @@ -27,8 +27,8 @@ pub fn attach(builder: &mut Builder, _: &mut ExtCtxt, node: Rc) { add_node_dependency(&node, sub); let tx_node_name = sub.get_ref_attr("tx").unwrap(); let rx_node_name = sub.get_ref_attr("rx").unwrap(); - let tx_node = builder.pt().get_by_name(tx_node_name.as_slice()).unwrap(); - let rx_node = builder.pt().get_by_name(rx_node_name.as_slice()).unwrap(); + let tx_node = builder.pt().get_by_name(tx_node_name.as_str()).unwrap(); + let rx_node = builder.pt().get_by_name(rx_node_name.as_str()).unwrap(); add_node_dependency(sub, &tx_node); add_node_dependency(sub, &rx_node); super::add_node_dependency_on_clock(builder, sub); @@ -46,21 +46,21 @@ pub fn mutate_pins(builder: &mut Builder, _: &mut ExtCtxt, sub: Rc) let tx_node_name = sub.get_ref_attr("tx").unwrap(); let rx_node_name = sub.get_ref_attr("rx").unwrap(); - build_uart_gpio(builder, sub.path.as_slice().parse().unwrap(), - tx_node_name.as_slice(), true); - build_uart_gpio(builder, sub.path.as_slice().parse().unwrap(), - rx_node_name.as_slice(), false); + build_uart_gpio(builder, sub.path.as_str().parse().unwrap(), + tx_node_name.as_str(), true); + build_uart_gpio(builder, sub.path.as_str().parse().unwrap(), + rx_node_name.as_str(), false); } pub fn build_uart(builder: &mut Builder, cx: &mut ExtCtxt, sub: Rc) { let uart_peripheral_str = format!("UARTPeripheral::UART{}", - match sub.path.as_slice().parse::().unwrap() { + match sub.path.as_str().parse::().unwrap() { 0|2|3 => sub.path.clone(), other => { cx.parse_sess().span_diagnostic.span_err(sub.path_span, format!("unknown UART `{}`, allowed values: 0, 2, 3", - other).as_slice()); + other).as_str()); return } }); @@ -83,17 +83,17 @@ pub fn build_uart(builder: &mut Builder, cx: &mut ExtCtxt, let baud_rate: u32 = sub.get_int_attr("baud_rate").unwrap() as u32; let mode = sub.get_string_attr("mode").unwrap(); - let word_len = mode.as_slice().char_at(0).to_digit(10).unwrap() as u8; + let word_len = mode.as_str().chars().nth(0).unwrap().to_digit(10).unwrap() as u8; let parity = TokenString( - match mode.as_slice().char_at(1) { - 'N' => "Parity::Disabled", - 'O' => "Parity::Odd", - 'E' => "Parity::Even", - '1' => "Parity::Forced1", - '0' => "Parity::Forced0", + match mode.as_str().chars().nth(1) { + Some('N') => "Parity::Disabled", + Some('O') => "Parity::Odd", + Some('E') => "Parity::Even", + Some('1') => "Parity::Forced1", + Some('0') => "Parity::Forced0", _ => panic!(), }.to_string()); - let stop_bits = mode.as_slice().char_at(2).to_digit(10).unwrap() as u8; + let stop_bits = mode.as_str().chars().nth(2).unwrap().to_digit(10).unwrap() as u8; sub.set_type_name("zinc::hal::lpc17xx::uart::UART".to_string()); let uart_name = TokenString(sub.name.clone().unwrap()); @@ -105,7 +105,7 @@ pub fn build_uart(builder: &mut Builder, cx: &mut ExtCtxt, $word_len, zinc::hal::uart::$parity, $stop_bits) - ); + ).unwrap(); builder.add_main_statement(st); } diff --git a/src/zinc/hal/mem_init.rs b/src/hal/mem_init.rs similarity index 100% rename from src/zinc/hal/mem_init.rs rename to src/hal/mem_init.rs diff --git a/src/zinc/hal/mod.rs b/src/hal/mod.rs similarity index 97% rename from src/zinc/hal/mod.rs rename to src/hal/mod.rs index 68a0902a..b2417b20 100644 --- a/src/zinc/hal/mod.rs +++ b/src/hal/mod.rs @@ -38,3 +38,6 @@ pub mod spi; pub mod stack; pub mod timer; pub mod uart; + +#[cfg(not(test))] +pub mod isr; diff --git a/src/zinc/hal/pin.rs b/src/hal/pin.rs similarity index 95% rename from src/zinc/hal/pin.rs rename to src/hal/pin.rs index d8688f1c..956bac98 100644 --- a/src/zinc/hal/pin.rs +++ b/src/hal/pin.rs @@ -19,7 +19,7 @@ pub use self::GpioDirection::*; pub use self::GpioLevel::*; /// GPIO direction. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum GpioDirection { /// Input mode. In, @@ -28,7 +28,7 @@ pub enum GpioDirection { } /// Logic levels. -#[derive(PartialEq, Copy)] +#[derive(PartialEq, Clone, Copy)] pub enum GpioLevel { /// Logic low. Low, diff --git a/src/zinc/hal/spi.rs b/src/hal/spi.rs similarity index 100% rename from src/zinc/hal/spi.rs rename to src/hal/spi.rs diff --git a/src/zinc/hal/stack.rs b/src/hal/stack.rs similarity index 88% rename from src/zinc/hal/stack.rs rename to src/hal/stack.rs index efdad465..d15cbe81 100644 --- a/src/zinc/hal/stack.rs +++ b/src/hal/stack.rs @@ -15,14 +15,18 @@ //! Stack layout information. +use core::intrinsics::transmute; + extern { - static __STACK_BASE: u32; + fn __STACK_BASE(); static mut __STACK_LIMIT: u32; } /// Returns the address of main stack base (end of ram). -pub fn stack_base() -> u32 { - (&__STACK_BASE as *const u32) as u32 +pub fn stack_base() -> usize { + unsafe { + transmute(__STACK_BASE) + } } /// Returns the current stack limit. diff --git a/src/zinc/hal/stm32f4/gpio.rs b/src/hal/stm32f4/gpio.rs similarity index 98% rename from src/zinc/hal/stm32f4/gpio.rs rename to src/hal/stm32f4/gpio.rs index 14add824..5d4a88c7 100644 --- a/src/zinc/hal/stm32f4/gpio.rs +++ b/src/hal/stm32f4/gpio.rs @@ -22,7 +22,7 @@ use hal::pin::{GpioDirection}; mod ioreg; /// Configuration for a GPIO. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct GPIOConf { /// Pin configuration for this GPIO. pub pin: pin::PinConf, diff --git a/src/zinc/hal/stm32f4/init.rs b/src/hal/stm32f4/init.rs similarity index 98% rename from src/zinc/hal/stm32f4/init.rs rename to src/hal/stm32f4/init.rs index 96516091..fe4abeac 100644 --- a/src/zinc/hal/stm32f4/init.rs +++ b/src/hal/stm32f4/init.rs @@ -27,7 +27,7 @@ use core::intrinsics::abort; #[macro_use] mod wait_for; /// System clock source. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum SystemClockSource { /// High-speed internal oscillator, 16MHz. SystemClockHSI, @@ -38,7 +38,7 @@ pub enum SystemClockSource { } /// PLL clock source. Applies to both PLL and PLLI2S. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum PLLClockSource { /// High-speed internal oscillator, 16MHz. PLLClockHSI, @@ -55,7 +55,7 @@ pub enum PLLClockSource { /// F_pll_out = Fvco / p /// F_pll_usb = Fvco / q /// ``` -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct PLLConf { /// Clock source. pub source: PLLClockSource, @@ -70,14 +70,14 @@ pub struct PLLConf { } /// MCU clock configuration. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct ClockConf { /// Clocking source. pub source: SystemClockSource, } /// MCU configuration. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct SysConf { /// Clock configuration. pub clock: ClockConf, @@ -279,7 +279,7 @@ impl PLLConf { pub mod reg { use util::volatile_cell::VolatileCell; - #[derive(Copy)] + #[derive(Clone, Copy)] pub enum SystemClockSwitch { SystemClockHSI = 0, SystemClockHSE = 1, diff --git a/src/zinc/hal/stm32f4/iomem.ld b/src/hal/stm32f4/iomem.ld similarity index 100% rename from src/zinc/hal/stm32f4/iomem.ld rename to src/hal/stm32f4/iomem.ld diff --git a/src/zinc/hal/stm32f4/layout.ld b/src/hal/stm32f4/layout.ld similarity index 80% rename from src/zinc/hal/stm32f4/layout.ld rename to src/hal/stm32f4/layout.ld index 4649577b..83b81072 100644 --- a/src/zinc/hal/stm32f4/layout.ld +++ b/src/hal/stm32f4/layout.ld @@ -1,7 +1,7 @@ __STACK_BASE = 0x2001FFFF; _data_load = LOADADDR(.data); -INCLUDE ./src/zinc/hal/stm32f4/iomem.ld +INCLUDE iomem.ld ENTRY(main) @@ -15,4 +15,4 @@ MEMORY REGION_ALIAS("vectors", rom); -INCLUDE ./src/zinc/hal/layout_common.ld +INCLUDE layout_common.ld diff --git a/src/zinc/hal/stm32f4/mod.rs b/src/hal/stm32f4/mod.rs similarity index 100% rename from src/zinc/hal/stm32f4/mod.rs rename to src/hal/stm32f4/mod.rs diff --git a/src/zinc/hal/stm32f4/peripheral_clock.rs b/src/hal/stm32f4/peripheral_clock.rs similarity index 99% rename from src/zinc/hal/stm32f4/peripheral_clock.rs rename to src/hal/stm32f4/peripheral_clock.rs index c07084d0..0802ea2f 100644 --- a/src/zinc/hal/stm32f4/peripheral_clock.rs +++ b/src/hal/stm32f4/peripheral_clock.rs @@ -30,6 +30,7 @@ use self::PeripheralClock::*; /// /// This enum contains all available clocks from both AHB and APB. #[allow(missing_docs)] +#[derive(Clone)] pub enum PeripheralClock { // AHB1 GPIOAClock, diff --git a/src/zinc/hal/stm32f4/pin.rs b/src/hal/stm32f4/pin.rs similarity index 98% rename from src/zinc/hal/stm32f4/pin.rs rename to src/hal/stm32f4/pin.rs index 93bc9ed6..a34f0c02 100644 --- a/src/zinc/hal/stm32f4/pin.rs +++ b/src/hal/stm32f4/pin.rs @@ -28,7 +28,7 @@ use self::Port::*; /// Available port names. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Port { PortA, PortB, @@ -43,7 +43,7 @@ pub enum Port { /// Pin functions. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Function { GPIOIn = 0, GPIOOut = 1, @@ -72,7 +72,7 @@ impl Port { /// /// This structure shouldn't be used directly, pinmap.rs, available via pin::map /// has all possible pin configurations. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct PinConf { /// Pin port, mcu-specific. pub port: Port, diff --git a/src/zinc/hal/stm32f4/pinmap.rs.rb b/src/hal/stm32f4/pinmap.rs.rb similarity index 100% rename from src/zinc/hal/stm32f4/pinmap.rs.rb rename to src/hal/stm32f4/pinmap.rs.rb diff --git a/src/zinc/hal/stm32f4/timer.rs b/src/hal/stm32f4/timer.rs similarity index 98% rename from src/zinc/hal/stm32f4/timer.rs rename to src/hal/stm32f4/timer.rs index 1e3c0de5..fb23e425 100644 --- a/src/zinc/hal/stm32f4/timer.rs +++ b/src/hal/stm32f4/timer.rs @@ -25,13 +25,13 @@ use hal::timer; /// Available timer peripherals. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum TimerPeripheral { Timer2, } /// Structure describing a Timer. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Timer { reg: &'static reg::TIM2To5, } diff --git a/src/zinc/hal/stm32l1/init.rs b/src/hal/stm32l1/init.rs similarity index 99% rename from src/zinc/hal/stm32l1/init.rs rename to src/hal/stm32l1/init.rs index bfb32ef3..f7c8723a 100644 --- a/src/zinc/hal/stm32l1/init.rs +++ b/src/hal/stm32l1/init.rs @@ -32,6 +32,7 @@ use self::SystemClockSource::*; /// Phase-locked loop clock source. #[repr(u8)] +#[derive(Clone)] pub enum PllClockSource { /// Takes base clock from HSI. PllSourceHSI = 0, @@ -49,6 +50,7 @@ pub type PllDivisor = u8; /// Multi-speed internal clock divisor. #[repr(u8)] +#[derive(Clone)] pub enum MsiSpeed { /// 65.536 kHz Msi65 = 0, @@ -69,6 +71,7 @@ pub enum MsiSpeed { impl Copy for MsiSpeed {} /// System clock source. +#[derive(Clone)] pub enum SystemClockSource { /// Multi-speed internal clock, SystemClockMSI(MsiSpeed), @@ -108,6 +111,7 @@ impl Copy for SystemClockSource {} #[allow(missing_docs)] #[repr(u8)] +#[derive(Clone)] pub enum McoSource { McoClockSystem = 1, McoClockHSI = 2, @@ -121,6 +125,7 @@ pub enum McoSource { impl Copy for McoSource {} /// Microchip clock output configuration. +#[derive(Clone)] pub struct McoConfig { /// MCO clock source source: McoSource, @@ -131,6 +136,7 @@ pub struct McoConfig { impl Copy for McoConfig {} /// System clock configuration. +#[derive(Clone)] pub struct ClockConfig { /// System clock source pub source : SystemClockSource, diff --git a/src/zinc/hal/stm32l1/iomem.ld b/src/hal/stm32l1/iomem.ld similarity index 100% rename from src/zinc/hal/stm32l1/iomem.ld rename to src/hal/stm32l1/iomem.ld diff --git a/src/zinc/hal/stm32l1/layout.ld b/src/hal/stm32l1/layout.ld similarity index 75% rename from src/zinc/hal/stm32l1/layout.ld rename to src/hal/stm32l1/layout.ld index 2dfc29ee..5e055b07 100644 --- a/src/zinc/hal/stm32l1/layout.ld +++ b/src/hal/stm32l1/layout.ld @@ -1,7 +1,7 @@ __STACK_BASE = 0x20008000; /* end of ram */ _data_load = LOADADDR(.data); -INCLUDE ./src/zinc/hal/stm32l1/iomem.ld +INCLUDE iomem.ld ENTRY(main) @@ -13,4 +13,4 @@ MEMORY REGION_ALIAS("vectors", rom); -INCLUDE ./src/zinc/hal/layout_common.ld +INCLUDE layout_common.ld diff --git a/src/zinc/hal/stm32l1/mod.rs b/src/hal/stm32l1/mod.rs similarity index 100% rename from src/zinc/hal/stm32l1/mod.rs rename to src/hal/stm32l1/mod.rs diff --git a/src/zinc/hal/stm32l1/peripheral_clock.rs b/src/hal/stm32l1/peripheral_clock.rs similarity index 98% rename from src/zinc/hal/stm32l1/peripheral_clock.rs rename to src/hal/stm32l1/peripheral_clock.rs index 889e4818..6f6f6e48 100644 --- a/src/zinc/hal/stm32l1/peripheral_clock.rs +++ b/src/hal/stm32l1/peripheral_clock.rs @@ -28,6 +28,7 @@ pub use self::PeripheralClock::*; #[allow(missing_docs)] #[repr(u8)] +#[derive(Clone)] pub enum BusAhb { GpioA, GpioB, @@ -81,6 +82,7 @@ impl BusAhb { #[allow(missing_docs)] #[repr(u8)] +#[derive(Clone)] pub enum BusApb1 { Tim2, Tim3, @@ -144,6 +146,7 @@ impl Copy for BusApb1 {} #[allow(missing_docs)] #[repr(u8)] +#[derive(Clone)] pub enum BusApb2 { SysCfg, Tim9, @@ -185,6 +188,7 @@ impl Copy for BusApb2 {} /// /// This enum contains all available clocks from both AHB and APB. #[allow(missing_docs)] +#[derive(Clone)] pub enum PeripheralClock { Ahb(BusAhb), Apb1(BusApb1), diff --git a/src/zinc/hal/stm32l1/pin.rs b/src/hal/stm32l1/pin.rs similarity index 97% rename from src/zinc/hal/stm32l1/pin.rs rename to src/hal/stm32l1/pin.rs index 6f493307..bbfb87a9 100644 --- a/src/zinc/hal/stm32l1/pin.rs +++ b/src/hal/stm32l1/pin.rs @@ -25,7 +25,7 @@ use self::Port::*; /// Available port names. #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Port { PortA, PortB, @@ -40,7 +40,7 @@ pub enum Port { /// Pin output type. #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum OutputType { OutPushPull = 0, OutOpenDrain = 1, @@ -49,7 +49,7 @@ pub enum OutputType { /// Pin pull resistors: up, down, or none. #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum PullType { PullNone = 0, PullUp = 1, @@ -58,7 +58,7 @@ pub enum PullType { /// Pin speed. #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Speed { /// 400 KHz VeryLow = 0, @@ -73,7 +73,7 @@ pub enum Speed { /// Extended pin modes. #[allow(missing_docs, non_camel_case_types)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum AltMode { AfRtc50Mhz_Mco_RtcAfl_Wakeup_SwJtag_Trace = 0, AfTim2 = 1, @@ -92,7 +92,7 @@ pub enum AltMode { } /// Pin mode. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Mode { /// GPIO Input Mode GpioIn, @@ -105,7 +105,7 @@ pub enum Mode { } /// Pin configuration. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Pin { /// Pin index. pub index: u8, diff --git a/src/zinc/hal/stm32l1/spi.rs b/src/hal/stm32l1/spi.rs similarity index 96% rename from src/zinc/hal/stm32l1/spi.rs rename to src/hal/stm32l1/spi.rs index 74f05a73..e6f12c3f 100644 --- a/src/zinc/hal/stm32l1/spi.rs +++ b/src/hal/stm32l1/spi.rs @@ -25,7 +25,7 @@ use core::marker::Copy; /// Available SPI peripherals. #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Peripheral { Spi1, Spi2, @@ -34,7 +34,7 @@ pub enum Peripheral { /// SPI direction modes. #[repr(u8)] -#[derive(PartialEq, Copy)] +#[derive(PartialEq, Clone, Copy)] pub enum Direction { /// 2 lines, default mode FullDuplex, @@ -48,6 +48,7 @@ pub enum Direction { #[allow(missing_docs)] #[repr(u8)] +#[derive(Clone)] pub enum Role { Slave = 0, Master = 1, @@ -57,7 +58,7 @@ impl Copy for Role {} #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum DataSize { U8 = 0, U16 = 1, @@ -65,7 +66,7 @@ pub enum DataSize { /// SPI data format. #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum DataFormat { /// Most Significant Bit MsbFirst = 0, @@ -75,7 +76,7 @@ pub enum DataFormat { #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum ClockPhase { Edge1 = 0, Edge2 = 1, @@ -83,7 +84,7 @@ pub enum ClockPhase { #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum ClockPolarity { Low = 0, High = 1, @@ -91,7 +92,7 @@ pub enum ClockPolarity { /// SPI initialization errors. #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Error { /// Invalid baud rate shift. BaudRate, @@ -100,7 +101,7 @@ pub enum Error { } /// Structure describing a SPI instance. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Spi { reg: &'static reg::SPI, } diff --git a/src/zinc/hal/stm32l1/timer.rs b/src/hal/stm32l1/timer.rs similarity index 98% rename from src/zinc/hal/stm32l1/timer.rs rename to src/hal/stm32l1/timer.rs index 19b1f9e0..59214ed0 100644 --- a/src/zinc/hal/stm32l1/timer.rs +++ b/src/hal/stm32l1/timer.rs @@ -21,13 +21,13 @@ /// Available timer peripherals. #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum TimerPeripheral { Timer2, } /// Structure describing a Timer. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Timer { reg: &'static reg::TIMER, } diff --git a/src/zinc/hal/stm32l1/usart.rs b/src/hal/stm32l1/usart.rs similarity index 98% rename from src/zinc/hal/stm32l1/usart.rs rename to src/hal/stm32l1/usart.rs index 18224a94..7f011b47 100644 --- a/src/zinc/hal/stm32l1/usart.rs +++ b/src/hal/stm32l1/usart.rs @@ -34,7 +34,7 @@ use self::UsartPeripheral::*; /// Available USART peripherals. #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum UsartPeripheral { Usart1, Usart2, @@ -46,7 +46,7 @@ pub enum UsartPeripheral { /// USART word length. #[allow(missing_docs)] #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum WordLen { WordLen8bits = 0, WordLen9bits = 1, @@ -54,7 +54,7 @@ pub enum WordLen { /// Stop bits configuration. #[repr(u8)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum StopBit { /// Single stop bit. StopBit1bit = 0, @@ -67,7 +67,7 @@ pub enum StopBit { } /// Structure describing a USART instance. -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Usart { reg: &'static reg::USART, } diff --git a/src/zinc/hal/timer.rs b/src/hal/timer.rs similarity index 100% rename from src/zinc/hal/timer.rs rename to src/hal/timer.rs diff --git a/src/zinc/hal/tiva_c/clock_pt.rs b/src/hal/tiva_c/clock_pt.rs similarity index 100% rename from src/zinc/hal/tiva_c/clock_pt.rs rename to src/hal/tiva_c/clock_pt.rs diff --git a/src/hal/tiva_c/iomem.ld b/src/hal/tiva_c/iomem.ld new file mode 100644 index 00000000..e69de29b diff --git a/src/zinc/hal/tiva_c/isr.rs b/src/hal/tiva_c/isr.rs similarity index 99% rename from src/zinc/hal/tiva_c/isr.rs rename to src/hal/tiva_c/isr.rs index 5b31c5cb..388cf516 100644 --- a/src/zinc/hal/tiva_c/isr.rs +++ b/src/hal/tiva_c/isr.rs @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +//! ISR data for tiva_c + use core::option::Option::{self, None}; const ISRCOUNT: usize = 139; diff --git a/src/zinc/hal/tiva_c/layout.ld b/src/hal/tiva_c/layout.ld similarity index 89% rename from src/zinc/hal/tiva_c/layout.ld rename to src/hal/tiva_c/layout.ld index 2cb643c9..76426661 100644 --- a/src/zinc/hal/tiva_c/layout.ld +++ b/src/hal/tiva_c/layout.ld @@ -13,4 +13,4 @@ __STACK_BASE = ORIGIN(ram) + LENGTH(ram); REGION_ALIAS("vectors", rom); -INCLUDE ./src/zinc/hal/layout_common.ld +INCLUDE layout_common.ld diff --git a/src/zinc/hal/tiva_c/mod.rs b/src/hal/tiva_c/mod.rs similarity index 100% rename from src/zinc/hal/tiva_c/mod.rs rename to src/hal/tiva_c/mod.rs diff --git a/src/zinc/hal/tiva_c/pin.rs b/src/hal/tiva_c/pin.rs similarity index 99% rename from src/zinc/hal/tiva_c/pin.rs rename to src/hal/tiva_c/pin.rs index aa647b9f..fc8c6168 100644 --- a/src/zinc/hal/tiva_c/pin.rs +++ b/src/hal/tiva_c/pin.rs @@ -24,7 +24,7 @@ use util::support::get_reg_ref; /// The pins are accessed through ports. Each port has 8 pins and are identified /// by a letter (PortA, PortB, etc...). #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum PortId { PortA, PortB, @@ -35,7 +35,7 @@ pub enum PortId { } /// Structure describing a single HW pin -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Pin { /// Timer register interface regs: &'static reg::Port, diff --git a/src/zinc/hal/tiva_c/pin_pt.rs b/src/hal/tiva_c/pin_pt.rs similarity index 100% rename from src/zinc/hal/tiva_c/pin_pt.rs rename to src/hal/tiva_c/pin_pt.rs diff --git a/src/zinc/hal/tiva_c/platformtree.rs b/src/hal/tiva_c/platformtree.rs similarity index 100% rename from src/zinc/hal/tiva_c/platformtree.rs rename to src/hal/tiva_c/platformtree.rs diff --git a/src/zinc/hal/tiva_c/sysctl.rs b/src/hal/tiva_c/sysctl.rs similarity index 91% rename from src/zinc/hal/tiva_c/sysctl.rs rename to src/hal/tiva_c/sysctl.rs index 267d0b42..569b5d16 100644 --- a/src/zinc/hal/tiva_c/sysctl.rs +++ b/src/hal/tiva_c/sysctl.rs @@ -29,11 +29,10 @@ pub mod clock { //! Clock tree configuration use core::option::Option; use core::option::Option::{Some, None}; - use core::num::from_u32; /// Clock sources available on the system. The values are the RCC/RCC2 OSCSRC /// field encoding. - #[derive(PartialEq, FromPrimitive)] + #[derive(PartialEq, Clone)] pub enum ClockSource { /// The Main Oscillator, external crystal/oscillator on OSC pins. /// The possible frequencies are listed in MOSCSource. @@ -52,7 +51,7 @@ pub mod clock { /// The chip supports a finite list of crystal frequencies for the MOSC, each /// having its own ID used to configure the PLL to output 400MHz. #[allow(missing_docs, non_camel_case_types)] - #[derive(FromPrimitive, Copy)] + #[derive(Clone, Copy)] pub enum MOSCFreq { X5_0MHz = 0x09, X5_12MHz = 0x0A, @@ -73,6 +72,34 @@ pub mod clock { X24MHz = 0x19, } + impl MOSCFreq { + /// Converts between the MOSCFreq enum and the u32 primitive + pub fn from_u32(v: u32) -> Option { + use self::*; + + match v { + 0x09 => Some(MOSCFreq::X5_0MHz), + 0x0A => Some(MOSCFreq::X5_12MHz), + 0x0B => Some(MOSCFreq::X6_0MHz), + 0x0C => Some(MOSCFreq::X6_144MHz), + 0x0D => Some(MOSCFreq::X7_3728MHz), + 0x0E => Some(MOSCFreq::X8_0MHz), + 0x0F => Some(MOSCFreq::X8_192MHz), + 0x10 => Some(MOSCFreq::X10_0MHz), + 0x11 => Some(MOSCFreq::X12_0MHz), + 0x12 => Some(MOSCFreq::X12_288MHz), + 0x13 => Some(MOSCFreq::X13_56MHz), + 0x14 => Some(MOSCFreq::X14_318MHz), + 0x15 => Some(MOSCFreq::X16_0MHz), + 0x16 => Some(MOSCFreq::X16_384MHz), + 0x17 => Some(MOSCFreq::X18MHz), + 0x18 => Some(MOSCFreq::X20MHz), + 0x19 => Some(MOSCFreq::X24MHz), + _ => None, + } + } + } + /// Configure the System Clock by setting the clock source and divisors. pub fn sysclk_configure(source: ClockSource, mosc_source: Option, @@ -165,9 +192,13 @@ pub mod clock { false => rcc.oscsrc(), }; - let clock_source = match from_u32::(oscsrc) { - Some(src) => src, - None => panic!("Unknown clock source"), + let clock_source = match oscsrc { + 0 => ClockSource::MOSC, + 1 => ClockSource::PIOSC, + 2 => ClockSource::PIOSC4MHz, + 3 => ClockSource::LFIOSC, + 7 => ClockSource::HOSC, + _ => panic!("Unknown clock source"), }; let input_freq = match clock_source { @@ -178,7 +209,7 @@ pub mod clock { ClockSource::MOSC => { // We're running from the external clock source, we need to figure out // what crystal we're using - let crystal = match from_u32::(rcc.xtal()) { + let crystal = match MOSCFreq::from_u32(rcc.xtal()) { Some(c) => c, None => panic!("Unknown crystal"), }; @@ -253,12 +284,9 @@ impl Copy for clock::ClockSource {} pub mod periph { //! peripheral system control - use core::iter::range; - use core::ptr::PtrExt; - /// Sysctl can reset/clock gate each module, as well as set various sleep and /// deep-sleep mode behaviour. - #[derive(Copy)] + #[derive(Clone, Copy)] pub struct PeripheralClock { /// Hardware register offset for this peripheral class within a system /// control block. @@ -293,7 +321,7 @@ pub mod periph { // maybe because we also have to take the bus write time into account or // the CPU is more clever than I think. Anyway, looping 5 times seems to // work - for _ in range(0usize, 10) { + for _ in 0..10 { unsafe { asm!("nop" :::: "volatile"); } diff --git a/src/zinc/hal/tiva_c/timer.rs b/src/hal/tiva_c/timer.rs similarity index 99% rename from src/zinc/hal/tiva_c/timer.rs rename to src/hal/tiva_c/timer.rs index 8c23ac43..9409daba 100644 --- a/src/zinc/hal/tiva_c/timer.rs +++ b/src/hal/tiva_c/timer.rs @@ -22,7 +22,7 @@ use util::support::get_reg_ref; /// There are 6 standard 16/32bit timers and 6 "wide" 32/64bit timers #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum TimerId { Timer0, Timer1, @@ -39,7 +39,7 @@ pub enum TimerId { } /// Timer modes -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Mode { /// Periodic timer loops and restarts once the timeout is reached. Periodic, @@ -59,7 +59,7 @@ pub enum Mode { } /// Structure describing a single timer counter (both 16/32bit and 32/64bit) -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Timer { /// Timer register interface regs : &'static reg::Timer, diff --git a/src/zinc/hal/tiva_c/timer_pt.rs b/src/hal/tiva_c/timer_pt.rs similarity index 100% rename from src/zinc/hal/tiva_c/timer_pt.rs rename to src/hal/tiva_c/timer_pt.rs diff --git a/src/zinc/hal/tiva_c/uart.rs b/src/hal/tiva_c/uart.rs similarity index 99% rename from src/zinc/hal/tiva_c/uart.rs rename to src/hal/tiva_c/uart.rs index cc3019ea..84da7804 100644 --- a/src/zinc/hal/tiva_c/uart.rs +++ b/src/hal/tiva_c/uart.rs @@ -28,7 +28,7 @@ use hal::uart; /// There are 8 UART instances in total #[allow(missing_docs)] -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum UartId { Uart0, Uart1, @@ -41,7 +41,7 @@ pub enum UartId { } /// Structure describing a single UART -#[derive(Copy)] +#[derive(Clone, Copy)] pub struct Uart { /// UART register interface regs: &'static reg::Uart, diff --git a/src/zinc/hal/tiva_c/uart_pt.rs b/src/hal/tiva_c/uart_pt.rs similarity index 100% rename from src/zinc/hal/tiva_c/uart_pt.rs rename to src/hal/tiva_c/uart_pt.rs diff --git a/src/zinc/hal/uart.rs b/src/hal/uart.rs similarity index 97% rename from src/zinc/hal/uart.rs rename to src/hal/uart.rs index 87a27354..6aad7664 100644 --- a/src/zinc/hal/uart.rs +++ b/src/hal/uart.rs @@ -22,7 +22,7 @@ UART objects implement CharIO trait to perform actual data transmission. */ /// UART parity mode. -#[derive(Copy)] +#[derive(Clone, Copy)] pub enum Parity { /// Partity disabled. Disabled, diff --git a/src/ioreg/test.rs b/src/ioreg/test.rs deleted file mode 100644 index 80421e4a..00000000 --- a/src/ioreg/test.rs +++ /dev/null @@ -1,176 +0,0 @@ -// Zinc, the bare metal stack for rust. -// Copyright 2014 Ben Gamari -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Tests for ioreg! syntax extension - -#![feature(core, plugin)] -#![plugin(ioreg, shiny)] - -extern crate core; - -#[path="../zinc/util/volatile_cell.rs"] mod volatile_cell; - -#[cfg(test)] -mod test { - use std::mem::{transmute, zeroed}; - use std::ptr::PtrExt; - use volatile_cell::VolatileCell; - - fn get_value<'a, T>(v: &'a T, offset: usize) -> u32 { - unsafe { - let ptr: *const u32 = transmute(v); - *(ptr.offset(offset as isize)) - } - } - - fn zeroed_safe() -> T { - unsafe { - return zeroed(); - } - } - - ioregs!(BASIC_TEST = { - 0x0 => reg32 reg1 { - 0 => field1, - 1..3 => field2, - 16..24 => field3, - 25 => field4: set_to_clear, - } - 0x4 => reg32 reg2 { - 0 => field1, - } - 0x8 => reg32 wo_reg { - 0..15 => field1: wo, - 16..31 => field2: wo, - } - }); - - describe!( - before_each { - let test: BASIC_TEST = zeroed_safe(); - } - - it "can round_trip simple field values 1" { - test.reg1.set_field1(true); - assert_eq!(test.reg1.field1(), true); - assert_eq!(get_value(&test, 0), 1); - assert_eq!(get_value(&test, 1), 0); - } - - it "can round trip simple field values 2" { - test.reg1.set_field3(0xde); - assert_eq!(test.reg1.field3(), 0xde); - assert_eq!(get_value(&test, 0), 0xde<<16); - } - - it "sets set_to_clear fields" { - test.reg1.clear_field4(); - assert_eq!(get_value(&test, 0), 1<<25); - } - - it "does not read from writeonly registers" { - test.wo_reg.set_field1(0xdead); - assert_eq!(get_value(&test, 2), 0xdead); - test.wo_reg.set_field2(0xdead); - assert_eq!(get_value(&test, 2), 0xdead<<16); - } - ); - - ioregs!(GROUP_TEST = { - 0x0 => group regs[5] { - 0x0 => reg32 reg1 { - 0..31 => field1 - } - 0x4 => reg32 reg2 { - 0..31 => field2 - } - } - }); - - describe!( - before_each { - let test: GROUP_TEST = zeroed_safe(); - } - - it "sets groups correctly" { - test.regs[0].reg1.set_field1(0xdeadbeef); - assert_eq!(test.regs[0].reg1.field1(), 0xdeadbeef); - assert_eq!(get_value(&test, 0), 0xdeadbeef); - for i in range(1, 10) { - assert_eq!(get_value(&test, i), 0); - } - - test.regs[2].reg2.set_field2(0xfeedbeef); - assert_eq!(test.regs[2].reg2.field2(), 0xfeedbeef); - assert_eq!(get_value(&test, 5), 0xfeedbeef); - } - ); - - ioregs!(FIELD_ARRAY_TEST = { - 0x0 => reg32 reg1 { - 0..31 => field[16] - } - }); - - describe!( - before_each { - let test: FIELD_ARRAY_TEST = zeroed_safe(); - } - - it "sets field arrays correctly" { - test.reg1.set_field(0, 1); - assert_eq!(test.reg1.field(0), 1); - assert_eq!(get_value(&test, 0), 0x1); - - test.reg1.set_field(4, 3); - assert_eq!(test.reg1.field(4), 3); - assert_eq!(get_value(&test, 0), 0x1 | 0x3<<8); - } - ); - - ioregs!(GAP_TEST = { - 0x0 => reg32 reg1 { - 0..31 => field, - } - 0x10 => reg32 reg2 { - 0..31 => field, - } - 0x14 => reg32 reg3 { - 0..31 => field, - } - 0x20 => reg32 reg4 { - 0..31 => field, - } - }); - - describe!( - before_each { - let test: GAP_TEST = zeroed_safe(); - let base = &test as *const GAP_TEST; - } - it "has zero base offset" { - let addr = &test.reg1 as *const GAP_TEST_reg1; - assert_eq!(addr as usize - base as usize, 0x0); - } - it "computes the correct first gap" { - let addr = &test.reg2 as *const GAP_TEST_reg2; - assert_eq!(addr as usize - base as usize, 0x10); - } - it "computes the correct second gap" { - let addr = &test.reg4 as *const GAP_TEST_reg4; - assert_eq!(addr as usize - base as usize, 0x20); - } - ); -} diff --git a/src/zinc/lib.rs b/src/lib.rs similarity index 95% rename from src/zinc/lib.rs rename to src/lib.rs index 5404bfd9..17176f97 100644 --- a/src/zinc/lib.rs +++ b/src/lib.rs @@ -13,9 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(asm, unsafe_destructor, lang_items, plugin, core)] -#![crate_name="zinc"] -#![crate_type="rlib"] +#![feature(asm, lang_items, plugin, core)] #![allow(improper_ctypes)] #![deny(missing_docs)] #![no_std] diff --git a/src/zinc/os/cond_var.rs b/src/os/cond_var.rs similarity index 100% rename from src/zinc/os/cond_var.rs rename to src/os/cond_var.rs diff --git a/src/zinc/os/debug.rs b/src/os/debug.rs similarity index 100% rename from src/zinc/os/debug.rs rename to src/os/debug.rs diff --git a/src/zinc/os/mod.rs b/src/os/mod.rs similarity index 100% rename from src/zinc/os/mod.rs rename to src/os/mod.rs diff --git a/src/zinc/os/mutex.rs b/src/os/mutex.rs similarity index 99% rename from src/zinc/os/mutex.rs rename to src/os/mutex.rs index 976cdf37..f237d28e 100644 --- a/src/zinc/os/mutex.rs +++ b/src/os/mutex.rs @@ -129,7 +129,6 @@ mod internal { } } - #[unsafe_destructor] impl<'a> Drop for Guard<'a> { #[inline] fn drop(&mut self) { @@ -192,7 +191,6 @@ mod internal { } } - #[unsafe_destructor] impl<'a> Drop for Guard<'a> { #[inline] fn drop(&mut self) { diff --git a/src/zinc/os/syscall.rs b/src/os/syscall.rs similarity index 100% rename from src/zinc/os/syscall.rs rename to src/os/syscall.rs diff --git a/src/zinc/os/task.rs b/src/os/task.rs similarity index 100% rename from src/zinc/os/task.rs rename to src/os/task.rs diff --git a/src/zinc/util/app.rs b/src/util/app.rs similarity index 100% rename from src/zinc/util/app.rs rename to src/util/app.rs diff --git a/src/zinc/util/ioreg.rs b/src/util/ioreg.rs similarity index 98% rename from src/zinc/util/ioreg.rs rename to src/util/ioreg.rs index b6293b9b..1f042bab 100644 --- a/src/zinc/util/ioreg.rs +++ b/src/util/ioreg.rs @@ -16,7 +16,7 @@ macro_rules! ioreg_old( ($io:ident: $ty:ty, $($reg:ident),+) => ( #[allow(non_snake_case)] - #[derive(Copy)] + #[derive(Clone, Copy)] pub struct $io { $( $reg: VolatileCell<$ty>, diff --git a/src/zinc/util/lang_items.rs b/src/util/lang_items.rs similarity index 100% rename from src/zinc/util/lang_items.rs rename to src/util/lang_items.rs diff --git a/src/zinc/util/mod.rs b/src/util/mod.rs similarity index 100% rename from src/zinc/util/mod.rs rename to src/util/mod.rs diff --git a/src/zinc/util/queue.rs b/src/util/queue.rs similarity index 100% rename from src/zinc/util/queue.rs rename to src/util/queue.rs diff --git a/src/zinc/util/shared.rs b/src/util/shared.rs similarity index 100% rename from src/zinc/util/shared.rs rename to src/util/shared.rs diff --git a/src/zinc/util/strconv.rs b/src/util/strconv.rs similarity index 100% rename from src/zinc/util/strconv.rs rename to src/util/strconv.rs diff --git a/src/zinc/util/support.rs b/src/util/support.rs similarity index 87% rename from src/zinc/util/support.rs rename to src/util/support.rs index 5170c501..0cd56b20 100644 --- a/src/zinc/util/support.rs +++ b/src/util/support.rs @@ -37,20 +37,6 @@ pub extern fn abort() -> ! { loop {} } -#[doc(hidden)] -#[no_stack_check] -#[no_mangle] -pub extern fn __aeabi_unwind_cpp_pr0() { - abort(); -} - -#[doc(hidden)] -#[no_stack_check] -#[no_mangle] -pub extern fn __aeabi_unwind_cpp_pr1() { - abort(); -} - // TODO(bgamari): This is only necessary for exception handling and // can be removed when we have this issue resolved. #[doc(hidden)] @@ -58,8 +44,8 @@ pub extern fn __aeabi_unwind_cpp_pr1() { #[no_mangle] pub extern fn __aeabi_memset(dest: *mut u8, size: usize, value: u32) { unsafe { - use core::intrinsics::set_memory; - set_memory(dest, value as u8, size); + use core::intrinsics::volatile_set_memory; + volatile_set_memory(dest, value as u8, size); } } diff --git a/src/zinc/util/volatile_cell.rs b/src/util/volatile_cell.rs similarity index 95% rename from src/zinc/util/volatile_cell.rs rename to src/util/volatile_cell.rs index 17f2df6f..e3e9d196 100644 --- a/src/zinc/util/volatile_cell.rs +++ b/src/util/volatile_cell.rs @@ -15,17 +15,15 @@ //! A cell that with volatile setter and getter. -use core::marker::Copy; use core::intrinsics::{volatile_load, volatile_store}; /// This structure is used to represent a hardware register. /// It is mostly used by the ioreg family of macros. +#[derive(Clone, Copy)] pub struct VolatileCell { value: T, } -impl Copy for VolatileCell {} - impl VolatileCell { /// Create a cell with initial value. pub fn new(value: T) -> VolatileCell { diff --git a/src/zinc/util/wait_for.rs b/src/util/wait_for.rs similarity index 100% rename from src/zinc/util/wait_for.rs rename to src/util/wait_for.rs diff --git a/thirdparty/librlibc/.gitignore b/thirdparty/librlibc/.gitignore deleted file mode 100644 index 80faedec..00000000 --- a/thirdparty/librlibc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Cargo.lock -/target/ diff --git a/thirdparty/librlibc/Cargo.toml b/thirdparty/librlibc/Cargo.toml deleted file mode 100644 index 550e8910..00000000 --- a/thirdparty/librlibc/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "rlibc" -version = "0.13.0" -authors = ["Ben Harris "] - -[lib] -name = "rlibc" -path = "src/lib.rs" - -[dependencies.core] -git = "https://github.com/bharrisau/rust-libcore.git" diff --git a/thirdparty/librlibc/src/lib.rs b/thirdparty/librlibc/src/lib.rs deleted file mode 100644 index 52ec204c..00000000 --- a/thirdparty/librlibc/src/lib.rs +++ /dev/null @@ -1,188 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A bare-metal library supplying functions rustc may lower code to -//! -//! This library is not intended for general use, and is superseded by a system -//! libc if one is available. In a freestanding context, however, common -//! functions such as memset, memcpy, etc are not implemented. This library -//! provides an implementation of these functions which are either required by -//! libcore or called by rustc implicitly. -//! -//! This library is never included by default, and must be manually included if -//! necessary. It is an error to include this library when also linking with -//! the system libc library. - -#![feature(no_std, core)] -#![crate_name = "rlibc"] -#![crate_type = "rlib"] - -#![no_std] - -// This library defines the builtin functions, so it would be a shame for -// LLVM to optimize these function calls to themselves! -#![no_builtins] - -extern crate core; - -#[phase(plugin, link)] -#[cfg(test)] extern crate std; -#[cfg(test)] extern crate native; - -use core::ptr::PtrExt; - -#[no_mangle] -pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8, - n: usize) -> *mut u8 { - let mut i = 0; - while i < n { - *dest.offset(i as isize) = *src.offset(i as isize); - i += 1; - } - return dest; -} - -#[no_mangle] -pub unsafe extern fn memmove(dest: *mut u8, src: *const u8, - n: usize) -> *mut u8 { - if src < dest as *const u8 { // copy from end - let mut i = n; - while i != 0 { - i -= 1; - *dest.offset(i as isize) = *src.offset(i as isize); - } - } else { // copy from beginning - let mut i = 0; - while i < n { - *dest.offset(i as isize) = *src.offset(i as isize); - i += 1; - } - } - return dest; -} - -#[no_mangle] -pub unsafe extern fn memset(s: *mut u8, c: i32, n: usize) -> *mut u8 { - let mut i = 0; - while i < n { - *s.offset(i as isize) = c as u8; - i += 1; - } - return s; -} - -#[no_mangle] -pub unsafe extern fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 { - let mut i = 0; - while i < n { - let a = *s1.offset(i as isize); - let b = *s2.offset(i as isize); - if a != b { - return a as i32 - b as i32 - } - i += 1; - } - return 0; -} - -#[cfg(test)] -mod test { - use core::str::StrSlice; - use core::slice::{MutableSlice, ImmutableSlice}; - - use super::{memcmp, memset, memcpy, memmove}; - - #[test] - fn memcmp_single_byte_pointers() { - unsafe { - assert_eq!(memcmp(&0xFAu8, &0xFAu8, 1), 0x00); - assert!(memcmp(&0xEFu8, &0xFEu8, 1) < 0x00); - } - } - - #[test] - fn memcmp_strings() { - { - let (x, z) = ("Hello!", "Good Bye."); - let l = x.len(); - unsafe { - assert_eq!(memcmp(x.as_ptr(), x.as_ptr(), l), 0); - assert!(memcmp(x.as_ptr(), z.as_ptr(), l) > 0); - assert!(memcmp(z.as_ptr(), x.as_ptr(), l) < 0); - } - } - { - let (x, z) = ("hey!", "hey."); - let l = x.len(); - unsafe { - assert!(memcmp(x.as_ptr(), z.as_ptr(), l) < 0); - } - } - } - - #[test] - fn memset_single_byte_pointers() { - let mut x: u8 = 0xFF; - unsafe { - memset(&mut x, 0xAA, 1); - assert_eq!(x, 0xAA); - memset(&mut x, 0x00, 1); - assert_eq!(x, 0x00); - x = 0x01; - memset(&mut x, 0x12, 0); - assert_eq!(x, 0x01); - } - } - - #[test] - fn memset_array() { - let mut buffer = [b'X', .. 100]; - unsafe { - memset(buffer.as_mut_ptr(), b'#' as i32, buffer.len()); - } - for byte in buffer.iter() { assert_eq!(*byte, b'#'); } - } - - #[test] - fn memcpy_and_memcmp_arrays() { - let (src, mut dst) = ([b'X', .. 100], [b'Y', .. 100]); - unsafe { - assert!(memcmp(src.as_ptr(), dst.as_ptr(), 100) != 0); - let _ = memcpy(dst.as_mut_ptr(), src.as_ptr(), 100); - assert_eq!(memcmp(src.as_ptr(), dst.as_ptr(), 100), 0); - } - } - - #[test] - fn memmove_overlapping() { - { - let mut buffer = [ b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9' ]; - unsafe { - memmove(&mut buffer[4], &buffer[0], 6); - let mut i = 0; - for byte in b"0123012345".iter() { - assert_eq!(buffer[i], *byte); - i += 1; - } - } - } - { - let mut buffer = [ b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9' ]; - unsafe { - memmove(&mut buffer[0], &buffer[4], 6); - let mut i = 0; - for byte in b"4567896789".iter() { - assert_eq!(buffer[i], *byte); - i += 1; - } - } - } - } -} diff --git a/support/target-specs/thumbv7em-none-eabi.json b/thumbv7em-none-eabi.json similarity index 61% rename from support/target-specs/thumbv7em-none-eabi.json rename to thumbv7em-none-eabi.json index 6f3f606d..b81bb8da 100644 --- a/support/target-specs/thumbv7em-none-eabi.json +++ b/thumbv7em-none-eabi.json @@ -9,5 +9,13 @@ "os": "none", "relocation-model": "static", "target-endian": "little", - "target-pointer-width": "32" + "target-pointer-width": "32", + "no-compiler-rt": true, + "pre-link-args": [ + "-mcpu=cortex-m4", "-mthumb", + "-Tlayout.ld" + ], + "post-link-args": [ + "-lm", "-lgcc", "-lnosys" + ] } diff --git a/support/target-specs/thumbv7m-none-eabi.json b/thumbv7m-none-eabi.json similarity index 61% rename from support/target-specs/thumbv7m-none-eabi.json rename to thumbv7m-none-eabi.json index b48770e1..36bbfa58 100644 --- a/support/target-specs/thumbv7m-none-eabi.json +++ b/thumbv7m-none-eabi.json @@ -9,5 +9,13 @@ "os": "none", "relocation-model": "static", "target-endian": "little", - "target-pointer-width": "32" + "target-pointer-width": "32", + "no-compiler-rt": true, + "pre-link-args": [ + "-mcpu=cortex-m3", "-mthumb", + "-Tlayout.ld" + ], + "post-link-args": [ + "-lm", "-lgcc", "-lnosys" + ] }