Compare commits
	
		
			155 Commits
		
	
	
		
			android-2.
			...
			gingerbrea
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					2c222c4906 | ||
| 
						 | 
					f0e5b680ba | ||
| 
						 | 
					30983c9ab9 | ||
| 
						 | 
					6cda7b6249 | ||
| 
						 | 
					50a83255d8 | ||
| 
						 | 
					c4a5e97624 | ||
| 
						 | 
					afb0167ad9 | ||
| 
						 | 
					a0aec0bd30 | ||
| 
						 | 
					3eb2657855 | ||
| 
						 | 
					3435fc600d | ||
| 
						 | 
					bf29647964 | ||
| 
						 | 
					b1dd939e90 | ||
| 
						 | 
					e0bdf2c3e2 | ||
| 
						 | 
					2cbb8f3f98 | ||
| 
						 | 
					84f8b3ad9c | ||
| 
						 | 
					4711f8faa8 | ||
| 
						 | 
					e5705524e2 | ||
| 
						 | 
					074af91700 | ||
| 
						 | 
					18142abc06 | ||
| 
						 | 
					4029e0e7cb | ||
| 
						 | 
					832a86eaba | ||
| 
						 | 
					88bb394c0d | ||
| 
						 | 
					0bbcbf0d57 | ||
| 
						 | 
					0f2dc2b60c | ||
| 
						 | 
					3f14ff34df | ||
| 
						 | 
					6139fa33ab | ||
| 
						 | 
					6bd73ed417 | ||
| 
						 | 
					2081fda69a | ||
| 
						 | 
					ba96e30fa0 | ||
| 
						 | 
					2e23e29245 | ||
| 
						 | 
					f4dca7be3b | ||
| 
						 | 
					a798b9f0e1 | ||
| 
						 | 
					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
 | 
			
		||||
							
								
								
									
										149
									
								
								libc/Android.mk
									
									
									
									
									
								
							
							
						
						
									
										149
									
								
								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/strlen.S \
 | 
			
		||||
	string/memmove.c \
 | 
			
		||||
	bionic/pthread.c \
 | 
			
		||||
	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_wrapper.S \
 | 
			
		||||
	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,29 @@ 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
 | 
			
		||||
 | 
			
		||||
ifeq ($(TARGET_ARCH),arm)
 | 
			
		||||
libc_crt_target_cflags += -DCRT_LEGACY_WORKAROUND
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Define some common includes
 | 
			
		||||
# ========================================================
 | 
			
		||||
libc_common_c_includes := \
 | 
			
		||||
@@ -453,22 +533,35 @@ libc_common_c_includes := \
 | 
			
		||||
# executables)
 | 
			
		||||
# ==========================================================================
 | 
			
		||||
 | 
			
		||||
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().
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
libc_crt_target_so_cflags := $(libc_crt_target_cflags)
 | 
			
		||||
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.
 | 
			
		||||
    # This flag must be added for x86 targets, but not for ARM
 | 
			
		||||
    libc_crt_target_so_cflags += -fPIC
 | 
			
		||||
endif
 | 
			
		||||
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
 | 
			
		||||
$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
 | 
			
		||||
	@mkdir -p $(dir $@)
 | 
			
		||||
	$(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
 | 
			
		||||
	$(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
 | 
			
		||||
ALL_GENERATED_SOURCES += $(GEN)
 | 
			
		||||
 | 
			
		||||
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
 | 
			
		||||
$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
 | 
			
		||||
	@mkdir -p $(dir $@)
 | 
			
		||||
	$(TARGET_CC) $(libc_crt_target_cflags) -o $@ -c $<
 | 
			
		||||
	$(TARGET_CC) $(libc_crt_target_so_cflags) -o $@ -c $<
 | 
			
		||||
ALL_GENERATED_SOURCES += $(GEN)
 | 
			
		||||
endif # TARGET_ARCH == x86
 | 
			
		||||
endif # TARGET_ARCH == x86 || TARGET_ARCH == arm
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
 | 
			
		||||
@@ -504,6 +597,9 @@ include $(CLEAR_VARS)
 | 
			
		||||
 | 
			
		||||
LOCAL_SRC_FILES := $(libc_common_src_files)
 | 
			
		||||
LOCAL_CFLAGS := $(libc_common_cflags)
 | 
			
		||||
ifeq ($(TARGET_ARCH),arm)
 | 
			
		||||
LOCAL_CFLAGS += -DCRT_LEGACY_WORKAROUND
 | 
			
		||||
endif
 | 
			
		||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
 | 
			
		||||
LOCAL_MODULE := libc_common
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
@@ -525,10 +621,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 +642,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 +667,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
 | 
			
		||||
@@ -616,6 +716,7 @@ LOCAL_MODULE:= libc_malloc_debug_leak
 | 
			
		||||
LOCAL_SHARED_LIBRARIES := libc
 | 
			
		||||
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
 | 
			
		||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
 | 
			
		||||
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
 | 
			
		||||
# Don't prelink
 | 
			
		||||
LOCAL_PRELINK_MODULE := false
 | 
			
		||||
# Don't install on release build
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										69
									
								
								libc/arch-arm/bionic/atexit.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								libc/arch-arm/bionic/atexit.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2011 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 CRT_LEGACY_WORKAROUND
 | 
			
		||||
	.arch armv5te
 | 
			
		||||
	.fpu softvfp
 | 
			
		||||
	.eabi_attribute 20, 1
 | 
			
		||||
	.eabi_attribute 21, 1
 | 
			
		||||
	.eabi_attribute 23, 3
 | 
			
		||||
	.eabi_attribute 24, 1
 | 
			
		||||
	.eabi_attribute 25, 1
 | 
			
		||||
	.eabi_attribute 26, 2
 | 
			
		||||
	.eabi_attribute 30, 4
 | 
			
		||||
	.eabi_attribute 18, 4
 | 
			
		||||
	.code	16
 | 
			
		||||
	.section	.text.atexit,"ax",%progbits
 | 
			
		||||
	.align	2
 | 
			
		||||
	.global	atexit
 | 
			
		||||
	.hidden	atexit
 | 
			
		||||
	.code	16
 | 
			
		||||
	.thumb_func
 | 
			
		||||
	.type	atexit, %function
 | 
			
		||||
atexit:
 | 
			
		||||
	.fnstart
 | 
			
		||||
.LFB0:
 | 
			
		||||
	.save	{r4, lr}
 | 
			
		||||
	push	{r4, lr}
 | 
			
		||||
.LCFI0:
 | 
			
		||||
	ldr	r3, .L3
 | 
			
		||||
	mov	r1, #0
 | 
			
		||||
	@ sp needed for prologue
 | 
			
		||||
.LPIC0:
 | 
			
		||||
	add	r3, pc
 | 
			
		||||
	ldr	r2, [r3]
 | 
			
		||||
	bl	__cxa_atexit
 | 
			
		||||
	pop	{r4, pc}
 | 
			
		||||
.L4:
 | 
			
		||||
	.align	2
 | 
			
		||||
.L3:
 | 
			
		||||
	.word	__dso_handle-(.LPIC0+4)
 | 
			
		||||
.LFE0:
 | 
			
		||||
	.fnend
 | 
			
		||||
	.size	atexit, .-atexit
 | 
			
		||||
#endif
 | 
			
		||||
@@ -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
 | 
			
		||||
   .equ     kernel_cmpxchg, 0xFFFF0FC0
 | 
			
		||||
   .equ     kernel_atomic_base, 0xFFFF0FFF
 | 
			
		||||
#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
 | 
			
		||||
@@ -63,13 +63,7 @@ _start:
 | 
			
		||||
    .long   __INIT_ARRAY__
 | 
			
		||||
    .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"
 | 
			
		||||
#include "atexit.S"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										61
									
								
								libc/arch-arm/bionic/crtbegin_so.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								libc/arch-arm/bionic/crtbegin_so.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,61 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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
 | 
			
		||||
 | 
			
		||||
#ifdef CRT_LEGACY_WORKAROUND
 | 
			
		||||
#include "__dso_handle.S"
 | 
			
		||||
#else
 | 
			
		||||
#include "__dso_handle_so.S"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "atexit.S"
 | 
			
		||||
@@ -63,13 +63,7 @@ _start:
 | 
			
		||||
    .long   __INIT_ARRAY__
 | 
			
		||||
    .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,6 @@ __FINI_ARRAY__:
 | 
			
		||||
__CTOR_LIST__:
 | 
			
		||||
	.long -1
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "__dso_handle.S"
 | 
			
		||||
#include "atexit.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,24 +59,26 @@ 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)]
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
	/* 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
 | 
			
		||||
 | 
			
		||||
.Lsetjmp_magic:
 | 
			
		||||
	.word	_JB_MAGIC_SETJMP
 | 
			
		||||
@@ -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
 | 
			
		||||
							
								
								
									
										48
									
								
								libc/arch-x86/bionic/__stack_chk_fail_local.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								libc/arch-x86/bionic/__stack_chk_fail_local.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2011 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.
 | 
			
		||||
 */
 | 
			
		||||
/*
 | 
			
		||||
 * Contributed by: Intel Corporation
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.globl	__stack_chk_fail_local
 | 
			
		||||
	.hidden	__stack_chk_fail_local
 | 
			
		||||
	.type	__stack_chk_fail_local, @function
 | 
			
		||||
 | 
			
		||||
__stack_chk_fail_local:
 | 
			
		||||
#ifdef __PIC__
 | 
			
		||||
	pushl	%ebx
 | 
			
		||||
	call	__x86.get_pc_thunk.bx
 | 
			
		||||
	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
 | 
			
		||||
	call	__stack_chk_fail@PLT
 | 
			
		||||
#else /* PIC */
 | 
			
		||||
	jmp   __stack_chk_fail
 | 
			
		||||
#endif /* not PIC */
 | 
			
		||||
 | 
			
		||||
	.size	__stack_chk_fail_local, .-__stack_chk_fail_local
 | 
			
		||||
							
								
								
									
										66
									
								
								libc/arch-x86/bionic/atexit.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								libc/arch-x86/bionic/atexit.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 */
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.globl	atexit
 | 
			
		||||
	.hidden	atexit
 | 
			
		||||
	.type	atexit, @function
 | 
			
		||||
atexit:
 | 
			
		||||
	pushl	%ebp
 | 
			
		||||
	movl	%esp, %ebp
 | 
			
		||||
	pushl	%ebx
 | 
			
		||||
	call	__x86.get_pc_thunk.bx
 | 
			
		||||
	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
 | 
			
		||||
	subl	$20, %esp
 | 
			
		||||
	movl	$0, 4(%esp)
 | 
			
		||||
	movl	__dso_handle@GOTOFF(%ebx), %eax
 | 
			
		||||
	movl	%eax, 8(%esp)
 | 
			
		||||
	movl	8(%ebp), %eax
 | 
			
		||||
	movl	%eax, (%esp)
 | 
			
		||||
	call	__cxa_atexit@PLT
 | 
			
		||||
	addl	$20, %esp
 | 
			
		||||
	popl	%ebx
 | 
			
		||||
	popl	%ebp
 | 
			
		||||
	ret
 | 
			
		||||
	.size	atexit, .-atexit
 | 
			
		||||
 | 
			
		||||
	.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
 | 
			
		||||
	.globl	__x86.get_pc_thunk.bx
 | 
			
		||||
	.hidden	__x86.get_pc_thunk.bx
 | 
			
		||||
	.type	__x86.get_pc_thunk.bx, @function
 | 
			
		||||
__x86.get_pc_thunk.bx:
 | 
			
		||||
	nop
 | 
			
		||||
	nop
 | 
			
		||||
	nop
 | 
			
		||||
	nop
 | 
			
		||||
	nop
 | 
			
		||||
	nop
 | 
			
		||||
	nop
 | 
			
		||||
	nop
 | 
			
		||||
	movl	(%esp), %ebx
 | 
			
		||||
	ret
 | 
			
		||||
@@ -73,100 +73,3 @@ __futex_syscall4:
 | 
			
		||||
    popl    %esi
 | 
			
		||||
    popl    %ebx
 | 
			
		||||
    ret
 | 
			
		||||
 | 
			
		||||
/* int __atomic_cmpxchg(int old, int new, volatile int* addr) */
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl __atomic_cmpxchg
 | 
			
		||||
.type __atomic_cmpxchg, @function
 | 
			
		||||
.align 4
 | 
			
		||||
__atomic_cmpxchg:
 | 
			
		||||
    mov     4(%esp), %eax             /* old */
 | 
			
		||||
    mov     8(%esp), %ecx             /* new */
 | 
			
		||||
    mov     12(%esp), %edx            /* addr */
 | 
			
		||||
    lock cmpxchg %ecx, (%edx)
 | 
			
		||||
    jnz 1f
 | 
			
		||||
    xor    %eax, %eax
 | 
			
		||||
    jmp 2f
 | 
			
		||||
1:
 | 
			
		||||
    movl   $1, %eax
 | 
			
		||||
2:
 | 
			
		||||
    ret                               /* 0 == success, 1 == failure */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* int __atomic_swap(int new, volatile int* addr) */
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl __atomic_swap
 | 
			
		||||
.type __atomic_swap, @function
 | 
			
		||||
.align 4
 | 
			
		||||
__atomic_swap:
 | 
			
		||||
    mov     4(%esp), %ecx             /* new */
 | 
			
		||||
    mov     8(%esp), %edx             /* addr */
 | 
			
		||||
    lock xchg %ecx, (%edx)
 | 
			
		||||
    mov     %ecx, %eax
 | 
			
		||||
    ret
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * int __atomic_dec(volatile int* addr)
 | 
			
		||||
 *
 | 
			
		||||
 * My x86 asm is really rusty.. this is probably suboptimal
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl __atomic_dec
 | 
			
		||||
.type __atomic_dec, @function
 | 
			
		||||
.align 4
 | 
			
		||||
__atomic_dec:
 | 
			
		||||
   pushl    %ebx
 | 
			
		||||
   pushl    %esi
 | 
			
		||||
   movl     12(%esp), %ebx             /* addr */
 | 
			
		||||
 | 
			
		||||
1:
 | 
			
		||||
   movl     (%ebx), %esi               /* old = *addr */
 | 
			
		||||
   movl     %esi, %edx
 | 
			
		||||
   subl     $1, %edx                   /* new = old - 1 */
 | 
			
		||||
 | 
			
		||||
   pushl    %ebx
 | 
			
		||||
   pushl    %edx
 | 
			
		||||
   pushl    %esi
 | 
			
		||||
   call     __atomic_cmpxchg
 | 
			
		||||
   addl     $12, %esp
 | 
			
		||||
   test     %eax, %eax
 | 
			
		||||
   jnz      1b
 | 
			
		||||
 | 
			
		||||
   movl     %esi, %eax               /* return old */
 | 
			
		||||
   popl     %esi
 | 
			
		||||
   popl     %ebx
 | 
			
		||||
   ret
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
/* int __atomic_inc(volatile int* addr) */
 | 
			
		||||
.globl __atomic_inc
 | 
			
		||||
.type __atomic_inc, @function
 | 
			
		||||
.align 4
 | 
			
		||||
__atomic_inc:
 | 
			
		||||
   pushl    %ebx
 | 
			
		||||
   pushl    %esi
 | 
			
		||||
   movl     12(%esp), %ebx             /* addr */
 | 
			
		||||
 | 
			
		||||
1:
 | 
			
		||||
   movl     (%ebx), %esi               /* old = *addr */
 | 
			
		||||
   movl     %esi, %edx
 | 
			
		||||
   addl     $1, %edx                   /* new = old + 1 */
 | 
			
		||||
 | 
			
		||||
   pushl    %ebx
 | 
			
		||||
   pushl    %edx
 | 
			
		||||
   pushl    %esi
 | 
			
		||||
   call     __atomic_cmpxchg
 | 
			
		||||
   addl     $12, %esp
 | 
			
		||||
   test     %eax, %eax
 | 
			
		||||
   jnz      1b
 | 
			
		||||
 | 
			
		||||
   movl     %esi, %eax               /* return old */
 | 
			
		||||
   popl     %esi
 | 
			
		||||
   popl     %ebx
 | 
			
		||||
   ret
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,8 +20,7 @@ __pthread_clone:
 | 
			
		||||
        movl    %eax, -12(%ecx)
 | 
			
		||||
        movl    24(%esp), %eax
 | 
			
		||||
        movl    %eax, -8(%ecx)
 | 
			
		||||
        lea     (%ecx), %eax
 | 
			
		||||
        movl    %eax, -4(%ecx)
 | 
			
		||||
        movl    %ecx, -4(%ecx)
 | 
			
		||||
 | 
			
		||||
        movl    $__NR_clone, %eax
 | 
			
		||||
        int     $0x80
 | 
			
		||||
@@ -52,4 +51,4 @@ __pthread_clone:
 | 
			
		||||
/* XXX: TODO: Add __bionic_clone here
 | 
			
		||||
 *            See bionic/bionic_clone.c and arch-arm/bionic/clone.S
 | 
			
		||||
 *            for more details...
 | 
			
		||||
 */
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
@@ -66,14 +66,7 @@ _start:
 | 
			
		||||
1:  .long   __PREINIT_ARRAY__
 | 
			
		||||
    .long   __INIT_ARRAY__
 | 
			
		||||
    .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__:
 | 
			
		||||
@@ -83,14 +76,62 @@ __PREINIT_ARRAY__:
 | 
			
		||||
	.globl __INIT_ARRAY__
 | 
			
		||||
__INIT_ARRAY__:
 | 
			
		||||
	.long -1
 | 
			
		||||
	.long	frame_dummy
 | 
			
		||||
 | 
			
		||||
	.section .fini_array, "aw"
 | 
			
		||||
	.globl __FINI_ARRAY__
 | 
			
		||||
__FINI_ARRAY__:
 | 
			
		||||
	.long -1
 | 
			
		||||
	.long	__do_global_dtors_aux
 | 
			
		||||
 | 
			
		||||
	.section .ctors, "aw"
 | 
			
		||||
	.globl __CTOR_LIST__
 | 
			
		||||
__CTOR_LIST__:
 | 
			
		||||
	.long -1
 | 
			
		||||
	.section	.eh_frame,"a",@progbits
 | 
			
		||||
	.align 4
 | 
			
		||||
	.type	__EH_FRAME_BEGIN__, @object
 | 
			
		||||
__EH_FRAME_BEGIN__:
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.type	__do_global_dtors_aux, @function
 | 
			
		||||
__do_global_dtors_aux:
 | 
			
		||||
	pushl	%ebp
 | 
			
		||||
	movl	%esp, %ebp
 | 
			
		||||
	subl	$24, %esp
 | 
			
		||||
	cmpb	$0, completed.4454
 | 
			
		||||
	jne	.L4
 | 
			
		||||
	movl	$__deregister_frame_info_bases, %eax
 | 
			
		||||
	testl	%eax, %eax
 | 
			
		||||
	je	.L3
 | 
			
		||||
	movl	$__EH_FRAME_BEGIN__, (%esp)
 | 
			
		||||
	call	__deregister_frame_info_bases
 | 
			
		||||
.L3:
 | 
			
		||||
	movb	$1, completed.4454
 | 
			
		||||
.L4:
 | 
			
		||||
	leave
 | 
			
		||||
	ret
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.type	frame_dummy, @function
 | 
			
		||||
frame_dummy:
 | 
			
		||||
	pushl	%ebp
 | 
			
		||||
	movl	$__register_frame_info_bases, %eax
 | 
			
		||||
	movl	%esp, %ebp
 | 
			
		||||
	subl	$24, %esp
 | 
			
		||||
	testl	%eax, %eax
 | 
			
		||||
	je	.L7
 | 
			
		||||
	movl	%ebx, 12(%esp)
 | 
			
		||||
	movl	$0, 8(%esp)
 | 
			
		||||
	movl	$object.4466, 4(%esp)
 | 
			
		||||
	movl	$__EH_FRAME_BEGIN__, (%esp)
 | 
			
		||||
	call	__register_frame_info_bases
 | 
			
		||||
.L7:
 | 
			
		||||
	leave
 | 
			
		||||
	ret
 | 
			
		||||
	.local	completed.4454
 | 
			
		||||
	.comm	completed.4454,1,1
 | 
			
		||||
	.local	object.4466
 | 
			
		||||
	.comm	object.4466,24,4
 | 
			
		||||
	.weak	__register_frame_info_bases
 | 
			
		||||
	.weak	__deregister_frame_info_bases
 | 
			
		||||
 | 
			
		||||
#include "__dso_handle.S"
 | 
			
		||||
#include "atexit.S"
 | 
			
		||||
#include "__stack_chk_fail_local.S"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,30 @@
 | 
			
		||||
/* 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 */
 | 
			
		||||
.section .init
 | 
			
		||||
.align 4
 | 
			
		||||
.type _init, @function
 | 
			
		||||
.globl _init
 | 
			
		||||
_init:
 | 
			
		||||
/*
 | 
			
		||||
 * 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.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
.section .init_array, "aw"
 | 
			
		||||
.align 4
 | 
			
		||||
@@ -13,6 +32,7 @@ _init:
 | 
			
		||||
.globl __INIT_ARRAY__
 | 
			
		||||
__INIT_ARRAY__:
 | 
			
		||||
    .long -1
 | 
			
		||||
    .long frame_dummy
 | 
			
		||||
 | 
			
		||||
.section .fini_array, "aw"
 | 
			
		||||
.align 4
 | 
			
		||||
@@ -20,10 +40,72 @@ __INIT_ARRAY__:
 | 
			
		||||
.globl __FINI_ARRAY__
 | 
			
		||||
__FINI_ARRAY__:
 | 
			
		||||
    .long -1
 | 
			
		||||
    .long __do_global_dtors_aux
 | 
			
		||||
 | 
			
		||||
.section .ctors, "aw"
 | 
			
		||||
.align 4
 | 
			
		||||
.type __CTOR_LIST__, @object
 | 
			
		||||
.globl __CTOR_LIST__
 | 
			
		||||
__CTOR_LIST__:
 | 
			
		||||
        .long -1
 | 
			
		||||
	.section	.eh_frame,"a",@progbits
 | 
			
		||||
	.align 4
 | 
			
		||||
	.type	__EH_FRAME_BEGIN__, @object
 | 
			
		||||
__EH_FRAME_BEGIN__:
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.type	__do_global_dtors_aux, @function
 | 
			
		||||
__do_global_dtors_aux:
 | 
			
		||||
	pushl	%ebp
 | 
			
		||||
	movl	%esp, %ebp
 | 
			
		||||
	pushl	%ebx
 | 
			
		||||
	call	__x86.get_pc_thunk.bx
 | 
			
		||||
	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
 | 
			
		||||
	subl	$20, %esp
 | 
			
		||||
	cmpb	$0, completed.4454@GOTOFF(%ebx)
 | 
			
		||||
	jne	.L5
 | 
			
		||||
	movl	__dso_handle@GOTOFF(%ebx), %eax
 | 
			
		||||
	movl	%eax, (%esp)
 | 
			
		||||
	call	__cxa_finalize@PLT
 | 
			
		||||
	movl	__deregister_frame_info_bases@GOT(%ebx), %eax
 | 
			
		||||
	testl	%eax, %eax
 | 
			
		||||
	je	.L4
 | 
			
		||||
	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
 | 
			
		||||
	movl	%eax, (%esp)
 | 
			
		||||
	call	__deregister_frame_info_bases@PLT
 | 
			
		||||
.L4:
 | 
			
		||||
	movb	$1, completed.4454@GOTOFF(%ebx)
 | 
			
		||||
.L5:
 | 
			
		||||
	addl	$20, %esp
 | 
			
		||||
	popl	%ebx
 | 
			
		||||
	popl	%ebp
 | 
			
		||||
	ret
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.type	frame_dummy, @function
 | 
			
		||||
frame_dummy:
 | 
			
		||||
	pushl	%ebp
 | 
			
		||||
	movl	%esp, %ebp
 | 
			
		||||
	pushl	%ebx
 | 
			
		||||
	call	__x86.get_pc_thunk.bx
 | 
			
		||||
	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
 | 
			
		||||
	subl	$20, %esp
 | 
			
		||||
	movl	__register_frame_info_bases@GOT(%ebx), %eax
 | 
			
		||||
	testl	%eax, %eax
 | 
			
		||||
	je	.L8
 | 
			
		||||
	leal	object.4469@GOTOFF(%ebx), %eax
 | 
			
		||||
	movl	%eax, 4(%esp)
 | 
			
		||||
	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
 | 
			
		||||
	movl	%ebx, 12(%esp)
 | 
			
		||||
	movl	$0, 8(%esp)
 | 
			
		||||
	movl	%eax, (%esp)
 | 
			
		||||
	call	__register_frame_info_bases@PLT
 | 
			
		||||
.L8:
 | 
			
		||||
	addl	$20, %esp
 | 
			
		||||
	popl	%ebx
 | 
			
		||||
	popl	%ebp
 | 
			
		||||
	ret
 | 
			
		||||
	.local	completed.4454
 | 
			
		||||
	.comm	completed.4454,1,1
 | 
			
		||||
	.local	object.4469
 | 
			
		||||
	.comm	object.4469,24,4
 | 
			
		||||
	.weak	__register_frame_info_bases
 | 
			
		||||
	.weak	__deregister_frame_info_bases
 | 
			
		||||
 | 
			
		||||
#include "__dso_handle_so.S"
 | 
			
		||||
#include "atexit.S"
 | 
			
		||||
#include "__stack_chk_fail_local.S"
 | 
			
		||||
 
 | 
			
		||||
@@ -65,14 +65,7 @@ _start:
 | 
			
		||||
1:  .long   __PREINIT_ARRAY__
 | 
			
		||||
    .long   __INIT_ARRAY__
 | 
			
		||||
    .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__:
 | 
			
		||||
@@ -82,14 +75,62 @@ __PREINIT_ARRAY__:
 | 
			
		||||
	.globl __INIT_ARRAY__
 | 
			
		||||
__INIT_ARRAY__:
 | 
			
		||||
	.long -1
 | 
			
		||||
	.long	frame_dummy
 | 
			
		||||
 | 
			
		||||
	.section .fini_array, "aw"
 | 
			
		||||
	.globl __FINI_ARRAY__
 | 
			
		||||
__FINI_ARRAY__:
 | 
			
		||||
	.long -1
 | 
			
		||||
	.long	__do_global_dtors_aux
 | 
			
		||||
 | 
			
		||||
	.section .ctors, "aw"
 | 
			
		||||
	.globl __CTOR_LIST__
 | 
			
		||||
__CTOR_LIST__:
 | 
			
		||||
	.long -1
 | 
			
		||||
	.section	.eh_frame,"a",@progbits
 | 
			
		||||
	.align 4
 | 
			
		||||
	.type	__EH_FRAME_BEGIN__, @object
 | 
			
		||||
__EH_FRAME_BEGIN__:
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.type	__do_global_dtors_aux, @function
 | 
			
		||||
__do_global_dtors_aux:
 | 
			
		||||
	pushl	%ebp
 | 
			
		||||
	movl	%esp, %ebp
 | 
			
		||||
	subl	$24, %esp
 | 
			
		||||
	cmpb	$0, completed.4454
 | 
			
		||||
	jne	.L4
 | 
			
		||||
	movl	$__deregister_frame_info_bases, %eax
 | 
			
		||||
	testl	%eax, %eax
 | 
			
		||||
	je	.L3
 | 
			
		||||
	movl	$__EH_FRAME_BEGIN__, (%esp)
 | 
			
		||||
	call	__deregister_frame_info_bases
 | 
			
		||||
.L3:
 | 
			
		||||
	movb	$1, completed.4454
 | 
			
		||||
.L4:
 | 
			
		||||
	leave
 | 
			
		||||
	ret
 | 
			
		||||
	.text
 | 
			
		||||
	.p2align 4,,15
 | 
			
		||||
	.type	frame_dummy, @function
 | 
			
		||||
frame_dummy:
 | 
			
		||||
	pushl	%ebp
 | 
			
		||||
	movl	$__register_frame_info_bases, %eax
 | 
			
		||||
	movl	%esp, %ebp
 | 
			
		||||
	subl	$24, %esp
 | 
			
		||||
	testl	%eax, %eax
 | 
			
		||||
	je	.L7
 | 
			
		||||
	movl	%ebx, 12(%esp)
 | 
			
		||||
	movl	$0, 8(%esp)
 | 
			
		||||
	movl	$object.4466, 4(%esp)
 | 
			
		||||
	movl	$__EH_FRAME_BEGIN__, (%esp)
 | 
			
		||||
	call	__register_frame_info_bases
 | 
			
		||||
.L7:
 | 
			
		||||
	leave
 | 
			
		||||
	ret
 | 
			
		||||
	.local	completed.4454
 | 
			
		||||
	.comm	completed.4454,1,1
 | 
			
		||||
	.local	object.4466
 | 
			
		||||
	.comm	object.4466,24,4
 | 
			
		||||
	.weak	__register_frame_info_bases
 | 
			
		||||
	.weak	__deregister_frame_info_bases
 | 
			
		||||
 | 
			
		||||
#include "__dso_handle.S"
 | 
			
		||||
#include "atexit.S"
 | 
			
		||||
#include "__stack_chk_fail_local.S"
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
	
 | 
			
		||||
	.section .preinit_array, "aw"
 | 
			
		||||
	.long 0
 | 
			
		||||
 | 
			
		||||
@@ -8,6 +7,9 @@
 | 
			
		||||
	.section .fini_array, "aw"
 | 
			
		||||
	.long 0
 | 
			
		||||
 | 
			
		||||
	.section .ctors, "aw"
 | 
			
		||||
	.long 0
 | 
			
		||||
 | 
			
		||||
	.section	.eh_frame,"a",@progbits
 | 
			
		||||
	.align 4
 | 
			
		||||
	.type	__FRAME_END__, @object
 | 
			
		||||
	.size	__FRAME_END__, 4
 | 
			
		||||
__FRAME_END__:
 | 
			
		||||
	.zero	4
 | 
			
		||||
 
 | 
			
		||||
@@ -1,47 +1,12 @@
 | 
			
		||||
.text
 | 
			
		||||
.align 4
 | 
			
		||||
.type __bionic_call_ctors, @function
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * The CTORS_LIST is marked by -1 (start) and 0 (end).
 | 
			
		||||
 * We mark the end of the .ctors section with the __CTOR_END__ section so
 | 
			
		||||
 * that we can just iterate backwards from it until we hit -1 and execute
 | 
			
		||||
 * all the function pointers. This seems to be the way to do it for SVR4
 | 
			
		||||
 * derived systems.
 | 
			
		||||
 */
 | 
			
		||||
__bionic_call_ctors:
 | 
			
		||||
    pushl  %esi
 | 
			
		||||
    mov    $__CTOR_END__, %esi
 | 
			
		||||
 | 
			
		||||
0:
 | 
			
		||||
    /* now grab the next function pointer and check if its -1. If not,
 | 
			
		||||
     * call it, otherwise we're done. We use %esi since it's callee saved.
 | 
			
		||||
     */
 | 
			
		||||
    subl    $4, %esi
 | 
			
		||||
    mov     (%esi), %eax
 | 
			
		||||
    cmp     $0xffffffff, %eax
 | 
			
		||||
    je      1f
 | 
			
		||||
    call    *%eax
 | 
			
		||||
    jmp     0b
 | 
			
		||||
 | 
			
		||||
1:
 | 
			
		||||
    /* we're done */
 | 
			
		||||
    popl    %esi
 | 
			
		||||
    ret
 | 
			
		||||
 | 
			
		||||
.section .init
 | 
			
		||||
.align 4
 | 
			
		||||
    call __bionic_call_ctors
 | 
			
		||||
    ret
 | 
			
		||||
 | 
			
		||||
.section .ctors, "aw", @progbits
 | 
			
		||||
.align 4
 | 
			
		||||
.type __CTOR_END__, @object
 | 
			
		||||
__CTOR_END__:
 | 
			
		||||
    .long 0
 | 
			
		||||
 | 
			
		||||
.section .init_array, "aw"
 | 
			
		||||
    .long 0
 | 
			
		||||
 | 
			
		||||
.section .fini_array, "aw"
 | 
			
		||||
    .long 0
 | 
			
		||||
 | 
			
		||||
	.section	.eh_frame,"a",@progbits
 | 
			
		||||
	.align 4
 | 
			
		||||
	.type	__FRAME_END__, @object
 | 
			
		||||
	.size	__FRAME_END__, 4
 | 
			
		||||
__FRAME_END__:
 | 
			
		||||
	.zero	4
 | 
			
		||||
 
 | 
			
		||||
@@ -31,14 +31,14 @@
 | 
			
		||||
 | 
			
		||||
#if defined(_KERNEL) && !defined(I386_CPU)
 | 
			
		||||
#define	__swap32md(x) ({						\
 | 
			
		||||
	u_int32_t __swap32md_x = (x);					\
 | 
			
		||||
	uint32_t __swap32md_x = (x);					\
 | 
			
		||||
									\
 | 
			
		||||
	__asm ("bswap %1" : "+r" (__swap32md_x));			\
 | 
			
		||||
	__swap32md_x;							\
 | 
			
		||||
})
 | 
			
		||||
#else
 | 
			
		||||
#define	__swap32md(x) ({						\
 | 
			
		||||
	u_int32_t __swap32md_x = (x);					\
 | 
			
		||||
	uint32_t __swap32md_x = (x);					\
 | 
			
		||||
									\
 | 
			
		||||
	__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" :		\
 | 
			
		||||
	    "+r" (__swap32md_x));					\
 | 
			
		||||
@@ -47,13 +47,13 @@
 | 
			
		||||
#endif	/* _KERNEL && !I386_CPU */
 | 
			
		||||
 | 
			
		||||
#define	__swap64md(x) ({						\
 | 
			
		||||
	u_int64_t __swap64md_x = (x);					\
 | 
			
		||||
	uint64_t __swap64md_x = (x);					\
 | 
			
		||||
									\
 | 
			
		||||
	(u_int64_t)__swap32md(__swap64md_x >> 32) |			\
 | 
			
		||||
	    (u_int64_t)__swap32md(__swap64md_x & 0xffffffff) << 32;	\
 | 
			
		||||
	(uint64_t)__swap32md(__swap64md_x >> 32) |			\
 | 
			
		||||
	    (uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32;	\
 | 
			
		||||
})
 | 
			
		||||
#define	__swap16md(x) ({						\
 | 
			
		||||
	u_int16_t __swap16md_x = (x);					\
 | 
			
		||||
	uint16_t __swap16md_x = (x);					\
 | 
			
		||||
									\
 | 
			
		||||
	__asm ("rorw $8, %w1" : "+r" (__swap16md_x));			\
 | 
			
		||||
	__swap16md_x;							\
 | 
			
		||||
 
 | 
			
		||||
@@ -36,13 +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_DEFINED_
 | 
			
		||||
#  define _SIZE_T_DEFINED_
 | 
			
		||||
#  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;
 | 
			
		||||
 | 
			
		||||
#define _OFF_T_DEFINED_
 | 
			
		||||
#define _SIZE_T_DEFINED_
 | 
			
		||||
typedef long           ptrdiff_t;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <linux/types.h>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										65
									
								
								libc/arch-x86/include/sys/atomics.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								libc/arch-x86/include/sys/atomics.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2011 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_ATOMICS_H
 | 
			
		||||
#define _SYS_ATOMICS_H
 | 
			
		||||
 | 
			
		||||
#include <sys/cdefs.h>
 | 
			
		||||
#include <sys/time.h>
 | 
			
		||||
 | 
			
		||||
__BEGIN_DECLS
 | 
			
		||||
 | 
			
		||||
static inline __attribute__((always_inline)) int
 | 
			
		||||
__atomic_cmpxchg(int old, int _new, volatile int *ptr)
 | 
			
		||||
{
 | 
			
		||||
  return !__sync_bool_compare_and_swap (ptr, old, _new);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__((always_inline)) int
 | 
			
		||||
__atomic_swap(int _new, volatile int *ptr)
 | 
			
		||||
{
 | 
			
		||||
  return __sync_lock_test_and_set(ptr, _new);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__((always_inline)) int
 | 
			
		||||
__atomic_dec(volatile int *ptr)
 | 
			
		||||
{
 | 
			
		||||
  return __sync_fetch_and_sub (ptr, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static inline __attribute__((always_inline)) int
 | 
			
		||||
__atomic_inc(volatile int *ptr)
 | 
			
		||||
{
 | 
			
		||||
  return __sync_fetch_and_add (ptr, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
 | 
			
		||||
int __futex_wake(volatile void *ftx, int count);
 | 
			
		||||
 | 
			
		||||
__END_DECLS
 | 
			
		||||
 | 
			
		||||
#endif /* _SYS_ATOMICS_H */
 | 
			
		||||
							
								
								
									
										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-new.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
 | 
			
		||||
							
								
								
									
										914
									
								
								libc/arch-x86/string/sse2-memset5-atom.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										914
									
								
								libc/arch-x86/string/sse2-memset5-atom.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,914 @@
 | 
			
		||||
/*
 | 
			
		||||
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
 | 
			
		||||
	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)
 | 
			
		||||
# define RESTORE_EBX_STATE CFI_PUSH (%ebx)
 | 
			
		||||
	cmp	$DATA_CACHE_SIZE, %ecx
 | 
			
		||||
#else
 | 
			
		||||
# ifdef SHARED
 | 
			
		||||
#  define RESTORE_EBX_STATE
 | 
			
		||||
	call	__i686.get_pc_thunk.bx
 | 
			
		||||
	add	$_GLOBAL_OFFSET_TABLE_, %ebx
 | 
			
		||||
	cmp	__x86_data_cache_size@GOTOFF(%ebx), %ecx
 | 
			
		||||
# else
 | 
			
		||||
	POP (%ebx)
 | 
			
		||||
#  define RESTORE_EBX_STATE CFI_PUSH (%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):
 | 
			
		||||
	add	$128, %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))
 | 
			
		||||
 | 
			
		||||
	RESTORE_EBX_STATE
 | 
			
		||||
L(128bytesormore_nt_start):
 | 
			
		||||
	sub	%ebx, %ecx
 | 
			
		||||
	mov	%ebx, %eax
 | 
			
		||||
	and	$0x7f, %eax
 | 
			
		||||
	add	%eax, %ecx
 | 
			
		||||
	movd	%xmm0, %eax
 | 
			
		||||
	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)
 | 
			
		||||
							
								
								
									
										369
									
								
								libc/arch-x86/string/sse2-strlen-atom.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										369
									
								
								libc/arch-x86/string/sse2-strlen-atom.S
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,369 @@
 | 
			
		||||
#define STRLEN sse2_strlen_atom
 | 
			
		||||
 | 
			
		||||
#ifndef L
 | 
			
		||||
# define L(label)	.L##label
 | 
			
		||||
#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 cfi_remember_state
 | 
			
		||||
# define cfi_remember_state		.cfi_remember_state
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef cfi_restore_state
 | 
			
		||||
# define cfi_restore_state		.cfi_restore_state
 | 
			
		||||
#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)
 | 
			
		||||
#define PARMS		4
 | 
			
		||||
#define	STR		PARMS
 | 
			
		||||
#define ENTRANCE
 | 
			
		||||
#define RETURN		ret
 | 
			
		||||
 | 
			
		||||
	.text
 | 
			
		||||
ENTRY (STRLEN)
 | 
			
		||||
	ENTRANCE
 | 
			
		||||
	mov	STR(%esp), %edx
 | 
			
		||||
	xor	%eax, %eax
 | 
			
		||||
	cmpb	$0, (%edx)
 | 
			
		||||
	jz	L(exit_tail0)
 | 
			
		||||
	cmpb	$0, 1(%edx)
 | 
			
		||||
	jz	L(exit_tail1)
 | 
			
		||||
	cmpb	$0, 2(%edx)
 | 
			
		||||
	jz	L(exit_tail2)
 | 
			
		||||
	cmpb	$0, 3(%edx)
 | 
			
		||||
	jz	L(exit_tail3)
 | 
			
		||||
	cmpb	$0, 4(%edx)
 | 
			
		||||
	jz	L(exit_tail4)
 | 
			
		||||
	cmpb	$0, 5(%edx)
 | 
			
		||||
	jz	L(exit_tail5)
 | 
			
		||||
	cmpb	$0, 6(%edx)
 | 
			
		||||
	jz	L(exit_tail6)
 | 
			
		||||
	cmpb	$0, 7(%edx)
 | 
			
		||||
	jz	L(exit_tail7)
 | 
			
		||||
	cmpb	$0, 8(%edx)
 | 
			
		||||
	jz	L(exit_tail8)
 | 
			
		||||
	cmpb	$0, 9(%edx)
 | 
			
		||||
	jz	L(exit_tail9)
 | 
			
		||||
	cmpb	$0, 10(%edx)
 | 
			
		||||
	jz	L(exit_tail10)
 | 
			
		||||
	cmpb	$0, 11(%edx)
 | 
			
		||||
	jz	L(exit_tail11)
 | 
			
		||||
	cmpb	$0, 12(%edx)
 | 
			
		||||
	jz	L(exit_tail12)
 | 
			
		||||
	cmpb	$0, 13(%edx)
 | 
			
		||||
	jz	L(exit_tail13)
 | 
			
		||||
	cmpb	$0, 14(%edx)
 | 
			
		||||
	jz	L(exit_tail14)
 | 
			
		||||
	cmpb	$0, 15(%edx)
 | 
			
		||||
	jz	L(exit_tail15)
 | 
			
		||||
	pxor	%xmm0, %xmm0
 | 
			
		||||
	mov	%edx, %eax
 | 
			
		||||
	mov	%edx, %ecx
 | 
			
		||||
	and	$-16, %eax
 | 
			
		||||
	add	$16, %ecx
 | 
			
		||||
	add	$16, %eax
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm0
 | 
			
		||||
	pmovmskb %xmm0, %edx
 | 
			
		||||
	pxor	%xmm1, %xmm1
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm1
 | 
			
		||||
	pmovmskb %xmm1, %edx
 | 
			
		||||
	pxor	%xmm2, %xmm2
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm2
 | 
			
		||||
	pmovmskb %xmm2, %edx
 | 
			
		||||
	pxor	%xmm3, %xmm3
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm3
 | 
			
		||||
	pmovmskb %xmm3, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm0
 | 
			
		||||
	pmovmskb %xmm0, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm1
 | 
			
		||||
	pmovmskb %xmm1, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm2
 | 
			
		||||
	pmovmskb %xmm2, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm3
 | 
			
		||||
	pmovmskb %xmm3, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm0
 | 
			
		||||
	pmovmskb %xmm0, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm1
 | 
			
		||||
	pmovmskb %xmm1, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm2
 | 
			
		||||
	pmovmskb %xmm2, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm3
 | 
			
		||||
	pmovmskb %xmm3, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm0
 | 
			
		||||
	pmovmskb %xmm0, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm1
 | 
			
		||||
	pmovmskb %xmm1, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm2
 | 
			
		||||
	pmovmskb %xmm2, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	pcmpeqb	(%eax), %xmm3
 | 
			
		||||
	pmovmskb %xmm3, %edx
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	lea	16(%eax), %eax
 | 
			
		||||
	jnz	L(exit)
 | 
			
		||||
 | 
			
		||||
	and	$-0x40, %eax
 | 
			
		||||
	PUSH (%esi)
 | 
			
		||||
	PUSH (%edi)
 | 
			
		||||
	PUSH (%ebx)
 | 
			
		||||
	PUSH (%ebp)
 | 
			
		||||
	xor	%ebp, %ebp
 | 
			
		||||
L(aligned_64):
 | 
			
		||||
	pcmpeqb	(%eax), %xmm0
 | 
			
		||||
	pcmpeqb	16(%eax), %xmm1
 | 
			
		||||
	pcmpeqb	32(%eax), %xmm2
 | 
			
		||||
	pcmpeqb	48(%eax), %xmm3
 | 
			
		||||
	pmovmskb %xmm0, %edx
 | 
			
		||||
	pmovmskb %xmm1, %esi
 | 
			
		||||
	pmovmskb %xmm2, %edi
 | 
			
		||||
	pmovmskb %xmm3, %ebx
 | 
			
		||||
	or	%edx, %ebp
 | 
			
		||||
	or	%esi, %ebp
 | 
			
		||||
	or	%edi, %ebp
 | 
			
		||||
	or	%ebx, %ebp
 | 
			
		||||
	lea	64(%eax), %eax
 | 
			
		||||
	jz	L(aligned_64)
 | 
			
		||||
L(48leave):
 | 
			
		||||
	test	%edx, %edx
 | 
			
		||||
	jnz	L(aligned_64_exit_16)
 | 
			
		||||
	test	%esi, %esi
 | 
			
		||||
	jnz	L(aligned_64_exit_32)
 | 
			
		||||
	test	%edi, %edi
 | 
			
		||||
	jnz	L(aligned_64_exit_48)
 | 
			
		||||
	mov	%ebx, %edx
 | 
			
		||||
	lea	(%eax), %eax
 | 
			
		||||
	jmp	L(aligned_64_exit)
 | 
			
		||||
L(aligned_64_exit_48):
 | 
			
		||||
	lea	-16(%eax), %eax
 | 
			
		||||
	mov	%edi, %edx
 | 
			
		||||
	jmp	L(aligned_64_exit)
 | 
			
		||||
L(aligned_64_exit_32):
 | 
			
		||||
	lea	-32(%eax), %eax
 | 
			
		||||
	mov	%esi, %edx
 | 
			
		||||
	jmp	L(aligned_64_exit)
 | 
			
		||||
L(aligned_64_exit_16):
 | 
			
		||||
	lea	-48(%eax), %eax
 | 
			
		||||
L(aligned_64_exit):
 | 
			
		||||
	POP (%ebp)
 | 
			
		||||
	POP (%ebx)
 | 
			
		||||
	POP (%edi)
 | 
			
		||||
	POP (%esi)
 | 
			
		||||
L(exit):
 | 
			
		||||
	sub	%ecx, %eax
 | 
			
		||||
	test	%dl, %dl
 | 
			
		||||
	jz	L(exit_high)
 | 
			
		||||
	test	$0x01, %dl
 | 
			
		||||
	jnz	L(exit_tail0)
 | 
			
		||||
 | 
			
		||||
	test	$0x02, %dl
 | 
			
		||||
	jnz	L(exit_tail1)
 | 
			
		||||
 | 
			
		||||
	test	$0x04, %dl
 | 
			
		||||
	jnz	L(exit_tail2)
 | 
			
		||||
 | 
			
		||||
	test	$0x08, %dl
 | 
			
		||||
	jnz	L(exit_tail3)
 | 
			
		||||
 | 
			
		||||
	test	$0x10, %dl
 | 
			
		||||
	jnz	L(exit_tail4)
 | 
			
		||||
 | 
			
		||||
	test	$0x20, %dl
 | 
			
		||||
	jnz	L(exit_tail5)
 | 
			
		||||
 | 
			
		||||
	test	$0x40, %dl
 | 
			
		||||
	jnz	L(exit_tail6)
 | 
			
		||||
	add	$7, %eax
 | 
			
		||||
L(exit_tail0):
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_high):
 | 
			
		||||
	add	$8, %eax
 | 
			
		||||
	test	$0x01, %dh
 | 
			
		||||
	jnz	L(exit_tail0)
 | 
			
		||||
 | 
			
		||||
	test	$0x02, %dh
 | 
			
		||||
	jnz	L(exit_tail1)
 | 
			
		||||
 | 
			
		||||
	test	$0x04, %dh
 | 
			
		||||
	jnz	L(exit_tail2)
 | 
			
		||||
 | 
			
		||||
	test	$0x08, %dh
 | 
			
		||||
	jnz	L(exit_tail3)
 | 
			
		||||
 | 
			
		||||
	test	$0x10, %dh
 | 
			
		||||
	jnz	L(exit_tail4)
 | 
			
		||||
 | 
			
		||||
	test	$0x20, %dh
 | 
			
		||||
	jnz	L(exit_tail5)
 | 
			
		||||
 | 
			
		||||
	test	$0x40, %dh
 | 
			
		||||
	jnz	L(exit_tail6)
 | 
			
		||||
	add	$7, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
	.p2align 4
 | 
			
		||||
L(exit_tail1):
 | 
			
		||||
	add	$1, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail2):
 | 
			
		||||
	add	$2, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail3):
 | 
			
		||||
	add	$3, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail4):
 | 
			
		||||
	add	$4, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail5):
 | 
			
		||||
	add	$5, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail6):
 | 
			
		||||
	add	$6, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail7):
 | 
			
		||||
	add	$7, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail8):
 | 
			
		||||
	add	$8, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail9):
 | 
			
		||||
	add	$9, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail10):
 | 
			
		||||
	add	$10, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail11):
 | 
			
		||||
	add	$11, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail12):
 | 
			
		||||
	add	$12, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail13):
 | 
			
		||||
	add	$13, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail14):
 | 
			
		||||
	add	$14, %eax
 | 
			
		||||
	RETURN
 | 
			
		||||
 | 
			
		||||
L(exit_tail15):
 | 
			
		||||
	add	$15, %eax
 | 
			
		||||
	ret
 | 
			
		||||
 | 
			
		||||
END (STRLEN)
 | 
			
		||||
							
								
								
									
										2035
									
								
								libc/arch-x86/string/ssse3-memcmp3-new.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2035
									
								
								libc/arch-x86/string/ssse3-memcmp3-new.S
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1812
									
								
								libc/arch-x86/string/ssse3-memcpy5.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1812
									
								
								libc/arch-x86/string/ssse3-memcpy5.S
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2274
									
								
								libc/arch-x86/string/ssse3-strcmp-latest.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2274
									
								
								libc/arch-x86/string/ssse3-strcmp-latest.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-latest.S"
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
# include "strcmp.S"
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										40
									
								
								libc/arch-x86/string/strlen_wrapper.S
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								libc/arch-x86/string/strlen_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_SSE2)
 | 
			
		||||
 | 
			
		||||
# define sse2_strlen_atom strlen
 | 
			
		||||
# include "sse2-strlen-atom.S"
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
# include "strlen.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-latest.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;
 | 
			
		||||
    char **P = environ;
 | 
			
		||||
 | 
			
		||||
	for (P = &environ[offset]; *P; ++P)
 | 
			
		||||
		*P = 0;
 | 
			
		||||
        return 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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -35,9 +35,12 @@ typedef struct
 | 
			
		||||
    void (**preinit_array)(void);
 | 
			
		||||
    void (**init_array)(void);
 | 
			
		||||
    void (**fini_array)(void);
 | 
			
		||||
#ifndef __i386__
 | 
			
		||||
    void (**ctors_array)(void);
 | 
			
		||||
#endif
 | 
			
		||||
} 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));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -75,8 +75,10 @@ __noreturn void __libc_init(uintptr_t *elfdata,
 | 
			
		||||
    /* pre-init array. */
 | 
			
		||||
    call_array(structors->preinit_array);
 | 
			
		||||
 | 
			
		||||
#ifndef __i386__
 | 
			
		||||
    /* .ctors section initializers, for non-arm-eabi ABIs */
 | 
			
		||||
    call_array(structors->ctors_array);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    // call static constructors
 | 
			
		||||
    call_array(structors->init_array);
 | 
			
		||||
@@ -85,5 +87,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,12 +38,17 @@
 | 
			
		||||
#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
 | 
			
		||||
#define LOG_BUF_SIZE    1024
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
    LOG_ID_NONE = 0,
 | 
			
		||||
@@ -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,34 +60,43 @@ HashTable gHashTable;
 | 
			
		||||
 | 
			
		||||
static int hash_entry_compare(const void* arg1, const void* arg2)
 | 
			
		||||
{
 | 
			
		||||
    int result;
 | 
			
		||||
 | 
			
		||||
    HashEntry* e1 = *(HashEntry**)arg1;
 | 
			
		||||
    HashEntry* e2 = *(HashEntry**)arg2;
 | 
			
		||||
 | 
			
		||||
    size_t nbAlloc1 = e1->allocations;
 | 
			
		||||
    size_t nbAlloc2 = e2->allocations;
 | 
			
		||||
    size_t size1 = e1->size & ~SIZE_FLAG_MASK;
 | 
			
		||||
    size_t size2 = e2->size & ~SIZE_FLAG_MASK;
 | 
			
		||||
    size_t alloc1 = nbAlloc1 * size1;
 | 
			
		||||
    size_t alloc2 = nbAlloc2 * size2;
 | 
			
		||||
 | 
			
		||||
    // sort in descending order by:
 | 
			
		||||
    // 1) total size
 | 
			
		||||
    // 2) number of allocations
 | 
			
		||||
    //
 | 
			
		||||
    // This is used for sorting, not determination of equality, so we don't
 | 
			
		||||
    // need to compare the bit flags.
 | 
			
		||||
    int result;
 | 
			
		||||
    if (alloc1 > alloc2) {
 | 
			
		||||
    // 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 if (alloc1 < alloc2) {
 | 
			
		||||
        result = 1;
 | 
			
		||||
    } else {
 | 
			
		||||
        if (nbAlloc1 > nbAlloc2) {
 | 
			
		||||
        size_t nbAlloc1 = e1->allocations;
 | 
			
		||||
        size_t nbAlloc2 = e2->allocations;
 | 
			
		||||
        size_t size1 = e1->size & ~SIZE_FLAG_MASK;
 | 
			
		||||
        size_t size2 = e2->size & ~SIZE_FLAG_MASK;
 | 
			
		||||
        size_t alloc1 = nbAlloc1 * size1;
 | 
			
		||||
        size_t alloc2 = nbAlloc2 * size2;
 | 
			
		||||
 | 
			
		||||
        // sort in descending order by:
 | 
			
		||||
        // 1) total size
 | 
			
		||||
        // 2) number of allocations
 | 
			
		||||
        //
 | 
			
		||||
        // This is used for sorting, not determination of equality, so we don't
 | 
			
		||||
        // need to compare the bit flags.
 | 
			
		||||
        int result;
 | 
			
		||||
        if (alloc1 > alloc2) {
 | 
			
		||||
            result = -1;
 | 
			
		||||
        } else if (nbAlloc1 < nbAlloc2) {
 | 
			
		||||
        } else if (alloc1 < alloc2) {
 | 
			
		||||
            result = 1;
 | 
			
		||||
        } else {
 | 
			
		||||
            result = 0;
 | 
			
		||||
            if (nbAlloc1 > nbAlloc2) {
 | 
			
		||||
                result = -1;
 | 
			
		||||
            } else if (nbAlloc1 < nbAlloc2) {
 | 
			
		||||
                result = 1;
 | 
			
		||||
            } else {
 | 
			
		||||
                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,17 +43,38 @@
 | 
			
		||||
#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)
 | 
			
		||||
 | 
			
		||||
void _thread_created_hook(pid_t thread_id) __attribute__((noinline));
 | 
			
		||||
#ifdef __i386__
 | 
			
		||||
#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
 | 
			
		||||
#else
 | 
			
		||||
#define ATTRIBUTES __attribute__((noinline))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void ATTRIBUTES _thread_created_hook(pid_t thread_id);
 | 
			
		||||
 | 
			
		||||
#define PTHREAD_ATTR_FLAG_DETACHED      0x00000001
 | 
			
		||||
#define PTHREAD_ATTR_FLAG_USER_STACK    0x00000002
 | 
			
		||||
@@ -712,24 +733,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 +886,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 +939,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 +952,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 +963,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 +1000,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 +1020,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,8 +1065,7 @@ 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;
 | 
			
		||||
    mtype |= shared;
 | 
			
		||||
 | 
			
		||||
    for (;;) {
 | 
			
		||||
        int  oldv;
 | 
			
		||||
@@ -1084,7 +1091,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 +1131,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 +1150,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 +1233,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 +1247,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 +1291,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 +1321,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 +1414,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 +1427,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 +1452,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 +1872,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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,63 +1,68 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2008 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/ptrace.h>
 | 
			
		||||
 | 
			
		||||
extern long __ptrace(int request, pid_t pid, void *addr, void *data);
 | 
			
		||||
 | 
			
		||||
long ptrace(int request, pid_t pid, void * addr, void * data)
 | 
			
		||||
{
 | 
			
		||||
    switch (request) {
 | 
			
		||||
        case PTRACE_PEEKUSR:
 | 
			
		||||
        case PTRACE_PEEKTEXT:
 | 
			
		||||
        case PTRACE_PEEKDATA:
 | 
			
		||||
        {
 | 
			
		||||
            long word;
 | 
			
		||||
            long ret;
 | 
			
		||||
            
 | 
			
		||||
            ret = __ptrace(request, pid, addr, &word);
 | 
			
		||||
            if (ret == 0) {
 | 
			
		||||
                return word;
 | 
			
		||||
            } else {
 | 
			
		||||
                // __ptrace will set errno for us
 | 
			
		||||
                return -1;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
             return __ptrace(request, pid, addr, data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Hook for gdb to get notified when a thread is created
 | 
			
		||||
 */
 | 
			
		||||
void _thread_created_hook(pid_t thread_id) __attribute__((noinline));
 | 
			
		||||
void _thread_created_hook(pid_t thread_id)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2008 The Android Open Source Project
 | 
			
		||||
 * All rights reserved.
 | 
			
		||||
 *
 | 
			
		||||
 * Redistribution and use in source and binary forms, with or without
 | 
			
		||||
 * modification, are permitted provided that the following conditions
 | 
			
		||||
 * are met:
 | 
			
		||||
 *  * Redistributions of source code must retain the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer.
 | 
			
		||||
 *  * Redistributions in binary form must reproduce the above copyright
 | 
			
		||||
 *    notice, this list of conditions and the following disclaimer in
 | 
			
		||||
 *    the documentation and/or other materials provided with the
 | 
			
		||||
 *    distribution.
 | 
			
		||||
 *
 | 
			
		||||
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 | 
			
		||||
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 | 
			
		||||
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 | 
			
		||||
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 | 
			
		||||
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 | 
			
		||||
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 | 
			
		||||
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 | 
			
		||||
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 | 
			
		||||
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 | 
			
		||||
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 | 
			
		||||
 * SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
#include <sys/ptrace.h>
 | 
			
		||||
 | 
			
		||||
extern long __ptrace(int request, pid_t pid, void *addr, void *data);
 | 
			
		||||
 | 
			
		||||
long ptrace(int request, pid_t pid, void * addr, void * data)
 | 
			
		||||
{
 | 
			
		||||
    switch (request) {
 | 
			
		||||
        case PTRACE_PEEKUSR:
 | 
			
		||||
        case PTRACE_PEEKTEXT:
 | 
			
		||||
        case PTRACE_PEEKDATA:
 | 
			
		||||
        {
 | 
			
		||||
            long word;
 | 
			
		||||
            long ret;
 | 
			
		||||
 | 
			
		||||
            ret = __ptrace(request, pid, addr, &word);
 | 
			
		||||
            if (ret == 0) {
 | 
			
		||||
                return word;
 | 
			
		||||
            } else {
 | 
			
		||||
                // __ptrace will set errno for us
 | 
			
		||||
                return -1;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        default:
 | 
			
		||||
             return __ptrace(request, pid, addr, data);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Hook for gdb to get notified when a thread is created
 | 
			
		||||
 */
 | 
			
		||||
#ifdef __i386__
 | 
			
		||||
#define ATTRIBUTES __attribute__((noinline)) __attribute__((fastcall))
 | 
			
		||||
#else
 | 
			
		||||
#define ATTRIBUTES __attribute__((noinline))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void ATTRIBUTES _thread_created_hook(pid_t thread_id)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -60,6 +60,10 @@
 | 
			
		||||
#define IN6_IS_ADDR_SITELOCAL(a)	\
 | 
			
		||||
	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
 | 
			
		||||
 | 
			
		||||
/* RFC 4193. */
 | 
			
		||||
#define IN6_IS_ADDR_ULA(a)	\
 | 
			
		||||
	(((a)->s6_addr[0] & 0xfe) == 0xfc)
 | 
			
		||||
 | 
			
		||||
#define IN6_IS_ADDR_MULTICAST(a)	\
 | 
			
		||||
	(((__const uint8_t *) (a))[0] == 0xff)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user