Merge "Clean up the 32-bit kernel support, fix LP64 fcntl declaration."
This commit is contained in:
commit
9e63e03d34
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
@ -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
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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)
|
@ -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();
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
88
libc/bionic/legacy_32_bit_support.cpp
Normal file
88
libc/bionic/legacy_32_bit_support.cpp
Normal file
@ -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));
|
||||
}
|
@ -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;
|
||||
}
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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 \
|
||||
|
36
tests/fcntl_test.cpp
Normal file
36
tests/fcntl_test.cpp
Normal file
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user