-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STD support for the ESP-IDF framework
- Loading branch information
Showing
29 changed files
with
581 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::spec::{LinkerFlavor, PanicStrategy, RelocModel}; | ||
use crate::spec::{Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
data_layout: "e-m:e-p:32:32-i64:64-n32-S128".to_string(), | ||
llvm_target: "riscv32".to_string(), | ||
pointer_width: 32, | ||
arch: "riscv32".to_string(), | ||
|
||
options: TargetOptions { | ||
families: vec!["unix".to_string()], | ||
os: "espidf".to_string(), | ||
env: "newlib".to_string(), | ||
vendor: "espressif".to_string(), | ||
linker_flavor: LinkerFlavor::Gcc, | ||
linker: Some("riscv32-esp-elf-gcc".to_string()), | ||
cpu: "generic-rv32".to_string(), | ||
|
||
// While the RiscV32IMC architecture does not natively support atomics, ESP-IDF does support | ||
// the __atomic* and __sync* GCC builtins, so setting `max_atomic_width` to `Some(32)` | ||
// and `atomic_cas` to `true` will cause the compiler to emit libcalls to these builtins. | ||
// | ||
// Support for atomics is necessary for the Rust STD library, which is supported by the ESP-IDF framework. | ||
max_atomic_width: Some(32), | ||
atomic_cas: true, | ||
|
||
features: "+m,+c".to_string(), | ||
executables: true, | ||
panic_strategy: PanicStrategy::Abort, | ||
relocation_model: RelocModel::Static, | ||
emit_debug_gdb_scripts: false, | ||
eh_frame_header: false, | ||
..Default::default() | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#![stable(feature = "metadata_ext", since = "1.1.0")] | ||
|
||
use crate::fs::Metadata; | ||
use crate::sys_common::AsInner; | ||
|
||
#[allow(deprecated)] | ||
use crate::os::espidf::raw; | ||
|
||
/// OS-specific extensions to [`fs::Metadata`]. | ||
/// | ||
/// [`fs::Metadata`]: crate::fs::Metadata | ||
#[stable(feature = "metadata_ext", since = "1.1.0")] | ||
pub trait MetadataExt { | ||
#[stable(feature = "metadata_ext", since = "1.1.0")] | ||
#[rustc_deprecated( | ||
since = "1.8.0", | ||
reason = "deprecated in favor of the accessor \ | ||
methods of this trait" | ||
)] | ||
#[allow(deprecated)] | ||
fn as_raw_stat(&self) -> &raw::stat; | ||
|
||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_dev(&self) -> u64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_ino(&self) -> u64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_mode(&self) -> u32; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_nlink(&self) -> u64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_uid(&self) -> u32; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_gid(&self) -> u32; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_rdev(&self) -> u64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_size(&self) -> u64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_atime(&self) -> i64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_atime_nsec(&self) -> i64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_mtime(&self) -> i64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_mtime_nsec(&self) -> i64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_ctime(&self) -> i64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_ctime_nsec(&self) -> i64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_blksize(&self) -> u64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_blocks(&self) -> u64; | ||
#[stable(feature = "metadata_ext2", since = "1.8.0")] | ||
fn st_spare4(&self) -> [u32; 2]; | ||
} | ||
|
||
#[stable(feature = "metadata_ext", since = "1.1.0")] | ||
impl MetadataExt for Metadata { | ||
#[allow(deprecated)] | ||
fn as_raw_stat(&self) -> &raw::stat { | ||
unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } | ||
} | ||
fn st_dev(&self) -> u64 { | ||
self.as_inner().as_inner().st_dev as u64 | ||
} | ||
fn st_ino(&self) -> u64 { | ||
self.as_inner().as_inner().st_ino as u64 | ||
} | ||
fn st_mode(&self) -> u32 { | ||
self.as_inner().as_inner().st_mode as u32 | ||
} | ||
fn st_nlink(&self) -> u64 { | ||
self.as_inner().as_inner().st_nlink as u64 | ||
} | ||
fn st_uid(&self) -> u32 { | ||
self.as_inner().as_inner().st_uid as u32 | ||
} | ||
fn st_gid(&self) -> u32 { | ||
self.as_inner().as_inner().st_gid as u32 | ||
} | ||
fn st_rdev(&self) -> u64 { | ||
self.as_inner().as_inner().st_rdev as u64 | ||
} | ||
fn st_size(&self) -> u64 { | ||
self.as_inner().as_inner().st_size as u64 | ||
} | ||
fn st_atime(&self) -> i64 { | ||
self.as_inner().as_inner().st_atime as i64 | ||
} | ||
fn st_atime_nsec(&self) -> i64 { | ||
0 | ||
} | ||
fn st_mtime(&self) -> i64 { | ||
self.as_inner().as_inner().st_mtime as i64 | ||
} | ||
fn st_mtime_nsec(&self) -> i64 { | ||
0 | ||
} | ||
fn st_ctime(&self) -> i64 { | ||
self.as_inner().as_inner().st_ctime as i64 | ||
} | ||
fn st_ctime_nsec(&self) -> i64 { | ||
0 | ||
} | ||
fn st_blksize(&self) -> u64 { | ||
self.as_inner().as_inner().st_blksize as u64 | ||
} | ||
fn st_blocks(&self) -> u64 { | ||
self.as_inner().as_inner().st_blocks as u64 | ||
} | ||
fn st_spare4(&self) -> [u32; 2] { | ||
let spare4 = self.as_inner().as_inner().st_spare4; | ||
[spare4[0] as u32, spare4[1] as u32] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//! Definitions for the ESP-IDF framework. | ||
|
||
#![stable(feature = "raw_ext", since = "1.1.0")] | ||
|
||
pub mod fs; | ||
pub mod raw; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//! Raw type definitions for the ESP-IDF framework. | ||
|
||
#![stable(feature = "raw_ext", since = "1.1.0")] | ||
#![rustc_deprecated( | ||
since = "1.8.0", | ||
reason = "these type aliases are no longer supported by \ | ||
the standard library, the `libc` crate on \ | ||
crates.io should be used instead for the correct \ | ||
definitions" | ||
)] | ||
|
||
use crate::os::raw::c_long; | ||
use crate::os::unix::raw::{gid_t, uid_t}; | ||
|
||
#[stable(feature = "pthread_t", since = "1.8.0")] | ||
pub type pthread_t = libc::pthread_t; | ||
|
||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type blkcnt_t = libc::blkcnt_t; | ||
|
||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type blksize_t = libc::blksize_t; | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type dev_t = libc::dev_t; | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type ino_t = libc::ino_t; | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type mode_t = libc::mode_t; | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type nlink_t = libc::nlink_t; | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type off_t = libc::off_t; | ||
|
||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub type time_t = libc::time_t; | ||
|
||
#[repr(C)] | ||
#[derive(Clone)] | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub struct stat { | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_dev: dev_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_ino: ino_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_mode: mode_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_nlink: nlink_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_uid: uid_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_gid: gid_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_rdev: dev_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_size: off_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_atime: time_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_mtime: time_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_ctime: time_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_blksize: blksize_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_blocks: blkcnt_t, | ||
#[stable(feature = "raw_ext", since = "1.1.0")] | ||
pub st_spare4: [c_long; 2usize], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.