From a4e774c2bb9b4bddc1dfedf4d6a4db6797f3478f Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 12 Jun 2017 14:59:38 -0700 Subject: [PATCH] Add sys/stat.h compatibility macros for old NDKs. Test: make checkbuild Bug: https://github.com/android-ndk/ndk/issues/417 Change-Id: I04fdb2f31131e87907adab9f3264b783917de542 --- libc/arch-mips64/bionic/stat.cpp | 12 ++++++------ libc/include/sys/stat.h | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libc/arch-mips64/bionic/stat.cpp b/libc/arch-mips64/bionic/stat.cpp index 29a50ed09..63b6cd1bb 100644 --- a/libc/arch-mips64/bionic/stat.cpp +++ b/libc/arch-mips64/bionic/stat.cpp @@ -43,11 +43,11 @@ struct kernel_stat { unsigned int st_pad1[3]; __kernel_off_t st_size; unsigned int _st_atime; - unsigned int st_atime_nsec; + unsigned int _st_atime_nsec; unsigned int _st_mtime; - unsigned int st_mtime_nsec; + unsigned int _st_mtime_nsec; unsigned int _st_ctime; - unsigned int st_ctime_nsec; + unsigned int _st_ctime_nsec; unsigned int st_blksize; unsigned int st_pad2; unsigned long st_blocks; @@ -65,11 +65,11 @@ static void copy_stat(struct stat* st, struct kernel_stat* s) { st->st_blksize = static_cast(s->st_blksize); st->st_blocks = static_cast(s->st_blocks); st->st_atim.tv_sec = static_cast(s->_st_atime); - st->st_atim.tv_nsec = static_cast(s->st_atime_nsec); + st->st_atim.tv_nsec = static_cast(s->_st_atime_nsec); st->st_mtim.tv_sec = static_cast(s->_st_mtime); - st->st_mtim.tv_nsec = static_cast(s->st_mtime_nsec); + st->st_mtim.tv_nsec = static_cast(s->_st_mtime_nsec); st->st_ctim.tv_sec = static_cast(s->_st_ctime); - st->st_ctim.tv_nsec = static_cast(s->st_ctime_nsec); + st->st_ctim.tv_nsec = static_cast(s->_st_ctime_nsec); } int fstat(int fp, struct stat* st) { diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index f8d854d80..47ff5c4cb 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -127,6 +127,10 @@ struct stat64 { __STAT64_BODY }; #define st_atimensec st_atim.tv_nsec #define st_mtimensec st_mtim.tv_nsec #define st_ctimensec st_ctim.tv_nsec +/* Compatibility with Linux headers and old NDKs. */ +#define st_atime_nsec st_atim.tv_nsec +#define st_mtime_nsec st_mtim.tv_nsec +#define st_ctime_nsec st_ctim.tv_nsec #if defined(__USE_BSD) /* Permission macros provided by glibc for compatibility with BSDs. */