Check me on this, but I’ve done https://chromium.googlesource.com/chromium/mini_chromium/+/dc3d480305b27a5a1fb57f51a997529e00fed00b in mini_chromium (and Crashpad).
1. _FILE_OFFSET_BITS historically never worked in the NDK.
2. _FILE_OFFSET_BITS now does have an effect in the NDK with unified headers, and it gets a 64-bit off_t where previously only a 32-bit off_t was used.
3. When you do this, the ability to call certain functions is restricted. For example, you can’t mmap() until API 21, because the NDK says that mmap() only knows about 32-bit off_t until then.
The safest thing to do on 32-bit platforms, at least while they’re still using API 16, is to not define _FILE_OFFSET_BITS. It never had any effect with the old NDK headers anyway.
_FILE_OFFSET_BITS doesn’t gain anything on 64-bit platforms even now, where off_t is always 64 bits, so it should be fine to just not define this macro on Android at all.
Bionic:
https://android.googlesource.com/platform/bionic/+/785b249df02434764db052507e956a2655fed0bb/libc/include/sys/mman.h#52
NDK:
https://android.googlesource.com/platform/prebuilts/ndk/+/03d7eb7070391c433cfb814f87fe5e7f09ee81a0/headers/sys/mman.h#52
Note that these give you *no* mmap() declaration if you’re __USE_FILE_OFFSET64 (which you get by defining _FILE_OFFSET_BITS = 64 on a 32-bit platform) and API 16.
Compare that to this previous example <sys/mman.h> prebuilt, which didn’t care about _FILE_OFFSET_BITS and always gave you a 32-bit off_t:
https://android.googlesource.com/platform/prebuilts/ndk/+/03d7eb7070391c433cfb814f87fe5e7f09ee81a0/r13/platforms/android-16/arch-arm/usr/include/sys/mman.h#47
Comment 1 by mark@chromium.org
, Apr 15 2017