https://github.com/chipshort/softfloat-c
Automated Rust port of Berkeley SoftFloat 3E
https://github.com/chipshort/softfloat-c
Last synced: about 1 year ago
JSON representation
Automated Rust port of Berkeley SoftFloat 3E
- Host: GitHub
- URL: https://github.com/chipshort/softfloat-c
- Owner: chipshort
- License: other
- Created: 2022-11-07T17:45:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-26T09:19:35.000Z (about 1 year ago)
- Last Synced: 2025-03-26T10:27:13.018Z (about 1 year ago)
- Language: Rust
- Size: 154 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING.txt
Awesome Lists containing this project
README
# SoftFloat 3e
This is a Rust conversion of the [Berkeley SoftFloat Release 3e](https://github.com/ucb-bar/berkeley-softfloat-3) library.
It is a direct translation using [c2rust](https://github.com/immunant/c2rust) with a little automatic cleanup in `transpile.sh`.
This crate is mostly useful in contexts where you cannot link the C library directly, like in WebAssembly.
If this is not a concern for you, take a look at [softfloat-wrapper](https://crates.io/crates/softfloat-wrapper) or [softfloat-sys](https://crates.io/crates/softfloat-sys).
You should probably consider the much better tested manual port [softfloat-pure](https://github.com/HarryR/softfloat-pure)
## Usage
Just add it as a dependency in your `Cargo.toml`:
```toml
[dependencies]
softfloat-c = { git = "https://github.com/chipshort/softfloat-c" }
```
## Code
No manual cleanup has been done. The only hand-written Rust code in this repository is in `src/lib.rs`, which just exports everything else,
and `src/types.rs`, which contains the structs from the C code (like `float32_t`), because `c2rust` generates those separately for every file and that's
very annoying to use.
### Generating latest version
To generate new code, first update the c submodule:
```sh
cd berkeley-softfloat-3
git pull
cd ..
```
For easier dependency management, this repo uses `nix-shell`, so to install all dependencies and transpile the code, just run:
```shell
nix-shell --run ./transpile.sh
```
If you do not have `nix`, just check the dependencies inside `shell.nix`, make sure to install those and then run `./transpile.sh`