ridiculousfish / libdivide

Official git repository for libdivide: optimized integer division
http://libdivide.com
Other
1.09k stars 77 forks source link

Added Low level FFI bindings to Rust #53

Closed thedrow closed 5 years ago

thedrow commented 5 years ago

This allows users to call libdivide's methods from Rust in an unsafe manner.

Higher level API may be added later on demand.

ridiculousfish commented 5 years ago

Can you explain more how this works? Won't the overhead of the FFI dominate any performance benefit from libdivide? libdivide really wants to be inlined.

thedrow commented 5 years ago

I haven't added any documentation since that's additional effort. I just wanted to see if there's demand for this.

rust-bindgen uses LLVM to parse the code and generate the appropriate bindings.

I wasn't sure what's the status on static inline methods since https://github.com/rust-lang/rust-bindgen/pull/1091 was merged but https://github.com/rust-lang/rust-bindgen/issues/1090#issuecomment-365815229 reports that it does not work correctly.

I checked the emitted bindings and it seems that the static inline methods are not exported which is a shame.

I don't believe that Rust's FFI have much overhead. I could be wrong though.

This is still not useful unfortunately. I'm going to close this PR :)