Skip to content
This repository has been archived by the owner on Aug 15, 2021. It is now read-only.

Commit

Permalink
Remove libc dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
pyfisch committed Mar 18, 2016
1 parent 057a129 commit beb76e7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "serde_cbor"
version = "0.3.0"
version = "0.3.1"
authors = ["Pyfisch <pyfisch@gmail.com>"]
repository = "https://github.com/pyfisch/cbor"
documentation = "http://pyfisch.github.io/cbor/serde_cbor/index.html"
Expand All @@ -11,7 +11,6 @@ keywords = ["serde", "cbor", "serialization"]

[dependencies]
byteorder = "0.3"
libc = "0.2.6"
serde = "0.7.0"

[features]
Expand Down
17 changes: 2 additions & 15 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,14 @@ impl<R: Read> Deserializer<R> {

#[inline]
fn parse_simple_value<V: Visitor>(&mut self, first: u8, mut visitor: V) -> Result<V::Value> {
// Workaround to not require the currently unstable `f32::ldexp`:
mod ffi {
use libc::c_int;

extern "C" {
pub fn ldexpf(x: f32, exp: c_int) -> f32;
}

#[inline]
pub fn c_ldexpf(x: f32, exp: isize) -> f32 {
unsafe { ldexpf(x, exp as c_int) }
}
}
#[inline]
fn decode_f16(half: u16) -> f32 {
let exp: u16 = half >> 10 & 0x1f;
let mant: u16 = half & 0x3ff;
let val: f32 = if exp == 0 {
ffi::c_ldexpf(mant as f32, -24)
(mant as f32) * (2.0f32).powi(-24)
} else if exp != 31 {
ffi::c_ldexpf(mant as f32 + 1024f32, exp as isize - 25)
(mant as f32 + 1024f32) * (2.0f32).powi(exp as i32 - 25)
} else if mant == 0 {
::std::f32::INFINITY
} else {
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
#![deny(missing_docs)]

extern crate byteorder;
extern crate libc;
extern crate serde;

pub use de::{from_slice, from_reader};
Expand Down

0 comments on commit beb76e7

Please sign in to comment.