Skip to content

Commit

Permalink
Undo recent _FILE_OFFSET_BITS=64 changes.
Browse files Browse the repository at this point in the history
We had several bugs filed saying "if I set _FILE_OFFSET_BITS=64 when
targeting an API < L, various functions are missing". Instead of
saying "yes, they are", we quietly just modified the header files to
expose the non-64-bit variants. This makes no sense. We can't just say
"oh, yeah, we don't have a version of this function that agrees with
your calling code about how large off_t is, but here's a version that
doesn't: I'm sure it'll be fine".

_FILE_OFFSET_BITS=64 on Android LP32 has always been a game of chance,
but that game should be "are all the functions my code needs available
at compile time?", not "will my code actually work at run time?".

Bug: android/ndk#442
Bug: android/ndk#333
Bug: android/ndk#332
Bug: android/ndk#324
Test: builds
Change-Id: Ib095251d3e21e77ed50cc3575388107fecec4ecd
  • Loading branch information
enh-google committed Jul 5, 2017
1 parent f45bc14 commit d5b1e4b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion libc/include/bits/lockf.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
__BEGIN_DECLS

#if defined(__USE_FILE_OFFSET64)
int lockf(int, int, off_t) __RENAME(lockf64);
int lockf(int, int, off_t) __RENAME(lockf64) __INTRODUCED_IN(24);
#else
int lockf(int, int, off_t) __INTRODUCED_IN(24);
#endif
Expand Down
12 changes: 6 additions & 6 deletions libc/include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,17 @@ int renameat(int, const char*, int, const char*);
int fseek(FILE*, long, int);
long ftell(FILE*);

#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_N__
int fgetpos(FILE*, fpos_t*) __RENAME(fgetpos64);
int fsetpos(FILE*, const fpos_t*) __RENAME(fsetpos64);
int fseeko(FILE*, off_t, int) __RENAME(fseeko64);
off_t ftello(FILE*) __RENAME(ftello64);
#if defined(__USE_FILE_OFFSET64)
int fgetpos(FILE*, fpos_t*) __RENAME(fgetpos64) __INTRODUCED_IN(24);
int fsetpos(FILE*, const fpos_t*) __RENAME(fsetpos64) __INTRODUCED_IN(24);
int fseeko(FILE*, off_t, int) __RENAME(fseeko64) __INTRODUCED_IN(24);
off_t ftello(FILE*) __RENAME(ftello64) __INTRODUCED_IN(24);
# if defined(__USE_BSD)
FILE* funopen(const void*,
int (*)(void*, char*, int),
int (*)(void*, const char*, int),
fpos_t (*)(void*, fpos_t, int),
int (*)(void*)) __RENAME(funopen64);
int (*)(void*)) __RENAME(funopen64) __INTRODUCED_IN(24);
# endif
#else
int fgetpos(FILE*, fpos_t*);
Expand Down
4 changes: 2 additions & 2 deletions libc/include/sys/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ __BEGIN_DECLS
#define MREMAP_MAYMOVE 1
#define MREMAP_FIXED 2

#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_L__
#if defined(__USE_FILE_OFFSET64)
void* mmap(void*, size_t, int, int, int, off_t) __RENAME(mmap64) __INTRODUCED_IN(21);
#else
void* mmap(void*, size_t, int, int, int, off_t);
Expand Down Expand Up @@ -71,7 +71,7 @@ int madvise(void*, size_t, int);
* Some third-party code uses the existence of POSIX_MADV_NORMAL to detect the
* availability of posix_madvise. This is not correct, since having up-to-date
* UAPI headers says nothing about the C library, but for the time being we
* don't want to harm adoption to the unified headers.
* don't want to harm adoption of the unified headers.
*
* https://github.com/android-ndk/ndk/issues/395
*/
Expand Down
5 changes: 2 additions & 3 deletions libc/include/sys/sendfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@

__BEGIN_DECLS

#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_L__
ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) __RENAME(sendfile64)
__INTRODUCED_IN(21);
#if defined(__USE_FILE_OFFSET64)
ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) __RENAME(sendfile64) __INTRODUCED_IN(21);
#else
ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count);
#endif
Expand Down
4 changes: 2 additions & 2 deletions libc/include/sys/uio.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ ssize_t writev(int, const struct iovec*, int);

#if defined(__USE_GNU)
#if defined(__USE_FILE_OFFSET64)
ssize_t preadv(int, const struct iovec*, int, off_t) __RENAME(preadv64);
ssize_t pwritev(int, const struct iovec*, int, off_t) __RENAME(pwritev64);
ssize_t preadv(int, const struct iovec*, int, off_t) __RENAME(preadv64) __INTRODUCED_IN(24);
ssize_t pwritev(int, const struct iovec*, int, off_t) __RENAME(pwritev64) __INTRODUCED_IN(24);
#else
ssize_t preadv(int, const struct iovec*, int, off_t) __INTRODUCED_IN(24);
ssize_t pwritev(int, const struct iovec*, int, off_t) __INTRODUCED_IN(24);
Expand Down
2 changes: 1 addition & 1 deletion libc/include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ off_t lseek(int __fd, off_t __offset, int __whence);

off64_t lseek64(int __fd, off64_t __offset, int __whence);

#if defined(__USE_FILE_OFFSET64) && __ANDROID_API__ >= __ANDROID_API_L__
#if defined(__USE_FILE_OFFSET64)
int truncate(const char* __path, off_t __length) __RENAME(truncate64) __INTRODUCED_IN(21);
ssize_t pread(int __fd, void* __buf, size_t __count, off_t __offset)
__overloadable __RENAME(pread64) __INTRODUCED_IN(12);
Expand Down

0 comments on commit d5b1e4b

Please sign in to comment.