#bare-metal #libc #unsafe #tiny #stable #newlib

no-std tinyrlibc

Tiny, incomplete C library for bare-metal targets, written in Stable (but Unsafe) Rust

8 releases (4 breaking)

0.5.0 Nov 29, 2024
0.4.0 Mar 22, 2024
0.3.0 Oct 19, 2022
0.2.2 Mar 18, 2022
0.1.2 Sep 1, 2019

#1563 in Embedded development

Download history 66/week @ 2024-08-26 33/week @ 2024-09-16 54/week @ 2024-09-23 17/week @ 2024-09-30 16/week @ 2024-11-18 107/week @ 2024-11-25 39/week @ 2024-12-02

162 downloads per month

Custom license

84KB
2.5K SLoC

Rust 2K SLoC // 0.0% comments C 289 SLoC // 0.4% comments

Tiny Rust libc

Introduction

This is a tiny libc implementation, mostly (but not entirely) written in the Rust programming language. It is useful for bare-metal embedded Rust applications that need a C library (maybe because of some third-party library written in C they want to use) but don't want to link against a full newlib, or who tried but had trouble with both newlib and compiler_builtins defining symbols like memset.

This crate basically came about so that the nrfxlib binary interface library for the nRF9160 would work with Rust.

Implemented so far

  • abs
  • strol
  • atoi
  • isspace
  • isdigit
  • isalpha
  • isupper
  • memchr
  • strcmp
  • strncmp
  • strncasecmp
  • strcat
  • strcpy
  • strncpy
  • strlen
  • strtol
  • strtoll
  • strtoul
  • strtoull
  • strtoimax
  • strtoumax
  • strstr
  • strchr
  • strrchr
  • snprintf
  • vsnprintf
  • qsort
  • rand
  • alloc (optional)
    • malloc
    • calloc
    • realloc
    • free
  • signal (optional)
    • signal
    • raise
    • abort

Non-standard helper functions

  • itoa
  • utoa
  • rand_r

To Do

  • Anything else nrfxlib needs
  • Anything anyone is prepared to submit

Licence

As this is going to be a bunch of bits taken from all over the place (some newlib, some relibc, etc), each function has its own file and each file has its own licence. Any new licences should be appended to the LICENCE.md file.

Dependencies

~0–570KB
~12K SLoC