summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-01-29 01:31:58 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-01-29 01:31:59 +0000
commita9c3d0569f3b9511af445457cd455a7bb967b60e (patch)
tree9a1e22ccb5e03fad0e7be544e008fd25faf9fb6d
parent9e82c4be359a4637f21988b66b6d25abbfb79ddb (diff)
parent86d2feef9f4df517dd5755b39b993bec0c3e1ea5 (diff)
downloadbionic-a9c3d0569f3b9511af445457cd455a7bb967b60e.zip
bionic-a9c3d0569f3b9511af445457cd455a7bb967b60e.tar.gz
bionic-a9c3d0569f3b9511af445457cd455a7bb967b60e.tar.bz2
Merge "Modify MIPS64 stat structure to match a generic one in AOSP."
-rw-r--r--libc/SYSCALLS.TXT4
-rw-r--r--libc/arch-mips64/bionic/stat.cpp103
-rw-r--r--libc/arch-mips64/mips64.mk1
-rw-r--r--libc/arch-mips64/syscalls/fstat64.S28
-rw-r--r--libc/arch-mips64/syscalls/fstatat64.S28
-rw-r--r--libc/include/sys/stat.h4
6 files changed, 108 insertions, 60 deletions
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index a648c9f..0fa2a1e 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -134,7 +134,7 @@ int faccessat(int, const char*, int, int) all
int fchmodat(int, const char*, mode_t, int) all
int fchownat(int, const char*, uid_t, gid_t, int) all
int fstatat64|fstatat:fstatat64(int, const char*, struct stat*, int) arm,mips,x86
-int fstatat64|fstatat:newfstatat(int, const char*, struct stat*, int) arm64,mips64,x86_64
+int fstatat64|fstatat:newfstatat(int, const char*, struct stat*, int) arm64,x86_64
int linkat(int, const char*, int, const char*, int) all
int mkdirat(int, const char*, mode_t) all
int mknodat(int, const char*, mode_t, dev_t) all
@@ -179,7 +179,7 @@ int __statfs64:statfs64(const char*, size_t, struct statfs*) arm,mips,x86
int statfs64|statfs:statfs(const char*, struct statfs*) arm64,mips64,x86_64
int fstat64|fstat:fstat64(int, struct stat*) arm,mips,x86
-int fstat64|fstat:fstat(int, struct stat*) arm64,mips64,x86_64
+int fstat64|fstat:fstat(int, struct stat*) arm64,x86_64
# file system
int chdir(const char*) all
diff --git a/libc/arch-mips64/bionic/stat.cpp b/libc/arch-mips64/bionic/stat.cpp
new file mode 100644
index 0000000..df63906
--- /dev/null
+++ b/libc/arch-mips64/bionic/stat.cpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <asm/unistd.h>
+
+struct kernel_stat {
+ unsigned int st_dev;
+ unsigned int st_pad0[3];
+ unsigned long st_ino;
+ mode_t st_mode;
+ __u32 st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned int st_rdev;
+ unsigned int st_pad1[3];
+ __kernel_off_t st_size;
+ unsigned int _st_atime;
+ unsigned int st_atime_nsec;
+ unsigned int _st_mtime;
+ unsigned int st_mtime_nsec;
+ unsigned int _st_ctime;
+ unsigned int st_ctime_nsec;
+ unsigned int st_blksize;
+ unsigned int st_pad2;
+ unsigned long st_blocks;
+};
+
+void copy_stat(struct stat *st, struct kernel_stat *s)
+{
+ st->st_dev = static_cast<dev_t>(s->st_dev);
+ st->st_ino = static_cast<ino_t>(s->st_ino);
+ st->st_mode = static_cast<mode_t>(s->st_mode);
+ st->st_nlink = static_cast<nlink_t>(s->st_nlink);
+ st->st_uid = static_cast<uid_t>(s->st_uid);
+ st->st_gid = static_cast<gid_t>(s->st_gid);
+ st->st_rdev = static_cast<dev_t>(s->st_rdev);
+ st->st_size = static_cast<off_t>(s->st_size);
+ st->st_blksize = static_cast<int>(s->st_blksize);
+ st->st_blocks = static_cast<long>(s->st_blocks);
+ st->st_atim.tv_sec = static_cast<time_t>(s->_st_atime);
+ st->st_atim.tv_nsec = static_cast<long>(s->st_atime_nsec);
+ st->st_mtim.tv_sec = static_cast<time_t>(s->_st_mtime);
+ st->st_mtim.tv_nsec = static_cast<long>(s->st_mtime_nsec);
+ st->st_ctim.tv_sec = static_cast<time_t>(s->_st_ctime);
+ st->st_ctim.tv_nsec = static_cast<long>(s->st_ctime_nsec);
+}
+
+int fstat(int fp, struct stat *st)
+{
+ kernel_stat s;
+ int ret;
+ ret = syscall (__NR_fstat, fp, &s);
+ copy_stat (st, &s);
+ return ret;
+}
+__strong_alias(fstat64, fstat);
+
+int newfstatat(int dirfd, const char *pathname, struct stat *buf, int flags)
+{
+ kernel_stat s;
+ int ret;
+ ret = syscall(__NR_newfstatat, dirfd, pathname, &s, flags);
+ copy_stat(buf, &s);
+ return ret;
+}
+
+int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags)
+{
+ kernel_stat s;
+ int ret;
+ ret = syscall(__NR_newfstatat, dirfd, pathname, &s, flags);
+ copy_stat(buf, &s);
+ return ret;
+}
+__strong_alias(fstatat64, fstatat);
diff --git a/libc/arch-mips64/mips64.mk b/libc/arch-mips64/mips64.mk
index 7990c69..1376395 100644
--- a/libc/arch-mips64/mips64.mk
+++ b/libc/arch-mips64/mips64.mk
@@ -52,6 +52,7 @@ libc_bionic_src_files_mips64 += \
arch-mips64/bionic/setjmp.S \
arch-mips64/bionic/syscall.S \
arch-mips64/bionic/vfork.S \
+ arch-mips64/bionic/stat.cpp \
libc_crt_target_cflags_mips64 := \
$($(my_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \
diff --git a/libc/arch-mips64/syscalls/fstat64.S b/libc/arch-mips64/syscalls/fstat64.S
deleted file mode 100644
index a14d51c..0000000
--- a/libc/arch-mips64/syscalls/fstat64.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(fstat64)
- .set push
- .set noreorder
- li v0, __NR_fstat
- syscall
- bnez a3, 1f
- move a0, v0
- j ra
- nop
-1:
- move t0, ra
- bal 2f
- nop
-2:
- .cpsetup ra, t1, 2b
- LA t9,__set_errno_internal
- .cpreturn
- j t9
- move ra, t0
- .set pop
-END(fstat64)
-
- .globl fstat
- .equ fstat, fstat64
diff --git a/libc/arch-mips64/syscalls/fstatat64.S b/libc/arch-mips64/syscalls/fstatat64.S
deleted file mode 100644
index 7888a43..0000000
--- a/libc/arch-mips64/syscalls/fstatat64.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <private/bionic_asm.h>
-
-ENTRY(fstatat64)
- .set push
- .set noreorder
- li v0, __NR_newfstatat
- syscall
- bnez a3, 1f
- move a0, v0
- j ra
- nop
-1:
- move t0, ra
- bal 2f
- nop
-2:
- .cpsetup ra, t1, 2b
- LA t9,__set_errno_internal
- .cpreturn
- j t9
- move ra, t0
- .set pop
-END(fstatat64)
-
- .globl fstatat
- .equ fstatat, fstatat64
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index 7017865..eb9bf2e 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -36,7 +36,7 @@
__BEGIN_DECLS
-#if defined(__aarch64__)
+#if defined(__aarch64__) || (defined(__mips__) && defined(__LP64__))
#define __STAT64_BODY \
dev_t st_dev; \
ino_t st_ino; \
@@ -56,7 +56,7 @@ __BEGIN_DECLS
unsigned int __unused4; \
unsigned int __unused5; \
-#elif defined(__mips__) /* and mips64 */
+#elif defined(__mips__) && !defined(__LP64__)
#define __STAT64_BODY \
unsigned int st_dev; \
unsigned int __pad0[3]; \