diff options
| author | Po Lu | 2023-08-07 13:01:56 +0800 |
|---|---|---|
| committer | Po Lu | 2023-08-07 13:01:56 +0800 |
| commit | 7fb0248a33dc721ae570c294b04f6da94cd96b10 (patch) | |
| tree | bb817cbfe7343349b424caecb8cae011db7b7a49 /src | |
| parent | fb997c8a8c1cde191986336d3ea83e911b32700b (diff) | |
| download | emacs-7fb0248a33dc721ae570c294b04f6da94cd96b10.tar.gz emacs-7fb0248a33dc721ae570c294b04f6da94cd96b10.zip | |
Port to the Android NDK r10b
* src/androidvfs.c (android_saf_stat, android_saf_file_open)
(android_fstat): Eschew accessing POSIX timespec fields in
struct stat, employing accessors supplied in Gnulib stat-time.h
in their place.
Diffstat (limited to 'src')
| -rw-r--r-- | src/androidvfs.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/androidvfs.c b/src/androidvfs.c index 5afa752163d..4234e337acb 100644 --- a/src/androidvfs.c +++ b/src/androidvfs.c | |||
| @@ -31,6 +31,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
| 32 | #include <sys/mman.h> | 32 | #include <sys/mman.h> |
| 33 | 33 | ||
| 34 | #include <stat-time.h> | ||
| 35 | |||
| 34 | #include <linux/ashmem.h> | 36 | #include <linux/ashmem.h> |
| 35 | 37 | ||
| 36 | #include "android.h" | 38 | #include "android.h" |
| @@ -4011,8 +4013,15 @@ android_saf_stat (const char *uri_name, const char *id_name, | |||
| 4011 | memset (statb, 0, sizeof *statb); | 4013 | memset (statb, 0, sizeof *statb); |
| 4012 | statb->st_size = MAX (0, MIN (TYPE_MAXIMUM (off_t), size)); | 4014 | statb->st_size = MAX (0, MIN (TYPE_MAXIMUM (off_t), size)); |
| 4013 | statb->st_mode = mode; | 4015 | statb->st_mode = mode; |
| 4014 | statb->st_mtim.tv_sec = mtim / 1000; | 4016 | #ifdef STAT_TIMESPEC |
| 4015 | statb->st_mtim.tv_nsec = (mtim % 1000) * 1000000; | 4017 | STAT_TIMESPEC (statb, st_mtim).tv_sec = mtim / 1000; |
| 4018 | STAT_TIMESPEC (statb, st_mtim).tv_nsec = (mtim % 1000) * 1000000; | ||
| 4019 | #else /* !STAT_TIMESPEC */ | ||
| 4020 | /* Headers supplied by the NDK r10b contain a `struct stat' without | ||
| 4021 | POSIX fields for nano-second timestamps. */ | ||
| 4022 | statb->st_mtime = mtim / 1000; | ||
| 4023 | statb->st_mtime_nsec = (mtim % 1000) * 1000000; | ||
| 4024 | #endif /* STAT_TIMESPEC */ | ||
| 4016 | statb->st_uid = getuid (); | 4025 | statb->st_uid = getuid (); |
| 4017 | statb->st_gid = getgid (); | 4026 | statb->st_gid = getgid (); |
| 4018 | return 0; | 4027 | return 0; |
| @@ -5674,7 +5683,7 @@ android_saf_file_open (struct android_vnode *vnode, int flags, | |||
| 5674 | 5683 | ||
| 5675 | if (!android_saf_stat (vp->tree_uri, vp->document_id, | 5684 | if (!android_saf_stat (vp->tree_uri, vp->document_id, |
| 5676 | &statb)) | 5685 | &statb)) |
| 5677 | info->mtime = statb.st_mtim; | 5686 | info->mtime = get_stat_mtime (&statb); |
| 5678 | else | 5687 | else |
| 5679 | info->mtime = invalid_timespec (); | 5688 | info->mtime = invalid_timespec (); |
| 5680 | 5689 | ||
| @@ -6678,7 +6687,12 @@ android_fstat (int fd, struct stat *statb) | |||
| 6678 | if (parcel_fd->fd == fd | 6687 | if (parcel_fd->fd == fd |
| 6679 | && timespec_valid_p (parcel_fd->mtime)) | 6688 | && timespec_valid_p (parcel_fd->mtime)) |
| 6680 | { | 6689 | { |
| 6681 | statb->st_mtim = parcel_fd->mtime; | 6690 | #ifdef STAT_TIMESPEC |
| 6691 | STAT_TIMESPEC (statb, st_mtim) = parcel_fd->mtime; | ||
| 6692 | #else /* !STAT_TIMESPEC */ | ||
| 6693 | statb->st_mtime = parcel_fd->mtime.tv_sec; | ||
| 6694 | statb->st_mtime_nsec = parcel_fd->mtime.tv_nsec; | ||
| 6695 | #endif /* STAT_TIMESPEC */ | ||
| 6682 | break; | 6696 | break; |
| 6683 | } | 6697 | } |
| 6684 | } | 6698 | } |