Compare commits
123 Commits
android-2.
...
android-2.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7bbd4580af | ||
![]() |
1df986c21e | ||
![]() |
d3f0638aee | ||
![]() |
1aa6708cc2 | ||
![]() |
b8d2233e8a | ||
![]() |
bb5581ad6e | ||
![]() |
5b81b91817 | ||
![]() |
af00228b70 | ||
![]() |
defd162212 | ||
![]() |
9973a56422 | ||
![]() |
a3ae60d343 | ||
![]() |
307aadb847 | ||
![]() |
79260746db | ||
![]() |
032a713549 | ||
![]() |
223ddfcfc4 | ||
![]() |
9df22a5a5f | ||
![]() |
ce2ebf8d73 | ||
![]() |
bd8d987b3c | ||
![]() |
80fba9a2fe | ||
![]() |
00eea3f8a0 | ||
![]() |
275cd48511 | ||
![]() |
f33a7700a5 | ||
![]() |
b9e49ad56e | ||
![]() |
fedbcde6ef | ||
![]() |
cb99ab98c9 | ||
![]() |
6e42398dd6 | ||
![]() |
e44cb1a35c | ||
![]() |
cc6b182910 | ||
![]() |
e77d54d98a | ||
![]() |
6a51defa03 | ||
![]() |
22f1e3d4fa | ||
![]() |
a716190241 | ||
![]() |
52e7d3d91a | ||
![]() |
18c5bcc66a | ||
![]() |
7ed132a1ae | ||
![]() |
cd7014fd06 | ||
![]() |
6774809b62 | ||
![]() |
9d1f5afc34 | ||
![]() |
b97c44dc9e | ||
![]() |
cb7e8c5ef3 | ||
![]() |
ab8b54101e | ||
![]() |
d466780c7c | ||
![]() |
519763265e | ||
![]() |
a02b93bd75 | ||
![]() |
0621a279ad | ||
![]() |
fa5755ae98 | ||
![]() |
21baae3d71 | ||
![]() |
50ace4fec5 | ||
![]() |
6a9b888d7c | ||
![]() |
6a09cfd9f9 | ||
![]() |
3527fd6f0d | ||
![]() |
a24bc688c0 | ||
![]() |
da3019b553 | ||
![]() |
ecb6d41334 | ||
![]() |
6c8a2f2a5b | ||
![]() |
8bff9a31aa | ||
![]() |
038fbae518 | ||
![]() |
9205fdf8c6 | ||
![]() |
2beac0f5c6 | ||
![]() |
20783c1428 | ||
![]() |
410b2ae7fb | ||
![]() |
506b13d910 | ||
![]() |
b8e6c50cfa | ||
![]() |
aa4b1d0429 | ||
![]() |
6304d8b218 | ||
![]() |
a8a2148863 | ||
![]() |
7b6e6fa572 | ||
![]() |
f982f03832 | ||
![]() |
fcd00ebbdf | ||
![]() |
4fdbadde92 | ||
![]() |
78c1c04ced | ||
![]() |
8a1d2cf142 | ||
![]() |
8e1ee7fd01 | ||
![]() |
a910abcd19 | ||
![]() |
fdf2454db2 | ||
![]() |
1297428e89 | ||
![]() |
4aef0ae660 | ||
![]() |
e4fa46e75c | ||
![]() |
f439445830 | ||
![]() |
bb7928ccda | ||
![]() |
c3581dc78a | ||
![]() |
7911e057a5 | ||
![]() |
16b59c4c38 | ||
![]() |
6ba5efd59a | ||
![]() |
161232820c | ||
![]() |
051ea9bc07 | ||
![]() |
4fd42c1dc0 | ||
![]() |
d791da7943 | ||
![]() |
c1f8dd9f0b | ||
![]() |
f450fa5f99 | ||
![]() |
0be7eda75a | ||
![]() |
716e06071a | ||
![]() |
3472348067 | ||
![]() |
5751c54bf1 | ||
![]() |
c8a850bcd1 | ||
![]() |
6aed4288eb | ||
![]() |
e734769276 | ||
![]() |
5ef5272be9 | ||
![]() |
95faecefde | ||
![]() |
1698d9ebfc | ||
![]() |
f1cd18bdec | ||
![]() |
81569aa72c | ||
![]() |
1d168621a5 | ||
![]() |
d046725133 | ||
![]() |
5ffedb22c8 | ||
![]() |
350bb359fa | ||
![]() |
f8916e2e45 | ||
![]() |
4ad72f89b1 | ||
![]() |
3cab22c8cf | ||
![]() |
8ab5b02b5f | ||
![]() |
87ae0da817 | ||
![]() |
62ac0dc457 | ||
![]() |
3f61212781 | ||
![]() |
acdb052030 | ||
![]() |
8ff1a2759a | ||
![]() |
58f0326362 | ||
![]() |
bdc6e3c83f | ||
![]() |
9bcb91a212 | ||
![]() |
1d7a8944d8 | ||
![]() |
aba3ee7d32 | ||
![]() |
72d3489612 | ||
![]() |
fb02ec25e9 | ||
![]() |
c22da7ed32 |
@@ -14,6 +14,11 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
ifneq ($(TARGET_SIMULATOR),true)
|
||||
include $(call all-subdir-makefiles)
|
||||
else
|
||||
# The host dalvikvm needs Android's concatenated & indexed timezone data.
|
||||
include $(LOCAL_PATH)/libc/zoneinfo/Android.mk
|
||||
endif
|
||||
|
10
ThirdPartyProject.prop
Normal file
10
ThirdPartyProject.prop
Normal file
@@ -0,0 +1,10 @@
|
||||
# Copyright 2010 Google Inc. All Rights Reserved.
|
||||
#Fri Jul 16 10:03:08 PDT 2010
|
||||
currentVersion=Unknown
|
||||
version=Unknown
|
||||
isNative=true
|
||||
feedurl=http\://www.openbsd.org/security.html
|
||||
name=openbsd
|
||||
keywords=openbsd
|
||||
onDevice=true
|
||||
homepage=http\://openbsd.org
|
129
libc/Android.mk
129
libc/Android.mk
@@ -11,9 +11,11 @@ libc_common_src_files := \
|
||||
unistd/brk.c \
|
||||
unistd/creat.c \
|
||||
unistd/daemon.c \
|
||||
unistd/eventfd.c \
|
||||
unistd/exec.c \
|
||||
unistd/fcntl.c \
|
||||
unistd/fnmatch.c \
|
||||
unistd/fstatfs.c \
|
||||
unistd/ftime.c \
|
||||
unistd/ftok.c \
|
||||
unistd/getcwd.c \
|
||||
@@ -63,7 +65,6 @@ libc_common_src_files := \
|
||||
unistd/sleep.c \
|
||||
unistd/statfs.c \
|
||||
unistd/strsignal.c \
|
||||
unistd/sysconf.c \
|
||||
unistd/syslog.c \
|
||||
unistd/system.c \
|
||||
unistd/tcgetpgrp.c \
|
||||
@@ -175,7 +176,6 @@ libc_common_src_files := \
|
||||
stdlib/tolower_.c \
|
||||
stdlib/toupper_.c \
|
||||
stdlib/wchar.c \
|
||||
string/bcopy.c \
|
||||
string/index.c \
|
||||
string/memccpy.c \
|
||||
string/memchr.c \
|
||||
@@ -186,7 +186,6 @@ libc_common_src_files := \
|
||||
string/strcasestr.c \
|
||||
string/strcat.c \
|
||||
string/strchr.c \
|
||||
string/strcmp.c \
|
||||
string/strcoll.c \
|
||||
string/strcpy.c \
|
||||
string/strcspn.c \
|
||||
@@ -196,7 +195,6 @@ libc_common_src_files := \
|
||||
string/strlcat.c \
|
||||
string/strlcpy.c \
|
||||
string/strncat.c \
|
||||
string/strncmp.c \
|
||||
string/strncpy.c \
|
||||
string/strndup.c \
|
||||
string/strnlen.c \
|
||||
@@ -208,6 +206,35 @@ libc_common_src_files := \
|
||||
string/strtok.c \
|
||||
string/strtotimeval.c \
|
||||
string/strxfrm.c \
|
||||
wchar/wcpcpy.c \
|
||||
wchar/wcpncpy.c \
|
||||
wchar/wcscasecmp.c \
|
||||
wchar/wcscat.c \
|
||||
wchar/wcschr.c \
|
||||
wchar/wcscmp.c \
|
||||
wchar/wcscoll.c \
|
||||
wchar/wcscpy.c \
|
||||
wchar/wcscspn.c \
|
||||
wchar/wcsdup.c \
|
||||
wchar/wcslcat.c \
|
||||
wchar/wcslcpy.c \
|
||||
wchar/wcslen.c \
|
||||
wchar/wcsncasecmp.c \
|
||||
wchar/wcsncat.c \
|
||||
wchar/wcsncmp.c \
|
||||
wchar/wcsncpy.c \
|
||||
wchar/wcsnlen.c \
|
||||
wchar/wcspbrk.c \
|
||||
wchar/wcsrchr.c \
|
||||
wchar/wcsspn.c \
|
||||
wchar/wcsstr.c \
|
||||
wchar/wcstok.c \
|
||||
wchar/wcswidth.c \
|
||||
wchar/wmemchr.c \
|
||||
wchar/wmemcmp.c \
|
||||
wchar/wmemcpy.c \
|
||||
wchar/wmemmove.c \
|
||||
wchar/wmemset.c \
|
||||
inet/bindresvport.c \
|
||||
inet/inet_addr.c \
|
||||
inet/inet_aton.c \
|
||||
@@ -219,7 +246,6 @@ libc_common_src_files := \
|
||||
tzcode/localtime.c \
|
||||
tzcode/strftime.c \
|
||||
tzcode/strptime.c \
|
||||
bionic/__errno.c \
|
||||
bionic/__set_errno.c \
|
||||
bionic/_rand48.c \
|
||||
bionic/cpuacct.c \
|
||||
@@ -288,11 +314,27 @@ libc_common_src_files := \
|
||||
regex/regexec.c \
|
||||
regex/regfree.c \
|
||||
|
||||
# The following files are common, but must be compiled
|
||||
# with different C flags when building a static C library.
|
||||
#
|
||||
# The reason for this is the implementation of __get_tls()
|
||||
# that will differ between the shared and static versions
|
||||
# of the library.
|
||||
#
|
||||
# See comments in private/bionic_tls.h for more details.
|
||||
#
|
||||
# NOTE: bionic/pthread.c is added later to this list
|
||||
# because it needs special handling on ARM, see
|
||||
# below.
|
||||
#
|
||||
libc_static_common_src_files := \
|
||||
unistd/sysconf.c \
|
||||
bionic/__errno.c \
|
||||
|
||||
# Architecture specific source files go here
|
||||
# =========================================================
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
libc_common_src_files += \
|
||||
bionic/eabi.c \
|
||||
bionic/bionic_clone.c \
|
||||
arch-arm/bionic/__get_pc.S \
|
||||
arch-arm/bionic/__get_sp.S \
|
||||
@@ -300,6 +342,7 @@ libc_common_src_files += \
|
||||
arch-arm/bionic/_setjmp.S \
|
||||
arch-arm/bionic/atomics_arm.S \
|
||||
arch-arm/bionic/clone.S \
|
||||
arch-arm/bionic/eabi.c \
|
||||
arch-arm/bionic/ffs.S \
|
||||
arch-arm/bionic/kill.S \
|
||||
arch-arm/bionic/libgcc_compat.c \
|
||||
@@ -313,16 +356,22 @@ libc_common_src_files += \
|
||||
arch-arm/bionic/strlen.c.arm \
|
||||
arch-arm/bionic/syscall.S \
|
||||
string/memmove.c.arm \
|
||||
string/bcopy.c \
|
||||
string/strcmp.c \
|
||||
string/strncmp.c \
|
||||
unistd/socketcalls.c
|
||||
|
||||
# These files need to be arm so that gdbserver
|
||||
# can set breakpoints in them without messing
|
||||
# up any thumb code.
|
||||
libc_common_src_files += \
|
||||
bionic/pthread.c.arm \
|
||||
bionic/pthread-rwlocks.c.arm \
|
||||
bionic/pthread-timers.c.arm \
|
||||
bionic/ptrace.c.arm
|
||||
|
||||
libc_static_common_src_files += \
|
||||
bionic/pthread.c.arm \
|
||||
|
||||
# these are used by the static and dynamic versions of the libc
|
||||
# respectively
|
||||
libc_arch_static_src_files := \
|
||||
@@ -344,16 +393,22 @@ libc_common_src_files += \
|
||||
arch-x86/bionic/_setjmp.S \
|
||||
arch-x86/bionic/vfork.S \
|
||||
arch-x86/bionic/syscall.S \
|
||||
arch-x86/string/bzero.S \
|
||||
arch-x86/string/memset.S \
|
||||
arch-x86/string/memcmp.S \
|
||||
arch-x86/string/memcpy.S \
|
||||
arch-x86/string/bcopy_wrapper.S \
|
||||
arch-x86/string/memcpy_wrapper.S \
|
||||
arch-x86/string/memmove_wrapper.S \
|
||||
arch-x86/string/bzero_wrapper.S \
|
||||
arch-x86/string/memcmp_wrapper.S \
|
||||
arch-x86/string/memset_wrapper.S \
|
||||
arch-x86/string/strcmp_wrapper.S \
|
||||
arch-x86/string/strncmp_wrapper.S \
|
||||
arch-x86/string/strlen.S \
|
||||
string/memmove.c \
|
||||
bionic/pthread.c \
|
||||
bionic/pthread-rwlocks.c \
|
||||
bionic/pthread-timers.c \
|
||||
bionic/ptrace.c
|
||||
|
||||
libc_static_common_src_files += \
|
||||
bionic/pthread.c \
|
||||
|
||||
# this is needed for static versions of libc
|
||||
libc_arch_static_src_files := \
|
||||
arch-x86/bionic/dl_iterate_phdr_static.c
|
||||
@@ -381,13 +436,19 @@ libc_common_src_files += \
|
||||
arch-sh/bionic/__set_tls.c \
|
||||
arch-sh/bionic/__get_tls.c \
|
||||
arch-sh/bionic/ffs.S \
|
||||
string/bcopy.c \
|
||||
string/strcmp.c \
|
||||
string/strncmp.c \
|
||||
string/memcmp.c \
|
||||
string/strlen.c \
|
||||
bionic/eabi.c \
|
||||
bionic/pthread.c \
|
||||
bionic/pthread-rwlocks.c \
|
||||
bionic/pthread-timers.c \
|
||||
bionic/ptrace.c \
|
||||
unistd/socketcalls.c
|
||||
|
||||
libc_static_common_src_files += \
|
||||
bionic/pthread.c \
|
||||
|
||||
endif # sh
|
||||
|
||||
endif # !x86
|
||||
@@ -403,7 +464,6 @@ libc_common_cflags := \
|
||||
-D_LIBC=1 \
|
||||
-DSOFTFLOAT \
|
||||
-DFLOATING_POINT \
|
||||
-DNEED_PSELECT=1 \
|
||||
-DINET6 \
|
||||
-I$(LOCAL_PATH)/private \
|
||||
-DUSE_DL_PREFIX \
|
||||
@@ -437,9 +497,25 @@ ifeq ($(TARGET_ARCH),arm)
|
||||
else # !arm
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
libc_crt_target_cflags := -m32
|
||||
|
||||
# Enable recent IA friendly memory routines (such as for Atom)
|
||||
# These will not work on the earlier x86 machines
|
||||
libc_common_cflags += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2
|
||||
endif # x86
|
||||
endif # !arm
|
||||
|
||||
# Define ANDROID_SMP appropriately.
|
||||
ifeq ($(TARGET_CPU_SMP),true)
|
||||
libc_common_cflags += -DANDROID_SMP=1
|
||||
else
|
||||
libc_common_cflags += -DANDROID_SMP=0
|
||||
endif
|
||||
|
||||
# Needed to access private/__dso_handle.S from
|
||||
# crtbegin_xxx.S and crtend_xxx.S
|
||||
#
|
||||
libc_crt_target_cflags += -I$(LOCAL_PATH)/private
|
||||
|
||||
# Define some common includes
|
||||
# ========================================================
|
||||
libc_common_c_includes := \
|
||||
@@ -453,10 +529,17 @@ libc_common_c_includes := \
|
||||
# executables)
|
||||
# ==========================================================================
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
# we only need begin_so/end_so for x86, since it needs an appropriate .init
|
||||
# section in the shared library with a function to call all the entries in
|
||||
# .ctors section. ARM uses init_array, and does not need the function.
|
||||
ifneq ($(filter arm x86,$(TARGET_ARCH)),)
|
||||
# ARM and x86 need crtbegin_so/crtend_so.
|
||||
#
|
||||
# For x86, the .init section must point to a function that calls all
|
||||
# entries in the .ctors section. (on ARM this is done through the
|
||||
# .init_array section instead).
|
||||
#
|
||||
# For both platforms, the .fini_array section must point to a function
|
||||
# that will call __cxa_finalize(&__dso_handle) in order to ensure that
|
||||
# static C++ destructors are properly called on dlclose().
|
||||
#
|
||||
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
|
||||
$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
|
||||
@mkdir -p $(dir $@)
|
||||
@@ -525,10 +608,12 @@ include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(libc_arch_static_src_files) \
|
||||
$(libc_static_common_src_files) \
|
||||
bionic/libc_init_static.c
|
||||
|
||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||
LOCAL_CFLAGS := $(libc_common_cflags)
|
||||
LOCAL_CFLAGS := $(libc_common_cflags) \
|
||||
-DLIBC_STATIC
|
||||
|
||||
LOCAL_MODULE := libc_nomalloc
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
|
||||
@@ -544,6 +629,7 @@ include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(libc_arch_static_src_files) \
|
||||
$(libc_static_common_src_files) \
|
||||
bionic/dlmalloc.c \
|
||||
bionic/malloc_debug_common.c \
|
||||
bionic/libc_init_static.c
|
||||
@@ -568,6 +654,7 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
$(libc_arch_dynamic_src_files) \
|
||||
$(libc_static_common_src_files) \
|
||||
bionic/dlmalloc.c \
|
||||
bionic/malloc_debug_common.c \
|
||||
bionic/libc_init_dynamic.c
|
||||
|
@@ -33,7 +33,7 @@ void _exit:exit_group (int) 248,252
|
||||
void _exit_thread:exit (int) 1
|
||||
pid_t __fork:fork (void) 2
|
||||
pid_t _waitpid:waitpid (pid_t, int*, int, struct rusage*) -1,7
|
||||
int waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284
|
||||
int __waitid:waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284
|
||||
|
||||
# NOTE: this system call is never called directly, but we list it there
|
||||
# to have __NR_clone properly defined.
|
||||
@@ -112,15 +112,17 @@ int flock(int, int) 143
|
||||
int fchmod(int, mode_t) 94
|
||||
int dup(int) 41
|
||||
int pipe(int *) 42,42,-1
|
||||
int pipe2(int *, int) 359,331
|
||||
int dup2(int, int) 63
|
||||
int select:_newselect(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *) 142
|
||||
int ftruncate(int, off_t) 93
|
||||
int getdents:getdents64(unsigned int, struct dirent *, unsigned int) 217,220
|
||||
int fsync(int) 118
|
||||
int fdatasync(int) 148
|
||||
int fchown:fchown32(int, uid_t, gid_t) 207
|
||||
void sync(void) 36
|
||||
int __fcntl64:fcntl64(int, int, void *) 221
|
||||
int fstatfs:fstatfs64(int, size_t, struct statfs *) 267,269
|
||||
int __fstatfs64:fstatfs64(int, size_t, struct statfs *) 267,269
|
||||
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) 187
|
||||
int fstatat:fstatat64(int dirfd, const char *path, struct stat *buf, int flags) 327,300
|
||||
int mkdirat(int dirfd, const char *pathname, mode_t mode) 323,296
|
||||
@@ -229,8 +231,8 @@ int sched_get_priority_min(int policy) 160
|
||||
int sched_rr_get_interval(pid_t pid, struct timespec *interval) 161
|
||||
|
||||
# io priorities
|
||||
int ioprio_set(int which, int who, int ioprio) 314,289
|
||||
int ioprio_get(int which, int who) 315,290
|
||||
int ioprio_set(int which, int who, int ioprio) 314,289,288
|
||||
int ioprio_get(int which, int who) 315,290,289
|
||||
|
||||
# other
|
||||
int uname(struct utsname *) 122
|
||||
@@ -241,6 +243,7 @@ int __syslog:syslog(int, char *, int) 103
|
||||
int init_module(void *, unsigned long, const char *) 128
|
||||
int delete_module(const char*, unsigned int) 129
|
||||
int klogctl:syslog(int, char *, int) 103
|
||||
int sysinfo(struct sysinfo *) 116
|
||||
|
||||
# futex
|
||||
int futex(void *, int, int, void *, void *, int) 240
|
||||
@@ -256,6 +259,8 @@ int inotify_rm_watch(int, unsigned int) 318,293,292
|
||||
|
||||
int poll(struct pollfd *, unsigned int, long) 168
|
||||
|
||||
int eventfd:eventfd2(unsigned int, int) 356,328
|
||||
|
||||
# ARM-specific ARM_NR_BASE == 0x0f0000 == 983040
|
||||
int __set_tls:ARM_set_tls(void*) 983045,-1
|
||||
int cacheflush:ARM_cacheflush(long start, long end, long flags) 983042,-1
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Mark Brinicombe
|
||||
* Copyright (c) 2010 Android Open Source Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,6 +36,7 @@
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <machine/setjmp.h>
|
||||
#include <machine/cpu-features.h>
|
||||
|
||||
/*
|
||||
* C library -- _setjmp, _longjmp
|
||||
@@ -51,18 +53,20 @@
|
||||
|
||||
ENTRY(_setjmp)
|
||||
ldr r1, .L_setjmp_magic
|
||||
str r1, [r0], #4
|
||||
#ifdef SOFTFLOAT
|
||||
add r0, r0, #52
|
||||
#else
|
||||
/* Store fp registers */
|
||||
sfm f4, 4, [r0], #48
|
||||
/* Store fpsr */
|
||||
rfs r1
|
||||
str r1, [r0], #0x0004
|
||||
#endif /* SOFTFLOAT */
|
||||
/* Store integer registers */
|
||||
stmia r0, {r4-r14}
|
||||
str r1, [r0, #(_JB_MAGIC * 4)]
|
||||
|
||||
/* Store core registers */
|
||||
add r1, r0, #(_JB_CORE_BASE * 4)
|
||||
stmia r1, {r4-r14}
|
||||
|
||||
#ifdef __ARM_HAVE_VFP
|
||||
/* Store floating-point registers */
|
||||
add r1, r0, #(_JB_FLOAT_BASE * 4)
|
||||
vstmia r1, {d8-d15}
|
||||
/* Store floating-point state */
|
||||
fmrx r1, fpscr
|
||||
str r1, [r0, #(_JB_FLOAT_STATE * 4)]
|
||||
#endif /* __ARM_HAVE_VFP */
|
||||
|
||||
mov r0, #0x00000000
|
||||
bx lr
|
||||
@@ -72,21 +76,22 @@ ENTRY(_setjmp)
|
||||
|
||||
ENTRY(_longjmp)
|
||||
ldr r2, .L_setjmp_magic
|
||||
ldr r3, [r0], #4
|
||||
ldr r3, [r0, #(_JB_MAGIC * 4)]
|
||||
teq r2, r3
|
||||
bne botch
|
||||
|
||||
#ifdef SOFTFLOAT
|
||||
add r0, r0, #52
|
||||
#else
|
||||
/* Restore fp registers */
|
||||
lfm f4, 4, [r0], #48
|
||||
/* Restore fpsr */
|
||||
ldr r4, [r0], #0x0004
|
||||
wfs r4
|
||||
#endif /* SOFTFLOAT */
|
||||
/* Restore integer registers */
|
||||
ldmia r0, {r4-r14}
|
||||
#ifdef __ARM_HAVE_VFP
|
||||
/* Restore floating-point registers */
|
||||
add r2, r0, #(_JB_FLOAT_BASE * 4)
|
||||
vldmia r2, {d8-d15}
|
||||
/* Restore floating-point state */
|
||||
ldr r2, [r0, #(_JB_FLOAT_STATE * 4)]
|
||||
fmxr fpscr, r2
|
||||
#endif /* __ARM_HAVE_VFP */
|
||||
|
||||
/* Restore core registers */
|
||||
add r2, r0, #(_JB_CORE_BASE * 4)
|
||||
ldmia r2, {r4-r14}
|
||||
|
||||
/* Validate sp and r14 */
|
||||
teq sp, #0
|
||||
|
@@ -26,6 +26,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/linux-syscalls.h>
|
||||
#include <machine/cpu-features.h>
|
||||
|
||||
.global __atomic_cmpxchg
|
||||
.type __atomic_cmpxchg, %function
|
||||
@@ -39,9 +40,73 @@
|
||||
#define FUTEX_WAIT 0
|
||||
#define FUTEX_WAKE 1
|
||||
|
||||
#if 1
|
||||
#if defined(__ARM_HAVE_LDREX_STREX)
|
||||
/*
|
||||
* ===========================================================================
|
||||
* ARMv6+ implementation
|
||||
* ===========================================================================
|
||||
*/
|
||||
|
||||
/* r0(addr) -> r0(old) */
|
||||
__atomic_dec:
|
||||
.fnstart
|
||||
mov r1, r0 @ copy addr so we don't clobber it
|
||||
1: ldrex r0, [r1] @ load current value into r0
|
||||
sub r2, r0, #1 @ generate new value into r2
|
||||
strex r3, r2, [r1] @ try to store new value; result in r3
|
||||
cmp r3, #0 @ success?
|
||||
bxeq lr @ yes, return
|
||||
b 1b @ no, retry
|
||||
.fnend
|
||||
|
||||
/* r0(addr) -> r0(old) */
|
||||
__atomic_inc:
|
||||
.fnstart
|
||||
mov r1, r0
|
||||
1: ldrex r0, [r1]
|
||||
add r2, r0, #1
|
||||
strex r3, r2, [r1]
|
||||
cmp r3, #0
|
||||
bxeq lr
|
||||
b 1b
|
||||
.fnend
|
||||
|
||||
/* r0(old) r1(new) r2(addr) -> r0(zero_if_succeeded) */
|
||||
__atomic_cmpxchg:
|
||||
.fnstart
|
||||
1: mov ip, #2 @ ip=2 means "new != old"
|
||||
ldrex r3, [r2] @ load current value into r3
|
||||
teq r0, r3 @ new == old?
|
||||
strexeq ip, r1, [r2] @ yes, try store, set ip to 0 or 1
|
||||
teq ip, #1 @ strex failure?
|
||||
beq 1b @ yes, retry
|
||||
mov r0, ip @ return 0 on success, 2 on failure
|
||||
bx lr
|
||||
.fnend
|
||||
|
||||
/* r0(new) r1(addr) -> r0(old) */
|
||||
__atomic_swap:
|
||||
.fnstart
|
||||
1: ldrex r2, [r1]
|
||||
strex r3, r0, [r1]
|
||||
teq r3, #0
|
||||
bne 1b
|
||||
mov r0, r2
|
||||
bx lr
|
||||
.fnend
|
||||
|
||||
#else /*not defined __ARM_HAVE_LDREX_STREX*/
|
||||
/*
|
||||
* ===========================================================================
|
||||
* Pre-ARMv6 implementation
|
||||
* ===========================================================================
|
||||
*/
|
||||
|
||||
/* int __kernel_cmpxchg(int oldval, int newval, int* ptr) */
|
||||
.equ kernel_cmpxchg, 0xFFFF0FC0
|
||||
.equ kernel_atomic_base, 0xFFFF0FFF
|
||||
|
||||
/* r0(addr) -> r0(old) */
|
||||
__atomic_dec:
|
||||
.fnstart
|
||||
.save {r4, lr}
|
||||
@@ -59,6 +124,7 @@ __atomic_dec:
|
||||
bx lr
|
||||
.fnend
|
||||
|
||||
/* r0(addr) -> r0(old) */
|
||||
__atomic_inc:
|
||||
.fnstart
|
||||
.save {r4, lr}
|
||||
@@ -95,64 +161,16 @@ __atomic_cmpxchg:
|
||||
ldmia sp!, {r4, lr}
|
||||
bx lr
|
||||
.fnend
|
||||
#else
|
||||
#define KUSER_CMPXCHG 0xffffffc0
|
||||
|
||||
/* r0(old) r1(new) r2(addr) -> r0(zero_if_succeeded) */
|
||||
__atomic_cmpxchg:
|
||||
stmdb sp!, {r4, lr}
|
||||
mov r4, r0 /* r4 = save oldvalue */
|
||||
1: add lr, pc, #4
|
||||
mov r0, r4 /* r0 = oldvalue */
|
||||
mov pc, #KUSER_CMPXCHG
|
||||
bcs 2f /* swap was made. we're good, return. */
|
||||
ldr r3, [r2] /* swap not made, see if it's because *ptr!=oldvalue */
|
||||
cmp r3, r4
|
||||
beq 1b
|
||||
2: ldmia sp!, {r4, lr}
|
||||
bx lr
|
||||
|
||||
/* r0(addr) -> r0(old) */
|
||||
__atomic_dec:
|
||||
stmdb sp!, {r4, lr}
|
||||
mov r2, r0 /* address */
|
||||
1: ldr r0, [r2] /* oldvalue */
|
||||
add lr, pc, #4
|
||||
sub r1, r0, #1 /* newvalue = oldvalue - 1 */
|
||||
mov pc, #KUSER_CMPXCHG
|
||||
bcc 1b /* no swap, try again until we get it right */
|
||||
mov r0, ip /* swapped, return the old value */
|
||||
ldmia sp!, {r4, lr}
|
||||
bx lr
|
||||
|
||||
/* r0(addr) -> r0(old) */
|
||||
__atomic_inc:
|
||||
stmdb sp!, {r4, lr}
|
||||
mov r2, r0 /* address */
|
||||
1: ldr r0, [r2] /* oldvalue */
|
||||
add lr, pc, #4
|
||||
add r1, r0, #1 /* newvalue = oldvalue + 1 */
|
||||
mov pc, #KUSER_CMPXCHG
|
||||
bcc 1b /* no swap, try again until we get it right */
|
||||
mov r0, ip /* swapped, return the old value */
|
||||
ldmia sp!, {r4, lr}
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
/* r0(new) r1(addr) -> r0(old) */
|
||||
/* replaced swp instruction with ldrex/strex for ARMv6 & ARMv7 */
|
||||
__atomic_swap:
|
||||
#if defined (_ARM_HAVE_LDREX_STREX)
|
||||
1: ldrex r2, [r1]
|
||||
strex r3, r0, [r1]
|
||||
teq r3, #0
|
||||
bne 1b
|
||||
mov r0, r2
|
||||
mcr p15, 0, r0, c7, c10, 5 /* or, use dmb */
|
||||
#else
|
||||
.fnstart
|
||||
swp r0, r0, [r1]
|
||||
#endif
|
||||
bx lr
|
||||
.fnend
|
||||
|
||||
#endif /*not defined __ARM_HAVE_LDREX_STREX*/
|
||||
|
||||
|
||||
/* __futex_wait(*ftx, val, *timespec) */
|
||||
/* __futex_wake(*ftx, counter) */
|
||||
@@ -197,6 +215,8 @@ __futex_wait:
|
||||
.fnend
|
||||
|
||||
__futex_wake:
|
||||
.fnstart
|
||||
.save {r4, r7}
|
||||
stmdb sp!, {r4, r7}
|
||||
mov r2, r1
|
||||
mov r1, #FUTEX_WAKE
|
||||
@@ -204,6 +224,7 @@ __futex_wake:
|
||||
swi #0
|
||||
ldmia sp!, {r4, r7}
|
||||
bx lr
|
||||
.fnend
|
||||
|
||||
#else
|
||||
|
||||
|
@@ -31,7 +31,7 @@
|
||||
.globl _start
|
||||
|
||||
# this is the small startup code that is first run when
|
||||
# any executable that is statically-linked with Bionic
|
||||
# any executable that is dynamically-linked with Bionic
|
||||
# runs.
|
||||
#
|
||||
# it's purpose is to call __libc_init with appropriate
|
||||
@@ -64,12 +64,6 @@ _start:
|
||||
.long __FINI_ARRAY__
|
||||
.long __CTOR_LIST__
|
||||
|
||||
# the .ctors section contains a list of pointers to "constructor"
|
||||
# functions that need to be called in order during C library initialization,
|
||||
# just before the program is being run. This is a C++ requirement
|
||||
#
|
||||
# the last entry shall be 0, and is defined in crtend.S
|
||||
#
|
||||
.section .preinit_array, "aw"
|
||||
.globl __PREINIT_ARRAY__
|
||||
__PREINIT_ARRAY__:
|
||||
@@ -90,3 +84,4 @@ __FINI_ARRAY__:
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
#include "__dso_handle.S"
|
||||
|
55
libc/arch-arm/bionic/crtbegin_so.S
Normal file
55
libc/arch-arm/bionic/crtbegin_so.S
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
# Implement static C++ destructors when the shared
|
||||
# library is unloaded through dlclose().
|
||||
#
|
||||
# A call to this function must be the first entry
|
||||
# in the .fini_array. See 3.3.5.3.C of C++ ABI
|
||||
# standard.
|
||||
#
|
||||
__on_dlclose:
|
||||
adr r0, 0f
|
||||
ldr r0, [r0]
|
||||
b __cxa_finalize
|
||||
|
||||
0:
|
||||
.long __dso_handle
|
||||
|
||||
.section .init_array, "aw"
|
||||
.globl __INIT_ARRAY__
|
||||
__INIT_ARRAY__:
|
||||
.long -1
|
||||
|
||||
.section .fini_array, "aw"
|
||||
.globl __FINI_ARRAY__
|
||||
__FINI_ARRAY__:
|
||||
.long -1
|
||||
.long __on_dlclose
|
||||
|
||||
#include "__dso_handle.S"
|
@@ -64,12 +64,6 @@ _start:
|
||||
.long __FINI_ARRAY__
|
||||
.long __CTOR_LIST__
|
||||
|
||||
# the .ctors section contains a list of pointers to "constructor"
|
||||
# functions that need to be called in order during C library initialization,
|
||||
# just before the program is being run. This is a C++ requirement
|
||||
#
|
||||
# the last entry shall be 0, and is defined in crtend.S
|
||||
#
|
||||
.section .preinit_array, "aw"
|
||||
.globl __PREINIT_ARRAY__
|
||||
__PREINIT_ARRAY__:
|
||||
@@ -90,3 +84,5 @@ __FINI_ARRAY__:
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
|
||||
#include "__dso_handle.S"
|
||||
|
38
libc/arch-arm/bionic/crtend_so.S
Normal file
38
libc/arch-arm/bionic/crtend_so.S
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* This is the same than crtend.S except that a shared library
|
||||
* cannot have a .preinit_array
|
||||
*/
|
||||
|
||||
.section .init_array, "aw"
|
||||
.long 0
|
||||
|
||||
.section .fini_array, "aw"
|
||||
.long 0
|
||||
|
@@ -30,7 +30,21 @@
|
||||
|
||||
extern int __cxa_atexit(void (*)(void*), void*, void* );
|
||||
|
||||
void* __dso_handle = 0;
|
||||
/* Temporary hack: this variable should not be part of the C library
|
||||
* itself, but placed in the .bss section of each executable or
|
||||
* shared library instead.
|
||||
*
|
||||
* We keep it here temporarily until the build system has been
|
||||
* modified properly to use crtbegin_so.S and crtend_so.S when
|
||||
* generating shared libraries.
|
||||
*
|
||||
* It must be a 'weak' symbol to avoid conflicts with the definitions
|
||||
* that have been moved to crtbegin_static.S and crtbegin_dynamic.S
|
||||
*
|
||||
* For the record, it is used for static C++ object construction
|
||||
* and destruction. See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
|
||||
*/
|
||||
void* __attribute__((weak)) __dso_handle;
|
||||
|
||||
/* The "C++ ABI for ARM" document states that static C++ constructors,
|
||||
* which are called from the .init_array, should manually call
|
@@ -3,6 +3,7 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Mark Brinicombe
|
||||
* Copyright (c) 2010 Android Open Source Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,6 +36,7 @@
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <machine/setjmp.h>
|
||||
#include <machine/cpu-features.h>
|
||||
|
||||
/*
|
||||
* C library -- setjmp, longjmp
|
||||
@@ -57,22 +59,24 @@ ENTRY(setjmp)
|
||||
ldmfd sp!, {r0, r14}
|
||||
|
||||
/* Store signal mask */
|
||||
str r1, [r0, #(25 * 4)]
|
||||
str r1, [r0, #(_JB_SIGMASK * 4)]
|
||||
|
||||
ldr r1, .Lsetjmp_magic
|
||||
str r1, [r0], #4
|
||||
str r1, [r0, #(_JB_MAGIC * 4)]
|
||||
|
||||
/* Store core registers */
|
||||
add r1, r0, #(_JB_CORE_BASE * 4)
|
||||
stmia r1, {r4-r14}
|
||||
|
||||
#ifdef __ARM_HAVE_VFP
|
||||
/* Store floating-point registers */
|
||||
add r1, r0, #(_JB_FLOAT_BASE * 4)
|
||||
vstmia r1, {d8-d15}
|
||||
/* Store floating-point state */
|
||||
fmrx r1, fpscr
|
||||
str r1, [r0, #(_JB_FLOAT_STATE * 4)]
|
||||
#endif /* __ARM_HAVE_VFP */
|
||||
|
||||
#ifdef SOFTFLOAT
|
||||
add r0, r0, #52
|
||||
#else
|
||||
/* Store fp registers */
|
||||
sfm f4, 4, [r0], #48
|
||||
/* Store fpsr */
|
||||
rfs r1
|
||||
str r1, [r0], #0x0004
|
||||
#endif /*SOFTFLOAT*/
|
||||
/* Store integer registers */
|
||||
stmia r0, {r4-r14}
|
||||
mov r0, #0x00000000
|
||||
bx lr
|
||||
|
||||
@@ -82,12 +86,12 @@ ENTRY(setjmp)
|
||||
|
||||
ENTRY(longjmp)
|
||||
ldr r2, .Lsetjmp_magic
|
||||
ldr r3, [r0]
|
||||
ldr r3, [r0, #(_JB_MAGIC * 4)]
|
||||
teq r2, r3
|
||||
bne botch
|
||||
|
||||
/* Fetch signal mask */
|
||||
ldr r2, [r0, #(25 * 4)]
|
||||
ldr r2, [r0, #(_JB_SIGMASK * 4)]
|
||||
|
||||
/* Set signal mask */
|
||||
stmfd sp!, {r0, r1, r14}
|
||||
@@ -99,18 +103,18 @@ ENTRY(longjmp)
|
||||
add sp, sp, #4 /* unalign the stack */
|
||||
ldmfd sp!, {r0, r1, r14}
|
||||
|
||||
add r0, r0, #4
|
||||
#ifdef SOFTFLOAT
|
||||
add r0, r0, #52
|
||||
#else
|
||||
/* Restore fp registers */
|
||||
lfm f4, 4, [r0], #48
|
||||
/* Restore FPSR */
|
||||
ldr r4, [r0], #0x0004
|
||||
wfs r4
|
||||
#endif /* SOFTFLOAT */
|
||||
/* Restore integer registers */
|
||||
ldmia r0, {r4-r14}
|
||||
#ifdef __ARM_HAVE_VFP
|
||||
/* Restore floating-point registers */
|
||||
add r2, r0, #(_JB_FLOAT_BASE * 4)
|
||||
vldmia r2, {d8-d15}
|
||||
/* Restore floating-point state */
|
||||
ldr r2, [r0, #(_JB_FLOAT_STATE * 4)]
|
||||
fmxr fpscr, r2
|
||||
#endif /* __ARM_HAVE_VFP */
|
||||
|
||||
/* Restore core registers */
|
||||
add r2, r0, #(_JB_CORE_BASE * 4)
|
||||
ldmia r2, {r4-r14}
|
||||
|
||||
/* Validate sp and r14 */
|
||||
teq sp, #0
|
||||
|
@@ -46,8 +46,6 @@ typedef long ssize_t;
|
||||
typedef long ptrdiff_t;
|
||||
#endif
|
||||
|
||||
//#include <linux/types.h>
|
||||
|
||||
/* 7.18.1.1 Exact-width integer types */
|
||||
typedef __signed char __int8_t;
|
||||
typedef unsigned char __uint8_t;
|
||||
|
@@ -38,7 +38,7 @@
|
||||
* IMPORTANT: We have no intention to support anything below an ARMv4T !
|
||||
*/
|
||||
|
||||
/* _ARM_ARCH_REVISION is a number corresponding to the ARM revision
|
||||
/* __ARM_ARCH__ is a number corresponding to the ARM revision
|
||||
* we're going to support
|
||||
*
|
||||
* it looks like our toolchain doesn't define __ARM_ARCH__
|
||||
@@ -142,20 +142,47 @@
|
||||
*
|
||||
* ldr pc, [<some address>]
|
||||
*
|
||||
* note that this affects any instruction that explicitely changes the
|
||||
* note that this affects any instruction that explicitly changes the
|
||||
* value of the pc register, including ldm { ...,pc } or 'add pc, #offset'
|
||||
*/
|
||||
#if __ARM_ARCH__ >= 5
|
||||
# define __ARM_HAVE_PC_INTERWORK
|
||||
#endif
|
||||
|
||||
/* define _ARM_HAVE_LDREX_STREX for ARMv6 and ARMv7 architecure to be
|
||||
* used in replacement of depricated swp instruction
|
||||
/* define __ARM_HAVE_LDREX_STREX for ARMv6 and ARMv7 architecture to be
|
||||
* used in replacement of deprecated swp instruction
|
||||
*/
|
||||
#if __ARM_ARCH__ >= 6
|
||||
# define _ARM_HAVE_LDREX_STREX
|
||||
# define __ARM_HAVE_LDREX_STREX
|
||||
#endif
|
||||
|
||||
/* define __ARM_HAVE_DMB for ARMv7 architecture
|
||||
*/
|
||||
#if __ARM_ARCH__ >= 7
|
||||
# define __ARM_HAVE_DMB
|
||||
#endif
|
||||
|
||||
/* define __ARM_HAVE_LDREXD for ARMv7 architecture
|
||||
* (also present in ARMv6K, but not implemented in ARMv7-M, neither of which
|
||||
* we care about)
|
||||
*/
|
||||
#if __ARM_ARCH__ >= 7
|
||||
# define __ARM_HAVE_LDREXD
|
||||
#endif
|
||||
|
||||
/* define _ARM_HAVE_VFP if we have VFPv3
|
||||
*/
|
||||
#if __ARM_ARCH__ >= 7 && defined __VFP_FP__
|
||||
# define __ARM_HAVE_VFP
|
||||
#endif
|
||||
|
||||
/* define _ARM_HAVE_NEON for ARMv7 architecture if we support the
|
||||
* Neon SIMD instruction set extensions. This also implies
|
||||
* that VFPv3-D32 is supported.
|
||||
*/
|
||||
#if __ARM_ARCH__ >= 7 && defined __ARM_NEON__
|
||||
# define __ARM_HAVE_NEON
|
||||
#endif
|
||||
|
||||
/* Assembly-only macros */
|
||||
|
||||
|
@@ -1,87 +1,82 @@
|
||||
/* $OpenBSD: setjmp.h,v 1.1 2004/02/01 05:09:49 drahn Exp $ */
|
||||
/* $NetBSD: setjmp.h,v 1.2 2001/08/25 14:45:59 bjh21 Exp $ */
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* machine/setjmp.h: machine dependent setjmp-related information.
|
||||
*/
|
||||
|
||||
#ifdef __ELF__
|
||||
#define _JBLEN 64 /* size, in longs, of a jmp_buf */
|
||||
#else
|
||||
#define _JBLEN 29 /* size, in longs, of a jmp_buf */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: The internal structure of a jmp_buf is *PRIVATE*
|
||||
* This information is provided as there is software
|
||||
* that fiddles with this with obtain the stack pointer
|
||||
* (yes really ! and its commercial !).
|
||||
/* _JBLEN is the size of a jmp_buf in longs.
|
||||
* Do not modify this value or you will break the ABI !
|
||||
*
|
||||
* Description of the setjmp buffer
|
||||
*
|
||||
* word 0 magic number (dependant on creator)
|
||||
* 1 - 3 f4 fp register 4
|
||||
* 4 - 6 f5 fp register 5
|
||||
* 7 - 9 f6 fp register 6
|
||||
* 10 - 12 f7 fp register 7
|
||||
* 13 fpsr fp status register
|
||||
* 14 r4 register 4
|
||||
* 15 r5 register 5
|
||||
* 16 r6 register 6
|
||||
* 17 r7 register 7
|
||||
* 18 r8 register 8
|
||||
* 19 r9 register 9
|
||||
* 20 r10 register 10 (sl)
|
||||
* 21 r11 register 11 (fp)
|
||||
* 22 r12 register 12 (ip)
|
||||
* 23 r13 register 13 (sp)
|
||||
* 24 r14 register 14 (lr)
|
||||
* 25 signal mask (dependant on magic)
|
||||
* 26 (con't)
|
||||
* 27 (con't)
|
||||
* 28 (con't)
|
||||
*
|
||||
* The magic number number identifies the jmp_buf and
|
||||
* how the buffer was created as well as providing
|
||||
* a sanity check
|
||||
*
|
||||
* A side note I should mention - Please do not tamper
|
||||
* with the floating point fields. While they are
|
||||
* always saved and restored at the moment this cannot
|
||||
* be garenteed especially if the compiler happens
|
||||
* to be generating soft-float code so no fp
|
||||
* registers will be used.
|
||||
*
|
||||
* Whilst this can be seen an encouraging people to
|
||||
* use the setjmp buffer in this way I think that it
|
||||
* is for the best then if changes occur compiles will
|
||||
* break rather than just having new builds falling over
|
||||
* mysteriously.
|
||||
* This value comes from the original OpenBSD ARM-specific header
|
||||
* that was replaced by this one.
|
||||
*/
|
||||
#define _JBLEN 64
|
||||
|
||||
/* According to the ARM AAPCS document, we only need to save
|
||||
* the following registers:
|
||||
*
|
||||
* Core r4-r14
|
||||
*
|
||||
* VFP d8-d15 (see section 5.1.2.1)
|
||||
*
|
||||
* Registers s16-s31 (d8-d15, q4-q7) must be preserved across subroutine
|
||||
* calls; registers s0-s15 (d0-d7, q0-q3) do not need to be preserved
|
||||
* (and can be used for passing arguments or returning results in standard
|
||||
* procedure-call variants). Registers d16-d31 (q8-q15), if present, do
|
||||
* not need to be preserved.
|
||||
*
|
||||
* FPSCR saved because GLibc does saves it too.
|
||||
*
|
||||
*/
|
||||
|
||||
/* The internal structure of a jmp_buf is totally private.
|
||||
* Current layout (may change in the future):
|
||||
*
|
||||
* word name description
|
||||
* 0 magic magic number
|
||||
* 1 sigmask signal mask (not used with _setjmp / _longjmp)
|
||||
* 2 float_base base of float registers (d8 to d15)
|
||||
* 18 float_state floating-point status and control register
|
||||
* 19 core_base base of core registers (r4 to r14)
|
||||
* 30 reserved reserved entries (room to grow)
|
||||
* 64
|
||||
*
|
||||
* NOTE: float_base must be at an even word index, since the
|
||||
* FP registers will be loaded/stored with instructions
|
||||
* that expect 8-byte alignment.
|
||||
*/
|
||||
|
||||
#define _JB_MAGIC 0
|
||||
#define _JB_SIGMASK (_JB_MAGIC+1)
|
||||
#define _JB_FLOAT_BASE (_JB_SIGMASK+1)
|
||||
#define _JB_FLOAT_STATE (_JB_FLOAT_BASE + (15-8+1)*2)
|
||||
#define _JB_CORE_BASE (_JB_FLOAT_STATE+1)
|
||||
|
||||
#define _JB_MAGIC__SETJMP 0x4278f500
|
||||
#define _JB_MAGIC_SETJMP 0x4278f501
|
||||
|
||||
/* Valid for all jmp_buf's */
|
||||
|
||||
#define _JB_MAGIC 0
|
||||
#define _JB_REG_F4 1
|
||||
#define _JB_REG_F5 4
|
||||
#define _JB_REG_F6 7
|
||||
#define _JB_REG_F7 10
|
||||
#define _JB_REG_FPSR 13
|
||||
#define _JB_REG_R4 14
|
||||
#define _JB_REG_R5 15
|
||||
#define _JB_REG_R6 16
|
||||
#define _JB_REG_R7 17
|
||||
#define _JB_REG_R8 18
|
||||
#define _JB_REG_R9 19
|
||||
#define _JB_REG_R10 20
|
||||
#define _JB_REG_R11 21
|
||||
#define _JB_REG_R12 22
|
||||
#define _JB_REG_R13 23
|
||||
#define _JB_REG_R14 24
|
||||
|
||||
/* Only valid with the _JB_MAGIC_SETJMP magic */
|
||||
|
||||
#define _JB_SIGMASK 25
|
||||
|
@@ -3,7 +3,7 @@ syscall_src :=
|
||||
syscall_src += arch-arm/syscalls/_exit.S
|
||||
syscall_src += arch-arm/syscalls/_exit_thread.S
|
||||
syscall_src += arch-arm/syscalls/__fork.S
|
||||
syscall_src += arch-arm/syscalls/waitid.S
|
||||
syscall_src += arch-arm/syscalls/__waitid.S
|
||||
syscall_src += arch-arm/syscalls/__sys_clone.S
|
||||
syscall_src += arch-arm/syscalls/execve.S
|
||||
syscall_src += arch-arm/syscalls/__setuid.S
|
||||
@@ -66,15 +66,17 @@ syscall_src += arch-arm/syscalls/flock.S
|
||||
syscall_src += arch-arm/syscalls/fchmod.S
|
||||
syscall_src += arch-arm/syscalls/dup.S
|
||||
syscall_src += arch-arm/syscalls/pipe.S
|
||||
syscall_src += arch-arm/syscalls/pipe2.S
|
||||
syscall_src += arch-arm/syscalls/dup2.S
|
||||
syscall_src += arch-arm/syscalls/select.S
|
||||
syscall_src += arch-arm/syscalls/ftruncate.S
|
||||
syscall_src += arch-arm/syscalls/getdents.S
|
||||
syscall_src += arch-arm/syscalls/fsync.S
|
||||
syscall_src += arch-arm/syscalls/fdatasync.S
|
||||
syscall_src += arch-arm/syscalls/fchown.S
|
||||
syscall_src += arch-arm/syscalls/sync.S
|
||||
syscall_src += arch-arm/syscalls/__fcntl64.S
|
||||
syscall_src += arch-arm/syscalls/fstatfs.S
|
||||
syscall_src += arch-arm/syscalls/__fstatfs64.S
|
||||
syscall_src += arch-arm/syscalls/sendfile.S
|
||||
syscall_src += arch-arm/syscalls/fstatat.S
|
||||
syscall_src += arch-arm/syscalls/mkdirat.S
|
||||
@@ -161,6 +163,7 @@ syscall_src += arch-arm/syscalls/__syslog.S
|
||||
syscall_src += arch-arm/syscalls/init_module.S
|
||||
syscall_src += arch-arm/syscalls/delete_module.S
|
||||
syscall_src += arch-arm/syscalls/klogctl.S
|
||||
syscall_src += arch-arm/syscalls/sysinfo.S
|
||||
syscall_src += arch-arm/syscalls/futex.S
|
||||
syscall_src += arch-arm/syscalls/epoll_create.S
|
||||
syscall_src += arch-arm/syscalls/epoll_ctl.S
|
||||
@@ -169,5 +172,6 @@ syscall_src += arch-arm/syscalls/inotify_init.S
|
||||
syscall_src += arch-arm/syscalls/inotify_add_watch.S
|
||||
syscall_src += arch-arm/syscalls/inotify_rm_watch.S
|
||||
syscall_src += arch-arm/syscalls/poll.S
|
||||
syscall_src += arch-arm/syscalls/eventfd.S
|
||||
syscall_src += arch-arm/syscalls/__set_tls.S
|
||||
syscall_src += arch-arm/syscalls/cacheflush.S
|
||||
|
@@ -2,12 +2,12 @@
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type fstatfs, #function
|
||||
.globl fstatfs
|
||||
.type __fstatfs64, #function
|
||||
.globl __fstatfs64
|
||||
.align 4
|
||||
.fnstart
|
||||
|
||||
fstatfs:
|
||||
__fstatfs64:
|
||||
.save {r4, r7}
|
||||
stmfd sp!, {r4, r7}
|
||||
ldr r7, =__NR_fstatfs64
|
@@ -2,12 +2,12 @@
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type waitid, #function
|
||||
.globl waitid
|
||||
.type __waitid, #function
|
||||
.globl __waitid
|
||||
.align 4
|
||||
.fnstart
|
||||
|
||||
waitid:
|
||||
__waitid:
|
||||
mov ip, sp
|
||||
.save {r4, r5, r6, r7}
|
||||
stmfd sp!, {r4, r5, r6, r7}
|
19
libc/arch-arm/syscalls/eventfd.S
Normal file
19
libc/arch-arm/syscalls/eventfd.S
Normal file
@@ -0,0 +1,19 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type eventfd, #function
|
||||
.globl eventfd
|
||||
.align 4
|
||||
.fnstart
|
||||
|
||||
eventfd:
|
||||
.save {r4, r7}
|
||||
stmfd sp!, {r4, r7}
|
||||
ldr r7, =__NR_eventfd2
|
||||
swi #0
|
||||
ldmfd sp!, {r4, r7}
|
||||
movs r0, r0
|
||||
bxpl lr
|
||||
b __set_syscall_errno
|
||||
.fnend
|
19
libc/arch-arm/syscalls/fdatasync.S
Normal file
19
libc/arch-arm/syscalls/fdatasync.S
Normal file
@@ -0,0 +1,19 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type fdatasync, #function
|
||||
.globl fdatasync
|
||||
.align 4
|
||||
.fnstart
|
||||
|
||||
fdatasync:
|
||||
.save {r4, r7}
|
||||
stmfd sp!, {r4, r7}
|
||||
ldr r7, =__NR_fdatasync
|
||||
swi #0
|
||||
ldmfd sp!, {r4, r7}
|
||||
movs r0, r0
|
||||
bxpl lr
|
||||
b __set_syscall_errno
|
||||
.fnend
|
19
libc/arch-arm/syscalls/pipe2.S
Normal file
19
libc/arch-arm/syscalls/pipe2.S
Normal file
@@ -0,0 +1,19 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type pipe2, #function
|
||||
.globl pipe2
|
||||
.align 4
|
||||
.fnstart
|
||||
|
||||
pipe2:
|
||||
.save {r4, r7}
|
||||
stmfd sp!, {r4, r7}
|
||||
ldr r7, =__NR_pipe2
|
||||
swi #0
|
||||
ldmfd sp!, {r4, r7}
|
||||
movs r0, r0
|
||||
bxpl lr
|
||||
b __set_syscall_errno
|
||||
.fnend
|
19
libc/arch-arm/syscalls/sysinfo.S
Normal file
19
libc/arch-arm/syscalls/sysinfo.S
Normal file
@@ -0,0 +1,19 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type sysinfo, #function
|
||||
.globl sysinfo
|
||||
.align 4
|
||||
.fnstart
|
||||
|
||||
sysinfo:
|
||||
.save {r4, r7}
|
||||
stmfd sp!, {r4, r7}
|
||||
ldr r7, =__NR_sysinfo
|
||||
swi #0
|
||||
ldmfd sp!, {r4, r7}
|
||||
movs r0, r0
|
||||
bxpl lr
|
||||
b __set_syscall_errno
|
||||
.fnend
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
* Copyright (C) 2009-2010 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -31,7 +31,7 @@
|
||||
.globl _start
|
||||
|
||||
# this is the small startup code that is first run when
|
||||
# any executable that is statically-linked with Bionic
|
||||
# any executable that is dynamically-linked with Bionic
|
||||
# runs.
|
||||
#
|
||||
# it's purpose is to call __libc_init with appropriate
|
||||
@@ -93,3 +93,5 @@ __FINI_ARRAY__:
|
||||
.globl __CTOR_LIST__
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
#include "__dso_handle.S"
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
* Copyright (C) 2009-2010 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -68,12 +68,6 @@ _start:
|
||||
.long __FINI_ARRAY__
|
||||
.long __CTOR_LIST__
|
||||
|
||||
# the .ctors section contains a list of pointers to "constructor"
|
||||
# functions that need to be called in order during C library initialization,
|
||||
# just before the program is being run. This is a C++ requirement
|
||||
#
|
||||
# the last entry shall be 0, and is defined in crtend.S
|
||||
#
|
||||
.section .preinit_array, "aw"
|
||||
.globl __PREINIT_ARRAY__
|
||||
__PREINIT_ARRAY__:
|
||||
@@ -94,3 +88,4 @@ __FINI_ARRAY__:
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
#include "__dso_handle.S"
|
||||
|
@@ -4,7 +4,7 @@ syscall_src += arch-sh/syscalls/_exit.S
|
||||
syscall_src += arch-sh/syscalls/_exit_thread.S
|
||||
syscall_src += arch-sh/syscalls/__fork.S
|
||||
syscall_src += arch-sh/syscalls/_waitpid.S
|
||||
syscall_src += arch-sh/syscalls/waitid.S
|
||||
syscall_src += arch-sh/syscalls/__waitid.S
|
||||
syscall_src += arch-sh/syscalls/__sys_clone.S
|
||||
syscall_src += arch-sh/syscalls/execve.S
|
||||
syscall_src += arch-sh/syscalls/__setuid.S
|
||||
@@ -69,15 +69,17 @@ syscall_src += arch-sh/syscalls/__fcntl.S
|
||||
syscall_src += arch-sh/syscalls/flock.S
|
||||
syscall_src += arch-sh/syscalls/fchmod.S
|
||||
syscall_src += arch-sh/syscalls/dup.S
|
||||
syscall_src += arch-sh/syscalls/pipe2.S
|
||||
syscall_src += arch-sh/syscalls/dup2.S
|
||||
syscall_src += arch-sh/syscalls/select.S
|
||||
syscall_src += arch-sh/syscalls/ftruncate.S
|
||||
syscall_src += arch-sh/syscalls/getdents.S
|
||||
syscall_src += arch-sh/syscalls/fsync.S
|
||||
syscall_src += arch-sh/syscalls/fdatasync.S
|
||||
syscall_src += arch-sh/syscalls/fchown.S
|
||||
syscall_src += arch-sh/syscalls/sync.S
|
||||
syscall_src += arch-sh/syscalls/__fcntl64.S
|
||||
syscall_src += arch-sh/syscalls/fstatfs.S
|
||||
syscall_src += arch-sh/syscalls/__fstatfs64.S
|
||||
syscall_src += arch-sh/syscalls/sendfile.S
|
||||
syscall_src += arch-sh/syscalls/fstatat.S
|
||||
syscall_src += arch-sh/syscalls/mkdirat.S
|
||||
@@ -150,6 +152,7 @@ syscall_src += arch-sh/syscalls/__syslog.S
|
||||
syscall_src += arch-sh/syscalls/init_module.S
|
||||
syscall_src += arch-sh/syscalls/delete_module.S
|
||||
syscall_src += arch-sh/syscalls/klogctl.S
|
||||
syscall_src += arch-sh/syscalls/sysinfo.S
|
||||
syscall_src += arch-sh/syscalls/futex.S
|
||||
syscall_src += arch-sh/syscalls/epoll_create.S
|
||||
syscall_src += arch-sh/syscalls/epoll_ctl.S
|
||||
@@ -158,3 +161,4 @@ syscall_src += arch-sh/syscalls/inotify_init.S
|
||||
syscall_src += arch-sh/syscalls/inotify_add_watch.S
|
||||
syscall_src += arch-sh/syscalls/inotify_rm_watch.S
|
||||
syscall_src += arch-sh/syscalls/poll.S
|
||||
syscall_src += arch-sh/syscalls/eventfd.S
|
||||
|
@@ -2,11 +2,11 @@
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type fstatfs, @function
|
||||
.globl fstatfs
|
||||
.type __fstatfs64, @function
|
||||
.globl __fstatfs64
|
||||
.align 4
|
||||
|
||||
fstatfs:
|
||||
__fstatfs64:
|
||||
|
||||
/* invoke trap */
|
||||
mov.l 0f, r3 /* trap num */
|
@@ -2,11 +2,11 @@
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type waitid, @function
|
||||
.globl waitid
|
||||
.type __waitid, @function
|
||||
.globl __waitid
|
||||
.align 4
|
||||
|
||||
waitid:
|
||||
__waitid:
|
||||
|
||||
/* get ready for additonal arg */
|
||||
mov.l @r15, r0
|
32
libc/arch-sh/syscalls/eventfd.S
Normal file
32
libc/arch-sh/syscalls/eventfd.S
Normal file
@@ -0,0 +1,32 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type eventfd, @function
|
||||
.globl eventfd
|
||||
.align 4
|
||||
|
||||
eventfd:
|
||||
|
||||
/* invoke trap */
|
||||
mov.l 0f, r3 /* trap num */
|
||||
trapa #(2 + 0x10)
|
||||
|
||||
/* check return value */
|
||||
cmp/pz r0
|
||||
bt __NR_eventfd2_end
|
||||
|
||||
/* keep error number */
|
||||
sts.l pr, @-r15
|
||||
mov.l 1f, r1
|
||||
jsr @r1
|
||||
mov r0, r4
|
||||
lds.l @r15+, pr
|
||||
|
||||
__NR_eventfd2_end:
|
||||
rts
|
||||
nop
|
||||
|
||||
.align 2
|
||||
0: .long __NR_eventfd2
|
||||
1: .long __set_syscall_errno
|
32
libc/arch-sh/syscalls/fdatasync.S
Normal file
32
libc/arch-sh/syscalls/fdatasync.S
Normal file
@@ -0,0 +1,32 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type fdatasync, @function
|
||||
.globl fdatasync
|
||||
.align 4
|
||||
|
||||
fdatasync:
|
||||
|
||||
/* invoke trap */
|
||||
mov.l 0f, r3 /* trap num */
|
||||
trapa #(1 + 0x10)
|
||||
|
||||
/* check return value */
|
||||
cmp/pz r0
|
||||
bt __NR_fdatasync_end
|
||||
|
||||
/* keep error number */
|
||||
sts.l pr, @-r15
|
||||
mov.l 1f, r1
|
||||
jsr @r1
|
||||
mov r0, r4
|
||||
lds.l @r15+, pr
|
||||
|
||||
__NR_fdatasync_end:
|
||||
rts
|
||||
nop
|
||||
|
||||
.align 2
|
||||
0: .long __NR_fdatasync
|
||||
1: .long __set_syscall_errno
|
32
libc/arch-sh/syscalls/pipe2.S
Normal file
32
libc/arch-sh/syscalls/pipe2.S
Normal file
@@ -0,0 +1,32 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type pipe2, @function
|
||||
.globl pipe2
|
||||
.align 4
|
||||
|
||||
pipe2:
|
||||
|
||||
/* invoke trap */
|
||||
mov.l 0f, r3 /* trap num */
|
||||
trapa #(2 + 0x10)
|
||||
|
||||
/* check return value */
|
||||
cmp/pz r0
|
||||
bt __NR_pipe2_end
|
||||
|
||||
/* keep error number */
|
||||
sts.l pr, @-r15
|
||||
mov.l 1f, r1
|
||||
jsr @r1
|
||||
mov r0, r4
|
||||
lds.l @r15+, pr
|
||||
|
||||
__NR_pipe2_end:
|
||||
rts
|
||||
nop
|
||||
|
||||
.align 2
|
||||
0: .long __NR_pipe2
|
||||
1: .long __set_syscall_errno
|
32
libc/arch-sh/syscalls/sysinfo.S
Normal file
32
libc/arch-sh/syscalls/sysinfo.S
Normal file
@@ -0,0 +1,32 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type sysinfo, @function
|
||||
.globl sysinfo
|
||||
.align 4
|
||||
|
||||
sysinfo:
|
||||
|
||||
/* invoke trap */
|
||||
mov.l 0f, r3 /* trap num */
|
||||
trapa #(1 + 0x10)
|
||||
|
||||
/* check return value */
|
||||
cmp/pz r0
|
||||
bt __NR_sysinfo_end
|
||||
|
||||
/* keep error number */
|
||||
sts.l pr, @-r15
|
||||
mov.l 1f, r1
|
||||
jsr @r1
|
||||
mov r0, r4
|
||||
lds.l @r15+, pr
|
||||
|
||||
__NR_sysinfo_end:
|
||||
rts
|
||||
nop
|
||||
|
||||
.align 2
|
||||
0: .long __NR_sysinfo
|
||||
1: .long __set_syscall_errno
|
@@ -30,7 +30,7 @@
|
||||
.globl _start
|
||||
|
||||
# this is the small startup code that is first run when
|
||||
# any executable that is statically-linked with Bionic
|
||||
# any executable that is dynamically-linked with Bionic
|
||||
# runs.
|
||||
#
|
||||
# it's purpose is to call __libc_init with appropriate
|
||||
@@ -94,3 +94,4 @@ __FINI_ARRAY__:
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
#include "__dso_handle.S"
|
||||
|
@@ -1,3 +1,10 @@
|
||||
# This function is to be called when the shared library
|
||||
# is unloaded through dlclose()
|
||||
_on_dlclose:
|
||||
lea __dso_handle, %eax
|
||||
call __cxa_finalize
|
||||
ret
|
||||
|
||||
/* we put the _init() function here in case the user files for the shared
|
||||
* libs want to drop things into .init section.
|
||||
* We then will call our ctors from crtend_so.o */
|
||||
@@ -20,6 +27,7 @@ __INIT_ARRAY__:
|
||||
.globl __FINI_ARRAY__
|
||||
__FINI_ARRAY__:
|
||||
.long -1
|
||||
.long _on_dlclose
|
||||
|
||||
.section .ctors, "aw"
|
||||
.align 4
|
||||
@@ -27,3 +35,5 @@ __FINI_ARRAY__:
|
||||
.globl __CTOR_LIST__
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
#include "__dso_handle.S"
|
||||
|
@@ -67,12 +67,6 @@ _start:
|
||||
.long __FINI_ARRAY__
|
||||
.long __CTOR_LIST__
|
||||
|
||||
# the .ctors section contains a list of pointers to "constructor"
|
||||
# functions that need to be called in order during C library initialization,
|
||||
# just before the program is being run. This is a C++ requirement
|
||||
#
|
||||
# the last entry shall be 0, and is defined in crtend.S
|
||||
#
|
||||
.section .preinit_array, "aw"
|
||||
.globl __PREINIT_ARRAY__
|
||||
__PREINIT_ARRAY__:
|
||||
@@ -93,3 +87,4 @@ __FINI_ARRAY__:
|
||||
__CTOR_LIST__:
|
||||
.long -1
|
||||
|
||||
#include "__dso_handle.S"
|
||||
|
@@ -36,10 +36,23 @@
|
||||
#define _I386__TYPES_H_
|
||||
|
||||
/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
|
||||
#define _SIZE_T
|
||||
#ifndef _SIZE_T
|
||||
# define _SIZE_T
|
||||
# ifdef ANDROID
|
||||
typedef unsigned int size_t;
|
||||
# else
|
||||
typedef unsigned long size_t;
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(_SSIZE_T) && !defined(_SSIZE_T_DEFINED_)
|
||||
#define _SSIZE_T
|
||||
#define _SSIZE_T_DEFINED_
|
||||
typedef long int ssize_t;
|
||||
#endif
|
||||
#ifndef _PTRDIFF_T
|
||||
#define _PTRDIFF_T
|
||||
typedef unsigned int size_t;
|
||||
typedef int ptrdiff_t;
|
||||
typedef long ptrdiff_t;
|
||||
#endif
|
||||
|
||||
#define _OFF_T_DEFINED_
|
||||
#define _SIZE_T_DEFINED_
|
||||
|
45
libc/arch-x86/string/bcopy_wrapper.S
Normal file
45
libc/arch-x86/string/bcopy_wrapper.S
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
#if defined(USE_SSSE3)
|
||||
|
||||
# include "cache_wrapper.S"
|
||||
# undef __i686
|
||||
# define MEMCPY bcopy
|
||||
# define USE_AS_MEMMOVE
|
||||
# define USE_AS_BCOPY
|
||||
# include "ssse3-memcpy5.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "bcopy.S"
|
||||
|
||||
#endif
|
43
libc/arch-x86/string/bzero_wrapper.S
Normal file
43
libc/arch-x86/string/bzero_wrapper.S
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSE2)
|
||||
|
||||
# include "cache_wrapper.S"
|
||||
# undef __i686
|
||||
# define USE_AS_BZERO
|
||||
# define sse2_memset5_atom bzero
|
||||
# include "sse2-memset5-atom.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "bzero.S"
|
||||
|
||||
#endif
|
35
libc/arch-x86/string/cache_wrapper.S
Normal file
35
libc/arch-x86/string/cache_wrapper.S
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* Values are optimized for Atom */
|
||||
#define SHARED_CACHE_SIZE (512*1024) /* Atom L2 Cache */
|
||||
#define DATA_CACHE_SIZE (24*1024) /* Atom L1 Data Cache */
|
||||
#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
|
||||
#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)
|
40
libc/arch-x86/string/memcmp_wrapper.S
Normal file
40
libc/arch-x86/string/memcmp_wrapper.S
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSSE3)
|
||||
|
||||
# define MEMCMP memcmp
|
||||
# include "ssse3-memcmp3.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "memcmp.S"
|
||||
|
||||
#endif
|
43
libc/arch-x86/string/memcpy_wrapper.S
Normal file
43
libc/arch-x86/string/memcpy_wrapper.S
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSSE3)
|
||||
|
||||
# include "cache_wrapper.S"
|
||||
# undef __i686
|
||||
# define MEMCPY memcpy
|
||||
# define USE_AS_MEMMOVE
|
||||
# include "ssse3-memcpy5.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "memcpy.S"
|
||||
|
||||
#endif
|
43
libc/arch-x86/string/memmove_wrapper.S
Normal file
43
libc/arch-x86/string/memmove_wrapper.S
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSSE3)
|
||||
|
||||
# include "cache_wrapper.S"
|
||||
# undef __i686
|
||||
# define MEMCPY memmove
|
||||
# define USE_AS_MEMMOVE
|
||||
# include "ssse3-memcpy5.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "memmove.S"
|
||||
|
||||
#endif
|
42
libc/arch-x86/string/memset_wrapper.S
Normal file
42
libc/arch-x86/string/memset_wrapper.S
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSE2)
|
||||
|
||||
# include "cache_wrapper.S"
|
||||
# undef __i686
|
||||
# define sse2_memset5_atom memset
|
||||
# include "sse2-memset5-atom.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "memset.S"
|
||||
|
||||
#endif
|
907
libc/arch-x86/string/sse2-memset5-atom.S
Normal file
907
libc/arch-x86/string/sse2-memset5-atom.S
Normal file
@@ -0,0 +1,907 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef L
|
||||
# define L(label) .L##label
|
||||
#endif
|
||||
|
||||
#ifndef ALIGN
|
||||
# define ALIGN(n) .p2align n
|
||||
#endif
|
||||
|
||||
#ifndef cfi_startproc
|
||||
# define cfi_startproc .cfi_startproc
|
||||
#endif
|
||||
|
||||
#ifndef cfi_endproc
|
||||
# define cfi_endproc .cfi_endproc
|
||||
#endif
|
||||
|
||||
#ifndef cfi_rel_offset
|
||||
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
|
||||
#endif
|
||||
|
||||
#ifndef cfi_restore
|
||||
# define cfi_restore(reg) .cfi_restore (reg)
|
||||
#endif
|
||||
|
||||
#ifndef cfi_adjust_cfa_offset
|
||||
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
|
||||
#endif
|
||||
|
||||
#ifndef ENTRY
|
||||
# define ENTRY(name) \
|
||||
.type name, @function; \
|
||||
.globl name; \
|
||||
.p2align 4; \
|
||||
name: \
|
||||
cfi_startproc
|
||||
#endif
|
||||
|
||||
#ifndef END
|
||||
# define END(name) \
|
||||
cfi_endproc; \
|
||||
.size name, .-name
|
||||
#endif
|
||||
|
||||
#define CFI_PUSH(REG) \
|
||||
cfi_adjust_cfa_offset (4); \
|
||||
cfi_rel_offset (REG, 0)
|
||||
|
||||
#define CFI_POP(REG) \
|
||||
cfi_adjust_cfa_offset (-4); \
|
||||
cfi_restore (REG)
|
||||
|
||||
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
|
||||
#define POP(REG) popl REG; CFI_POP (REG)
|
||||
|
||||
#ifdef USE_AS_BZERO
|
||||
# define DEST PARMS
|
||||
# define LEN DEST+4
|
||||
# define SETRTNVAL
|
||||
#else
|
||||
# define DEST PARMS
|
||||
# define CHR DEST+4
|
||||
# define LEN CHR+4
|
||||
# define SETRTNVAL movl DEST(%esp), %eax
|
||||
#endif
|
||||
|
||||
#ifdef SHARED
|
||||
# define ENTRANCE PUSH (%ebx);
|
||||
# define RETURN_END POP (%ebx); ret
|
||||
# define RETURN RETURN_END; CFI_PUSH (%ebx)
|
||||
# define PARMS 8 /* Preserve EBX. */
|
||||
# define JMPTBL(I, B) I - B
|
||||
|
||||
/* Load an entry in a jump table into EBX and branch to it. TABLE is a
|
||||
jump table with relative offsets. */
|
||||
# define BRANCH_TO_JMPTBL_ENTRY(TABLE) \
|
||||
/* We first load PC into EBX. */ \
|
||||
call __i686.get_pc_thunk.bx; \
|
||||
/* Get the address of the jump table. */ \
|
||||
add $(TABLE - .), %ebx; \
|
||||
/* Get the entry and convert the relative offset to the \
|
||||
absolute address. */ \
|
||||
add (%ebx,%ecx,4), %ebx; \
|
||||
add %ecx, %edx; \
|
||||
/* We loaded the jump table and adjuested EDX. Go. */ \
|
||||
jmp *%ebx
|
||||
|
||||
.section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
|
||||
.globl __i686.get_pc_thunk.bx
|
||||
.hidden __i686.get_pc_thunk.bx
|
||||
ALIGN (4)
|
||||
.type __i686.get_pc_thunk.bx,@function
|
||||
__i686.get_pc_thunk.bx:
|
||||
movl (%esp), %ebx
|
||||
ret
|
||||
#else
|
||||
# define ENTRANCE
|
||||
# define RETURN_END ret
|
||||
# define RETURN RETURN_END
|
||||
# define PARMS 4
|
||||
# define JMPTBL(I, B) I
|
||||
|
||||
/* Branch to an entry in a jump table. TABLE is a jump table with
|
||||
absolute offsets. */
|
||||
# define BRANCH_TO_JMPTBL_ENTRY(TABLE) \
|
||||
add %ecx, %edx; \
|
||||
jmp *TABLE(,%ecx,4)
|
||||
#endif
|
||||
|
||||
.section .text.sse2,"ax",@progbits
|
||||
ALIGN (4)
|
||||
ENTRY (sse2_memset5_atom)
|
||||
ENTRANCE
|
||||
|
||||
movl LEN(%esp), %ecx
|
||||
#ifdef USE_AS_BZERO
|
||||
xor %eax, %eax
|
||||
#else
|
||||
movzbl CHR(%esp), %eax
|
||||
movb %al, %ah
|
||||
/* Fill the whole EAX with pattern. */
|
||||
movl %eax, %edx
|
||||
shl $16, %eax
|
||||
or %edx, %eax
|
||||
#endif
|
||||
movl DEST(%esp), %edx
|
||||
cmp $32, %ecx
|
||||
jae L(32bytesormore)
|
||||
|
||||
L(write_less32bytes):
|
||||
BRANCH_TO_JMPTBL_ENTRY (L(table_less_32bytes))
|
||||
|
||||
|
||||
.pushsection .rodata.sse2,"a",@progbits
|
||||
ALIGN (2)
|
||||
L(table_less_32bytes):
|
||||
.int JMPTBL (L(write_0bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_1bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_2bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_3bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_4bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_5bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_6bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_7bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_8bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_9bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_10bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_11bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_12bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_13bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_14bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_15bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_16bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_17bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_18bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_19bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_20bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_21bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_22bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_23bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_24bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_25bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_26bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_27bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_28bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_29bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_30bytes), L(table_less_32bytes))
|
||||
.int JMPTBL (L(write_31bytes), L(table_less_32bytes))
|
||||
.popsection
|
||||
|
||||
ALIGN (4)
|
||||
L(write_28bytes):
|
||||
movl %eax, -28(%edx)
|
||||
L(write_24bytes):
|
||||
movl %eax, -24(%edx)
|
||||
L(write_20bytes):
|
||||
movl %eax, -20(%edx)
|
||||
L(write_16bytes):
|
||||
movl %eax, -16(%edx)
|
||||
L(write_12bytes):
|
||||
movl %eax, -12(%edx)
|
||||
L(write_8bytes):
|
||||
movl %eax, -8(%edx)
|
||||
L(write_4bytes):
|
||||
movl %eax, -4(%edx)
|
||||
L(write_0bytes):
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(write_29bytes):
|
||||
movl %eax, -29(%edx)
|
||||
L(write_25bytes):
|
||||
movl %eax, -25(%edx)
|
||||
L(write_21bytes):
|
||||
movl %eax, -21(%edx)
|
||||
L(write_17bytes):
|
||||
movl %eax, -17(%edx)
|
||||
L(write_13bytes):
|
||||
movl %eax, -13(%edx)
|
||||
L(write_9bytes):
|
||||
movl %eax, -9(%edx)
|
||||
L(write_5bytes):
|
||||
movl %eax, -5(%edx)
|
||||
L(write_1bytes):
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(write_30bytes):
|
||||
movl %eax, -30(%edx)
|
||||
L(write_26bytes):
|
||||
movl %eax, -26(%edx)
|
||||
L(write_22bytes):
|
||||
movl %eax, -22(%edx)
|
||||
L(write_18bytes):
|
||||
movl %eax, -18(%edx)
|
||||
L(write_14bytes):
|
||||
movl %eax, -14(%edx)
|
||||
L(write_10bytes):
|
||||
movl %eax, -10(%edx)
|
||||
L(write_6bytes):
|
||||
movl %eax, -6(%edx)
|
||||
L(write_2bytes):
|
||||
movw %ax, -2(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(write_31bytes):
|
||||
movl %eax, -31(%edx)
|
||||
L(write_27bytes):
|
||||
movl %eax, -27(%edx)
|
||||
L(write_23bytes):
|
||||
movl %eax, -23(%edx)
|
||||
L(write_19bytes):
|
||||
movl %eax, -19(%edx)
|
||||
L(write_15bytes):
|
||||
movl %eax, -15(%edx)
|
||||
L(write_11bytes):
|
||||
movl %eax, -11(%edx)
|
||||
L(write_7bytes):
|
||||
movl %eax, -7(%edx)
|
||||
L(write_3bytes):
|
||||
movw %ax, -3(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
/* ECX > 32 and EDX is 4 byte aligned. */
|
||||
L(32bytesormore):
|
||||
/* Fill xmm0 with the pattern. */
|
||||
#ifdef USE_AS_BZERO
|
||||
pxor %xmm0, %xmm0
|
||||
#else
|
||||
movd %eax, %xmm0
|
||||
punpcklbw %xmm0, %xmm0
|
||||
pshufd $0, %xmm0, %xmm0
|
||||
#endif
|
||||
testl $0xf, %edx
|
||||
jz L(aligned_16)
|
||||
/* ECX > 32 and EDX is not 16 byte aligned. */
|
||||
L(not_aligned_16):
|
||||
movdqu %xmm0, (%edx)
|
||||
movl %edx, %eax
|
||||
and $-16, %edx
|
||||
add $16, %edx
|
||||
sub %edx, %eax
|
||||
add %eax, %ecx
|
||||
movd %xmm0, %eax
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16):
|
||||
cmp $128, %ecx
|
||||
jae L(128bytesormore)
|
||||
|
||||
L(aligned_16_less128bytes):
|
||||
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
|
||||
|
||||
ALIGN (4)
|
||||
L(128bytesormore):
|
||||
#ifdef SHARED_CACHE_SIZE
|
||||
PUSH (%ebx)
|
||||
mov $SHARED_CACHE_SIZE, %ebx
|
||||
#else
|
||||
# ifdef SHARED
|
||||
call __i686.get_pc_thunk.bx
|
||||
add $_GLOBAL_OFFSET_TABLE_, %ebx
|
||||
mov __x86_shared_cache_size@GOTOFF(%ebx), %ebx
|
||||
# else
|
||||
PUSH (%ebx)
|
||||
mov __x86_shared_cache_size, %ebx
|
||||
# endif
|
||||
#endif
|
||||
cmp %ebx, %ecx
|
||||
jae L(128bytesormore_nt_start)
|
||||
|
||||
|
||||
#ifdef DATA_CACHE_SIZE
|
||||
POP (%ebx)
|
||||
cmp $DATA_CACHE_SIZE, %ecx
|
||||
#else
|
||||
# ifdef SHARED
|
||||
call __i686.get_pc_thunk.bx
|
||||
add $_GLOBAL_OFFSET_TABLE_, %ebx
|
||||
cmp __x86_data_cache_size@GOTOFF(%ebx), %ecx
|
||||
# else
|
||||
POP (%ebx)
|
||||
cmp __x86_data_cache_size, %ecx
|
||||
# endif
|
||||
#endif
|
||||
|
||||
jae L(128bytes_L2_normal)
|
||||
subl $128, %ecx
|
||||
L(128bytesormore_normal):
|
||||
sub $128, %ecx
|
||||
movdqa %xmm0, (%edx)
|
||||
movdqa %xmm0, 0x10(%edx)
|
||||
movdqa %xmm0, 0x20(%edx)
|
||||
movdqa %xmm0, 0x30(%edx)
|
||||
movdqa %xmm0, 0x40(%edx)
|
||||
movdqa %xmm0, 0x50(%edx)
|
||||
movdqa %xmm0, 0x60(%edx)
|
||||
movdqa %xmm0, 0x70(%edx)
|
||||
lea 128(%edx), %edx
|
||||
jb L(128bytesless_normal)
|
||||
|
||||
|
||||
sub $128, %ecx
|
||||
movdqa %xmm0, (%edx)
|
||||
movdqa %xmm0, 0x10(%edx)
|
||||
movdqa %xmm0, 0x20(%edx)
|
||||
movdqa %xmm0, 0x30(%edx)
|
||||
movdqa %xmm0, 0x40(%edx)
|
||||
movdqa %xmm0, 0x50(%edx)
|
||||
movdqa %xmm0, 0x60(%edx)
|
||||
movdqa %xmm0, 0x70(%edx)
|
||||
lea 128(%edx), %edx
|
||||
jae L(128bytesormore_normal)
|
||||
|
||||
L(128bytesless_normal):
|
||||
lea 128(%ecx), %ecx
|
||||
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
|
||||
|
||||
ALIGN (4)
|
||||
L(128bytes_L2_normal):
|
||||
prefetcht0 0x380(%edx)
|
||||
prefetcht0 0x3c0(%edx)
|
||||
sub $128, %ecx
|
||||
movdqa %xmm0, (%edx)
|
||||
movaps %xmm0, 0x10(%edx)
|
||||
movaps %xmm0, 0x20(%edx)
|
||||
movaps %xmm0, 0x30(%edx)
|
||||
movaps %xmm0, 0x40(%edx)
|
||||
movaps %xmm0, 0x50(%edx)
|
||||
movaps %xmm0, 0x60(%edx)
|
||||
movaps %xmm0, 0x70(%edx)
|
||||
add $128, %edx
|
||||
cmp $128, %ecx
|
||||
jae L(128bytes_L2_normal)
|
||||
|
||||
L(128bytesless_L2_normal):
|
||||
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
|
||||
|
||||
L(128bytesormore_nt_start):
|
||||
sub %ebx, %ecx
|
||||
ALIGN (4)
|
||||
L(128bytesormore_shared_cache_loop):
|
||||
prefetcht0 0x3c0(%edx)
|
||||
prefetcht0 0x380(%edx)
|
||||
sub $0x80, %ebx
|
||||
movdqa %xmm0, (%edx)
|
||||
movdqa %xmm0, 0x10(%edx)
|
||||
movdqa %xmm0, 0x20(%edx)
|
||||
movdqa %xmm0, 0x30(%edx)
|
||||
movdqa %xmm0, 0x40(%edx)
|
||||
movdqa %xmm0, 0x50(%edx)
|
||||
movdqa %xmm0, 0x60(%edx)
|
||||
movdqa %xmm0, 0x70(%edx)
|
||||
add $0x80, %edx
|
||||
cmp $0x80, %ebx
|
||||
jae L(128bytesormore_shared_cache_loop)
|
||||
cmp $0x80, %ecx
|
||||
jb L(shared_cache_loop_end)
|
||||
ALIGN (4)
|
||||
L(128bytesormore_nt):
|
||||
sub $0x80, %ecx
|
||||
movntdq %xmm0, (%edx)
|
||||
movntdq %xmm0, 0x10(%edx)
|
||||
movntdq %xmm0, 0x20(%edx)
|
||||
movntdq %xmm0, 0x30(%edx)
|
||||
movntdq %xmm0, 0x40(%edx)
|
||||
movntdq %xmm0, 0x50(%edx)
|
||||
movntdq %xmm0, 0x60(%edx)
|
||||
movntdq %xmm0, 0x70(%edx)
|
||||
add $0x80, %edx
|
||||
cmp $0x80, %ecx
|
||||
jae L(128bytesormore_nt)
|
||||
sfence
|
||||
L(shared_cache_loop_end):
|
||||
#if defined DATA_CACHE_SIZE || !defined SHARED
|
||||
POP (%ebx)
|
||||
#endif
|
||||
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
|
||||
|
||||
|
||||
.pushsection .rodata.sse2,"a",@progbits
|
||||
ALIGN (2)
|
||||
L(table_16_128bytes):
|
||||
.int JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_1bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_2bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_3bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_5bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_6bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_7bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_9bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_10bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_11bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_13bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_14bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_15bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_17bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_18bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_19bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_21bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_22bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_23bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_25bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_26bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_27bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_29bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_30bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_31bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_33bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_34bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_35bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_37bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_38bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_39bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_41bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_42bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_43bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_45bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_46bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_47bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_49bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_50bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_51bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_53bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_54bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_55bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_57bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_58bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_59bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_61bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_62bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_63bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_65bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_66bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_67bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_69bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_70bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_71bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_73bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_74bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_75bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_77bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_78bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_79bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_81bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_82bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_83bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_85bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_86bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_87bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_89bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_90bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_91bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_93bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_94bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_95bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_97bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_98bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_99bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_101bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_102bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_103bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_105bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_106bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_107bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_109bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_110bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_111bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_113bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_114bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_115bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_117bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_118bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_119bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_121bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_122bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_123bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_125bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_126bytes), L(table_16_128bytes))
|
||||
.int JMPTBL (L(aligned_16_127bytes), L(table_16_128bytes))
|
||||
.popsection
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_112bytes):
|
||||
movdqa %xmm0, -112(%edx)
|
||||
L(aligned_16_96bytes):
|
||||
movdqa %xmm0, -96(%edx)
|
||||
L(aligned_16_80bytes):
|
||||
movdqa %xmm0, -80(%edx)
|
||||
L(aligned_16_64bytes):
|
||||
movdqa %xmm0, -64(%edx)
|
||||
L(aligned_16_48bytes):
|
||||
movdqa %xmm0, -48(%edx)
|
||||
L(aligned_16_32bytes):
|
||||
movdqa %xmm0, -32(%edx)
|
||||
L(aligned_16_16bytes):
|
||||
movdqa %xmm0, -16(%edx)
|
||||
L(aligned_16_0bytes):
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_113bytes):
|
||||
movdqa %xmm0, -113(%edx)
|
||||
L(aligned_16_97bytes):
|
||||
movdqa %xmm0, -97(%edx)
|
||||
L(aligned_16_81bytes):
|
||||
movdqa %xmm0, -81(%edx)
|
||||
L(aligned_16_65bytes):
|
||||
movdqa %xmm0, -65(%edx)
|
||||
L(aligned_16_49bytes):
|
||||
movdqa %xmm0, -49(%edx)
|
||||
L(aligned_16_33bytes):
|
||||
movdqa %xmm0, -33(%edx)
|
||||
L(aligned_16_17bytes):
|
||||
movdqa %xmm0, -17(%edx)
|
||||
L(aligned_16_1bytes):
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_114bytes):
|
||||
movdqa %xmm0, -114(%edx)
|
||||
L(aligned_16_98bytes):
|
||||
movdqa %xmm0, -98(%edx)
|
||||
L(aligned_16_82bytes):
|
||||
movdqa %xmm0, -82(%edx)
|
||||
L(aligned_16_66bytes):
|
||||
movdqa %xmm0, -66(%edx)
|
||||
L(aligned_16_50bytes):
|
||||
movdqa %xmm0, -50(%edx)
|
||||
L(aligned_16_34bytes):
|
||||
movdqa %xmm0, -34(%edx)
|
||||
L(aligned_16_18bytes):
|
||||
movdqa %xmm0, -18(%edx)
|
||||
L(aligned_16_2bytes):
|
||||
movw %ax, -2(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_115bytes):
|
||||
movdqa %xmm0, -115(%edx)
|
||||
L(aligned_16_99bytes):
|
||||
movdqa %xmm0, -99(%edx)
|
||||
L(aligned_16_83bytes):
|
||||
movdqa %xmm0, -83(%edx)
|
||||
L(aligned_16_67bytes):
|
||||
movdqa %xmm0, -67(%edx)
|
||||
L(aligned_16_51bytes):
|
||||
movdqa %xmm0, -51(%edx)
|
||||
L(aligned_16_35bytes):
|
||||
movdqa %xmm0, -35(%edx)
|
||||
L(aligned_16_19bytes):
|
||||
movdqa %xmm0, -19(%edx)
|
||||
L(aligned_16_3bytes):
|
||||
movw %ax, -3(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_116bytes):
|
||||
movdqa %xmm0, -116(%edx)
|
||||
L(aligned_16_100bytes):
|
||||
movdqa %xmm0, -100(%edx)
|
||||
L(aligned_16_84bytes):
|
||||
movdqa %xmm0, -84(%edx)
|
||||
L(aligned_16_68bytes):
|
||||
movdqa %xmm0, -68(%edx)
|
||||
L(aligned_16_52bytes):
|
||||
movdqa %xmm0, -52(%edx)
|
||||
L(aligned_16_36bytes):
|
||||
movdqa %xmm0, -36(%edx)
|
||||
L(aligned_16_20bytes):
|
||||
movdqa %xmm0, -20(%edx)
|
||||
L(aligned_16_4bytes):
|
||||
movl %eax, -4(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_117bytes):
|
||||
movdqa %xmm0, -117(%edx)
|
||||
L(aligned_16_101bytes):
|
||||
movdqa %xmm0, -101(%edx)
|
||||
L(aligned_16_85bytes):
|
||||
movdqa %xmm0, -85(%edx)
|
||||
L(aligned_16_69bytes):
|
||||
movdqa %xmm0, -69(%edx)
|
||||
L(aligned_16_53bytes):
|
||||
movdqa %xmm0, -53(%edx)
|
||||
L(aligned_16_37bytes):
|
||||
movdqa %xmm0, -37(%edx)
|
||||
L(aligned_16_21bytes):
|
||||
movdqa %xmm0, -21(%edx)
|
||||
L(aligned_16_5bytes):
|
||||
movl %eax, -5(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_118bytes):
|
||||
movdqa %xmm0, -118(%edx)
|
||||
L(aligned_16_102bytes):
|
||||
movdqa %xmm0, -102(%edx)
|
||||
L(aligned_16_86bytes):
|
||||
movdqa %xmm0, -86(%edx)
|
||||
L(aligned_16_70bytes):
|
||||
movdqa %xmm0, -70(%edx)
|
||||
L(aligned_16_54bytes):
|
||||
movdqa %xmm0, -54(%edx)
|
||||
L(aligned_16_38bytes):
|
||||
movdqa %xmm0, -38(%edx)
|
||||
L(aligned_16_22bytes):
|
||||
movdqa %xmm0, -22(%edx)
|
||||
L(aligned_16_6bytes):
|
||||
movl %eax, -6(%edx)
|
||||
movw %ax, -2(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_119bytes):
|
||||
movdqa %xmm0, -119(%edx)
|
||||
L(aligned_16_103bytes):
|
||||
movdqa %xmm0, -103(%edx)
|
||||
L(aligned_16_87bytes):
|
||||
movdqa %xmm0, -87(%edx)
|
||||
L(aligned_16_71bytes):
|
||||
movdqa %xmm0, -71(%edx)
|
||||
L(aligned_16_55bytes):
|
||||
movdqa %xmm0, -55(%edx)
|
||||
L(aligned_16_39bytes):
|
||||
movdqa %xmm0, -39(%edx)
|
||||
L(aligned_16_23bytes):
|
||||
movdqa %xmm0, -23(%edx)
|
||||
L(aligned_16_7bytes):
|
||||
movl %eax, -7(%edx)
|
||||
movw %ax, -3(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_120bytes):
|
||||
movdqa %xmm0, -120(%edx)
|
||||
L(aligned_16_104bytes):
|
||||
movdqa %xmm0, -104(%edx)
|
||||
L(aligned_16_88bytes):
|
||||
movdqa %xmm0, -88(%edx)
|
||||
L(aligned_16_72bytes):
|
||||
movdqa %xmm0, -72(%edx)
|
||||
L(aligned_16_56bytes):
|
||||
movdqa %xmm0, -56(%edx)
|
||||
L(aligned_16_40bytes):
|
||||
movdqa %xmm0, -40(%edx)
|
||||
L(aligned_16_24bytes):
|
||||
movdqa %xmm0, -24(%edx)
|
||||
L(aligned_16_8bytes):
|
||||
movq %xmm0, -8(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_121bytes):
|
||||
movdqa %xmm0, -121(%edx)
|
||||
L(aligned_16_105bytes):
|
||||
movdqa %xmm0, -105(%edx)
|
||||
L(aligned_16_89bytes):
|
||||
movdqa %xmm0, -89(%edx)
|
||||
L(aligned_16_73bytes):
|
||||
movdqa %xmm0, -73(%edx)
|
||||
L(aligned_16_57bytes):
|
||||
movdqa %xmm0, -57(%edx)
|
||||
L(aligned_16_41bytes):
|
||||
movdqa %xmm0, -41(%edx)
|
||||
L(aligned_16_25bytes):
|
||||
movdqa %xmm0, -25(%edx)
|
||||
L(aligned_16_9bytes):
|
||||
movq %xmm0, -9(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_122bytes):
|
||||
movdqa %xmm0, -122(%edx)
|
||||
L(aligned_16_106bytes):
|
||||
movdqa %xmm0, -106(%edx)
|
||||
L(aligned_16_90bytes):
|
||||
movdqa %xmm0, -90(%edx)
|
||||
L(aligned_16_74bytes):
|
||||
movdqa %xmm0, -74(%edx)
|
||||
L(aligned_16_58bytes):
|
||||
movdqa %xmm0, -58(%edx)
|
||||
L(aligned_16_42bytes):
|
||||
movdqa %xmm0, -42(%edx)
|
||||
L(aligned_16_26bytes):
|
||||
movdqa %xmm0, -26(%edx)
|
||||
L(aligned_16_10bytes):
|
||||
movq %xmm0, -10(%edx)
|
||||
movw %ax, -2(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_123bytes):
|
||||
movdqa %xmm0, -123(%edx)
|
||||
L(aligned_16_107bytes):
|
||||
movdqa %xmm0, -107(%edx)
|
||||
L(aligned_16_91bytes):
|
||||
movdqa %xmm0, -91(%edx)
|
||||
L(aligned_16_75bytes):
|
||||
movdqa %xmm0, -75(%edx)
|
||||
L(aligned_16_59bytes):
|
||||
movdqa %xmm0, -59(%edx)
|
||||
L(aligned_16_43bytes):
|
||||
movdqa %xmm0, -43(%edx)
|
||||
L(aligned_16_27bytes):
|
||||
movdqa %xmm0, -27(%edx)
|
||||
L(aligned_16_11bytes):
|
||||
movq %xmm0, -11(%edx)
|
||||
movw %ax, -3(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_124bytes):
|
||||
movdqa %xmm0, -124(%edx)
|
||||
L(aligned_16_108bytes):
|
||||
movdqa %xmm0, -108(%edx)
|
||||
L(aligned_16_92bytes):
|
||||
movdqa %xmm0, -92(%edx)
|
||||
L(aligned_16_76bytes):
|
||||
movdqa %xmm0, -76(%edx)
|
||||
L(aligned_16_60bytes):
|
||||
movdqa %xmm0, -60(%edx)
|
||||
L(aligned_16_44bytes):
|
||||
movdqa %xmm0, -44(%edx)
|
||||
L(aligned_16_28bytes):
|
||||
movdqa %xmm0, -28(%edx)
|
||||
L(aligned_16_12bytes):
|
||||
movq %xmm0, -12(%edx)
|
||||
movl %eax, -4(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_125bytes):
|
||||
movdqa %xmm0, -125(%edx)
|
||||
L(aligned_16_109bytes):
|
||||
movdqa %xmm0, -109(%edx)
|
||||
L(aligned_16_93bytes):
|
||||
movdqa %xmm0, -93(%edx)
|
||||
L(aligned_16_77bytes):
|
||||
movdqa %xmm0, -77(%edx)
|
||||
L(aligned_16_61bytes):
|
||||
movdqa %xmm0, -61(%edx)
|
||||
L(aligned_16_45bytes):
|
||||
movdqa %xmm0, -45(%edx)
|
||||
L(aligned_16_29bytes):
|
||||
movdqa %xmm0, -29(%edx)
|
||||
L(aligned_16_13bytes):
|
||||
movq %xmm0, -13(%edx)
|
||||
movl %eax, -5(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_126bytes):
|
||||
movdqa %xmm0, -126(%edx)
|
||||
L(aligned_16_110bytes):
|
||||
movdqa %xmm0, -110(%edx)
|
||||
L(aligned_16_94bytes):
|
||||
movdqa %xmm0, -94(%edx)
|
||||
L(aligned_16_78bytes):
|
||||
movdqa %xmm0, -78(%edx)
|
||||
L(aligned_16_62bytes):
|
||||
movdqa %xmm0, -62(%edx)
|
||||
L(aligned_16_46bytes):
|
||||
movdqa %xmm0, -46(%edx)
|
||||
L(aligned_16_30bytes):
|
||||
movdqa %xmm0, -30(%edx)
|
||||
L(aligned_16_14bytes):
|
||||
movq %xmm0, -14(%edx)
|
||||
movl %eax, -6(%edx)
|
||||
movw %ax, -2(%edx)
|
||||
SETRTNVAL
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
L(aligned_16_127bytes):
|
||||
movdqa %xmm0, -127(%edx)
|
||||
L(aligned_16_111bytes):
|
||||
movdqa %xmm0, -111(%edx)
|
||||
L(aligned_16_95bytes):
|
||||
movdqa %xmm0, -95(%edx)
|
||||
L(aligned_16_79bytes):
|
||||
movdqa %xmm0, -79(%edx)
|
||||
L(aligned_16_63bytes):
|
||||
movdqa %xmm0, -63(%edx)
|
||||
L(aligned_16_47bytes):
|
||||
movdqa %xmm0, -47(%edx)
|
||||
L(aligned_16_31bytes):
|
||||
movdqa %xmm0, -31(%edx)
|
||||
L(aligned_16_15bytes):
|
||||
movq %xmm0, -15(%edx)
|
||||
movl %eax, -7(%edx)
|
||||
movw %ax, -3(%edx)
|
||||
movb %al, -1(%edx)
|
||||
SETRTNVAL
|
||||
RETURN_END
|
||||
|
||||
END (sse2_memset5_atom)
|
2027
libc/arch-x86/string/ssse3-memcmp3.S
Normal file
2027
libc/arch-x86/string/ssse3-memcmp3.S
Normal file
File diff suppressed because it is too large
Load Diff
1770
libc/arch-x86/string/ssse3-memcpy5.S
Normal file
1770
libc/arch-x86/string/ssse3-memcpy5.S
Normal file
File diff suppressed because it is too large
Load Diff
2265
libc/arch-x86/string/ssse3-strcmp.S
Normal file
2265
libc/arch-x86/string/ssse3-strcmp.S
Normal file
File diff suppressed because it is too large
Load Diff
40
libc/arch-x86/string/strcmp_wrapper.S
Normal file
40
libc/arch-x86/string/strcmp_wrapper.S
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSSE3)
|
||||
|
||||
# define ssse3_strcmp_latest strcmp
|
||||
# include "ssse3-strcmp.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "strcmp.S"
|
||||
|
||||
#endif
|
42
libc/arch-x86/string/strncmp_wrapper.S
Normal file
42
libc/arch-x86/string/strncmp_wrapper.S
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
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.
|
||||
|
||||
* Neither the name of Intel Corporation nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSSE3)
|
||||
|
||||
# define USE_AS_STRNCMP
|
||||
# define ssse3_strcmp_latest strncmp
|
||||
# include "ssse3-strcmp.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "strncmp.S"
|
||||
|
||||
#endif
|
||||
|
@@ -4,7 +4,7 @@ syscall_src += arch-x86/syscalls/_exit.S
|
||||
syscall_src += arch-x86/syscalls/_exit_thread.S
|
||||
syscall_src += arch-x86/syscalls/__fork.S
|
||||
syscall_src += arch-x86/syscalls/_waitpid.S
|
||||
syscall_src += arch-x86/syscalls/waitid.S
|
||||
syscall_src += arch-x86/syscalls/__waitid.S
|
||||
syscall_src += arch-x86/syscalls/__sys_clone.S
|
||||
syscall_src += arch-x86/syscalls/execve.S
|
||||
syscall_src += arch-x86/syscalls/__setuid.S
|
||||
@@ -69,15 +69,17 @@ syscall_src += arch-x86/syscalls/flock.S
|
||||
syscall_src += arch-x86/syscalls/fchmod.S
|
||||
syscall_src += arch-x86/syscalls/dup.S
|
||||
syscall_src += arch-x86/syscalls/pipe.S
|
||||
syscall_src += arch-x86/syscalls/pipe2.S
|
||||
syscall_src += arch-x86/syscalls/dup2.S
|
||||
syscall_src += arch-x86/syscalls/select.S
|
||||
syscall_src += arch-x86/syscalls/ftruncate.S
|
||||
syscall_src += arch-x86/syscalls/getdents.S
|
||||
syscall_src += arch-x86/syscalls/fsync.S
|
||||
syscall_src += arch-x86/syscalls/fdatasync.S
|
||||
syscall_src += arch-x86/syscalls/fchown.S
|
||||
syscall_src += arch-x86/syscalls/sync.S
|
||||
syscall_src += arch-x86/syscalls/__fcntl64.S
|
||||
syscall_src += arch-x86/syscalls/fstatfs.S
|
||||
syscall_src += arch-x86/syscalls/__fstatfs64.S
|
||||
syscall_src += arch-x86/syscalls/sendfile.S
|
||||
syscall_src += arch-x86/syscalls/fstatat.S
|
||||
syscall_src += arch-x86/syscalls/mkdirat.S
|
||||
@@ -164,6 +166,7 @@ syscall_src += arch-x86/syscalls/__syslog.S
|
||||
syscall_src += arch-x86/syscalls/init_module.S
|
||||
syscall_src += arch-x86/syscalls/delete_module.S
|
||||
syscall_src += arch-x86/syscalls/klogctl.S
|
||||
syscall_src += arch-x86/syscalls/sysinfo.S
|
||||
syscall_src += arch-x86/syscalls/futex.S
|
||||
syscall_src += arch-x86/syscalls/epoll_create.S
|
||||
syscall_src += arch-x86/syscalls/epoll_ctl.S
|
||||
@@ -172,3 +175,4 @@ syscall_src += arch-x86/syscalls/inotify_init.S
|
||||
syscall_src += arch-x86/syscalls/inotify_add_watch.S
|
||||
syscall_src += arch-x86/syscalls/inotify_rm_watch.S
|
||||
syscall_src += arch-x86/syscalls/poll.S
|
||||
syscall_src += arch-x86/syscalls/eventfd.S
|
||||
|
@@ -2,11 +2,11 @@
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type fstatfs, @function
|
||||
.globl fstatfs
|
||||
.type __fstatfs64, @function
|
||||
.globl __fstatfs64
|
||||
.align 4
|
||||
|
||||
fstatfs:
|
||||
__fstatfs64:
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
pushl %edx
|
@@ -2,11 +2,11 @@
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type waitid, @function
|
||||
.globl waitid
|
||||
.type __waitid, @function
|
||||
.globl __waitid
|
||||
.align 4
|
||||
|
||||
waitid:
|
||||
__waitid:
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
pushl %edx
|
26
libc/arch-x86/syscalls/eventfd.S
Normal file
26
libc/arch-x86/syscalls/eventfd.S
Normal file
@@ -0,0 +1,26 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type eventfd, @function
|
||||
.globl eventfd
|
||||
.align 4
|
||||
|
||||
eventfd:
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
mov 12(%esp), %ebx
|
||||
mov 16(%esp), %ecx
|
||||
movl $__NR_eventfd2, %eax
|
||||
int $0x80
|
||||
cmpl $-129, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
ret
|
23
libc/arch-x86/syscalls/fdatasync.S
Normal file
23
libc/arch-x86/syscalls/fdatasync.S
Normal file
@@ -0,0 +1,23 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type fdatasync, @function
|
||||
.globl fdatasync
|
||||
.align 4
|
||||
|
||||
fdatasync:
|
||||
pushl %ebx
|
||||
mov 8(%esp), %ebx
|
||||
movl $__NR_fdatasync, %eax
|
||||
int $0x80
|
||||
cmpl $-129, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ebx
|
||||
ret
|
26
libc/arch-x86/syscalls/pipe2.S
Normal file
26
libc/arch-x86/syscalls/pipe2.S
Normal file
@@ -0,0 +1,26 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type pipe2, @function
|
||||
.globl pipe2
|
||||
.align 4
|
||||
|
||||
pipe2:
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
mov 12(%esp), %ebx
|
||||
mov 16(%esp), %ecx
|
||||
movl $__NR_pipe2, %eax
|
||||
int $0x80
|
||||
cmpl $-129, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
ret
|
23
libc/arch-x86/syscalls/sysinfo.S
Normal file
23
libc/arch-x86/syscalls/sysinfo.S
Normal file
@@ -0,0 +1,23 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <sys/linux-syscalls.h>
|
||||
|
||||
.text
|
||||
.type sysinfo, @function
|
||||
.globl sysinfo
|
||||
.align 4
|
||||
|
||||
sysinfo:
|
||||
pushl %ebx
|
||||
mov 8(%esp), %ebx
|
||||
movl $__NR_sysinfo, %eax
|
||||
int $0x80
|
||||
cmpl $-129, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ebx
|
||||
ret
|
@@ -26,14 +26,17 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
extern char** environ;
|
||||
|
||||
int clearenv(void)
|
||||
{
|
||||
char **P = environ;
|
||||
int offset;
|
||||
|
||||
for (P = &environ[offset]; *P; ++P)
|
||||
*P = 0;
|
||||
if (P != NULL) {
|
||||
for (; *P; ++P)
|
||||
*P = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
//#include <sys/types.h>
|
||||
#include "cpuacct.h"
|
||||
|
||||
int cpuacct_add(uid_t uid)
|
||||
{
|
||||
|
@@ -27,6 +27,7 @@
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include "pthread_internal.h"
|
||||
#include "cpuacct.h"
|
||||
|
||||
extern int __fork(void);
|
||||
|
||||
|
@@ -548,9 +548,9 @@ fts_build(FTS *sp, int type)
|
||||
DIR *dirp;
|
||||
void *oldaddr;
|
||||
size_t len, maxlen;
|
||||
int nitems, cderrno, descend, level, nlinks, nostat, doadjust;
|
||||
int nitems, cderrno, descend, level, nlinks, nostat = 0, doadjust;
|
||||
int saved_errno;
|
||||
char *cp;
|
||||
char *cp = NULL;
|
||||
|
||||
/* Set current node pointer. */
|
||||
cur = sp->fts_cur;
|
||||
|
@@ -84,3 +84,39 @@ void __libc_init_common(uintptr_t *elfdata)
|
||||
/* setup system properties - requires environment */
|
||||
__system_properties_init();
|
||||
}
|
||||
|
||||
/* This function will be called during normal program termination
|
||||
* to run the destructors that are listed in the .fini_array section
|
||||
* of the executable, if any.
|
||||
*
|
||||
* 'fini_array' points to a list of function addresses. The first
|
||||
* entry in the list has value -1, the last one has value 0.
|
||||
*/
|
||||
void __libc_fini(void* array)
|
||||
{
|
||||
int count;
|
||||
void** fini_array = array;
|
||||
const size_t minus1 = ~(size_t)0; /* ensure proper sign extension */
|
||||
|
||||
/* Sanity check - first entry must be -1 */
|
||||
if (array == NULL || (size_t)fini_array[0] != minus1) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* skip over it */
|
||||
fini_array += 1;
|
||||
|
||||
/* Count the number of destructors. */
|
||||
for (count = 0; fini_array[count] != NULL; count++);
|
||||
|
||||
/* Now call each destructor in reverse order. */
|
||||
while (count > 0) {
|
||||
void (*func)() = (void (*)) fini_array[--count];
|
||||
|
||||
/* Sanity check, any -1 in the list is ignored */
|
||||
if ((size_t)func == minus1)
|
||||
continue;
|
||||
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
@@ -39,5 +39,6 @@ typedef struct
|
||||
} structors_array_t;
|
||||
|
||||
extern void __libc_init_common(uintptr_t *elfdata);
|
||||
extern void __libc_fini(void* finit_array);
|
||||
|
||||
#endif
|
||||
|
@@ -57,9 +57,9 @@
|
||||
* This ensures that the function is called by the dynamic linker
|
||||
* as soon as the shared library is loaded.
|
||||
*/
|
||||
void __attribute__((constructor)) __libc_prenit(void);
|
||||
void __attribute__((constructor)) __libc_preinit(void);
|
||||
|
||||
void __libc_prenit(void)
|
||||
void __libc_preinit(void)
|
||||
{
|
||||
/* Read the ELF data pointer form a special slot of the
|
||||
* TLS area, then call __libc_init_common with it.
|
||||
@@ -83,14 +83,19 @@ void __libc_prenit(void)
|
||||
malloc_debug_init();
|
||||
}
|
||||
|
||||
/* This function is called from the executable's _start entry point
|
||||
* (see arch-$ARCH/bionic/crtbegin_dynamic.S), which is itself
|
||||
* called by the dynamic linker after it has loaded all shared
|
||||
* libraries the executable depends on.
|
||||
*
|
||||
* Note that the dynamic linker has also run all constructors in the
|
||||
* executable at this point.
|
||||
*/
|
||||
__noreturn void __libc_init(uintptr_t *elfdata,
|
||||
void (*onexit)(void),
|
||||
int (*slingshot)(int, char**, char**),
|
||||
structors_array_t const * const structors)
|
||||
{
|
||||
/* When we reach this point, all initializers have been already
|
||||
* run by the dynamic linker, so ignore 'structors'.
|
||||
*/
|
||||
int argc = (int)*elfdata;
|
||||
char** argv = (char**)(elfdata + 1);
|
||||
char** envp = argv + argc + 1;
|
||||
@@ -99,5 +104,12 @@ __noreturn void __libc_init(uintptr_t *elfdata,
|
||||
* do never use it. Therefore, we ignore it.
|
||||
*/
|
||||
|
||||
/* The executable may have its own destructors listed in its .fini_array
|
||||
* so we need to ensure that these are called when the program exits
|
||||
* normally.
|
||||
*/
|
||||
if (structors->fini_array)
|
||||
__cxa_atexit(__libc_fini,structors->fini_array,NULL);
|
||||
|
||||
exit(slingshot(argc, argv, envp));
|
||||
}
|
||||
|
@@ -85,5 +85,12 @@ __noreturn void __libc_init(uintptr_t *elfdata,
|
||||
argv = (char**)(elfdata + 1);
|
||||
envp = argv + argc + 1;
|
||||
|
||||
/* The executable may have its own destructors listed in its .fini_array
|
||||
* so we need to ensure that these are called when the program exits
|
||||
* normally.
|
||||
*/
|
||||
if (structors->fini_array)
|
||||
__cxa_atexit(__libc_fini,structors->fini_array,NULL);
|
||||
|
||||
exit(slingshot(argc, argv, envp));
|
||||
}
|
||||
|
@@ -38,9 +38,14 @@
|
||||
#include <stdarg.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <cutils/logger.h>
|
||||
#include "logd.h"
|
||||
|
||||
/* should match system/core/include/cutils/logger.h */
|
||||
#define LOGGER_LOG_MAIN "log/main"
|
||||
#define LOGGER_LOG_RADIO "log/radio"
|
||||
#define LOGGER_LOG_EVENTS "log/events"
|
||||
#define LOGGER_LOG_SYSTEM "log/system"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define LOG_BUF_SIZE 1024
|
||||
@@ -114,6 +119,8 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec)
|
||||
(fd < 0) ? __write_to_log_null : __write_to_log_kernel;
|
||||
log_channels[log_id].fd = fd;
|
||||
|
||||
log_channels[log_id].fd = fd;
|
||||
|
||||
pthread_mutex_unlock(&log_init_lock);
|
||||
|
||||
return log_channels[log_id].logger(log_id, vec);
|
||||
|
@@ -60,9 +60,17 @@ HashTable gHashTable;
|
||||
|
||||
static int hash_entry_compare(const void* arg1, const void* arg2)
|
||||
{
|
||||
int result;
|
||||
|
||||
HashEntry* e1 = *(HashEntry**)arg1;
|
||||
HashEntry* e2 = *(HashEntry**)arg2;
|
||||
|
||||
// if one or both arg pointers are null, deal gracefully
|
||||
if (e1 == NULL) {
|
||||
result = (e2 == NULL) ? 0 : 1;
|
||||
} else if (e2 == NULL) {
|
||||
result = -1;
|
||||
} else {
|
||||
size_t nbAlloc1 = e1->allocations;
|
||||
size_t nbAlloc2 = e2->allocations;
|
||||
size_t size1 = e1->size & ~SIZE_FLAG_MASK;
|
||||
@@ -90,6 +98,7 @@ static int hash_entry_compare(const void* arg1, const void* arg2)
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -149,7 +158,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
|
||||
|
||||
if (*info == NULL) {
|
||||
*overallSize = 0;
|
||||
goto done;
|
||||
goto out_nomem_info;
|
||||
}
|
||||
|
||||
qsort((void*)list, gHashTable.count, sizeof(void*), hash_entry_compare);
|
||||
@@ -161,8 +170,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
|
||||
size_t entrySize = (sizeof(size_t) * 2) + (sizeof(intptr_t) * entry->numEntries);
|
||||
if (entrySize < *infoSize) {
|
||||
/* we're writing less than a full entry, clear out the rest */
|
||||
/* TODO: only clear out the part we're not overwriting? */
|
||||
memset(head, 0, *infoSize);
|
||||
memset(head + entrySize, 0, *infoSize - entrySize);
|
||||
} else {
|
||||
/* make sure the amount we're copying doesn't exceed the limit */
|
||||
entrySize = *infoSize;
|
||||
@@ -171,6 +179,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
|
||||
head += *infoSize;
|
||||
}
|
||||
|
||||
out_nomem_info:
|
||||
dlfree(list);
|
||||
|
||||
done:
|
||||
|
@@ -149,6 +149,8 @@ static HashEntry* record_backtrace(intptr_t* backtrace, size_t numEntries, size_
|
||||
} else {
|
||||
// create a new entry
|
||||
entry = (HashEntry*)dlmalloc(sizeof(HashEntry) + numEntries*sizeof(intptr_t));
|
||||
if (!entry)
|
||||
return NULL;
|
||||
entry->allocations = 1;
|
||||
entry->slot = slot;
|
||||
entry->prev = NULL;
|
||||
|
347
libc/bionic/pthread-rwlocks.c
Normal file
347
libc/bionic/pthread-rwlocks.c
Normal file
@@ -0,0 +1,347 @@
|
||||
/*
|
||||
* 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 "pthread_internal.h"
|
||||
#include <errno.h>
|
||||
|
||||
/* Technical note:
|
||||
*
|
||||
* Possible states of a read/write lock:
|
||||
*
|
||||
* - no readers and no writer (unlocked)
|
||||
* - one or more readers sharing the lock at the same time (read-locked)
|
||||
* - one writer holding the lock (write-lock)
|
||||
*
|
||||
* Additionally:
|
||||
* - trying to get the write-lock while there are any readers blocks
|
||||
* - trying to get the read-lock while there is a writer blocks
|
||||
* - a single thread can acquire the lock multiple times in the same mode
|
||||
*
|
||||
* - Posix states that behaviour is undefined it a thread tries to acquire
|
||||
* the lock in two distinct modes (e.g. write after read, or read after write).
|
||||
*
|
||||
* - This implementation tries to avoid writer starvation by making the readers
|
||||
* block as soon as there is a waiting writer on the lock. However, it cannot
|
||||
* completely eliminate it: each time the lock is unlocked, all waiting threads
|
||||
* are woken and battle for it, which one gets it depends on the kernel scheduler
|
||||
* and is semi-random.
|
||||
*
|
||||
*/
|
||||
|
||||
#define __likely(cond) __builtin_expect(!!(cond), 1)
|
||||
#define __unlikely(cond) __builtin_expect(!!(cond), 0)
|
||||
|
||||
#define RWLOCKATTR_DEFAULT 0
|
||||
#define RWLOCKATTR_SHARED_MASK 0x0010
|
||||
|
||||
extern pthread_internal_t* __get_thread(void);
|
||||
|
||||
/* Return a global kernel ID for the current thread */
|
||||
static int __get_thread_id(void)
|
||||
{
|
||||
return __get_thread()->kernel_id;
|
||||
}
|
||||
|
||||
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
|
||||
{
|
||||
if (!attr)
|
||||
return EINVAL;
|
||||
|
||||
*attr = PTHREAD_PROCESS_PRIVATE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
|
||||
{
|
||||
if (!attr)
|
||||
return EINVAL;
|
||||
|
||||
*attr = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared)
|
||||
{
|
||||
if (!attr)
|
||||
return EINVAL;
|
||||
|
||||
switch (pshared) {
|
||||
case PTHREAD_PROCESS_PRIVATE:
|
||||
case PTHREAD_PROCESS_SHARED:
|
||||
*attr = pshared;
|
||||
return 0;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *attr, int *pshared)
|
||||
{
|
||||
if (!attr || !pshared)
|
||||
return EINVAL;
|
||||
|
||||
*pshared = *attr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
|
||||
{
|
||||
pthread_mutexattr_t* lock_attr = NULL;
|
||||
pthread_condattr_t* cond_attr = NULL;
|
||||
pthread_mutexattr_t lock_attr0;
|
||||
pthread_condattr_t cond_attr0;
|
||||
int ret;
|
||||
|
||||
if (rwlock == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if (attr && *attr == PTHREAD_PROCESS_SHARED) {
|
||||
lock_attr = &lock_attr0;
|
||||
pthread_mutexattr_init(lock_attr);
|
||||
pthread_mutexattr_setpshared(lock_attr, PTHREAD_PROCESS_SHARED);
|
||||
|
||||
cond_attr = &cond_attr0;
|
||||
pthread_condattr_init(cond_attr);
|
||||
pthread_condattr_setpshared(cond_attr, PTHREAD_PROCESS_SHARED);
|
||||
}
|
||||
|
||||
ret = pthread_mutex_init(&rwlock->lock, lock_attr);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
ret = pthread_cond_init(&rwlock->cond, cond_attr);
|
||||
if (ret != 0) {
|
||||
pthread_mutex_destroy(&rwlock->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
rwlock->numLocks = 0;
|
||||
rwlock->pendingReaders = 0;
|
||||
rwlock->pendingWriters = 0;
|
||||
rwlock->writerThreadId = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (rwlock == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if (rwlock->numLocks > 0)
|
||||
return EBUSY;
|
||||
|
||||
pthread_cond_destroy(&rwlock->cond);
|
||||
pthread_mutex_destroy(&rwlock->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Returns TRUE iff we can acquire a read lock. */
|
||||
static __inline__ int read_precondition(pthread_rwlock_t *rwlock, int thread_id)
|
||||
{
|
||||
/* We can't have the lock if any writer is waiting for it (writer bias).
|
||||
* This tries to avoid starvation when there are multiple readers racing.
|
||||
*/
|
||||
if (rwlock->pendingWriters > 0)
|
||||
return 0;
|
||||
|
||||
/* We can have the lock if there is no writer, or if we write-own it */
|
||||
/* The second test avoids a self-dead lock in case of buggy code. */
|
||||
if (rwlock->writerThreadId == 0 || rwlock->writerThreadId == thread_id)
|
||||
return 1;
|
||||
|
||||
/* Otherwise, we can't have it */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* returns TRUE iff we can acquire a write lock. */
|
||||
static __inline__ int write_precondition(pthread_rwlock_t *rwlock, int thread_id)
|
||||
{
|
||||
/* We can get the lock if nobody has it */
|
||||
if (rwlock->numLocks == 0)
|
||||
return 1;
|
||||
|
||||
/* Or if we already own it */
|
||||
if (rwlock->writerThreadId == thread_id)
|
||||
return 1;
|
||||
|
||||
/* Otherwise, not */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function is used to waken any waiting thread contending
|
||||
* for the lock. One of them should be able to grab it after
|
||||
* that.
|
||||
*/
|
||||
static void _pthread_rwlock_pulse(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
if (rwlock->pendingReaders > 0 || rwlock->pendingWriters > 0)
|
||||
pthread_cond_broadcast(&rwlock->cond);
|
||||
}
|
||||
|
||||
|
||||
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
return pthread_rwlock_timedrdlock(rwlock, NULL);
|
||||
}
|
||||
|
||||
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (rwlock == NULL)
|
||||
return EINVAL;
|
||||
|
||||
pthread_mutex_lock(&rwlock->lock);
|
||||
if (__unlikely(!read_precondition(rwlock, __get_thread_id())))
|
||||
ret = EBUSY;
|
||||
else
|
||||
rwlock->numLocks ++;
|
||||
pthread_mutex_unlock(&rwlock->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
|
||||
{
|
||||
int thread_id, ret = 0;
|
||||
|
||||
if (rwlock == NULL)
|
||||
return EINVAL;
|
||||
|
||||
pthread_mutex_lock(&rwlock->lock);
|
||||
thread_id = __get_thread_id();
|
||||
if (__unlikely(!read_precondition(rwlock, thread_id))) {
|
||||
rwlock->pendingReaders += 1;
|
||||
do {
|
||||
ret = pthread_cond_timedwait(&rwlock->cond, &rwlock->lock, abs_timeout);
|
||||
} while (ret == 0 && !read_precondition(rwlock, thread_id));
|
||||
rwlock->pendingReaders -= 1;
|
||||
if (ret != 0)
|
||||
goto EXIT;
|
||||
}
|
||||
rwlock->numLocks ++;
|
||||
EXIT:
|
||||
pthread_mutex_unlock(&rwlock->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
return pthread_rwlock_timedwrlock(rwlock, NULL);
|
||||
}
|
||||
|
||||
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
int thread_id, ret = 0;
|
||||
|
||||
if (rwlock == NULL)
|
||||
return EINVAL;
|
||||
|
||||
pthread_mutex_lock(&rwlock->lock);
|
||||
thread_id = __get_thread_id();
|
||||
if (__unlikely(!write_precondition(rwlock, thread_id))) {
|
||||
ret = EBUSY;
|
||||
} else {
|
||||
rwlock->numLocks ++;
|
||||
rwlock->writerThreadId = thread_id;
|
||||
}
|
||||
pthread_mutex_unlock(&rwlock->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
|
||||
{
|
||||
int thread_id, ret = 0;
|
||||
|
||||
if (rwlock == NULL)
|
||||
return EINVAL;
|
||||
|
||||
pthread_mutex_lock(&rwlock->lock);
|
||||
thread_id = __get_thread_id();
|
||||
if (__unlikely(!write_precondition(rwlock, thread_id))) {
|
||||
/* If we can't read yet, wait until the rwlock is unlocked
|
||||
* and try again. Increment pendingReaders to get the
|
||||
* cond broadcast when that happens.
|
||||
*/
|
||||
rwlock->pendingWriters += 1;
|
||||
do {
|
||||
ret = pthread_cond_timedwait(&rwlock->cond, &rwlock->lock, abs_timeout);
|
||||
} while (ret == 0 && !write_precondition(rwlock, thread_id));
|
||||
rwlock->pendingWriters -= 1;
|
||||
if (ret != 0)
|
||||
goto EXIT;
|
||||
}
|
||||
rwlock->numLocks ++;
|
||||
rwlock->writerThreadId = thread_id;
|
||||
EXIT:
|
||||
pthread_mutex_unlock(&rwlock->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (rwlock == NULL)
|
||||
return EINVAL;
|
||||
|
||||
pthread_mutex_lock(&rwlock->lock);
|
||||
|
||||
/* The lock must be held */
|
||||
if (rwlock->numLocks == 0) {
|
||||
ret = EPERM;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
/* If it has only readers, writerThreadId is 0 */
|
||||
if (rwlock->writerThreadId == 0) {
|
||||
if (--rwlock->numLocks == 0)
|
||||
_pthread_rwlock_pulse(rwlock);
|
||||
}
|
||||
/* Otherwise, it has only a single writer, which
|
||||
* must be ourselves.
|
||||
*/
|
||||
else {
|
||||
if (rwlock->writerThreadId != __get_thread_id()) {
|
||||
ret = EPERM;
|
||||
goto EXIT;
|
||||
}
|
||||
if (--rwlock->numLocks == 0) {
|
||||
rwlock->writerThreadId = 0;
|
||||
_pthread_rwlock_pulse(rwlock);
|
||||
}
|
||||
}
|
||||
EXIT:
|
||||
pthread_mutex_unlock(&rwlock->lock);
|
||||
return ret;
|
||||
}
|
@@ -43,13 +43,28 @@
|
||||
#include <memory.h>
|
||||
#include <assert.h>
|
||||
#include <malloc.h>
|
||||
#include <linux/futex.h>
|
||||
#include <bionic_futex.h>
|
||||
#include <bionic_atomic_inline.h>
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int __pthread_clone(int (*fn)(void*), void *child_stack, int flags, void *arg);
|
||||
extern void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode);
|
||||
extern void _exit_thread(int retCode);
|
||||
extern int __set_errno(int);
|
||||
|
||||
int __futex_wake_ex(volatile void *ftx, int pshared, int val)
|
||||
{
|
||||
return __futex_syscall3(ftx, pshared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, val);
|
||||
}
|
||||
|
||||
int __futex_wait_ex(volatile void *ftx, int pshared, int val, const struct timespec *timeout)
|
||||
{
|
||||
return __futex_syscall4(ftx, pshared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE, val, timeout);
|
||||
}
|
||||
|
||||
#define __likely(cond) __builtin_expect(!!(cond), 1)
|
||||
#define __unlikely(cond) __builtin_expect(!!(cond), 0)
|
||||
|
||||
@@ -712,24 +727,6 @@ int pthread_setschedparam(pthread_t thid, int policy,
|
||||
}
|
||||
|
||||
|
||||
int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
|
||||
int __futex_wake(volatile void *ftx, int count);
|
||||
|
||||
int __futex_syscall3(volatile void *ftx, int op, int val);
|
||||
int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout);
|
||||
|
||||
#ifndef FUTEX_PRIVATE_FLAG
|
||||
#define FUTEX_PRIVATE_FLAG 128
|
||||
#endif
|
||||
|
||||
#ifndef FUTEX_WAIT_PRIVATE
|
||||
#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT|FUTEX_PRIVATE_FLAG)
|
||||
#endif
|
||||
|
||||
#ifndef FUTEX_WAKE_PRIVATE
|
||||
#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE|FUTEX_PRIVATE_FLAG)
|
||||
#endif
|
||||
|
||||
// mutex lock states
|
||||
//
|
||||
// 0: unlocked
|
||||
@@ -883,8 +880,13 @@ int pthread_mutex_init(pthread_mutex_t *mutex,
|
||||
|
||||
int pthread_mutex_destroy(pthread_mutex_t *mutex)
|
||||
{
|
||||
if (__unlikely(mutex == NULL))
|
||||
return EINVAL;
|
||||
int ret;
|
||||
|
||||
/* use trylock to ensure that the mutex value is
|
||||
* valid and is not already locked. */
|
||||
ret = pthread_mutex_trylock(mutex);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
mutex->value = 0xdead10cc;
|
||||
return 0;
|
||||
@@ -931,11 +933,10 @@ _normal_lock(pthread_mutex_t* mutex)
|
||||
* that the mutex is in state 2 when we go to sleep on it, which
|
||||
* guarantees a wake-up call.
|
||||
*/
|
||||
int wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
|
||||
|
||||
while (__atomic_swap(shared|2, &mutex->value ) != (shared|0))
|
||||
__futex_syscall4(&mutex->value, wait_op, shared|2, 0);
|
||||
__futex_wait_ex(&mutex->value, shared, shared|2, 0);
|
||||
}
|
||||
ANDROID_MEMBAR_FULL();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -945,6 +946,8 @@ _normal_lock(pthread_mutex_t* mutex)
|
||||
static __inline__ void
|
||||
_normal_unlock(pthread_mutex_t* mutex)
|
||||
{
|
||||
ANDROID_MEMBAR_FULL();
|
||||
|
||||
/* We need to preserve the shared flag during operations */
|
||||
int shared = mutex->value & MUTEX_SHARED_MASK;
|
||||
|
||||
@@ -954,7 +957,6 @@ _normal_unlock(pthread_mutex_t* mutex)
|
||||
* if it wasn't 1 we have to do some additional work.
|
||||
*/
|
||||
if (__atomic_dec(&mutex->value) != (shared|1)) {
|
||||
int wake_op = shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE;
|
||||
/*
|
||||
* Start by releasing the lock. The decrement changed it from
|
||||
* "contended lock" to "uncontended lock", which means we still
|
||||
@@ -992,7 +994,7 @@ _normal_unlock(pthread_mutex_t* mutex)
|
||||
* Either way we have correct behavior and nobody is orphaned on
|
||||
* the wait queue.
|
||||
*/
|
||||
__futex_syscall3(&mutex->value, wake_op, 1);
|
||||
__futex_wake_ex(&mutex->value, shared, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,7 +1014,7 @@ _recursive_unlock(void)
|
||||
|
||||
int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
{
|
||||
int mtype, tid, new_lock_type, shared, wait_op;
|
||||
int mtype, tid, new_lock_type, shared;
|
||||
|
||||
if (__unlikely(mutex == NULL))
|
||||
return EINVAL;
|
||||
@@ -1057,7 +1059,6 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
new_lock_type = 1;
|
||||
|
||||
/* compute futex wait opcode and restore shared flag in mtype */
|
||||
wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
|
||||
mtype |= shared;
|
||||
|
||||
for (;;) {
|
||||
@@ -1084,7 +1085,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
*/
|
||||
new_lock_type = 2;
|
||||
|
||||
__futex_syscall4(&mutex->value, wait_op, oldv, NULL);
|
||||
__futex_wait_ex(&mutex->value, shared, oldv, NULL);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1124,8 +1125,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||
|
||||
/* Wake one waiting thread, if any */
|
||||
if ((oldv & 3) == 2) {
|
||||
int wake_op = shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE;
|
||||
__futex_syscall3(&mutex->value, wake_op, 1);
|
||||
__futex_wake_ex(&mutex->value, shared, 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1144,8 +1144,10 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||
/* Handle common case first */
|
||||
if ( __likely(mtype == MUTEX_TYPE_NORMAL) )
|
||||
{
|
||||
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0)
|
||||
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0) {
|
||||
ANDROID_MEMBAR_FULL();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return EBUSY;
|
||||
}
|
||||
@@ -1225,7 +1227,7 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
|
||||
clockid_t clock = CLOCK_MONOTONIC;
|
||||
struct timespec abstime;
|
||||
struct timespec ts;
|
||||
int mtype, tid, oldv, new_lock_type, shared, wait_op;
|
||||
int mtype, tid, oldv, new_lock_type, shared;
|
||||
|
||||
/* compute absolute expiration time */
|
||||
__timespec_to_relative_msec(&abstime, msecs, clock);
|
||||
@@ -1239,19 +1241,20 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
|
||||
/* Handle common case first */
|
||||
if ( __likely(mtype == MUTEX_TYPE_NORMAL) )
|
||||
{
|
||||
int wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
|
||||
|
||||
/* fast path for unconteded lock */
|
||||
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0)
|
||||
/* fast path for uncontended lock */
|
||||
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0) {
|
||||
ANDROID_MEMBAR_FULL();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* loop while needed */
|
||||
while (__atomic_swap(shared|2, &mutex->value) != (shared|0)) {
|
||||
if (__timespec_to_absolute(&ts, &abstime, clock) < 0)
|
||||
return EBUSY;
|
||||
|
||||
__futex_syscall4(&mutex->value, wait_op, shared|2, &ts);
|
||||
__futex_wait_ex(&mutex->value, shared, shared|2, &ts);
|
||||
}
|
||||
ANDROID_MEMBAR_FULL();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1282,7 +1285,6 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
|
||||
new_lock_type = 1;
|
||||
|
||||
/* Compute wait op and restore sharing bit in mtype */
|
||||
wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
|
||||
mtype |= shared;
|
||||
|
||||
for (;;) {
|
||||
@@ -1313,7 +1315,7 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
|
||||
if (__timespec_to_absolute(&ts, &abstime, clock) < 0)
|
||||
return EBUSY;
|
||||
|
||||
__futex_syscall4(&mutex->value, wait_op, oldv, &ts);
|
||||
__futex_wait_ex(&mutex->value, shared, oldv, &ts);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1406,7 +1408,6 @@ static int
|
||||
__pthread_cond_pulse(pthread_cond_t *cond, int counter)
|
||||
{
|
||||
long flags;
|
||||
int wake_op;
|
||||
|
||||
if (__unlikely(cond == NULL))
|
||||
return EINVAL;
|
||||
@@ -1420,8 +1421,7 @@ __pthread_cond_pulse(pthread_cond_t *cond, int counter)
|
||||
break;
|
||||
}
|
||||
|
||||
wake_op = COND_IS_SHARED(cond) ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE;
|
||||
__futex_syscall3(&cond->value, wake_op, counter);
|
||||
__futex_wake_ex(&cond->value, COND_IS_SHARED(cond), counter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1446,10 +1446,9 @@ int __pthread_cond_timedwait_relative(pthread_cond_t *cond,
|
||||
{
|
||||
int status;
|
||||
int oldvalue = cond->value;
|
||||
int wait_op = COND_IS_SHARED(cond) ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
|
||||
|
||||
pthread_mutex_unlock(mutex);
|
||||
status = __futex_syscall4(&cond->value, wait_op, oldvalue, reltime);
|
||||
status = __futex_wait_ex(&cond->value, COND_IS_SHARED(cond), oldvalue, reltime);
|
||||
pthread_mutex_lock(mutex);
|
||||
|
||||
if (status == (-ETIMEDOUT)) return ETIMEDOUT;
|
||||
@@ -1867,15 +1866,66 @@ int pthread_getcpuclockid(pthread_t tid, clockid_t *clockid)
|
||||
*/
|
||||
int pthread_once( pthread_once_t* once_control, void (*init_routine)(void) )
|
||||
{
|
||||
static pthread_mutex_t once_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t once_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
|
||||
|
||||
if (*once_control == PTHREAD_ONCE_INIT) {
|
||||
_normal_lock( &once_lock );
|
||||
pthread_mutex_lock( &once_lock );
|
||||
if (*once_control == PTHREAD_ONCE_INIT) {
|
||||
(*init_routine)();
|
||||
*once_control = ~PTHREAD_ONCE_INIT;
|
||||
}
|
||||
_normal_unlock( &once_lock );
|
||||
pthread_mutex_unlock( &once_lock );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This value is not exported by kernel headers, so hardcode it here */
|
||||
#define MAX_TASK_COMM_LEN 16
|
||||
#define TASK_COMM_FMT "/proc/self/task/%u/comm"
|
||||
|
||||
int pthread_setname_np(pthread_t thid, const char *thname)
|
||||
{
|
||||
size_t thname_len;
|
||||
int saved_errno, ret;
|
||||
|
||||
if (thid == 0 || thname == NULL)
|
||||
return EINVAL;
|
||||
|
||||
thname_len = strlen(thname);
|
||||
if (thname_len >= MAX_TASK_COMM_LEN)
|
||||
return ERANGE;
|
||||
|
||||
saved_errno = errno;
|
||||
if (thid == pthread_self())
|
||||
{
|
||||
ret = prctl(PR_SET_NAME, (unsigned long)thname, 0, 0, 0) ? errno : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Have to change another thread's name */
|
||||
pthread_internal_t *thread = (pthread_internal_t *)thid;
|
||||
char comm_name[sizeof(TASK_COMM_FMT) + 8];
|
||||
ssize_t n;
|
||||
int fd;
|
||||
|
||||
snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, (unsigned int)thread->kernel_id);
|
||||
fd = open(comm_name, O_RDWR);
|
||||
if (fd == -1)
|
||||
{
|
||||
ret = errno;
|
||||
goto exit;
|
||||
}
|
||||
n = TEMP_FAILURE_RETRY(write(fd, thname, thname_len));
|
||||
close(fd);
|
||||
|
||||
if (n < 0)
|
||||
ret = errno;
|
||||
else if ((size_t)n != thname_len)
|
||||
ret = EIO;
|
||||
else
|
||||
ret = 0;
|
||||
}
|
||||
exit:
|
||||
errno = saved_errno;
|
||||
return ret;
|
||||
}
|
||||
|
@@ -30,6 +30,62 @@
|
||||
#include <sys/time.h>
|
||||
#include <sys/atomics.h>
|
||||
#include <time.h>
|
||||
#include <bionic_atomic_inline.h>
|
||||
#include <bionic_futex.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* In this implementation, a semaphore contains a
|
||||
* 31-bit signed value and a 1-bit 'shared' flag
|
||||
* (for process-sharing purpose).
|
||||
*
|
||||
* We use the value -1 to indicate contention on the
|
||||
* semaphore, 0 or more to indicate uncontended state,
|
||||
* any value lower than -2 is invalid at runtime.
|
||||
*
|
||||
* State diagram:
|
||||
*
|
||||
* post(1) ==> 2
|
||||
* post(0) ==> 1
|
||||
* post(-1) ==> 1, then wake all waiters
|
||||
*
|
||||
* wait(2) ==> 1
|
||||
* wait(1) ==> 0
|
||||
* wait(0) ==> -1 then wait for a wake up + loop
|
||||
* wait(-1) ==> -1 then wait for a wake up + loop
|
||||
*
|
||||
*/
|
||||
|
||||
/* Use the upper 31-bits for the counter, and the lower one
|
||||
* for the shared flag.
|
||||
*/
|
||||
#define SEMCOUNT_SHARED_MASK 0x00000001
|
||||
#define SEMCOUNT_VALUE_MASK 0xfffffffe
|
||||
#define SEMCOUNT_VALUE_SHIFT 1
|
||||
|
||||
/* Maximum unsigned value that can be stored in the semaphore.
|
||||
* One bit is used for the shared flag, another one for the
|
||||
* sign bit, leaving us with only 30 bits.
|
||||
*/
|
||||
#define SEM_MAX_VALUE 0x3fffffff
|
||||
|
||||
/* convert a value into the corresponding sem->count bit pattern */
|
||||
#define SEMCOUNT_FROM_VALUE(val) (((val) << SEMCOUNT_VALUE_SHIFT) & SEMCOUNT_VALUE_MASK)
|
||||
|
||||
/* convert a sem->count bit pattern into the corresponding signed value */
|
||||
#define SEMCOUNT_TO_VALUE(sval) ((int)(sval) >> SEMCOUNT_VALUE_SHIFT)
|
||||
|
||||
/* the value +1 as a sem->count bit-pattern. */
|
||||
#define SEMCOUNT_ONE SEMCOUNT_FROM_VALUE(1)
|
||||
|
||||
/* the value -1 as a sem->count bit-pattern. */
|
||||
#define SEMCOUNT_MINUS_ONE SEMCOUNT_FROM_VALUE(-1)
|
||||
|
||||
#define SEMCOUNT_DECREMENT(sval) (((sval) - (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
|
||||
#define SEMCOUNT_INCREMENT(sval) (((sval) + (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
|
||||
|
||||
/* return the shared bitflag from a semaphore */
|
||||
#define SEM_GET_SHARED(sem) ((sem)->count & SEMCOUNT_SHARED_MASK)
|
||||
|
||||
|
||||
int sem_init(sem_t *sem, int pshared, unsigned int value)
|
||||
{
|
||||
@@ -38,26 +94,34 @@ int sem_init(sem_t *sem, int pshared, unsigned int value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pshared != 0) {
|
||||
errno = ENOSYS;
|
||||
/* ensure that 'value' can be stored in the semaphore */
|
||||
if (value > SEM_MAX_VALUE) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
sem->count = value;
|
||||
sem->count = SEMCOUNT_FROM_VALUE(value);
|
||||
if (pshared != 0)
|
||||
sem->count |= SEMCOUNT_SHARED_MASK;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int sem_destroy(sem_t *sem)
|
||||
{
|
||||
int count;
|
||||
|
||||
if (sem == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (sem->count == 0) {
|
||||
count = SEMCOUNT_TO_VALUE(sem->count);
|
||||
if (count < 0) {
|
||||
errno = EBUSY;
|
||||
return -1;
|
||||
}
|
||||
sem->count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,38 +154,120 @@ int sem_unlink(const char * name)
|
||||
}
|
||||
|
||||
|
||||
/* Decrement a semaphore's value atomically,
|
||||
* and return the old one. As a special case,
|
||||
* this returns immediately if the value is
|
||||
* negative (i.e. -1)
|
||||
*/
|
||||
static int
|
||||
__atomic_dec_if_positive( volatile unsigned int* pvalue )
|
||||
__sem_dec(volatile unsigned int *pvalue)
|
||||
{
|
||||
unsigned int old;
|
||||
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
|
||||
unsigned int old, new;
|
||||
int ret;
|
||||
|
||||
do {
|
||||
old = *pvalue;
|
||||
}
|
||||
while ( old != 0 && __atomic_cmpxchg( (int)old, (int)old-1, (volatile int*)pvalue ) != 0 );
|
||||
old = (*pvalue & SEMCOUNT_VALUE_MASK);
|
||||
ret = SEMCOUNT_TO_VALUE(old);
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
return old;
|
||||
new = SEMCOUNT_DECREMENT(old);
|
||||
}
|
||||
while (__atomic_cmpxchg((int)(old|shared),
|
||||
(int)(new|shared),
|
||||
(volatile int *)pvalue) != 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Same as __sem_dec, but will not touch anything if the
|
||||
* value is already negative *or* 0. Returns the old value.
|
||||
*/
|
||||
static int
|
||||
__sem_trydec(volatile unsigned int *pvalue)
|
||||
{
|
||||
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
|
||||
unsigned int old, new;
|
||||
int ret;
|
||||
|
||||
do {
|
||||
old = (*pvalue & SEMCOUNT_VALUE_MASK);
|
||||
ret = SEMCOUNT_TO_VALUE(old);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
|
||||
new = SEMCOUNT_DECREMENT(old);
|
||||
}
|
||||
while (__atomic_cmpxchg((int)(old|shared),
|
||||
(int)(new|shared),
|
||||
(volatile int *)pvalue) != 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* "Increment" the value of a semaphore atomically and
|
||||
* return its old value. Note that this implements
|
||||
* the special case of "incrementing" any negative
|
||||
* value to +1 directly.
|
||||
*
|
||||
* NOTE: The value will _not_ wrap above SEM_VALUE_MAX
|
||||
*/
|
||||
static int
|
||||
__sem_inc(volatile unsigned int *pvalue)
|
||||
{
|
||||
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
|
||||
unsigned int old, new;
|
||||
int ret;
|
||||
|
||||
do {
|
||||
old = (*pvalue & SEMCOUNT_VALUE_MASK);
|
||||
ret = SEMCOUNT_TO_VALUE(old);
|
||||
|
||||
/* Can't go higher than SEM_MAX_VALUE */
|
||||
if (ret == SEM_MAX_VALUE)
|
||||
break;
|
||||
|
||||
/* If the counter is negative, go directly to +1,
|
||||
* otherwise just increment */
|
||||
if (ret < 0)
|
||||
new = SEMCOUNT_ONE;
|
||||
else
|
||||
new = SEMCOUNT_INCREMENT(old);
|
||||
}
|
||||
while ( __atomic_cmpxchg((int)(old|shared),
|
||||
(int)(new|shared),
|
||||
(volatile int*)pvalue) != 0);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* lock a semaphore */
|
||||
int sem_wait(sem_t *sem)
|
||||
{
|
||||
unsigned shared;
|
||||
|
||||
if (sem == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared = SEM_GET_SHARED(sem);
|
||||
|
||||
for (;;) {
|
||||
if (__atomic_dec_if_positive(&sem->count))
|
||||
if (__sem_dec(&sem->count) > 0)
|
||||
break;
|
||||
|
||||
__futex_wait(&sem->count, 0, 0);
|
||||
__futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, NULL);
|
||||
}
|
||||
ANDROID_MEMBAR_FULL();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
|
||||
{
|
||||
int ret;
|
||||
unsigned int shared;
|
||||
|
||||
if (sem == NULL) {
|
||||
errno = EINVAL;
|
||||
@@ -129,11 +275,15 @@ int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
|
||||
}
|
||||
|
||||
/* POSIX says we need to try to decrement the semaphore
|
||||
* before checking the timeout value */
|
||||
if (__atomic_dec_if_positive(&sem->count))
|
||||
* before checking the timeout value. Note that if the
|
||||
* value is currently 0, __sem_trydec() does nothing.
|
||||
*/
|
||||
if (__sem_trydec(&sem->count) > 0) {
|
||||
ANDROID_MEMBAR_FULL();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check it as per Posix */
|
||||
/* Check it as per Posix */
|
||||
if (abs_timeout == NULL ||
|
||||
abs_timeout->tv_sec < 0 ||
|
||||
abs_timeout->tv_nsec < 0 ||
|
||||
@@ -143,6 +293,8 @@ int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared = SEM_GET_SHARED(sem);
|
||||
|
||||
for (;;) {
|
||||
struct timespec ts;
|
||||
int ret;
|
||||
@@ -161,27 +313,47 @@ int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = __futex_wait(&sem->count, 0, &ts);
|
||||
/* Try to grab the semaphore. If the value was 0, this
|
||||
* will also change it to -1 */
|
||||
if (__sem_dec(&sem->count) > 0) {
|
||||
ANDROID_MEMBAR_FULL();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Contention detected. wait for a wakeup event */
|
||||
ret = __futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, &ts);
|
||||
|
||||
/* return in case of timeout or interrupt */
|
||||
if (ret == -ETIMEDOUT || ret == -EINTR) {
|
||||
errno = -ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (__atomic_dec_if_positive(&sem->count))
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unlock a semaphore */
|
||||
int sem_post(sem_t *sem)
|
||||
{
|
||||
unsigned int shared;
|
||||
int old;
|
||||
|
||||
if (sem == NULL)
|
||||
return EINVAL;
|
||||
|
||||
if (__atomic_inc((volatile int*)&sem->count) >= 0)
|
||||
__futex_wake(&sem->count, 1);
|
||||
shared = SEM_GET_SHARED(sem);
|
||||
|
||||
ANDROID_MEMBAR_FULL();
|
||||
old = __sem_inc(&sem->count);
|
||||
if (old < 0) {
|
||||
/* contention on the semaphore, wake up all waiters */
|
||||
__futex_wake_ex(&sem->count, shared, INT_MAX);
|
||||
}
|
||||
else if (old == SEM_MAX_VALUE) {
|
||||
/* overflow detected */
|
||||
errno = EOVERFLOW;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -193,7 +365,8 @@ int sem_trywait(sem_t *sem)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (__atomic_dec_if_positive(&sem->count) > 0) {
|
||||
if (__sem_trydec(&sem->count) > 0) {
|
||||
ANDROID_MEMBAR_FULL();
|
||||
return 0;
|
||||
} else {
|
||||
errno = EAGAIN;
|
||||
@@ -201,13 +374,29 @@ int sem_trywait(sem_t *sem)
|
||||
}
|
||||
}
|
||||
|
||||
/* Note that Posix requires that sem_getvalue() returns, in
|
||||
* case of contention, the negative of the number of waiting
|
||||
* threads.
|
||||
*
|
||||
* However, code that depends on this negative value to be
|
||||
* meaningful is most probably racy. The GLibc sem_getvalue()
|
||||
* only returns the semaphore value, which is 0, in case of
|
||||
* contention, so we will mimick this behaviour here instead
|
||||
* for better compatibility.
|
||||
*/
|
||||
int sem_getvalue(sem_t *sem, int *sval)
|
||||
{
|
||||
int val;
|
||||
|
||||
if (sem == NULL || sval == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*sval = sem->count;
|
||||
val = SEMCOUNT_TO_VALUE(sem->count);
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
|
||||
*sval = val;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ int __system_property_read(const prop_info *pi, char *name, char *value)
|
||||
for(;;) {
|
||||
serial = pi->serial;
|
||||
while(SERIAL_DIRTY(serial)) {
|
||||
__futex_wait(&pi->serial, serial, 0);
|
||||
__futex_wait((volatile void *)&pi->serial, serial, 0);
|
||||
serial = pi->serial;
|
||||
}
|
||||
len = SERIAL_VALUE_LEN(serial);
|
||||
@@ -164,7 +164,7 @@ int __system_property_wait(const prop_info *pi)
|
||||
} else {
|
||||
n = pi->serial;
|
||||
do {
|
||||
__futex_wait(&pi->serial, n, 0);
|
||||
__futex_wait((volatile void *)&pi->serial, n, 0);
|
||||
} while(n == pi->serial);
|
||||
}
|
||||
return 0;
|
||||
|
@@ -1,7 +1,89 @@
|
||||
Bionic ChangeLog:
|
||||
-----------------
|
||||
|
||||
Differences between current and Android 2.1:
|
||||
Differences between current and Android 2.2:
|
||||
|
||||
- <pthread.h>: Add reader/writer locks implementation. Add sanity
|
||||
checking to pthread_mutex_destroy() (e.g. a locked mutex will return
|
||||
EBUSY).
|
||||
|
||||
- <semaphore.h>: Use private futexes for semaphore implementation,
|
||||
unless your set 'pshared' to non-0 when calling sem_init().
|
||||
|
||||
Also fixed a bug in sem_post() to make it wake up all waiting
|
||||
threads, instead of one. As a consequence, the maximum semaphore
|
||||
value is now reduced to 0x3fffffff.
|
||||
|
||||
- <math.h>: Added sincos(), sincosf() and sincosl() (GLibc compatibility).
|
||||
|
||||
- <sys/sysinfo.h>: Added missing sysinfo() system call implementation
|
||||
(the function was already declared in the header though).
|
||||
|
||||
- sysconf() didn't work for some arguments due to a small bug in the
|
||||
/proc line parser.
|
||||
|
||||
- <termio.h>: added missing header (just includes <termios.h>)
|
||||
|
||||
- <unistd.h>: add missing declaration for truncate(). The implementation
|
||||
was already here since Android 1.5.
|
||||
|
||||
modify implementation of alarm() to return 0 in case of error (i.e.
|
||||
if a value larger than 0x7fffffff seconds is passed to it). This
|
||||
makes the implementation compliant with the GLibc behaviour.
|
||||
|
||||
- <wchar.h>: small fixes to really support wchar_t in Bionic (not there yet).
|
||||
|
||||
the size of wchar_t is still 32-bit (decided by the compiler)
|
||||
|
||||
WCHAR_MIN: changed from 0 to INT_MIN
|
||||
WCHAR_MAX: changed from 255 to INT_MAX
|
||||
|
||||
wcpcpy(), wcpncpy(), wcscat(), wcschr(), wcscmp(),
|
||||
wcscpy(), wcscspn(), wcsdup(), wcslcat(), wcslcpy(),
|
||||
wcslen(), wcsncat(), wcsncmp(), wcsncpy(), wcsnlen(),
|
||||
wcspbrk(), wcsrchr(), wcsrchr(), wcsspn(), wcsstr(),
|
||||
wcstok(), wcswidth(), wmemchr(), wmemcmp(), wmemcpy(),
|
||||
wmemmove(), wmemset(): Added proper implementations.
|
||||
|
||||
wcscasecmp(), wcsncasecmp(): Added implementation limited
|
||||
to ASCII codes for lower/upper.
|
||||
|
||||
wcscoll(): added dummy implementation that calls wcscmp()
|
||||
wcsxfrm(): added dummy implementation that calls wcsncpy()
|
||||
|
||||
NOTE: Technically, this breaks the ABI, but we never claimed to support
|
||||
wchar_t anyway. The wchar_t support is still *NOT* official at this
|
||||
point. We need better multi-byte support code, and wprintf/wscanf
|
||||
stuff too.
|
||||
|
||||
- <inttypes.h>: add missing declarations for strntoimax abd strntoumax.
|
||||
|
||||
- <stdlib.h>: add missing declarations for drand48() and erand48().
|
||||
|
||||
- clearerr(): fix broken implementation.
|
||||
|
||||
- Feature test macros like _POSIX_C_SOURCE / _XOPEN_SOURCE / _C99_SOURCE
|
||||
are now handled correctly by our C library headers (see <sys/cdefs.h>)
|
||||
|
||||
- <sys/select.h>: add missing declaration for pselect()
|
||||
|
||||
- <sys/vfs.h>: fixed implementation of fstatfs() (also fixes fpathconf()
|
||||
which uses it).
|
||||
|
||||
- <dlfcn.h>: fixed dlopen() implementation to support dlopen(NULL, ...).
|
||||
This allows one to look at the dynamic symbols exported by an executable.
|
||||
|
||||
- <private/bionic_tls.h>: use kernel helper functions for static versions
|
||||
of the C library. This is necessary because we don't know where the corresponding
|
||||
machine code is going to run, and the optimization for __get_tls() might
|
||||
not match the features of the target device where we run a static executable
|
||||
linked to the C library. This fixes one of the bug that explains why gdbserver
|
||||
didn't work well with threads.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Differences between Android 2.2. and Android 2.1:
|
||||
|
||||
- Support FP register save/load in setjmp()/longjmp() on ARMv7 builds.
|
||||
|
||||
- Add support for SH-4 CPU architecture !
|
||||
|
||||
|
@@ -39,6 +39,10 @@ __BEGIN_DECLS
|
||||
#define O_ASYNC FASYNC
|
||||
#endif
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 02000000
|
||||
#endif
|
||||
|
||||
extern int open(const char* path, int mode, ...);
|
||||
extern int openat(int fd, const char* path, int mode, ...);
|
||||
extern int unlinkat(int dirfd, const char *pathname, int flags);
|
||||
|
@@ -71,14 +71,19 @@ int getopt_long_only(int, char * const *, const char *,
|
||||
#ifndef _GETOPT_DEFINED_
|
||||
#define _GETOPT_DEFINED_
|
||||
int getopt(int, char * const *, const char *);
|
||||
int getsubopt(char **, char * const *, char **);
|
||||
|
||||
|
||||
extern char *optarg; /* getopt(3) external variables */
|
||||
extern int opterr;
|
||||
extern int optind;
|
||||
extern int optopt;
|
||||
extern int optreset;
|
||||
|
||||
#if 0 /* MISSING FROM BIONIC */
|
||||
int getsubopt(char **, char * const *, char **);
|
||||
extern char *suboptarg; /* getsubopt(3) external variable */
|
||||
#endif /* MISSING */
|
||||
|
||||
#endif
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -253,6 +253,9 @@ intmax_t imaxabs(intmax_t);
|
||||
imaxdiv_t imaxdiv(intmax_t, intmax_t);
|
||||
intmax_t strtoimax(const char *, char **, int);
|
||||
uintmax_t strtoumax(const char *, char **, int);
|
||||
|
||||
intmax_t strntoimax(const char *nptr, char **endptr, int base, size_t n);
|
||||
uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _INTTYPES_H_ */
|
||||
|
@@ -86,7 +86,7 @@
|
||||
#include <sys/limits.h>
|
||||
|
||||
#if __POSIX_VISIBLE
|
||||
#include <arch/syslimits.h>
|
||||
#include <sys/syslimits.h>
|
||||
#endif
|
||||
|
||||
#ifndef PAGESIZE
|
||||
|
@@ -28,6 +28,10 @@
|
||||
#ifndef _PATHCONF_H_
|
||||
#define _PATHCONF_H_
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* constants to be used for the 'name' paremeter of pathconf/fpathconf */
|
||||
|
||||
#define _PC_FILESIZEBITS 0x0000
|
||||
@@ -54,5 +58,7 @@
|
||||
extern long fpathconf(int fildes, int name);
|
||||
extern long pathconf(const char *path, int name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _PATHCONF_H_ */
|
||||
|
||||
|
@@ -219,6 +219,41 @@ int pthread_cond_timeout_np(pthread_cond_t *cond,
|
||||
*/
|
||||
int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs);
|
||||
|
||||
/* read-write lock support */
|
||||
|
||||
typedef int pthread_rwlockattr_t;
|
||||
|
||||
typedef struct {
|
||||
pthread_mutex_t lock;
|
||||
pthread_cond_t cond;
|
||||
int numLocks;
|
||||
int writerThreadId;
|
||||
int pendingReaders;
|
||||
int pendingWriters;
|
||||
void* reserved[4]; /* for future extensibility */
|
||||
} pthread_rwlock_t;
|
||||
|
||||
#define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, NULL, 0, 0 }
|
||||
|
||||
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
|
||||
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
|
||||
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);
|
||||
int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *attr, int *pshared);
|
||||
|
||||
int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr);
|
||||
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
|
||||
|
||||
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
|
||||
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
|
||||
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout);
|
||||
|
||||
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
|
||||
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
|
||||
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout);
|
||||
|
||||
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
|
||||
|
||||
|
||||
int pthread_key_create(pthread_key_t *key, void (*destructor_function)(void *));
|
||||
int pthread_key_delete (pthread_key_t);
|
||||
int pthread_setspecific(pthread_key_t key, const void *value);
|
||||
@@ -231,6 +266,8 @@ int pthread_getcpuclockid(pthread_t tid, clockid_t *clockid);
|
||||
|
||||
int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
|
||||
|
||||
int pthread_setname_np(pthread_t thid, const char *thname);
|
||||
|
||||
typedef void (*__pthread_cleanup_func_t)(void*);
|
||||
|
||||
typedef struct __pthread_cleanup_t {
|
||||
@@ -272,4 +309,4 @@ extern void __pthread_cleanup_pop(__pthread_cleanup_t* c,
|
||||
#define LONG_LONG_MAX __LONG_LONG_MAX__
|
||||
#define LONG_LONG_MIN (-__LONG_LONG_MAX__ - 1)
|
||||
|
||||
#endif // _PTHREAD_H_
|
||||
#endif /* _PTHREAD_H_ */
|
||||
|
@@ -69,7 +69,7 @@ extern int sched_rr_get_interval(pid_t pid, struct timespec *tp);
|
||||
#define CLONE_CHILD_SETTID 0x01000000
|
||||
#define CLONE_STOPPED 0x02000000
|
||||
|
||||
#ifdef __GNU_SOURCE
|
||||
#ifdef _GNU_SOURCE
|
||||
extern int clone(int (*fn)(void *), void *child_stack, int flags, void* arg, ...);
|
||||
#endif
|
||||
|
||||
|
@@ -51,6 +51,7 @@ typedef int sig_atomic_t;
|
||||
#endif
|
||||
|
||||
extern const char * const sys_siglist[];
|
||||
extern const char * const sys_signame[];
|
||||
|
||||
static __inline__ int sigismember(sigset_t *set, int signum)
|
||||
{
|
||||
@@ -119,6 +120,7 @@ extern int siginterrupt(int sig, int flag);
|
||||
extern int raise(int);
|
||||
extern int kill(pid_t, int);
|
||||
extern int killpg(int pgrp, int sig);
|
||||
extern int sigaltstack(const stack_t *ss, stack_t *oss);
|
||||
|
||||
|
||||
__END_DECLS
|
||||
|
@@ -300,12 +300,14 @@ __END_DECLS
|
||||
#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */
|
||||
|
||||
__BEGIN_DECLS
|
||||
#if 0 /* MISSING FROM BIONIC */
|
||||
char *ctermid(char *);
|
||||
char *cuserid(char *);
|
||||
#endif /* MISSING */
|
||||
FILE *fdopen(int, const char *);
|
||||
int fileno(FILE *);
|
||||
|
||||
#if (__POSIX_VISIBLE >= 199209) || 1 /* ANDROID: Bionic does include this */
|
||||
#if (__POSIX_VISIBLE >= 199209)
|
||||
int pclose(FILE *);
|
||||
FILE *popen(const char *, const char *);
|
||||
#endif
|
||||
|
@@ -50,7 +50,6 @@ __BEGIN_DECLS
|
||||
extern __noreturn void exit(int);
|
||||
extern __noreturn void abort(void);
|
||||
extern int atexit(void (*)(void));
|
||||
extern int on_exit(void (*)(int, void *), void *);
|
||||
|
||||
extern char *getenv(const char *);
|
||||
extern int putenv(const char *);
|
||||
@@ -107,6 +106,8 @@ extern long mrand48(void);
|
||||
extern long nrand48(unsigned short *);
|
||||
extern long lrand48(void);
|
||||
extern unsigned short *seed48(unsigned short*);
|
||||
extern double erand48(unsigned short xsubi[3]);
|
||||
extern double drand48(void);
|
||||
extern void srand48(long);
|
||||
extern unsigned int arc4random(void);
|
||||
extern void arc4random_stir(void);
|
||||
@@ -135,7 +136,7 @@ extern char* ptsname(int);
|
||||
extern int ptsname_r(int, char*, size_t);
|
||||
extern int getpt(void);
|
||||
|
||||
static __inline__ int grantpt(int __fd)
|
||||
static __inline__ int grantpt(int __fd __attribute((unused)))
|
||||
{
|
||||
(void)__fd;
|
||||
return 0; /* devpts does this all for us! */
|
||||
@@ -162,6 +163,7 @@ typedef struct {
|
||||
|
||||
extern lldiv_t lldiv(long long, long long);
|
||||
|
||||
#if 1 /* MISSING FROM BIONIC - ENABLED FOR STLPort and libstdc++-v3 */
|
||||
/* make STLPort happy */
|
||||
extern int mblen(const char *, size_t);
|
||||
extern size_t mbstowcs(wchar_t *, const char *, size_t);
|
||||
@@ -170,8 +172,14 @@ extern int mbtowc(wchar_t *, const char *, size_t);
|
||||
/* Likewise, make libstdc++-v3 happy. */
|
||||
extern int wctomb(char *, wchar_t);
|
||||
extern size_t wcstombs(char *, const wchar_t *, size_t);
|
||||
#endif /* MISSING */
|
||||
|
||||
#define MB_CUR_MAX 1
|
||||
|
||||
#if 0 /* MISSING FROM BIONIC */
|
||||
extern int on_exit(void (*)(int, void *), void *);
|
||||
#endif /* MISSING */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _STDLIB_H_ */
|
||||
|
@@ -37,12 +37,6 @@
|
||||
#ifndef _SYS_CDEFS_H_
|
||||
#define _SYS_CDEFS_H_
|
||||
|
||||
|
||||
/* our implementation of wchar_t is only 8-bit - die die non-portable code */
|
||||
#undef __WCHAR_TYPE__
|
||||
#define __WCHAR_TYPE__ unsigned char
|
||||
|
||||
|
||||
/*
|
||||
* Macro to test if we're using a GNU C compiler of a specific vintage
|
||||
* or later, for e.g. features that appeared in a particular version
|
||||
@@ -62,11 +56,6 @@
|
||||
#define __GNUC_PREREQ__(x, y) 0
|
||||
#endif
|
||||
|
||||
//XXX #include <machine/cdefs.h>
|
||||
|
||||
/* BIONIC: simpler definition */
|
||||
#define __BSD_VISIBLE 1
|
||||
|
||||
#include <sys/cdefs_elf.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -371,6 +360,142 @@
|
||||
|
||||
#define __link_set_entry(set, idx) (__link_set_begin(set)[idx])
|
||||
|
||||
/*
|
||||
* Some of the recend FreeBSD sources used in Bionic need this.
|
||||
* Originally, this is used to embed the rcs versions of each source file
|
||||
* in the generated binary. We certainly don't want this in Bionic.
|
||||
*/
|
||||
#define __FBSDID(s) struct __hack
|
||||
|
||||
/*-
|
||||
* The following definitions are an extension of the behavior originally
|
||||
* implemented in <sys/_posix.h>, but with a different level of granularity.
|
||||
* POSIX.1 requires that the macros we test be defined before any standard
|
||||
* header file is included.
|
||||
*
|
||||
* Here's a quick run-down of the versions:
|
||||
* defined(_POSIX_SOURCE) 1003.1-1988
|
||||
* _POSIX_C_SOURCE == 1 1003.1-1990
|
||||
* _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
|
||||
* _POSIX_C_SOURCE == 199309 1003.1b-1993
|
||||
* _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
|
||||
* and the omnibus ISO/IEC 9945-1: 1996
|
||||
* _POSIX_C_SOURCE == 200112 1003.1-2001
|
||||
* _POSIX_C_SOURCE == 200809 1003.1-2008
|
||||
*
|
||||
* In addition, the X/Open Portability Guide, which is now the Single UNIX
|
||||
* Specification, defines a feature-test macro which indicates the version of
|
||||
* that specification, and which subsumes _POSIX_C_SOURCE.
|
||||
*
|
||||
* Our macros begin with two underscores to avoid namespace screwage.
|
||||
*/
|
||||
|
||||
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
|
||||
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
|
||||
#define _POSIX_C_SOURCE 199009
|
||||
#endif
|
||||
|
||||
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
|
||||
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199209
|
||||
#endif
|
||||
|
||||
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
|
||||
#ifdef _XOPEN_SOURCE
|
||||
#if _XOPEN_SOURCE - 0 >= 700
|
||||
#define __XSI_VISIBLE 700
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200809
|
||||
#elif _XOPEN_SOURCE - 0 >= 600
|
||||
#define __XSI_VISIBLE 600
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 200112
|
||||
#elif _XOPEN_SOURCE - 0 >= 500
|
||||
#define __XSI_VISIBLE 500
|
||||
#undef _POSIX_C_SOURCE
|
||||
#define _POSIX_C_SOURCE 199506
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Deal with all versions of POSIX. The ordering relative to the tests above is
|
||||
* important.
|
||||
*/
|
||||
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
|
||||
#define _POSIX_C_SOURCE 198808
|
||||
#endif
|
||||
#ifdef _POSIX_C_SOURCE
|
||||
#if _POSIX_C_SOURCE >= 200809
|
||||
#define __POSIX_VISIBLE 200809
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#elif _POSIX_C_SOURCE >= 200112
|
||||
#define __POSIX_VISIBLE 200112
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#elif _POSIX_C_SOURCE >= 199506
|
||||
#define __POSIX_VISIBLE 199506
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif _POSIX_C_SOURCE >= 199309
|
||||
#define __POSIX_VISIBLE 199309
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif _POSIX_C_SOURCE >= 199209
|
||||
#define __POSIX_VISIBLE 199209
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif _POSIX_C_SOURCE >= 199009
|
||||
#define __POSIX_VISIBLE 199009
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#else
|
||||
#define __POSIX_VISIBLE 198808
|
||||
#define __ISO_C_VISIBLE 0
|
||||
#endif /* _POSIX_C_SOURCE */
|
||||
#else
|
||||
/*-
|
||||
* Deal with _ANSI_SOURCE:
|
||||
* If it is defined, and no other compilation environment is explicitly
|
||||
* requested, then define our internal feature-test macros to zero. This
|
||||
* makes no difference to the preprocessor (undefined symbols in preprocessing
|
||||
* expressions are defined to have value zero), but makes it more convenient for
|
||||
* a test program to print out the values.
|
||||
*
|
||||
* If a program mistakenly defines _ANSI_SOURCE and some other macro such as
|
||||
* _POSIX_C_SOURCE, we will assume that it wants the broader compilation
|
||||
* environment (and in fact we will never get here).
|
||||
*/
|
||||
#if defined(_ANSI_SOURCE) /* Hide almost everything. */
|
||||
#define __POSIX_VISIBLE 0
|
||||
#define __XSI_VISIBLE 0
|
||||
#define __BSD_VISIBLE 0
|
||||
#define __ISO_C_VISIBLE 1990
|
||||
#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
|
||||
#define __POSIX_VISIBLE 0
|
||||
#define __XSI_VISIBLE 0
|
||||
#define __BSD_VISIBLE 0
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#else /* Default environment: show everything. */
|
||||
#define __POSIX_VISIBLE 200809
|
||||
#define __XSI_VISIBLE 700
|
||||
#define __BSD_VISIBLE 1
|
||||
#define __ISO_C_VISIBLE 1999
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default values.
|
||||
*/
|
||||
#ifndef __XPG_VISIBLE
|
||||
# define __XPG_VISIBLE 700
|
||||
#endif
|
||||
#ifndef __POSIX_VISIBLE
|
||||
# define __POSIX_VISIBLE 200809
|
||||
#endif
|
||||
#ifndef __ISO_C_VISIBLE
|
||||
# define __ISO_C_VISIBLE 1999
|
||||
#endif
|
||||
#ifndef __BSD_VISIBLE
|
||||
# define __BSD_VISIBLE 1
|
||||
#endif
|
||||
|
||||
#define __BIONIC__ 1
|
||||
|
||||
#endif /* !_SYS_CDEFS_H_ */
|
||||
|
50
libc/include/sys/eventfd.h
Normal file
50
libc/include/sys/eventfd.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef _SYS_EVENTFD_H
|
||||
#define _SYS_EVENTFD_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define EFD_CLOEXEC O_CLOEXEC
|
||||
#define EFD_NONBLOCK O_NONBLOCK
|
||||
|
||||
/* type of event counter */
|
||||
typedef uint64_t eventfd_t;
|
||||
|
||||
extern int eventfd(unsigned int initval, int flags);
|
||||
|
||||
/* Compatibility with GLibc */
|
||||
extern int eventfd_read(int fd, eventfd_t *counter);
|
||||
extern int eventfd_write(int fd, const eventfd_t counter);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_EVENTFD_H */
|
@@ -31,7 +31,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// ANDROID: needed for flock()
|
||||
/* ANDROID: needed for flock() */
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
@@ -33,8 +33,10 @@
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if 0 /* MISSING FROM BIONIC */
|
||||
extern int setfsuid(uid_t);
|
||||
extern int setfsgid(gid_t);
|
||||
#endif /* MISSING */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -39,8 +39,8 @@
|
||||
#ifndef _SYS_IOCTL_COMPAT_H_
|
||||
#define _SYS_IOCTL_COMPAT_H_
|
||||
|
||||
//#include <sys/ttychars.h>
|
||||
//#include <sys/ttydev.h>
|
||||
/*#include <sys/ttychars.h>*/
|
||||
/*#include <sys/ttydev.h>*/
|
||||
|
||||
struct tchars {
|
||||
char t_intrc; /* interrupt */
|
||||
|
@@ -72,6 +72,7 @@
|
||||
#define __NR__newselect (__NR_SYSCALL_BASE + 142)
|
||||
#define __NR_ftruncate (__NR_SYSCALL_BASE + 93)
|
||||
#define __NR_fsync (__NR_SYSCALL_BASE + 118)
|
||||
#define __NR_fdatasync (__NR_SYSCALL_BASE + 148)
|
||||
#define __NR_fchown32 (__NR_SYSCALL_BASE + 207)
|
||||
#define __NR_sync (__NR_SYSCALL_BASE + 36)
|
||||
#define __NR_fcntl64 (__NR_SYSCALL_BASE + 221)
|
||||
@@ -127,6 +128,7 @@
|
||||
#define __NR_init_module (__NR_SYSCALL_BASE + 128)
|
||||
#define __NR_delete_module (__NR_SYSCALL_BASE + 129)
|
||||
#define __NR_syslog (__NR_SYSCALL_BASE + 103)
|
||||
#define __NR_sysinfo (__NR_SYSCALL_BASE + 116)
|
||||
#define __NR_futex (__NR_SYSCALL_BASE + 240)
|
||||
#define __NR_poll (__NR_SYSCALL_BASE + 168)
|
||||
|
||||
@@ -137,6 +139,7 @@
|
||||
#define __NR_openat (__NR_SYSCALL_BASE + 322)
|
||||
#define __NR_madvise (__NR_SYSCALL_BASE + 220)
|
||||
#define __NR_mincore (__NR_SYSCALL_BASE + 219)
|
||||
#define __NR_pipe2 (__NR_SYSCALL_BASE + 359)
|
||||
#define __NR_getdents64 (__NR_SYSCALL_BASE + 217)
|
||||
#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 267)
|
||||
#define __NR_fstatat64 (__NR_SYSCALL_BASE + 327)
|
||||
@@ -179,6 +182,7 @@
|
||||
#define __NR_inotify_init (__NR_SYSCALL_BASE + 316)
|
||||
#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 317)
|
||||
#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 318)
|
||||
#define __NR_eventfd2 (__NR_SYSCALL_BASE + 356)
|
||||
#define __NR_ARM_set_tls (__NR_SYSCALL_BASE + 983045)
|
||||
#define __NR_ARM_cacheflush (__NR_SYSCALL_BASE + 983042)
|
||||
#endif
|
||||
@@ -193,6 +197,7 @@
|
||||
#define __NR_openat (__NR_SYSCALL_BASE + 295)
|
||||
#define __NR_madvise (__NR_SYSCALL_BASE + 219)
|
||||
#define __NR_mincore (__NR_SYSCALL_BASE + 218)
|
||||
#define __NR_pipe2 (__NR_SYSCALL_BASE + 331)
|
||||
#define __NR_getdents64 (__NR_SYSCALL_BASE + 220)
|
||||
#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 269)
|
||||
#define __NR_fstatat64 (__NR_SYSCALL_BASE + 300)
|
||||
@@ -221,6 +226,7 @@
|
||||
#define __NR_inotify_init (__NR_SYSCALL_BASE + 291)
|
||||
#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 292)
|
||||
#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 293)
|
||||
#define __NR_eventfd2 (__NR_SYSCALL_BASE + 328)
|
||||
#endif
|
||||
|
||||
#if defined(__SH3__) || defined(__SH4__)
|
||||
@@ -234,6 +240,7 @@
|
||||
#define __NR_openat (__NR_SYSCALL_BASE + 295)
|
||||
#define __NR_madvise (__NR_SYSCALL_BASE + 219)
|
||||
#define __NR_mincore (__NR_SYSCALL_BASE + 218)
|
||||
#define __NR_pipe2 (__NR_SYSCALL_BASE + 331)
|
||||
#define __NR_getdents64 (__NR_SYSCALL_BASE + 220)
|
||||
#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 269)
|
||||
#define __NR_fstatat64 (__NR_SYSCALL_BASE + 300)
|
||||
@@ -269,14 +276,15 @@
|
||||
#define __NR_socketcall (__NR_SYSCALL_BASE + 102)
|
||||
#define __NR_socketcall (__NR_SYSCALL_BASE + 102)
|
||||
#define __NR___socketcall (__NR_SYSCALL_BASE + 102)
|
||||
#define __NR_ioprio_set (__NR_SYSCALL_BASE + 289)
|
||||
#define __NR_ioprio_get (__NR_SYSCALL_BASE + 290)
|
||||
#define __NR_ioprio_set (__NR_SYSCALL_BASE + 288)
|
||||
#define __NR_ioprio_get (__NR_SYSCALL_BASE + 289)
|
||||
#define __NR_epoll_create (__NR_SYSCALL_BASE + 254)
|
||||
#define __NR_epoll_ctl (__NR_SYSCALL_BASE + 255)
|
||||
#define __NR_epoll_wait (__NR_SYSCALL_BASE + 256)
|
||||
#define __NR_inotify_init (__NR_SYSCALL_BASE + 290)
|
||||
#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 291)
|
||||
#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 292)
|
||||
#define __NR_eventfd2 (__NR_SYSCALL_BASE + 328)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -9,7 +9,7 @@ void _exit (int);
|
||||
void _exit_thread (int);
|
||||
pid_t __fork (void);
|
||||
pid_t _waitpid (pid_t, int*, int, struct rusage*);
|
||||
int waitid (int, pid_t, struct siginfo_t*, int,void*);
|
||||
int __waitid (int, pid_t, struct siginfo_t*, int,void*);
|
||||
pid_t __sys_clone (int, void*, int*, void*, int*);
|
||||
int execve (const char*, char* const*, char* const*);
|
||||
int __setuid (uid_t);
|
||||
@@ -79,15 +79,17 @@ int flock (int, int);
|
||||
int fchmod (int, mode_t);
|
||||
int dup (int);
|
||||
int pipe (int *);
|
||||
int pipe2 (int *, int);
|
||||
int dup2 (int, int);
|
||||
int select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
|
||||
int ftruncate (int, off_t);
|
||||
int getdents (unsigned int, struct dirent *, unsigned int);
|
||||
int fsync (int);
|
||||
int fdatasync (int);
|
||||
int fchown (int, uid_t, gid_t);
|
||||
void sync (void);
|
||||
int __fcntl64 (int, int, void *);
|
||||
int fstatfs (int, size_t, struct statfs *);
|
||||
int __fstatfs64 (int, size_t, struct statfs *);
|
||||
ssize_t sendfile (int out_fd, int in_fd, off_t *offset, size_t count);
|
||||
int fstatat (int dirfd, const char *path, struct stat *buf, int flags);
|
||||
int mkdirat (int dirfd, const char *pathname, mode_t mode);
|
||||
@@ -191,6 +193,7 @@ int __syslog (int, char *, int);
|
||||
int init_module (void *, unsigned long, const char *);
|
||||
int delete_module (const char*, unsigned int);
|
||||
int klogctl (int, char *, int);
|
||||
int sysinfo (struct sysinfo *);
|
||||
int futex (void *, int, int, void *, void *, int);
|
||||
int epoll_create (int size);
|
||||
int epoll_ctl (int epfd, int op, int fd, struct epoll_event *event);
|
||||
@@ -199,6 +202,7 @@ int inotify_init (void);
|
||||
int inotify_add_watch (int, const char *, unsigned int);
|
||||
int inotify_rm_watch (int, unsigned int);
|
||||
int poll (struct pollfd *, unsigned int, long);
|
||||
int eventfd (unsigned int, int);
|
||||
int __set_tls (void*);
|
||||
int cacheflush (long start, long end, long flags);
|
||||
#ifdef __cplusplus
|
||||
|
@@ -92,7 +92,10 @@ extern int mount(const char *, const char *,
|
||||
const void *);
|
||||
extern int umount(const char *);
|
||||
extern int umount2(const char *, int);
|
||||
|
||||
#if 0 /* MISSING FROM BIONIC */
|
||||
extern int pivot_root(const char *, const char *);
|
||||
#endif /* MISSING */
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -30,7 +30,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
// For all of the defines
|
||||
/* For all of the defines */
|
||||
#include <linux/ptrace.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
@@ -31,12 +31,15 @@
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef __kernel_fd_set fd_set;
|
||||
|
||||
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
extern int pselect(int n, fd_set *readfds, fd_set *writefds, fd_set *errfds,
|
||||
const struct timespec *timeout, const sigset_t *sigmask);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@@ -62,8 +62,10 @@ typedef __kernel_ino_t ino_t;
|
||||
typedef __kernel_key_t key_t;
|
||||
typedef __kernel_mode_t mode_t;
|
||||
typedef __kernel_nlink_t nlink_t;
|
||||
#ifndef _OFF_T_DEFINED_
|
||||
#define _OFF_T_DEFINED_
|
||||
typedef __kernel_off_t off_t;
|
||||
#endif
|
||||
typedef __kernel_loff_t loff_t;
|
||||
typedef loff_t off64_t; /* GLibc-specific */
|
||||
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/resource.h>
|
||||
#include <linux/wait.h>
|
||||
#include <signal.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
@@ -49,6 +50,14 @@ extern pid_t waitpid(pid_t, int *, int);
|
||||
extern pid_t wait3(int *, int, struct rusage *);
|
||||
extern pid_t wait4(pid_t, int *, int, struct rusage *);
|
||||
|
||||
/* Posix states that idtype_t should be an enumeration type, but
|
||||
* the kernel headers define P_ALL, P_PID and P_PGID as constant macros
|
||||
* instead.
|
||||
*/
|
||||
typedef int idtype_t;
|
||||
|
||||
extern int waitid(idtype_t which, id_t id, siginfo_t *info, int options);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SYS_WAIT_H_ */
|
||||
|
32
libc/include/termio.h
Normal file
32
libc/include/termio.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* All definitions related to termio are in Linux kernel headers
|
||||
* that are already included by <termios.h>
|
||||
*/
|
||||
#include <termios.h>
|
@@ -61,16 +61,13 @@ extern pid_t getppid(void);
|
||||
extern pid_t getpgrp(void);
|
||||
extern int setpgrp(void);
|
||||
extern pid_t setsid(void);
|
||||
extern pid_t getsid(pid_t);
|
||||
|
||||
extern int execv(const char *, char * const *);
|
||||
extern int execvp(const char *, char * const *);
|
||||
extern int execve(const char *, char * const *, char * const *);
|
||||
extern int execvpe(const char *, char * const *, char * const *);
|
||||
extern int execl(const char *, const char *, ...);
|
||||
extern int execlp(const char *, const char *, ...);
|
||||
extern int execle(const char *, const char *, ...);
|
||||
extern int execlpe(const char *, const char *, ...);
|
||||
extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
|
||||
extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
|
||||
extern int prctl(int option, unsigned long arg2, unsigned long arg3,
|
||||
@@ -94,11 +91,8 @@ extern int setresuid(uid_t, uid_t, uid_t);
|
||||
extern int setresgid(gid_t, gid_t, gid_t);
|
||||
extern int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
|
||||
extern int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
|
||||
extern int getfsuid(uid_t);
|
||||
extern int setfsuid(uid_t);
|
||||
extern int issetugid(void);
|
||||
extern char* getlogin(void);
|
||||
extern int getlogin_r(char* name, size_t namesize);
|
||||
extern char* getusershell(void);
|
||||
extern void setusershell(void);
|
||||
extern void endusershell(void);
|
||||
@@ -118,12 +112,16 @@ extern int chdir(const char *);
|
||||
extern int fchdir(int);
|
||||
extern int rmdir(const char *);
|
||||
extern int pipe(int *);
|
||||
#ifdef _GNU_SOURCE /* GLibc compatibility */
|
||||
extern int pipe2(int *, int);
|
||||
#endif
|
||||
extern int chroot(const char *);
|
||||
extern int symlink(const char *, const char *);
|
||||
extern int readlink(const char *, char *, size_t);
|
||||
extern int chown(const char *, uid_t, gid_t);
|
||||
extern int fchown(int, uid_t, gid_t);
|
||||
extern int lchown(const char *, uid_t, gid_t);
|
||||
extern int truncate(const char *, off_t);
|
||||
extern char *getcwd(char *, size_t);
|
||||
|
||||
extern int sync(void);
|
||||
@@ -152,9 +150,6 @@ extern unsigned int sleep(unsigned int);
|
||||
extern int usleep(unsigned long);
|
||||
|
||||
extern int gethostname(char *, size_t);
|
||||
extern int sethostname(const char *, size_t);
|
||||
extern int getdomainname(char *, size_t);
|
||||
extern int setdomainname(const char *, size_t);
|
||||
|
||||
extern int getdtablesize(void);
|
||||
|
||||
@@ -191,6 +186,18 @@ extern int cacheflush(long start, long end, long flags);
|
||||
extern pid_t tcgetpgrp(int fd);
|
||||
extern int tcsetpgrp(int fd, pid_t _pid);
|
||||
|
||||
#if 0 /* MISSING FROM BIONIC */
|
||||
extern pid_t getsid(pid_t);
|
||||
extern int execvpe(const char *, char * const *, char * const *);
|
||||
extern int execlpe(const char *, const char *, ...);
|
||||
extern int getfsuid(uid_t);
|
||||
extern int setfsuid(uid_t);
|
||||
extern int getlogin_r(char* name, size_t namesize);
|
||||
extern int sethostname(const char *, size_t);
|
||||
extern int getdomainname(char *, size_t);
|
||||
extern int setdomainname(const char *, size_t);
|
||||
#endif /* MISSING */
|
||||
|
||||
/* Used to retry syscalls that can return EINTR. */
|
||||
#define TEMP_FAILURE_RETRY(exp) ({ \
|
||||
typeof (exp) _rc; \
|
||||
|
@@ -87,4 +87,4 @@ struct utmp* getutent();
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif // _UTMP_H_
|
||||
#endif /* _UTMP_H_ */
|
||||
|
@@ -70,9 +70,9 @@ typedef enum {
|
||||
WC_TYPE_MAX
|
||||
} wctype_t;
|
||||
|
||||
#define WCHAR_MAX 255
|
||||
#define WCHAR_MIN 0
|
||||
#define WEOF (-1)
|
||||
#define WCHAR_MAX INT_MAX
|
||||
#define WCHAR_MIN INT_MIN
|
||||
#define WEOF ((wint_t)(-1))
|
||||
|
||||
extern wint_t btowc(int);
|
||||
extern int fwprintf(FILE *, const wchar_t *, ...);
|
||||
|
14
libc/kernel/arch-sh/asm/adc.h
Normal file
14
libc/kernel/arch-sh/asm/adc.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/****************************************************************************
|
||||
****************************************************************************
|
||||
***
|
||||
*** This header was automatically generated from a Linux kernel header
|
||||
*** of the same name, to make information necessary for userspace to
|
||||
*** call into the kernel available to libc. It contains only constants,
|
||||
*** structures, and macros generated from the original header, and thus,
|
||||
*** contains no copyrightable information.
|
||||
***
|
||||
****************************************************************************
|
||||
****************************************************************************/
|
||||
#ifndef __ASM_ADC_H
|
||||
#define __ASM_ADC_H
|
||||
#endif
|
15
libc/kernel/arch-sh/asm/addrspace.h
Normal file
15
libc/kernel/arch-sh/asm/addrspace.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/****************************************************************************
|
||||
****************************************************************************
|
||||
***
|
||||
*** This header was automatically generated from a Linux kernel header
|
||||
*** of the same name, to make information necessary for userspace to
|
||||
*** call into the kernel available to libc. It contains only constants,
|
||||
*** structures, and macros generated from the original header, and thus,
|
||||
*** contains no copyrightable information.
|
||||
***
|
||||
****************************************************************************
|
||||
****************************************************************************/
|
||||
#ifndef __ASM_SH_ADDRSPACE_H
|
||||
#define __ASM_SH_ADDRSPACE_H
|
||||
|
||||
#endif
|
15
libc/kernel/arch-sh/asm/atomic-grb.h
Normal file
15
libc/kernel/arch-sh/asm/atomic-grb.h
Normal file
@@ -0,0 +1,15 @@
|
||||
/****************************************************************************
|
||||
****************************************************************************
|
||||
***
|
||||
*** This header was automatically generated from a Linux kernel header
|
||||
*** of the same name, to make information necessary for userspace to
|
||||
*** call into the kernel available to libc. It contains only constants,
|
||||
*** structures, and macros generated from the original header, and thus,
|
||||
*** contains no copyrightable information.
|
||||
***
|
||||
****************************************************************************
|
||||
****************************************************************************/
|
||||
#ifndef __ASM_SH_ATOMIC_GRB_H
|
||||
#define __ASM_SH_ATOMIC_GRB_H
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user