-
Notifications
You must be signed in to change notification settings - Fork 14
Fix feature dependency #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jonathanpallant
merged 20 commits into
rust-embedded-community:master
from
gmmyung:master
Jan 22, 2024
Merged
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2e69cf6
implemented nedded functions for real
gmmyung b911649
fix feature dependency
gmmyung dcd3453
fix Readme
gmmyung b5dade9
fix typo
gmmyung e977b61
cargo fmt
gmmyung 9a15a8d
fix clippy
gmmyung cabad4a
fix type casting
gmmyung 55e0120
update clippy version
gmmyung 0e65d88
update clippy version to 1.75.0
gmmyung 3af14f5
intermediate change
gmmyung 09766e9
fix c lint error
gmmyung 01a4b0f
fix c lint error 2
gmmyung 52c91a4
use cfg_attr
gmmyung 4f78737
unify all as no_mangle
gmmyung 2ce9ba5
add extern c, add macro to snprintf.c
gmmyung a5eb74b
fmt
gmmyung 25a2d8b
fix build.rs
gmmyung d80876f
fmt
gmmyung 188ab61
remove errno feature
gmmyung 66633f6
Update Cargo.toml - remove duplicate flag
jonathanpallant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,11 +1,30 @@ | ||
fn main() { | ||
if cfg!(feature = "snprintf") { | ||
// Build our snprintf substitute (which has to be C as Rust doesn't do varargs) | ||
cc::Build::new() | ||
let mut build = cc::Build::new(); | ||
|
||
build | ||
.warnings(true) | ||
.extra_warnings(true) | ||
.flag("-std=c99") | ||
.file("./src/snprintf.c") | ||
.compile("clocal"); | ||
.file("./src/snprintf.c"); | ||
|
||
#[cfg(not(feature = "itoa"))] | ||
{ | ||
build.define("itoa", "tinyrlibc_itoa"); | ||
} | ||
#[cfg(not(feature = "utoa"))] | ||
{ | ||
build.define("utoa", "tinyrlibc_utoa"); | ||
} | ||
#[cfg(not(feature = "strtoul"))] | ||
{ | ||
build.define("strtoul", "tinyrlibc_strtoul"); | ||
} | ||
|
||
build.compile("clocal"); | ||
} | ||
|
||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=src/snprintf.c"); | ||
} |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,67 @@ | ||
//! A tiny C library, written in Rust. | ||
//! | ||
//! See README.md for more details. | ||
//! | ||
//! This file is Copyright (c) Jonathan 'theJPster' Pallant 2019 | ||
//! Licensed under the Blue Oak Model Licence 1.0.0 | ||
//! | ||
//! See each module for its respective licence. | ||
|
||
/// `void` | ||
pub type CVoid = ::core::ffi::c_void; | ||
|
||
/// `long long int` | ||
pub type CLongLong = ::core::ffi::c_longlong; | ||
|
||
/// `unsigned long long int` | ||
pub type CULongLong = ::core::ffi::c_ulonglong; | ||
|
||
/// `intmax_t` | ||
pub type CUIntMax = CULongLong; | ||
|
||
/// `uintmax_t` | ||
pub type CIntMax = CLongLong; | ||
|
||
/// `long int` | ||
pub type CLong = ::core::ffi::c_long; | ||
|
||
/// `unsigned long int` | ||
pub type CULong = ::core::ffi::c_ulong; | ||
|
||
/// `int` | ||
pub type CInt = ::core::ffi::c_int; | ||
|
||
/// `unsigned int` | ||
pub type CUInt = ::core::ffi::c_uint; | ||
|
||
/// Represents an 8-bit `char`. Rust does not (and will never) support | ||
/// platforms where `char` is not 8-bits long. | ||
pub type CChar = u8; | ||
|
||
/// This allows you to iterate a null-terminated string in a relatively simple | ||
/// way. | ||
pub struct CStringIter { | ||
ptr: *const CChar, | ||
idx: isize, | ||
} | ||
|
||
impl CStringIter { | ||
/// Create a new iterator from a pointer to a null-terminated string. The | ||
/// behaviour is undefined if the string is not null-terminated. | ||
pub fn new(s: *const CChar) -> CStringIter { | ||
CStringIter { ptr: s, idx: 0 } | ||
} | ||
} | ||
|
||
impl core::iter::Iterator for CStringIter { | ||
type Item = CChar; | ||
fn next(&mut self) -> Option<Self::Item> { | ||
let c = unsafe { *self.ptr.offset(self.idx) }; | ||
if c == 0 { | ||
None | ||
} else { | ||
self.idx += 1; | ||
Some(c) | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.