rust-lang / libc

Raw bindings to platform APIs for Rust
https://docs.rs/libc
Apache License 2.0
2.07k stars 1.04k forks source link

Match unified NDK headers #641

Closed ndusart closed 5 years ago

ndusart commented 7 years ago

Before Android NDK r14b, each android api version has their own libc headers set which were not totally correct.

Since Android NDK r14b, Google unified the headers so that they apply to all api version (using #ifdef when needed to differentiate between mismatching versions). These new headers are directly taken from the bionic source which was not apparently the case before.

Unfortunately, this crate was based on these not unified headers and contain some incompatibilities with the new correct headers. For now, we manage to update the NDK used to r15b by skipping the tests of the functions and structs that have changed. But ideally, we should update these functions to match the new headers for the next major version of libc.

So, for new symbols, please do not look into $NDK_PATH/platforms/android-xx/arch-arm/usr/include for reference but into $NDK_PATH/sysroot/usr/include as this path contains the new headers.

Here is a list of the changes written in C that we need to cover for the next major release:

alexcrichton commented 7 years ago

Thanks for opening this @ndusart!

roblabla commented 7 years ago

It means we could just keep the stat struct as is and just change the types of _mtime and _nsec to match the nex types and drop the new fields st_atim (without final e) and st_atimensec an alike (without the underscore before nsec) or find a way to present the field with different names.

I think we should just present the same physical layout (a struct with three timespec field) and have people use that. The C #defines are there to keep API compatible. Since we're going to do breaking changes anyway, I think we should just do the "right thing" and ignore those.

gnzlbg commented 5 years ago

This is fixed (or should be) fixed on master.