Merge "Move libportable from ndk.git to development.git."
This commit is contained in:
@@ -1 +1,3 @@
|
|||||||
# Please this file empty. It is used to make the Android build system happy.
|
# Please this file empty. It is used to make the Android build system happy.
|
||||||
|
|
||||||
|
include development/ndk/sources/android/libportable/Android.mk
|
||||||
|
|||||||
65
ndk/sources/android/libportable/Android.mk
Normal file
65
ndk/sources/android/libportable/Android.mk
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2012 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
#=====================================================================
|
||||||
|
# Device Shared Library libportable
|
||||||
|
#=====================================================================
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_MODULE := libportable
|
||||||
|
LOCAL_MODULE_TAGS := optional
|
||||||
|
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := -I $(LOCAL_PATH)/common/include
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH),mips)
|
||||||
|
libportable_arch_src_files += \
|
||||||
|
arch-mips/ioctl.c \
|
||||||
|
arch-mips/mmap.c \
|
||||||
|
arch-mips/stat.c \
|
||||||
|
arch-mips/open.c \
|
||||||
|
arch-mips/socket.c \
|
||||||
|
arch-mips/sockopt.c \
|
||||||
|
arch-mips/epoll.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH),arm)
|
||||||
|
libportable_arch_src_files += \
|
||||||
|
arch-arm/stat.c \
|
||||||
|
arch-arm/socket.c \
|
||||||
|
arch-arm/sockopt.c \
|
||||||
|
arch-arm/epoll.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(TARGET_ARCH),x86)
|
||||||
|
libportable_arch_src_files += \
|
||||||
|
arch-x86/ioctl.c \
|
||||||
|
arch-x86/stat.c \
|
||||||
|
arch-x86/open.c \
|
||||||
|
arch-x86/socket.c \
|
||||||
|
arch-x86/sockopt.c \
|
||||||
|
arch-x86/fcntl.c \
|
||||||
|
arch-x86/epoll.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_SRC_FILES := \
|
||||||
|
$(libportable_common_src_files) \
|
||||||
|
$(libportable_arch_src_files)
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
28
ndk/sources/android/libportable/arch-arm/epoll.c
Normal file
28
ndk/sources/android/libportable/arch-arm/epoll.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <sys/epoll.h>
|
||||||
|
|
||||||
|
int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
|
||||||
|
{
|
||||||
|
return epoll_ctl(epfd, op, fd, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
|
||||||
|
{
|
||||||
|
return epoll_wait(epfd, events, max, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
23
ndk/sources/android/libportable/arch-arm/socket.c
Normal file
23
ndk/sources/android/libportable/arch-arm/socket.c
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/linux-syscalls.h>
|
||||||
|
|
||||||
|
int socket_portable(int domain, int type, int protocol) {
|
||||||
|
return socket(domain, type, protocol);
|
||||||
|
}
|
||||||
30
ndk/sources/android/libportable/arch-arm/sockopt.c
Normal file
30
ndk/sources/android/libportable/arch-arm/sockopt.c
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
extern int setsockopt(int, int, int, const void *, socklen_t);
|
||||||
|
int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
|
||||||
|
{
|
||||||
|
return setsockopt(s, level, optname, optval, optlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int getsockopt (int, int, int, void *, socklen_t *);
|
||||||
|
int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
|
||||||
|
{
|
||||||
|
return getsockopt(s, level, optname, optval, optlen);
|
||||||
|
}
|
||||||
38
ndk/sources/android/libportable/arch-arm/stat.c
Normal file
38
ndk/sources/android/libportable/arch-arm/stat.c
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <stat_portable.h>
|
||||||
|
|
||||||
|
/* Note: The Portable Header will define stat to stat_portable */
|
||||||
|
int stat_portable(const char *path, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
return stat(path, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstat_portable(int fd, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
return fstat(fd, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lstat_portable(const char *path, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
return lstat(path, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
|
||||||
|
{
|
||||||
|
return fstatat(dirfd, path, s, flags);
|
||||||
|
}
|
||||||
28
ndk/sources/android/libportable/arch-mips/epoll.c
Normal file
28
ndk/sources/android/libportable/arch-mips/epoll.c
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <sys/epoll.h>
|
||||||
|
|
||||||
|
int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event *event)
|
||||||
|
{
|
||||||
|
return epoll_ctl(epfd, op, fd, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
int epoll_wait_portable(int epfd, struct epoll_event *events, int max, int timeout)
|
||||||
|
{
|
||||||
|
return epoll_wait(epfd, events, max, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
56
ndk/sources/android/libportable/arch-mips/ioctl.c
Normal file
56
ndk/sources/android/libportable/arch-mips/ioctl.c
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <stdarg.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <ioctls_portable.h>
|
||||||
|
|
||||||
|
#if FIONREAD_PORTABLE==FIONREAD
|
||||||
|
#error Bad build environment
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int mips_change_request(int request)
|
||||||
|
{
|
||||||
|
/* Only handles FIO* for now */
|
||||||
|
switch(request) {
|
||||||
|
case FIONREAD_PORTABLE:
|
||||||
|
return FIONREAD;
|
||||||
|
case FIONBIO_PORTABLE:
|
||||||
|
return FIONBIO;
|
||||||
|
case FIONCLEX_PORTABLE:
|
||||||
|
return FIONCLEX;
|
||||||
|
case FIOCLEX_PORTABLE:
|
||||||
|
return FIOCLEX;
|
||||||
|
case FIOASYNC_PORTABLE:
|
||||||
|
return FIOASYNC;
|
||||||
|
case FIOQSIZE_PORTABLE:
|
||||||
|
return FIOQSIZE;
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int __ioctl(int, int, void *);
|
||||||
|
int ioctl_portable(int fd, int request, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
void * arg;
|
||||||
|
|
||||||
|
va_start(ap, request);
|
||||||
|
arg = va_arg(ap, void *);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return __ioctl(fd, mips_change_request(request), arg);
|
||||||
|
}
|
||||||
87
ndk/sources/android/libportable/arch-mips/mmap.c
Normal file
87
ndk/sources/android/libportable/arch-mips/mmap.c
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <mman_portable.h>
|
||||||
|
|
||||||
|
#if MAP_ANONYMOUS_PORTABLE==MAP_ANONYMOUS
|
||||||
|
#error Bad build environment
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int mips_change_prot(int prot)
|
||||||
|
{
|
||||||
|
/* Only PROT_SEM is different */
|
||||||
|
if (prot & PROT_SEM_PORTABLE) {
|
||||||
|
prot &= ~PROT_SEM_PORTABLE;
|
||||||
|
prot |= PROT_SEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return prot;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int mips_change_flags(int flags)
|
||||||
|
{
|
||||||
|
int mipsflags = 0;
|
||||||
|
/* These are the documented flags for mmap */
|
||||||
|
if (flags & MAP_SHARED_PORTABLE)
|
||||||
|
mipsflags |= MAP_SHARED;
|
||||||
|
if (flags & MAP_PRIVATE_PORTABLE)
|
||||||
|
mipsflags |= MAP_PRIVATE;
|
||||||
|
#if defined(MAP_32BIT_PORTABLE) && defined(MAP_32BIT)
|
||||||
|
if (flags & MAP_32BIT_PORTABLE)
|
||||||
|
mipsflags |= MAP_32BIT;
|
||||||
|
#endif
|
||||||
|
if (flags & MAP_ANONYMOUS_PORTABLE)
|
||||||
|
mipsflags |= MAP_ANONYMOUS;
|
||||||
|
if (flags & MAP_FIXED_PORTABLE)
|
||||||
|
mipsflags |= MAP_FIXED;
|
||||||
|
if (flags & MAP_GROWSDOWN_PORTABLE)
|
||||||
|
mipsflags |= MAP_GROWSDOWN;
|
||||||
|
#if defined(MAP_HUGETLB_PORTABLE) && defined(MAP_HUGETLB)
|
||||||
|
if (flags & MAP_HUGETLB_PORTABLE)
|
||||||
|
mipsflags |= MAP_HUGETLB;
|
||||||
|
#endif
|
||||||
|
if (flags & MAP_LOCKED_PORTABLE)
|
||||||
|
mipsflags |= MAP_LOCKED;
|
||||||
|
if (flags & MAP_NONBLOCK_PORTABLE)
|
||||||
|
mipsflags |= MAP_NONBLOCK;
|
||||||
|
if (flags & MAP_NORESERVE_PORTABLE)
|
||||||
|
mipsflags |= MAP_NORESERVE;
|
||||||
|
if (flags & MAP_POPULATE_PORTABLE)
|
||||||
|
mipsflags |= MAP_POPULATE;
|
||||||
|
#if defined(MAP_STACK_PORTABLE) && defined(MAP_STACK)
|
||||||
|
if (flags & MAP_STACK_PORTABLE)
|
||||||
|
mipsflags |= MAP_STACK;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return mipsflags;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MMAP2_SHIFT 12
|
||||||
|
extern void *__mmap2(void *, size_t, int, int, int, size_t);
|
||||||
|
void *mmap_portable(void *addr, size_t size, int prot, int flags, int fd, long offset)
|
||||||
|
{
|
||||||
|
if ( offset & ((1UL << MMAP2_SHIFT)-1) ) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return MAP_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return __mmap2(addr, size, mips_change_prot(prot), mips_change_flags(flags),
|
||||||
|
fd, (size_t)offset >> MMAP2_SHIFT);
|
||||||
|
}
|
||||||
78
ndk/sources/android/libportable/arch-mips/open.c
Normal file
78
ndk/sources/android/libportable/arch-mips/open.c
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <fcntl_portable.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if O_CREAT_PORTABLE==O_CREAT
|
||||||
|
#error Bad build environment
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int mips_change_flags(int flags)
|
||||||
|
{
|
||||||
|
int mipsflags = flags & O_ACCMODE_PORTABLE;
|
||||||
|
if (flags & O_CREAT_PORTABLE)
|
||||||
|
mipsflags |= O_CREAT;
|
||||||
|
if (flags & O_EXCL_PORTABLE)
|
||||||
|
mipsflags |= O_EXCL;
|
||||||
|
if (flags & O_NOCTTY_PORTABLE)
|
||||||
|
mipsflags |= O_NOCTTY;
|
||||||
|
if (flags & O_TRUNC_PORTABLE)
|
||||||
|
mipsflags |= O_TRUNC;
|
||||||
|
if (flags & O_APPEND_PORTABLE)
|
||||||
|
mipsflags |= O_APPEND;
|
||||||
|
if (flags & O_NONBLOCK_PORTABLE)
|
||||||
|
mipsflags |= O_NONBLOCK;
|
||||||
|
if (flags & O_SYNC_PORTABLE)
|
||||||
|
mipsflags |= O_SYNC;
|
||||||
|
if (flags & FASYNC_PORTABLE)
|
||||||
|
mipsflags |= FASYNC;
|
||||||
|
if (flags & O_DIRECT_PORTABLE)
|
||||||
|
mipsflags |= O_DIRECT;
|
||||||
|
if (flags & O_LARGEFILE_PORTABLE)
|
||||||
|
mipsflags |= O_LARGEFILE;
|
||||||
|
if (flags & O_DIRECTORY_PORTABLE)
|
||||||
|
mipsflags |= O_DIRECTORY;
|
||||||
|
if (flags & O_NOFOLLOW_PORTABLE)
|
||||||
|
mipsflags |= O_NOFOLLOW;
|
||||||
|
if (flags & O_NOATIME_PORTABLE)
|
||||||
|
mipsflags |= O_NOATIME;
|
||||||
|
if (flags & O_NDELAY_PORTABLE)
|
||||||
|
mipsflags |= O_NDELAY;
|
||||||
|
|
||||||
|
return mipsflags;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int __open(const char*, int, int);
|
||||||
|
int open_portable(const char *pathname, int flags, ...)
|
||||||
|
{
|
||||||
|
mode_t mode = 0;
|
||||||
|
flags |= O_LARGEFILE;
|
||||||
|
|
||||||
|
if (flags & O_CREAT)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, flags);
|
||||||
|
mode = (mode_t) va_arg(args, int);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return __open(pathname, mips_change_flags(flags), mode);
|
||||||
|
}
|
||||||
44
ndk/sources/android/libportable/arch-mips/socket.c
Normal file
44
ndk/sources/android/libportable/arch-mips/socket.c
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/linux-syscalls.h>
|
||||||
|
#include <socket_portable.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if SOCK_STREAM==SOCK_STREAM_PORTABLE
|
||||||
|
#error Bad build environment
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int mips_change_type(int type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case SOCK_STREAM_PORTABLE: return SOCK_STREAM;
|
||||||
|
case SOCK_DGRAM_PORTABLE: return SOCK_DGRAM;
|
||||||
|
case SOCK_RAW_PORTABLE: return SOCK_RAW;
|
||||||
|
case SOCK_RDM_PORTABLE: return SOCK_RDM;
|
||||||
|
case SOCK_SEQPACKET_PORTABLE: return SOCK_SEQPACKET;
|
||||||
|
case SOCK_PACKET_PORTABLE: return SOCK_PACKET;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int socket(int, int, int);
|
||||||
|
|
||||||
|
int socket_portable(int domain, int type, int protocol) {
|
||||||
|
return socket(domain, mips_change_type(type), protocol);
|
||||||
|
}
|
||||||
120
ndk/sources/android/libportable/arch-mips/sockopt.c
Normal file
120
ndk/sources/android/libportable/arch-mips/sockopt.c
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <socket_portable.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if SOL_SOCKET_PORTABLE==SOL_SOCKET
|
||||||
|
#error Build environment
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int mips_change_level(int level)
|
||||||
|
{
|
||||||
|
switch (level) {
|
||||||
|
case SOL_SOCKET_PORTABLE:
|
||||||
|
level = SOL_SOCKET;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int mips_change_optname(int optname)
|
||||||
|
{
|
||||||
|
switch (optname) {
|
||||||
|
case SO_DEBUG_PORTABLE:
|
||||||
|
return SO_DEBUG;
|
||||||
|
case SO_REUSEADDR_PORTABLE:
|
||||||
|
return SO_REUSEADDR;
|
||||||
|
case SO_TYPE_PORTABLE:
|
||||||
|
return SO_TYPE;
|
||||||
|
case SO_ERROR_PORTABLE:
|
||||||
|
return SO_ERROR;
|
||||||
|
case SO_DONTROUTE_PORTABLE:
|
||||||
|
return SO_DONTROUTE;
|
||||||
|
case SO_BROADCAST_PORTABLE:
|
||||||
|
return SO_BROADCAST;
|
||||||
|
case SO_SNDBUF_PORTABLE:
|
||||||
|
return SO_SNDBUF;
|
||||||
|
case SO_RCVBUF_PORTABLE:
|
||||||
|
return SO_RCVBUF;
|
||||||
|
case SO_SNDBUFFORCE_PORTABLE:
|
||||||
|
return SO_SNDBUFFORCE;
|
||||||
|
case SO_RCVBUFFORCE_PORTABLE:
|
||||||
|
return SO_RCVBUFFORCE;
|
||||||
|
case SO_KEEPALIVE_PORTABLE:
|
||||||
|
return SO_KEEPALIVE;
|
||||||
|
case SO_OOBINLINE_PORTABLE:
|
||||||
|
return SO_OOBINLINE;
|
||||||
|
case SO_NO_CHECK_PORTABLE:
|
||||||
|
return SO_NO_CHECK;
|
||||||
|
case SO_PRIORITY_PORTABLE:
|
||||||
|
return SO_PRIORITY;
|
||||||
|
case SO_LINGER_PORTABLE:
|
||||||
|
return SO_LINGER;
|
||||||
|
case SO_BSDCOMPAT_PORTABLE:
|
||||||
|
return SO_BSDCOMPAT;
|
||||||
|
case SO_PASSCRED_PORTABLE:
|
||||||
|
return SO_PASSCRED;
|
||||||
|
case SO_PEERCRED_PORTABLE:
|
||||||
|
return SO_PEERCRED;
|
||||||
|
case SO_RCVLOWAT_PORTABLE:
|
||||||
|
return SO_RCVLOWAT;
|
||||||
|
case SO_SNDLOWAT_PORTABLE:
|
||||||
|
return SO_SNDLOWAT;
|
||||||
|
case SO_RCVTIMEO_PORTABLE:
|
||||||
|
return SO_RCVTIMEO;
|
||||||
|
case SO_SNDTIMEO_PORTABLE:
|
||||||
|
return SO_SNDTIMEO;
|
||||||
|
case SO_SECURITY_AUTHENTICATION_PORTABLE:
|
||||||
|
return SO_SECURITY_AUTHENTICATION;
|
||||||
|
case SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE:
|
||||||
|
return SO_SECURITY_ENCRYPTION_TRANSPORT;
|
||||||
|
case SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE:
|
||||||
|
return SO_SECURITY_ENCRYPTION_NETWORK;
|
||||||
|
case SO_BINDTODEVICE_PORTABLE:
|
||||||
|
return SO_BINDTODEVICE;
|
||||||
|
case SO_ATTACH_FILTER_PORTABLE:
|
||||||
|
return SO_ATTACH_FILTER;
|
||||||
|
case SO_DETACH_FILTER_PORTABLE:
|
||||||
|
return SO_DETACH_FILTER;
|
||||||
|
case SO_PEERNAME_PORTABLE:
|
||||||
|
return SO_PEERNAME;
|
||||||
|
case SO_TIMESTAMP_PORTABLE:
|
||||||
|
return SO_TIMESTAMP;
|
||||||
|
case SO_ACCEPTCONN_PORTABLE:
|
||||||
|
return SO_ACCEPTCONN;
|
||||||
|
case SO_PEERSEC_PORTABLE:
|
||||||
|
return SO_PEERSEC;
|
||||||
|
case SO_PASSSEC_PORTABLE:
|
||||||
|
return SO_PASSSEC;
|
||||||
|
}
|
||||||
|
return optname;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int setsockopt(int, int, int, const void *, socklen_t);
|
||||||
|
int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
|
||||||
|
{
|
||||||
|
return setsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int getsockopt (int, int, int, void *, socklen_t *);
|
||||||
|
int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
|
||||||
|
{
|
||||||
|
return getsockopt(s, mips_change_level(level), mips_change_optname(optname), optval, optlen);
|
||||||
|
}
|
||||||
50
ndk/sources/android/libportable/arch-mips/stat.c
Normal file
50
ndk/sources/android/libportable/arch-mips/stat.c
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <stat_portable.h>
|
||||||
|
|
||||||
|
/* Note: The Portable Header will define stat to stat_portable */
|
||||||
|
int stat_portable(const char *path, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
struct stat mips_stat;
|
||||||
|
int ret = stat(path, &mips_stat);
|
||||||
|
stat_ntop(&mips_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstat_portable(int fd, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
struct stat mips_stat;
|
||||||
|
int ret = fstat(fd, &mips_stat);
|
||||||
|
stat_ntop(&mips_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lstat_portable(const char *path, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
struct stat mips_stat;
|
||||||
|
int ret = lstat(path, &mips_stat);
|
||||||
|
stat_ntop(&mips_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
|
||||||
|
{
|
||||||
|
struct stat mips_stat;
|
||||||
|
int ret = fstatat(dirfd, path, &mips_stat, flags);
|
||||||
|
stat_ntop(&mips_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
40
ndk/sources/android/libportable/arch-x86/epoll.c
Normal file
40
ndk/sources/android/libportable/arch-x86/epoll.c
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <sys/epoll.h>
|
||||||
|
#include <epoll_portable.h>
|
||||||
|
|
||||||
|
int epoll_ctl_portable(int epfd, int op, int fd, struct epoll_event_portable *event)
|
||||||
|
{
|
||||||
|
struct epoll_event x86_epoll_event;
|
||||||
|
|
||||||
|
x86_epoll_event.events = event->events;
|
||||||
|
x86_epoll_event.data = event->data;
|
||||||
|
|
||||||
|
return epoll_ctl(epfd, op, fd, &x86_epoll_event);
|
||||||
|
}
|
||||||
|
|
||||||
|
int epoll_wait_portable(int epfd, struct epoll_event_portable *events, int max, int timeout)
|
||||||
|
{
|
||||||
|
struct epoll_event x86_epoll_event;
|
||||||
|
int ret = epoll_wait(epfd, &x86_epoll_event, max, timeout);
|
||||||
|
|
||||||
|
events->events = x86_epoll_event.events;
|
||||||
|
events->data = x86_epoll_event.data;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
52
ndk/sources/android/libportable/arch-x86/fcntl.c
Normal file
52
ndk/sources/android/libportable/arch-x86/fcntl.c
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <fcntl_portable.h>
|
||||||
|
|
||||||
|
extern int __fcntl64(int, int, void *);
|
||||||
|
|
||||||
|
int fcntl_portable(int fd, int cmd, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
void * arg;
|
||||||
|
|
||||||
|
va_start(ap, cmd);
|
||||||
|
arg = va_arg(ap, void *);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (cmd == F_GETLK64 ||
|
||||||
|
cmd == F_SETLK64 ||
|
||||||
|
cmd == F_SETLKW64) {
|
||||||
|
struct flock64 x86_flock64;
|
||||||
|
int result = __fcntl64(fd, cmd, (void *) &x86_flock64);
|
||||||
|
|
||||||
|
struct flock64_portable * flock64 = (struct flock64_portable *) arg;
|
||||||
|
|
||||||
|
flock64->l_type = x86_flock64.l_type;
|
||||||
|
flock64->l_whence = x86_flock64.l_whence;
|
||||||
|
flock64->l_start = x86_flock64.l_start;
|
||||||
|
flock64->l_len = x86_flock64.l_len;
|
||||||
|
flock64->l_pid = x86_flock64.l_pid;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return __fcntl64(fd, cmd, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
44
ndk/sources/android/libportable/arch-x86/ioctl.c
Normal file
44
ndk/sources/android/libportable/arch-x86/ioctl.c
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <stdarg.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <ioctls_portable.h>
|
||||||
|
|
||||||
|
#if FIOQSIZE_PORTABLE == FIOQSIZE
|
||||||
|
#error Bad build environment
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline int x86_change_request(int request)
|
||||||
|
{
|
||||||
|
if (request == FIOQSIZE_PORTABLE)
|
||||||
|
return FIOQSIZE;
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int __ioctl(int, int, void *);
|
||||||
|
int ioctl_portable(int fd, int request, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
void * arg;
|
||||||
|
|
||||||
|
va_start(ap, request);
|
||||||
|
arg = va_arg(ap, void *);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return __ioctl(fd, x86_change_request(request), arg);
|
||||||
|
}
|
||||||
74
ndk/sources/android/libportable/arch-x86/open.c
Normal file
74
ndk/sources/android/libportable/arch-x86/open.c
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <fcntl_portable.h>
|
||||||
|
|
||||||
|
|
||||||
|
static inline int x86_change_flags(int flags)
|
||||||
|
{
|
||||||
|
int x86flags = flags & O_ACCMODE_PORTABLE;
|
||||||
|
if (flags & O_CREAT_PORTABLE)
|
||||||
|
x86flags |= O_CREAT;
|
||||||
|
if (flags & O_EXCL_PORTABLE)
|
||||||
|
x86flags |= O_EXCL;
|
||||||
|
if (flags & O_NOCTTY_PORTABLE)
|
||||||
|
x86flags |= O_NOCTTY;
|
||||||
|
if (flags & O_TRUNC_PORTABLE)
|
||||||
|
x86flags |= O_TRUNC;
|
||||||
|
if (flags & O_APPEND_PORTABLE)
|
||||||
|
x86flags |= O_APPEND;
|
||||||
|
if (flags & O_NONBLOCK_PORTABLE)
|
||||||
|
x86flags |= O_NONBLOCK;
|
||||||
|
if (flags & O_SYNC_PORTABLE)
|
||||||
|
x86flags |= O_SYNC;
|
||||||
|
if (flags & FASYNC_PORTABLE)
|
||||||
|
x86flags |= FASYNC;
|
||||||
|
if (flags & O_DIRECT_PORTABLE)
|
||||||
|
x86flags |= O_DIRECT;
|
||||||
|
if (flags & O_LARGEFILE_PORTABLE)
|
||||||
|
x86flags |= O_LARGEFILE;
|
||||||
|
if (flags & O_DIRECTORY_PORTABLE)
|
||||||
|
x86flags |= O_DIRECTORY;
|
||||||
|
if (flags & O_NOFOLLOW_PORTABLE)
|
||||||
|
x86flags |= O_NOFOLLOW;
|
||||||
|
if (flags & O_NOATIME_PORTABLE)
|
||||||
|
x86flags |= O_NOATIME;
|
||||||
|
if (flags & O_NDELAY_PORTABLE)
|
||||||
|
x86flags |= O_NDELAY;
|
||||||
|
|
||||||
|
return x86flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int __open(const char*, int, int);
|
||||||
|
int open_portable(const char *pathname, int flags, ...)
|
||||||
|
{
|
||||||
|
mode_t mode = 0;
|
||||||
|
flags |= O_LARGEFILE;
|
||||||
|
|
||||||
|
if (flags & O_CREAT)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
va_start(args, flags);
|
||||||
|
mode = (mode_t) va_arg(args, int);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return __open(pathname, x86_change_flags(flags), mode);
|
||||||
|
}
|
||||||
23
ndk/sources/android/libportable/arch-x86/socket.c
Normal file
23
ndk/sources/android/libportable/arch-x86/socket.c
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/linux-syscalls.h>
|
||||||
|
|
||||||
|
int socket_portable(int domain, int type, int protocol) {
|
||||||
|
return socket(domain, type, protocol);
|
||||||
|
}
|
||||||
30
ndk/sources/android/libportable/arch-x86/sockopt.c
Normal file
30
ndk/sources/android/libportable/arch-x86/sockopt.c
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
extern int setsockopt(int, int, int, const void *, socklen_t);
|
||||||
|
int setsockopt_portable(int s, int level, int optname, const void *optval, socklen_t optlen)
|
||||||
|
{
|
||||||
|
return setsockopt(s, level, optname, optval, optlen);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int getsockopt (int, int, int, void *, socklen_t *);
|
||||||
|
int getsockopt_portable(int s, int level, int optname, void *optval, socklen_t *optlen)
|
||||||
|
{
|
||||||
|
return getsockopt(s, level, optname, optval, optlen);
|
||||||
|
}
|
||||||
50
ndk/sources/android/libportable/arch-x86/stat.c
Normal file
50
ndk/sources/android/libportable/arch-x86/stat.c
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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 <stat_portable.h>
|
||||||
|
|
||||||
|
/* Note: The Portable Header will define stat to stat_portable */
|
||||||
|
int stat_portable(const char *path, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
struct stat x86_stat;
|
||||||
|
int ret = stat(path, &x86_stat);
|
||||||
|
stat_ntop(&x86_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstat_portable(int fd, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
struct stat x86_stat;
|
||||||
|
int ret = fstat(fd, &x86_stat);
|
||||||
|
stat_ntop(&x86_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lstat_portable(const char *path, struct stat_portable *s)
|
||||||
|
{
|
||||||
|
struct stat x86_stat;
|
||||||
|
int ret = lstat(path, &x86_stat);
|
||||||
|
stat_ntop(&x86_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fstatat_portable(int dirfd, const char *path, struct stat_portable *s, int flags)
|
||||||
|
{
|
||||||
|
struct stat x86_stat;
|
||||||
|
int ret = fstatat(dirfd, path, &x86_stat, flags);
|
||||||
|
stat_ntop(&x86_stat, s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _EPOLL_PORTABLE_H_
|
||||||
|
#define _EPOLL_PORTABLE_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GDK's compiler generates paddings to guarantee 8-byte alignment on
|
||||||
|
* struct and 64bit POD types. If compilers on your platform have no such
|
||||||
|
* alignment rule, please use the following struct and convert it into your
|
||||||
|
* native struct form.
|
||||||
|
*/
|
||||||
|
struct epoll_event_portable
|
||||||
|
{
|
||||||
|
unsigned int events;
|
||||||
|
unsigned char __padding[4];
|
||||||
|
epoll_data_t data;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _EPOLL_PORTABLE_H */
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FCNTL_PORTABLE_H_
|
||||||
|
#define _FCNTL_PORTABLE_H_
|
||||||
|
|
||||||
|
/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/fcntl.h */
|
||||||
|
/* NB x86 does not have these and only uses the generic definitions */
|
||||||
|
#define O_DIRECTORY_PORTABLE 040000
|
||||||
|
#define O_NOFOLLOW_PORTABLE 0100000
|
||||||
|
#define O_DIRECT_PORTABLE 0200000
|
||||||
|
#define O_LARGEFILE_PORTABLE 0400000
|
||||||
|
|
||||||
|
/* Derived from development/ndk/platforms/android-3/include/asm-generic/fcntl.h */
|
||||||
|
#define O_ACCMODE_PORTABLE 00000003
|
||||||
|
#define O_RDONLY_PORTABLE 00000000
|
||||||
|
#define O_WRONLY_PORTABLE 00000001
|
||||||
|
#define O_RDWR_PORTABLE 00000002
|
||||||
|
#ifndef O_CREAT_PORTABLE
|
||||||
|
#define O_CREAT_PORTABLE 00000100
|
||||||
|
#endif
|
||||||
|
#ifndef O_EXCL_PORTABLE
|
||||||
|
#define O_EXCL_PORTABLE 00000200
|
||||||
|
#endif
|
||||||
|
#ifndef O_NOCTTY_PORTABLE
|
||||||
|
#define O_NOCTTY_PORTABLE 00000400
|
||||||
|
#endif
|
||||||
|
#ifndef O_TRUNC_PORTABLE
|
||||||
|
#define O_TRUNC_PORTABLE 00001000
|
||||||
|
#endif
|
||||||
|
#ifndef O_APPEND_PORTABLE
|
||||||
|
#define O_APPEND_PORTABLE 00002000
|
||||||
|
#endif
|
||||||
|
#ifndef O_NONBLOCK_PORTABLE
|
||||||
|
#define O_NONBLOCK_PORTABLE 00004000
|
||||||
|
#endif
|
||||||
|
#ifndef O_SYNC_PORTABLE
|
||||||
|
#define O_SYNC_PORTABLE 00010000
|
||||||
|
#endif
|
||||||
|
#ifndef FASYNC_PORTABLE
|
||||||
|
#define FASYNC_PORTABLE 00020000
|
||||||
|
#endif
|
||||||
|
#ifndef O_DIRECT_PORTABLE
|
||||||
|
#define O_DIRECT_PORTABLE 00040000
|
||||||
|
#endif
|
||||||
|
#ifndef O_LARGEFILE_PORTABLE
|
||||||
|
#define O_LARGEFILE_PORTABLE 00100000
|
||||||
|
#endif
|
||||||
|
#ifndef O_DIRECTORY_PORTABLE
|
||||||
|
#define O_DIRECTORY_PORTABLE 00200000
|
||||||
|
#endif
|
||||||
|
#ifndef O_NOFOLLOW_PORTABLE
|
||||||
|
#define O_NOFOLLOW_PORTABLE 00400000
|
||||||
|
#endif
|
||||||
|
#ifndef O_NOATIME_PORTABLE
|
||||||
|
#define O_NOATIME_PORTABLE 01000000
|
||||||
|
#endif
|
||||||
|
#ifndef O_NDELAY_PORTABLE
|
||||||
|
#define O_NDELAY_PORTABLE O_NONBLOCK_PORTABLE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct flock64_portable {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
unsigned char __padding[4];
|
||||||
|
loff_t l_start;
|
||||||
|
loff_t l_len;
|
||||||
|
pid_t l_pid;
|
||||||
|
__ARCH_FLOCK64_PAD
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
The X86 Version is
|
||||||
|
|
||||||
|
struct flock64 {
|
||||||
|
short l_type;
|
||||||
|
short l_whence;
|
||||||
|
loff_t l_start;
|
||||||
|
loff_t l_len;
|
||||||
|
pid_t l_pid;
|
||||||
|
__ARCH_FLOCK64_PAD
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif /* _FCNTL_PORTABLE_H */
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _IOCTLS_PORTABLE_H_
|
||||||
|
#define _IOCTLS_PORTABLE_H_
|
||||||
|
|
||||||
|
/* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/ioctls.h */
|
||||||
|
|
||||||
|
#define TCGETS_PORTABLE 0x5401
|
||||||
|
#define TCSETS_PORTABLE 0x5402
|
||||||
|
#define TCSETSW_PORTABLE 0x5403
|
||||||
|
#define TCSETSF_PORTABLE 0x5404
|
||||||
|
#define TCGETA_PORTABLE 0x5405
|
||||||
|
#define TCSETA_PORTABLE 0x5406
|
||||||
|
#define TCSETAW_PORTABLE 0x5407
|
||||||
|
#define TCSETAF_PORTABLE 0x5408
|
||||||
|
#define TCSBRK_PORTABLE 0x5409
|
||||||
|
#define TCXONC_PORTABLE 0x540A
|
||||||
|
#define TCFLSH_PORTABLE 0x540B
|
||||||
|
#define TIOCEXCL_PORTABLE 0x540C
|
||||||
|
#define TIOCNXCL_PORTABLE 0x540D
|
||||||
|
#define TIOCSCTTY_PORTABLE 0x540E
|
||||||
|
#define TIOCGPGRP_PORTABLE 0x540F
|
||||||
|
#define TIOCSPGRP_PORTABLE 0x5410
|
||||||
|
#define TIOCOUTQ_PORTABLE 0x5411
|
||||||
|
#define TIOCSTI_PORTABLE 0x5412
|
||||||
|
#define TIOCGWINSZ_PORTABLE 0x5413
|
||||||
|
#define TIOCSWINSZ_PORTABLE 0x5414
|
||||||
|
#define TIOCMGET_PORTABLE 0x5415
|
||||||
|
#define TIOCMBIS_PORTABLE 0x5416
|
||||||
|
#define TIOCMBIC_PORTABLE 0x5417
|
||||||
|
#define TIOCMSET_PORTABLE 0x5418
|
||||||
|
#define TIOCGSOFTCAR_PORTABLE 0x5419
|
||||||
|
#define TIOCSSOFTCAR_PORTABLE 0x541A
|
||||||
|
#define FIONREAD_PORTABLE 0x541B
|
||||||
|
#define TIOCINQ_PORTABLE FIONREAD_PORTABLE
|
||||||
|
#define TIOCLINUX_PORTABLE 0x541C
|
||||||
|
#define TIOCCONS_PORTABLE 0x541D
|
||||||
|
#define TIOCGSERIAL_PORTABLE 0x541E
|
||||||
|
#define TIOCSSERIAL_PORTABLE 0x541F
|
||||||
|
#define TIOCPKT_PORTABLE 0x5420
|
||||||
|
#define FIONBIO_PORTABLE 0x5421
|
||||||
|
#define TIOCNOTTY_PORTABLE 0x5422
|
||||||
|
#define TIOCSETD_PORTABLE 0x5423
|
||||||
|
#define TIOCGETD_PORTABLE 0x5424
|
||||||
|
#define TCSBRKP_PORTABLE 0x5425
|
||||||
|
#define TIOCSBRK_PORTABLE 0x5427
|
||||||
|
#define TIOCCBRK_PORTABLE 0x5428
|
||||||
|
#define TIOCGSID_PORTABLE 0x5429
|
||||||
|
//#define TIOCGPTN _IOR('T',0x30, unsigned int)
|
||||||
|
//#define TIOCSPTLCK _IOW('T',0x31, int)
|
||||||
|
|
||||||
|
#define FIONCLEX_PORTABLE 0x5450
|
||||||
|
#define FIOCLEX_PORTABLE 0x5451
|
||||||
|
#define FIOASYNC_PORTABLE 0x5452
|
||||||
|
#define TIOCSERCONFIG_PORTABLE 0x5453
|
||||||
|
#define TIOCSERGWILD_PORTABLE 0x5454
|
||||||
|
#define TIOCSERSWILD_PORTABLE 0x5455
|
||||||
|
#define TIOCGLCKTRMIOS_PORTABLE 0x5456
|
||||||
|
#define TIOCSLCKTRMIOS_PORTABLE 0x5457
|
||||||
|
#define TIOCSERGSTRUCT_PORTABLE 0x5458
|
||||||
|
#define TIOCSERGETLSR_PORTABLE 0x5459
|
||||||
|
#define TIOCSERGETMULTI_PORTABLE 0x545A
|
||||||
|
#define TIOCSERSETMULTI_PORTABLE 0x545B
|
||||||
|
|
||||||
|
#define TIOCMIWAIT_PORTABLE 0x545C
|
||||||
|
#define TIOCGICOUNT_PORTABLE 0x545D
|
||||||
|
#define FIOQSIZE_PORTABLE 0x545E /* x86 differs here */
|
||||||
|
|
||||||
|
#define TIOCPKT_DATA_PORTABLE 0
|
||||||
|
#define TIOCPKT_FLUSHREAD_PORTABLE 1
|
||||||
|
#define TIOCPKT_FLUSHWRITE_PORTABLE 2
|
||||||
|
#define TIOCPKT_STOP_PORTABLE 4
|
||||||
|
#define TIOCPKT_START_PORTABLE 8
|
||||||
|
#define TIOCPKT_NOSTOP_PORTABLE 16
|
||||||
|
#define TIOCPKT_DOSTOP_PORTABLE 32
|
||||||
|
|
||||||
|
#define TIOCSER_TEMT_PORTABLE 0x01
|
||||||
|
|
||||||
|
#endif /* _IOCTLS_PORTABLE_H */
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MMAN_PORTABLE_H_
|
||||||
|
#define _MMAN_PORTABLE_H_
|
||||||
|
|
||||||
|
/* Derived from development/ndk/platforms/android-3/include/asm-generic/mman.h */
|
||||||
|
#define PROT_READ_PORTABLE 0x1
|
||||||
|
#define PROT_WRITE_PORTABLE 0x2
|
||||||
|
#define PROT_EXEC_PORTABLE 0x4
|
||||||
|
#define PROT_SEM_PORTABLE 0x8
|
||||||
|
#define PROT_NONE_PORTABLE 0x0
|
||||||
|
#define PROT_GROWSDOWN_PORTABLE 0x01000000
|
||||||
|
#define PROT_GROWSUP_PORTABLE 0x02000000
|
||||||
|
|
||||||
|
#define MAP_SHARED_PORTABLE 0x01
|
||||||
|
#define MAP_PRIVATE_PORTABLE 0x02
|
||||||
|
#define MAP_TYPE_PORTABLE 0x0f
|
||||||
|
#define MAP_FIXED_PORTABLE 0x10
|
||||||
|
#define MAP_ANONYMOUS_PORTABLE 0x20
|
||||||
|
|
||||||
|
#define MS_ASYNC_PORTABLE 1
|
||||||
|
#define MS_INVALIDATE_PORTABLE 2
|
||||||
|
#define MS_SYNC_PORTABLE 4
|
||||||
|
|
||||||
|
#define MADV_NORMAL_PORTABLE 0
|
||||||
|
#define MADV_RANDOM_PORTABLE 1
|
||||||
|
#define MADV_SEQUENTIAL_PORTABLE 2
|
||||||
|
#define MADV_WILLNEED_PORTABLE 3
|
||||||
|
#define MADV_DONTNEED_PORTABLE 4
|
||||||
|
|
||||||
|
#define MADV_REMOVE_PORTABLE 9
|
||||||
|
#define MADV_DONTFORK_PORTABLE 10
|
||||||
|
#define MADV_DOFORK_PORTABLE 11
|
||||||
|
|
||||||
|
#define MAP_ANON_PORTABLE MAP_ANONYMOUS_PORTABLE
|
||||||
|
#define MAP_FILE_PORTABLE 0
|
||||||
|
|
||||||
|
/* Derived from development/ndk/platforms/android-3/include/asm-generic/mman.h */
|
||||||
|
#define MAP_GROWSDOWN_PORTABLE 0x0100
|
||||||
|
#define MAP_DENYWRITE_PORTABLE 0x0800
|
||||||
|
#define MAP_EXECUTABLE_PORTABLE 0x1000
|
||||||
|
#define MAP_LOCKED_PORTABLE 0x2000
|
||||||
|
#define MAP_NORESERVE_PORTABLE 0x4000
|
||||||
|
#define MAP_POPULATE_PORTABLE 0x8000
|
||||||
|
#define MAP_NONBLOCK_PORTABLE 0x10000
|
||||||
|
|
||||||
|
#define MCL_CURRENT_PORTABLE 1
|
||||||
|
#define MCL_FUTURE_PORTABLE 2
|
||||||
|
|
||||||
|
#endif /* _MMAN_PORTABLE_H */
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SOCKET_PORTABLE_H_
|
||||||
|
#define _SOCKET_PORTABLE_H_
|
||||||
|
|
||||||
|
/* From ndk/platforms/android-3/include/sys/socket.h */
|
||||||
|
#define SOCK_STREAM_PORTABLE 1
|
||||||
|
#define SOCK_DGRAM_PORTABLE 2
|
||||||
|
#define SOCK_RAW_PORTABLE 3
|
||||||
|
#define SOCK_RDM_PORTABLE 4
|
||||||
|
#define SOCK_SEQPACKET_PORTABLE 5
|
||||||
|
#define SOCK_PACKET_PORTABLE 10
|
||||||
|
|
||||||
|
|
||||||
|
/* Derived from android-3/arch-arm/include/asm/socket.h */
|
||||||
|
|
||||||
|
#define SOL_SOCKET_PORTABLE 1
|
||||||
|
|
||||||
|
#define SO_DEBUG_PORTABLE 1
|
||||||
|
#define SO_REUSEADDR_PORTABLE 2
|
||||||
|
#define SO_TYPE_PORTABLE 3
|
||||||
|
#define SO_ERROR_PORTABLE 4
|
||||||
|
#define SO_DONTROUTE_PORTABLE 5
|
||||||
|
#define SO_BROADCAST_PORTABLE 6
|
||||||
|
#define SO_SNDBUF_PORTABLE 7
|
||||||
|
#define SO_RCVBUF_PORTABLE 8
|
||||||
|
#define SO_SNDBUFFORCE_PORTABLE 32
|
||||||
|
#define SO_RCVBUFFORCE_PORTABLE 33
|
||||||
|
#define SO_KEEPALIVE_PORTABLE 9
|
||||||
|
#define SO_OOBINLINE_PORTABLE 10
|
||||||
|
#define SO_NO_CHECK_PORTABLE 11
|
||||||
|
#define SO_PRIORITY_PORTABLE 12
|
||||||
|
#define SO_LINGER_PORTABLE 13
|
||||||
|
#define SO_BSDCOMPAT_PORTABLE 14
|
||||||
|
|
||||||
|
#define SO_PASSCRED_PORTABLE 16
|
||||||
|
#define SO_PEERCRED_PORTABLE 17
|
||||||
|
#define SO_RCVLOWAT_PORTABLE 18
|
||||||
|
#define SO_SNDLOWAT_PORTABLE 19
|
||||||
|
#define SO_RCVTIMEO_PORTABLE 20
|
||||||
|
#define SO_SNDTIMEO_PORTABLE 21
|
||||||
|
|
||||||
|
#define SO_SECURITY_AUTHENTICATION_PORTABLE 22
|
||||||
|
#define SO_SECURITY_ENCRYPTION_TRANSPORT_PORTABLE 23
|
||||||
|
#define SO_SECURITY_ENCRYPTION_NETWORK_PORTABLE 24
|
||||||
|
|
||||||
|
#define SO_BINDTODEVICE_PORTABLE 25
|
||||||
|
|
||||||
|
#define SO_ATTACH_FILTER_PORTABLE 26
|
||||||
|
#define SO_DETACH_FILTER_PORTABLE 27
|
||||||
|
|
||||||
|
#define SO_PEERNAME_PORTABLE 28
|
||||||
|
#define SO_TIMESTAMP_PORTABLE 29
|
||||||
|
#define SCM_TIMESTAMP_PORTABLE SO_TIMESTAMP_PORTABLE
|
||||||
|
|
||||||
|
#define SO_ACCEPTCONN_PORTABLE 30
|
||||||
|
|
||||||
|
#define SO_PEERSEC_PORTABLE 31
|
||||||
|
#define SO_PASSSEC_PORTABLE 34
|
||||||
|
|
||||||
|
#endif /* _SOCKET_PORTABLE_H */
|
||||||
146
ndk/sources/android/libportable/common/include/stat_portable.h
Normal file
146
ndk/sources/android/libportable/common/include/stat_portable.h
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _STAT_PORTABLE_H_
|
||||||
|
#define _STAT_PORTABLE_H_
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* It's easy to change kernel to support stat */
|
||||||
|
struct stat_portable {
|
||||||
|
unsigned long long st_dev;
|
||||||
|
unsigned char __pad0[4];
|
||||||
|
|
||||||
|
unsigned long __st_ino;
|
||||||
|
unsigned int st_mode;
|
||||||
|
unsigned int st_nlink;
|
||||||
|
|
||||||
|
unsigned long st_uid;
|
||||||
|
unsigned long st_gid;
|
||||||
|
|
||||||
|
unsigned long long st_rdev;
|
||||||
|
unsigned char __pad3[4];
|
||||||
|
|
||||||
|
unsigned char __pad4[4];
|
||||||
|
long long st_size;
|
||||||
|
unsigned long st_blksize;
|
||||||
|
unsigned char __pad5[4];
|
||||||
|
unsigned long long st_blocks;
|
||||||
|
|
||||||
|
unsigned long st_atime;
|
||||||
|
unsigned long st_atime_nsec;
|
||||||
|
|
||||||
|
unsigned long st_mtime;
|
||||||
|
unsigned long st_mtime_nsec;
|
||||||
|
|
||||||
|
unsigned long st_ctime;
|
||||||
|
unsigned long st_ctime_nsec;
|
||||||
|
|
||||||
|
unsigned long long st_ino;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
The X86 Version is
|
||||||
|
struct stat {
|
||||||
|
unsigned long long st_dev;
|
||||||
|
unsigned char __pad0[4];
|
||||||
|
|
||||||
|
unsigned long __st_ino;
|
||||||
|
unsigned int st_mode;
|
||||||
|
unsigned int st_nlink;
|
||||||
|
|
||||||
|
unsigned long st_uid;
|
||||||
|
unsigned long st_gid;
|
||||||
|
|
||||||
|
unsigned long long st_rdev;
|
||||||
|
unsigned char __pad3[4];
|
||||||
|
|
||||||
|
long long st_size;
|
||||||
|
unsigned long st_blksize;
|
||||||
|
unsigned long long st_blocks;
|
||||||
|
|
||||||
|
unsigned long st_atime;
|
||||||
|
unsigned long st_atime_nsec;
|
||||||
|
|
||||||
|
unsigned long st_mtime;
|
||||||
|
unsigned long st_mtime_nsec;
|
||||||
|
|
||||||
|
unsigned long st_ctime;
|
||||||
|
unsigned long st_ctime_nsec;
|
||||||
|
|
||||||
|
unsigned long long st_ino;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
The MIPS Version is
|
||||||
|
struct stat {
|
||||||
|
unsigned long st_dev;
|
||||||
|
unsigned long __pad0[3];
|
||||||
|
|
||||||
|
unsigned long long st_ino;
|
||||||
|
|
||||||
|
unsigned int st_mode;
|
||||||
|
unsigned int st_nlink;
|
||||||
|
|
||||||
|
unsigned long st_uid;
|
||||||
|
unsigned long st_gid;
|
||||||
|
|
||||||
|
unsigned long st_rdev;
|
||||||
|
unsigned long __pad1[3];
|
||||||
|
|
||||||
|
long long st_size;
|
||||||
|
|
||||||
|
unsigned long st_atime;
|
||||||
|
unsigned long st_atime_nsec;
|
||||||
|
|
||||||
|
unsigned long st_mtime;
|
||||||
|
unsigned long st_mtime_nsec;
|
||||||
|
|
||||||
|
unsigned long st_ctime;
|
||||||
|
unsigned long st_ctime_nsec;
|
||||||
|
|
||||||
|
unsigned long st_blksize;
|
||||||
|
unsigned long __pad2;
|
||||||
|
|
||||||
|
unsigned long long st_blocks;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline void stat_ntop(struct stat *n_stat, struct stat_portable *p_stat)
|
||||||
|
{
|
||||||
|
memset(p_stat, '\0', sizeof(struct stat_portable));
|
||||||
|
p_stat->st_dev = n_stat->st_dev;
|
||||||
|
p_stat->__st_ino = n_stat->__st_ino;
|
||||||
|
p_stat->st_mode = n_stat->st_mode;
|
||||||
|
p_stat->st_nlink = n_stat->st_nlink;
|
||||||
|
p_stat->st_uid = n_stat->st_uid;
|
||||||
|
p_stat->st_gid = n_stat->st_gid;
|
||||||
|
p_stat->st_rdev = n_stat->st_rdev;
|
||||||
|
p_stat->st_size = n_stat->st_size;
|
||||||
|
p_stat->st_blksize = n_stat->st_blksize;
|
||||||
|
p_stat->st_blocks = n_stat->st_blocks;
|
||||||
|
p_stat->st_atime = n_stat->st_atime;
|
||||||
|
p_stat->st_atime_nsec = n_stat->st_atime_nsec;
|
||||||
|
p_stat->st_mtime = n_stat->st_mtime;
|
||||||
|
p_stat->st_mtime_nsec = n_stat->st_mtime_nsec;
|
||||||
|
p_stat->st_ctime = n_stat->st_ctime;
|
||||||
|
p_stat->st_ctime_nsec = n_stat->st_ctime_nsec;
|
||||||
|
p_stat->st_ino = n_stat->st_ino;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _STAT_PORTABLE_H */
|
||||||
Reference in New Issue
Block a user