android: use proper types for dirent.d_ino, dirent.d_off, stat.st_mode and stat64.st_mode #4216
+17
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This bug was noticed in termux/termux-packages#22609
Description
Fixes types for
dirent.d_ino
,dirent.d_off
,stat.st_mode
andstat64.st_mode
on Android.The hardcoded types are incorrect and this PR changes them to how they are declared for Linux. Also fixes the incorrect type errors in termux/termux-packages#22609, where I found the bug (The builds are still failing due to missing
posix_spawn*
support here, but that's a different issue.)This patch should likely also be backported to 0.2.x release, I have the patchset already applied on my other branch. Will link another PR soon.It seems that this patch applies cleanly to libc-0.2 branch, I was backporting to an older release earlier.
@rustbot label stable-nominated
should be it according to CONTRIBUTING.mdSources
mode_t
:mode_t
is defined asunsigned int
on 64-bit android platforms:https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/sys/types.h#64
https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/asm-generic/posix_types.h#18
and is defined as
unsigned short
on 32-bit platforms:https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/i686-linux-android/asm/posix_types_32.h#9
https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/arm-linux-androideabi/asm/posix_types.h#9
off_t
:https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md mentions that
off_t
isi32
on 32-bit andi64
on 64-bitino_t
:https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/dirent.h#64
https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/sys/types.h#70
https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/asm-generic/posix_types.h#14
Due to "historic accident", although
ino_t
isunsigned long
on all platforms, the actual type used isunsigned long
on 64-bit anduint64_t
on 32-bit. I think we should just declareino_t
to be of typeunsigned long
on 64-bit anduint64_t
on 32-bit as that's how code using these types is supposed to be used.Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI
I tried building the tests locally, it seems like the tests are already broken for Android. But I was able to fix some of the issues in [DO NOT MERGE] bump(main/fish): 4.0b1 termux/termux-packages#22609