summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-11-06 16:20:54 -0800
committerElliott Hughes <enh@google.com>2013-11-06 16:33:39 -0800
commit062092543fdbd6fa2676e4f5b37a15f7bba94332 (patch)
tree1363126a8783cca6b0ae3faf7cab2657d1934323
parent7115c80231aa88272294076c8775c09727ece85a (diff)
downloadbionic-062092543fdbd6fa2676e4f5b37a15f7bba94332.zip
bionic-062092543fdbd6fa2676e4f5b37a15f7bba94332.tar.gz
bionic-062092543fdbd6fa2676e4f5b37a15f7bba94332.tar.bz2
Clean up the 32-bit kernel support, fix LP64 fcntl declaration.
In practice, thanks to all the registers the stubs don't actually change, but it's confusing to have an incorrect declaration. I suspect that fcntl remains broken for aarch64; it happens to work for x86_64 because the first vararg argument gets placed in the right register anyway, but I have no reason to believe that's true for aarch64. This patch adds a unit test, though, so we'll be able to tell when we get as far as running the unit tests. Change-Id: I58dd0054fe99d7d51d04c22781d8965dff1afbf3
-rw-r--r--libc/Android.mk10
-rw-r--r--libc/SYSCALLS.TXT5
-rw-r--r--libc/arch-arm/syscalls.mk1
-rw-r--r--libc/arch-arm/syscalls/__fcntl.S16
-rw-r--r--libc/arch-mips/syscalls.mk1
-rw-r--r--libc/arch-mips/syscalls/__fcntl.S23
-rw-r--r--libc/arch-x86/syscalls.mk1
-rw-r--r--libc/arch-x86/syscalls/__fcntl.S28
-rw-r--r--libc/bionic/__get_tls.cpp32
-rw-r--r--libc/bionic/fcntl.c43
-rw-r--r--libc/bionic/fstatfs.c35
-rw-r--r--libc/bionic/legacy_32_bit_support.cpp88
-rw-r--r--libc/bionic/lseek64.c40
-rw-r--r--libc/bionic/ndk_cruft.cpp7
-rw-r--r--libc/bionic/pread.c35
-rw-r--r--libc/bionic/pwrite.c35
-rw-r--r--libc/bionic/statfs.c35
-rw-r--r--tests/Android.mk1
-rw-r--r--tests/fcntl_test.cpp36
19 files changed, 136 insertions, 336 deletions
diff --git a/libc/Android.mk b/libc/Android.mk
index 190272e..b24320d 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -170,17 +170,11 @@ libc_dns_src_files += \
netbsd/resolv/res_state.c \
-# These are shared by all the 32-bit targets, but not the 64-bit ones.
+# These are used by the 32-bit targets, but not the 64-bit ones.
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm mips x86))
libc_common_src_files += \
- bionic/fcntl.c \
- bionic/fstatfs.c \
- bionic/__get_tls.cpp \
- bionic/lseek64.c \
+ bionic/legacy_32_bit_support.cpp \
bionic/ndk_cruft.cpp \
- bionic/pread.c \
- bionic/pwrite.c \
- bionic/statfs.c \
endif
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index ce79e9c..7c15297 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -109,8 +109,8 @@ int mincore(void* start, size_t length, unsigned char* vec) all
int __ioctl:ioctl(int, int, void*) all
int readv(int, const struct iovec*, int) all
int writev(int, const struct iovec*, int) all
-int __fcntl:fcntl(int, int, void*) arm,mips,x86
-int fcntl(int, void*) aarch64,x86_64
+int __fcntl64:fcntl64(int, int, void*) arm,mips,x86
+int fcntl(int, int, void*) aarch64,x86_64
int flock(int, int) all
int fchmod(int, mode_t) all
int dup(int) all
@@ -122,7 +122,6 @@ int fdatasync(int) all
int fchown:fchown32(int, uid_t, gid_t) arm,x86
int fchown:fchown(int, uid_t, gid_t) aarch64,mips,x86_64
void sync(void) all
-int __fcntl64:fcntl64(int, int, void*) arm,mips,x86
int __fstatfs64:fstatfs64(int, size_t, struct statfs*) arm,mips,x86
int fstatfs(int, struct statfs*) aarch64,x86_64
int fsetxattr(int, const char*, const void*, size_t, int) all
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index 9d24a1d..75b6133 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -4,7 +4,6 @@ syscall_src += arch-arm/syscalls/__brk.S
syscall_src += arch-arm/syscalls/__clone.S
syscall_src += arch-arm/syscalls/__epoll_pwait.S
syscall_src += arch-arm/syscalls/__exit.S
-syscall_src += arch-arm/syscalls/__fcntl.S
syscall_src += arch-arm/syscalls/__fcntl64.S
syscall_src += arch-arm/syscalls/__fstatfs64.S
syscall_src += arch-arm/syscalls/__getcpu.S
diff --git a/libc/arch-arm/syscalls/__fcntl.S b/libc/arch-arm/syscalls/__fcntl.S
deleted file mode 100644
index 5479a0f..0000000
--- a/libc/arch-arm/syscalls/__fcntl.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(__fcntl)
- mov ip, r7
- ldr r7, =__NR_fcntl
- swi #0
- mov r7, ip
- cmn r0, #(MAX_ERRNO + 1)
- bxls lr
- neg r0, r0
- b __set_errno
-END(__fcntl)
diff --git a/libc/arch-mips/syscalls.mk b/libc/arch-mips/syscalls.mk
index 6882877..9be6197 100644
--- a/libc/arch-mips/syscalls.mk
+++ b/libc/arch-mips/syscalls.mk
@@ -4,7 +4,6 @@ syscall_src += arch-mips/syscalls/__brk.S
syscall_src += arch-mips/syscalls/__clone.S
syscall_src += arch-mips/syscalls/__epoll_pwait.S
syscall_src += arch-mips/syscalls/__exit.S
-syscall_src += arch-mips/syscalls/__fcntl.S
syscall_src += arch-mips/syscalls/__fcntl64.S
syscall_src += arch-mips/syscalls/__fstatfs64.S
syscall_src += arch-mips/syscalls/__getcpu.S
diff --git a/libc/arch-mips/syscalls/__fcntl.S b/libc/arch-mips/syscalls/__fcntl.S
deleted file mode 100644
index 2288c7e..0000000
--- a/libc/arch-mips/syscalls/__fcntl.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
- .text
- .globl __fcntl
- .align 4
- .ent __fcntl
-
-__fcntl:
- .set noreorder
- .cpload $t9
- li $v0, __NR_fcntl
- syscall
- bnez $a3, 1f
- move $a0, $v0
- j $ra
- nop
-1:
- la $t9,__set_errno
- j $t9
- nop
- .set reorder
- .end __fcntl
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
index ade6d55..70e6e39 100644
--- a/libc/arch-x86/syscalls.mk
+++ b/libc/arch-x86/syscalls.mk
@@ -4,7 +4,6 @@ syscall_src += arch-x86/syscalls/__brk.S
syscall_src += arch-x86/syscalls/__clone.S
syscall_src += arch-x86/syscalls/__epoll_pwait.S
syscall_src += arch-x86/syscalls/__exit.S
-syscall_src += arch-x86/syscalls/__fcntl.S
syscall_src += arch-x86/syscalls/__fcntl64.S
syscall_src += arch-x86/syscalls/__fstatfs64.S
syscall_src += arch-x86/syscalls/__getcpu.S
diff --git a/libc/arch-x86/syscalls/__fcntl.S b/libc/arch-x86/syscalls/__fcntl.S
deleted file mode 100644
index e0d069a..0000000
--- a/libc/arch-x86/syscalls/__fcntl.S
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Generated by gensyscalls.py. Do not edit. */
-
-#include <asm/unistd.h>
-#include <linux/err.h>
-#include <machine/asm.h>
-
-ENTRY(__fcntl)
- pushl %ebx
- pushl %ecx
- pushl %edx
- mov 16(%esp), %ebx
- mov 20(%esp), %ecx
- mov 24(%esp), %edx
- movl $__NR_fcntl, %eax
- int $0x80
- cmpl $-MAX_ERRNO, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %edx
- popl %ecx
- popl %ebx
- ret
-END(__fcntl)
diff --git a/libc/bionic/__get_tls.cpp b/libc/bionic/__get_tls.cpp
deleted file mode 100644
index d01e2aa..0000000
--- a/libc/bionic/__get_tls.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2008 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.
- */
-
-extern "C" void** __get_tls() {
-#include "private/__get_tls.h"
- return __get_tls();
-}
diff --git a/libc/bionic/fcntl.c b/libc/bionic/fcntl.c
deleted file mode 100644
index b49db0a..0000000
--- a/libc/bionic/fcntl.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 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 <stdarg.h>
-#include <errno.h>
-
-extern int __fcntl64(int, int, void *);
-
-int fcntl(int fd, int cmd, ...)
-{
- va_list ap;
- void * arg;
-
- va_start(ap, cmd);
- arg = va_arg(ap, void *);
- va_end(ap);
-
- return __fcntl64(fd, cmd, arg);
-}
diff --git a/libc/bionic/fstatfs.c b/libc/bionic/fstatfs.c
deleted file mode 100644
index 3d7c696..0000000
--- a/libc/bionic/fstatfs.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2010 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/vfs.h>
-
-extern int __fstatfs64(int, size_t, struct statfs *);
-
-int fstatfs(int fd, struct statfs* stat)
-{
- return __fstatfs64(fd, sizeof(struct statfs), stat);
-}
diff --git a/libc/bionic/legacy_32_bit_support.cpp b/libc/bionic/legacy_32_bit_support.cpp
new file mode 100644
index 0000000..884dd8b
--- /dev/null
+++ b/libc/bionic/legacy_32_bit_support.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2008 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 <errno.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/vfs.h>
+#include <sys/vfs.h>
+#include <unistd.h>
+#include <unistd.h>
+
+#if __LP64__
+#error This code is only needed on 32-bit systems!
+#endif
+
+// System calls we need.
+extern "C" int __fcntl64(int, int, void*);
+extern "C" int __fstatfs64(int, size_t, struct statfs*);
+extern "C" int __llseek(int, unsigned long, unsigned long, off64_t*, int);
+extern "C" int __statfs64(const char*, size_t, struct statfs*);
+
+// For fcntl we use the fcntl64 system call to signal that we're using struct flock64.
+int fcntl(int fd, int cmd, ...) {
+ va_list ap;
+
+ va_start(ap, cmd);
+ void* arg = va_arg(ap, void*);
+ va_end(ap);
+
+ return __fcntl64(fd, cmd, arg);
+}
+
+// For fstatfs we need to add the extra argument giving the kernel the size of the buffer.
+int fstatfs(int fd, struct statfs* stat) {
+ return __fstatfs64(fd, sizeof(*stat), stat);
+}
+
+// For statfs we need to add the extra argument giving the kernel the size of the buffer.
+int statfs(const char* path, struct statfs* stat) {
+ return __statfs64(path, sizeof(*stat), stat);
+}
+
+// For lseek64 we need to use the llseek system call which splits the off64_t in two and
+// returns the off64_t result via a pointer because 32-bit kernels can't return 64-bit results.
+off64_t lseek64(int fd, off64_t off, int whence) {
+ off64_t result;
+ unsigned long off_hi = static_cast<unsigned long>(off >> 32);
+ unsigned long off_lo = static_cast<unsigned long>(off);
+ if (__llseek(fd, off_hi, off_lo, &result, whence) < 0) {
+ return -1;
+ }
+ return result;
+}
+
+// There is no pread for 32-bit off_t, so we need to widen and call pread64.
+ssize_t pread(int fd, void* buf, size_t byte_count, off_t offset) {
+ return pread64(fd, buf, byte_count, static_cast<off64_t>(offset));
+}
+
+// There is no pwrite for 32-bit off_t, so we need to widen and call pwrite64.
+ssize_t pwrite(int fd, const void* buf, size_t byte_count, off_t offset) {
+ return pwrite64(fd, buf, byte_count, static_cast<off64_t>(offset));
+}
diff --git a/libc/bionic/lseek64.c b/libc/bionic/lseek64.c
deleted file mode 100644
index c24ae64..0000000
--- a/libc/bionic/lseek64.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2008 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 <unistd.h>
-
-extern int __llseek(int fd, unsigned long offset_hi, unsigned long offset_lo, off64_t* result, int whence);
-
-off64_t lseek64(int fd, off64_t off, int whence) {
- off64_t result;
- if (__llseek(fd, (unsigned long)(off >> 32),(unsigned long)(off), &result, whence) < 0) {
- return -1;
- }
-
- return result;
-}
diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp
index cbdc6e6..3637c3e 100644
--- a/libc/bionic/ndk_cruft.cpp
+++ b/libc/bionic/ndk_cruft.cpp
@@ -48,8 +48,15 @@ extern "C" pid_t __wait4(pid_t pid, int* status, int options, struct rusage* rus
return wait4(pid, status, options, rusage);
}
+// TODO: does anything still need this?
extern "C" int __open() {
abort();
}
+// TODO: does anything still need this?
+extern "C" void** __get_tls() {
+#include "private/__get_tls.h"
+ return __get_tls();
+}
+
#endif
diff --git a/libc/bionic/pread.c b/libc/bionic/pread.c
deleted file mode 100644
index 42fc3bc..0000000
--- a/libc/bionic/pread.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 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/types.h>
-#include <unistd.h>
-
-ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset)
-{
- return pread64(fd, buf, nbytes, (off64_t)offset);
-}
-
diff --git a/libc/bionic/pwrite.c b/libc/bionic/pwrite.c
deleted file mode 100644
index f106cb3..0000000
--- a/libc/bionic/pwrite.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 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/types.h>
-#include <unistd.h>
-
-ssize_t pwrite(int fd, const void *buf, size_t nbytes, off_t offset)
-{
- return pwrite64(fd, buf, nbytes, (off64_t)offset);
-}
-
diff --git a/libc/bionic/statfs.c b/libc/bionic/statfs.c
deleted file mode 100644
index 491ef7a..0000000
--- a/libc/bionic/statfs.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 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/vfs.h>
-
-extern int __statfs64(const char *, size_t, struct statfs *);
-
-int statfs(const char* path, struct statfs* stat)
-{
- return __statfs64(path, sizeof(struct statfs), stat);
-}
diff --git a/tests/Android.mk b/tests/Android.mk
index 3345e3e..ca6a06b 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -60,6 +60,7 @@ test_c_flags = \
test_src_files = \
dirent_test.cpp \
eventfd_test.cpp \
+ fcntl_test.cpp \
fenv_test.cpp \
getauxval_test.cpp \
getcwd_test.cpp \
diff --git a/tests/fcntl_test.cpp b/tests/fcntl_test.cpp
new file mode 100644
index 0000000..a094fac
--- /dev/null
+++ b/tests/fcntl_test.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+#include <errno.h>
+#include <fcntl.h>
+
+TEST(fcntl, fcntl_smoke) {
+ int fd = open("/proc/version", O_RDONLY);
+ ASSERT_TRUE(fd != -1);
+
+ int flags = fcntl(fd, F_GETFD);
+ ASSERT_TRUE(flags != -1);
+ ASSERT_EQ(0, flags & FD_CLOEXEC);
+
+ int rc = fcntl(fd, F_SETFD, FD_CLOEXEC);
+ ASSERT_EQ(0, rc);
+
+ flags = fcntl(fd, F_GETFD);
+ ASSERT_TRUE(flags != -1);
+ ASSERT_EQ(FD_CLOEXEC, flags & FD_CLOEXEC);
+}