Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect FFI examples in tutorial #3055

Closed
brson opened this issue Jul 30, 2012 · 1 comment
Closed

Incorrect FFI examples in tutorial #3055

brson opened this issue Jul 30, 2012 · 1 comment
Labels
A-FFI Area: Foreign function interface (FFI)

Comments

@brson
Copy link
Contributor

brson commented Jul 30, 2012

From Florian Weimer:

I went over tutorial and spotted a few typos (see below).

I think the SHA-1 example shouldn't use the static buffer because it
is not task-safe.

More significantly, the gettimeofday example still uses the wrong
types for time_t and suseconds_t. time_t is usually signed and not
always 64 bit (or the size of a machine word). suseconds_t can be a
32-bit type even on 64-bit machines, and the padding is in the wrong
place on big-endian machines. Not sure if rustc already works on
anything besides i386 and amd64 on GNU libc platforms. But even to
support these two, you need this:

type timeval = {mut tv_sec: c_long, mut tv_usec: c_long};

time_t and suseconds_t are two of the most problematic types for FFI.
It's difficult to find structs in POSIX which are essentially fixed.
struct pollfd appears to be one such type, but the example would have
to be larger.

@thestinger
Copy link
Contributor

My rewrite of the tutorial fixed these issues.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 12, 2023
Implement some `llvm.x86.sse2.*` intrinsics and add tests

Continuation of rust-lang/miri#2989 with SSE2 intrinsics.

Thankfully, a significant amount of SSE2 functions use `simd_*` intrinsics, which are already implemented in Miri.
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Dependency upgrade resulting from `cargo update`.

Co-authored-by: tautschnig <1144736+tautschnig@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-FFI Area: Foreign function interface (FFI)
Projects
None yet
Development

No branches or pull requests

2 participants