diff --git a/CHANGELOG.md b/CHANGELOG.md index f71be7c..7f9f066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - +## [0.4.0] - 2026-06-21 + +### Changed + +- Remove the implementations of `strchr`, `strlen`, `strcspn` and `strspn` by default and add the `tinyrlibc` feature to pull them in from `tinyrlibc`. + When updating from an earlier version, enable the `tinyrlibc` feature. + ## [0.3.2] - 2026-02-25 ### Added diff --git a/Cargo.toml b/Cargo.toml index aaa1a6a..ab1b931 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "littlefs2-sys" description = "Low-level bindings to littlefs" -version = "0.3.2" +version = "0.4.0" authors = ["Nicolas Stalder ", "The Trussed Developers"] edition = "2018" license = "BSD-3-Clause" @@ -9,6 +9,9 @@ readme = "README.md" categories = ["embedded", "filesystem", "no-std"] repository = "https://github.com/nickray/littlefs2-sys" +[dependencies] +tinyrlibc = { version = "0.5", default-features = false, features = ["strchr", "strlen", "strcspn", "strspn"], optional = true } + [build-dependencies] bindgen = { version = "0.70.1", default-features = false , features = ["runtime"] } cc = "1" @@ -20,6 +23,10 @@ malloc = [] software-intrinsics = [] multiversion = [] +# littlefs2-sys requires implementations of the strchr, strlen, strcspn and strspn functions. If +# these are not provided by a different source, enable this feature to pull them in from tinyrlibc. +tinyrlibc = ["dep:tinyrlibc"] + # unstable features -- enabling one of the following features may break semantic versioning guarantees # use a patched version of littlefs: https://github.com/trussed-dev/littlefs/releases/tag/v2.9-trussed.1 diff --git a/README.md b/README.md index 809b90f..8b2108d 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,6 @@ Upstream release: [v2.9.3][upstream-release] #### License -littlefs is licensed under [BSD-3-Clause][bsd-3-clause], as are these bindings. -
-The file `string.c` is licensed under GPL-2.0.
-Permissively licensed replacement implementation welcome!
+littlefs is licensed under [BSD-3-Clause][bsd-3-clause], as are these bindings. [bsd-3-clause]: https://github.com/ARMmbed/littlefs/blob/master/LICENSE.md diff --git a/build.rs b/build.rs index 71c0303..f5a7c3c 100644 --- a/build.rs +++ b/build.rs @@ -37,8 +37,7 @@ fn main() -> Result<(), Box> { .include(&out_path) .include(littlefs_path) .file(format!("{littlefs_path}/lfs.c")) - .file(format!("{littlefs_path}/lfs_util.c")) - .file("string.c"); + .file(format!("{littlefs_path}/lfs_util.c")); #[cfg(feature = "software-intrinsics")] let builder = builder.flag("-DLFS_NO_INTRINSICS"); diff --git a/src/lib.rs b/src/lib.rs index 4e4ebb6..0977569 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,4 +2,8 @@ #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] +// We need this extern crate statement to indicate that we want to link against tinyrlibc. +#[cfg(feature = "tinyrlibc")] +extern crate tinyrlibc; + include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/string.c b/string.c deleted file mode 100644 index a2ab96c..0000000 --- a/string.c +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * linux/lib/string.c - * - * Copyright (C) 1991, 1992 Linus Torvalds - */ - -#include - -size_t strspn(const char *s, const char *accept) -{ - const char *p; - const char *a; - size_t count = 0; - - for (p = s; *p != '\0'; ++p) { - for (a = accept; *a != '\0'; ++a) { - if (*p == *a) - break; - } - if (*a == '\0') - return count; - ++count; - } - return count; -} - -size_t strcspn(const char *s, const char *reject) -{ - const char *p; - const char *r; - size_t count = 0; - - for (p = s; *p != '\0'; ++p) { - for (r = reject; *r != '\0'; ++r) { - if (*p == *r) - return count; - } - ++count; - } - return count; -} - -size_t strlen(const char *s) -{ - const char *sc; - - for (sc = s; *sc != '\0'; ++sc) - /* nothing */; - return sc - s; -} - -char *strchr(const char *s, int c) -{ - for (; *s != (char)c; ++s) - if (*s == '\0') - return NULL; - return (char *)s; -}