Compare commits
282 Commits
jb-mr2-cts
...
jb-mr1.1-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8d06766c7 | ||
|
|
061246b600 | ||
|
|
d0f2a6014c | ||
|
|
0995a7b322 | ||
|
|
6fe4a58f84 | ||
|
|
4cf1395217 | ||
|
|
e8bd8c2ed9 | ||
|
|
284f788032 | ||
|
|
f8a66bb312 | ||
|
|
4c6b925bac | ||
|
|
8fa9081f48 | ||
|
|
368860124c | ||
|
|
2be511d405 | ||
|
|
84114c8dd5 | ||
|
|
40e7a87864 | ||
|
|
107cdd406b | ||
|
|
b7b36b819e | ||
|
|
e459bba398 | ||
|
|
2cf5a6f662 | ||
|
|
d14dc3b87f | ||
|
|
8c1b96681a | ||
|
|
eb1b07469f | ||
|
|
f63c28f033 | ||
|
|
6f4fed74cb | ||
|
|
9ad2a73ed6 | ||
|
|
0aa9b52efa | ||
|
|
f35e0c149f | ||
|
|
5cf87951ab | ||
|
|
026867c7dc | ||
|
|
aa754dca90 | ||
|
|
9562d38df1 | ||
|
|
d4e753fea9 | ||
|
|
f152e386fc | ||
|
|
da4a3e6515 | ||
|
|
67750c8515 | ||
|
|
b95cf0d23a | ||
|
|
59ed029b28 | ||
|
|
ce4783ce76 | ||
|
|
3db1f359e9 | ||
|
|
ee178bfb79 | ||
|
|
8a363692be | ||
|
|
0dff43cab4 | ||
|
|
d30877ae28 | ||
|
|
6b1dd1797e | ||
|
|
b7f4923752 | ||
|
|
6184c1feaa | ||
|
|
9d476716c2 | ||
|
|
06040fd75c | ||
|
|
4fc8a0c116 | ||
|
|
c2cd33efc4 | ||
|
|
ff145277da | ||
|
|
5149de09ad | ||
|
|
e31c45c9fa | ||
|
|
3a040d8379 | ||
|
|
6b33f31b09 | ||
|
|
bfc6a59556 | ||
|
|
e63ea6aca7 | ||
|
|
e42e51d563 | ||
|
|
84983592ad | ||
|
|
e91f71783b | ||
|
|
de2781d906 | ||
|
|
f936ef1a9f | ||
|
|
d7b0d6e1e1 | ||
|
|
ebc8ce1de6 | ||
|
|
2753e12af5 | ||
|
|
87b4286f09 | ||
|
|
b8e435c1d5 | ||
|
|
feec97a7c7 | ||
|
|
74f0833df6 | ||
|
|
1ba3a2c269 | ||
|
|
ce7c404dc7 | ||
|
|
7c14d67bc1 | ||
|
|
413eef716f | ||
|
|
b61103dff4 | ||
|
|
a6cde39276 | ||
|
|
227b47a461 | ||
|
|
ca43d73d23 | ||
|
|
394df35e64 | ||
|
|
5bcf39842e | ||
|
|
78a7bf998d | ||
|
|
c8ae8bd941 | ||
|
|
fbec57d46c | ||
|
|
5e9a086145 | ||
|
|
1ec20a086c | ||
|
|
b116bf7628 | ||
|
|
995f17e6a9 | ||
|
|
d278b828fe | ||
|
|
c76550b337 | ||
|
|
64a4f6adf7 | ||
|
|
d206b560e7 | ||
|
|
7d624e9aff | ||
|
|
c45087bffa | ||
|
|
bfacb603e4 | ||
|
|
621b19dddb | ||
|
|
1642edb520 | ||
|
|
836dbf65e4 | ||
|
|
1d36ee1a6e | ||
|
|
1540f601be | ||
|
|
996cdc4b1a | ||
|
|
f7511e3bc9 | ||
|
|
cb215a7e9e | ||
|
|
0ea1d5c0ae | ||
|
|
c6eb985454 | ||
|
|
53ddcc9070 | ||
|
|
c9084427aa | ||
|
|
6819773103 | ||
|
|
17fc25d20f | ||
|
|
0ce28d20ea | ||
|
|
8bafa7452e | ||
|
|
4eed65090b | ||
|
|
02ca0e3142 | ||
|
|
3225f49848 | ||
|
|
3cd4cac2ce | ||
|
|
dc5d3426d8 | ||
|
|
c6ff844d75 | ||
|
|
c656d732c7 | ||
|
|
a33dc57c7c | ||
|
|
0846109c96 | ||
|
|
dd0880fec3 | ||
|
|
6807af773f | ||
|
|
02002443d4 | ||
|
|
e2fb05b45b | ||
|
|
7e5a8cc523 | ||
|
|
7d06813d93 | ||
|
|
a641c18f0c | ||
|
|
0005b3544b | ||
|
|
7d90cfa6b5 | ||
|
|
16d1af167f | ||
|
|
b24c0637d0 | ||
|
|
977a33137d | ||
|
|
b27e200ad6 | ||
|
|
5cf32de7a0 | ||
|
|
5995bf880e | ||
|
|
b6e340080a | ||
|
|
657d0da751 | ||
|
|
18bc975bfe | ||
|
|
560e9f7e7a | ||
|
|
7c89506e3a | ||
|
|
c843a3e7b2 | ||
|
|
4eeec44e29 | ||
|
|
c843d7667a | ||
|
|
0f020d18b1 | ||
|
|
92e841d0aa | ||
|
|
78419467a2 | ||
|
|
6a44d2271f | ||
|
|
2815b1dd45 | ||
|
|
55189a0fbd | ||
|
|
677ee56477 | ||
|
|
f1867d47cb | ||
|
|
9248d3a58c | ||
|
|
55c5ec64bd | ||
|
|
d8627af159 | ||
|
|
944ea1a320 | ||
|
|
61e699a133 | ||
|
|
5cde15eb17 | ||
|
|
2c157aec9b | ||
|
|
b6e880200d | ||
|
|
fd0325bd98 | ||
|
|
fc104f899d | ||
|
|
7e6ce1a3c5 | ||
|
|
8252b8e4b7 | ||
|
|
2fbc9dda34 | ||
|
|
157c42997b | ||
|
|
06708df6fb | ||
|
|
9647f797d5 | ||
|
|
885f3b9cad | ||
|
|
e7dffe150b | ||
|
|
b7b4f5b838 | ||
|
|
156ccf42ff | ||
|
|
18af450393 | ||
|
|
36fa67bcdd | ||
|
|
c5bfb62433 | ||
|
|
8d36050ac2 | ||
|
|
328223230b | ||
|
|
94d0daa2dd | ||
|
|
4c001859fe | ||
|
|
a24e81efd3 | ||
|
|
13476deec4 | ||
|
|
0671393072 | ||
|
|
6bec5b792a | ||
|
|
404d491eb6 | ||
|
|
a123b5d319 | ||
|
|
8539961ff2 | ||
|
|
cf870199d5 | ||
|
|
0a490665a3 | ||
|
|
72f59c84fd | ||
|
|
8cc145edf4 | ||
|
|
d515f46888 | ||
|
|
4fe461b3a6 | ||
|
|
8d79fd1c94 | ||
|
|
e4c4ada580 | ||
|
|
2317275f85 | ||
|
|
615684c256 | ||
|
|
25a87f7641 | ||
|
|
f5f29de6ae | ||
|
|
82dcc7910d | ||
|
|
2e317075b0 | ||
|
|
22bda4bd67 | ||
|
|
5217fb528c | ||
|
|
d35106fd55 | ||
|
|
6f502bc743 | ||
|
|
d04c183979 | ||
|
|
349ef893e8 | ||
|
|
b2e1abda05 | ||
|
|
5b7b2809a2 | ||
|
|
b0a2fc35d6 | ||
|
|
f0f4fa3fb1 | ||
|
|
4200e6203a | ||
|
|
e1c58ab5bb | ||
|
|
5c4340b2ab | ||
|
|
7cb82791ca | ||
|
|
23b9fd2c1d | ||
|
|
d8a9cccb4d | ||
|
|
bb0b09cad6 | ||
|
|
98f7659d7e | ||
|
|
8147d3c284 | ||
|
|
ff220f7003 | ||
|
|
63dd03cced | ||
|
|
b9256adab3 | ||
|
|
52171b9bdc | ||
|
|
d541ba1719 | ||
|
|
1c462b7a04 | ||
|
|
b01f7afd5f | ||
|
|
532d6f09b1 | ||
|
|
e4ac8feb58 | ||
|
|
4f40e511b0 | ||
|
|
5e3b502b6b | ||
|
|
277226bf43 | ||
|
|
8c00c91aa0 | ||
|
|
80541922e3 | ||
|
|
bee0ab16e4 | ||
|
|
3b2e6bc9ac | ||
|
|
c46871302e | ||
|
|
9020fd503c | ||
|
|
b94b2851d7 | ||
|
|
78d6d9888c | ||
|
|
382a775378 | ||
|
|
1aae9bd170 | ||
|
|
c6dc62f09c | ||
|
|
e66ad7809e | ||
|
|
f7153fd13f | ||
|
|
9ff1ffd805 | ||
|
|
e7aaad8b83 | ||
|
|
5f28fde8ae | ||
|
|
8d3e91d4f8 | ||
|
|
e8f46e8edd | ||
|
|
87efcd2e63 | ||
|
|
85aeb49144 | ||
|
|
c705daa0a2 | ||
|
|
21da42ea91 | ||
|
|
2c60c18c50 | ||
|
|
bda2fb5efa | ||
|
|
676e66db25 | ||
|
|
2379088a90 | ||
|
|
70e0bd3a44 | ||
|
|
f8dff7d449 | ||
|
|
8c181aa8fe | ||
|
|
516a897053 | ||
|
|
b3c8c4d865 | ||
|
|
796cbe249b | ||
|
|
ea489745dc | ||
|
|
0b25f633a2 | ||
|
|
ed36d95fac | ||
|
|
6b05c8e280 | ||
|
|
b632857a50 | ||
|
|
4ca685e36e | ||
|
|
fc76c7d394 | ||
|
|
bf0d1ad72b | ||
|
|
68fd78efa0 | ||
|
|
185ce72d00 | ||
|
|
240fb8623b | ||
|
|
0d787c1fa1 | ||
|
|
014c75c78b | ||
|
|
8baa929d5d | ||
|
|
14c840df90 | ||
|
|
a51916b58b | ||
|
|
162b4411fc | ||
|
|
4ace92c62a | ||
|
|
7a29f404e1 | ||
|
|
378b0e1ea2 | ||
|
|
6bb17dfad3 | ||
|
|
cfa089df23 |
199
libc/Android.mk
199
libc/Android.mk
@@ -6,67 +6,33 @@ include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
|
||||
# =========================================================
|
||||
libc_common_src_files := \
|
||||
$(syscall_src) \
|
||||
unistd/abort.c \
|
||||
unistd/alarm.c \
|
||||
unistd/exec.c \
|
||||
unistd/fnmatch.c \
|
||||
unistd/getopt_long.c \
|
||||
unistd/syslog.c \
|
||||
unistd/system.c \
|
||||
unistd/time.c \
|
||||
stdio/asprintf.c \
|
||||
stdio/clrerr.c \
|
||||
stdio/fclose.c \
|
||||
stdio/fdopen.c \
|
||||
stdio/feof.c \
|
||||
stdio/ferror.c \
|
||||
stdio/fflush.c \
|
||||
stdio/fgetc.c \
|
||||
stdio/fgetln.c \
|
||||
stdio/fgetpos.c \
|
||||
stdio/fgets.c \
|
||||
stdio/fileno.c \
|
||||
stdio/findfp.c \
|
||||
stdio/flags.c \
|
||||
stdio/fopen.c \
|
||||
stdio/fprintf.c \
|
||||
stdio/fpurge.c \
|
||||
stdio/fputc.c \
|
||||
stdio/fputs.c \
|
||||
stdio/fread.c \
|
||||
stdio/freopen.c \
|
||||
stdio/fscanf.c \
|
||||
stdio/fseek.c \
|
||||
stdio/fsetpos.c \
|
||||
stdio/ftell.c \
|
||||
stdio/funopen.c \
|
||||
stdio/fvwrite.c \
|
||||
stdio/fwalk.c \
|
||||
stdio/fwrite.c \
|
||||
stdio/getc.c \
|
||||
stdio/getchar.c \
|
||||
stdio/gets.c \
|
||||
stdio/makebuf.c \
|
||||
stdio/mktemp.c \
|
||||
stdio/printf.c \
|
||||
stdio/putc.c \
|
||||
stdio/putchar.c \
|
||||
stdio/puts.c \
|
||||
stdio/putw.c \
|
||||
stdio/refill.c \
|
||||
stdio/remove.c \
|
||||
stdio/rewind.c \
|
||||
stdio/rget.c \
|
||||
stdio/scanf.c \
|
||||
stdio/setbuf.c \
|
||||
stdio/setbuffer.c \
|
||||
stdio/setvbuf.c \
|
||||
stdio/snprintf.c\
|
||||
stdio/sprintf.c \
|
||||
stdio/sscanf.c \
|
||||
stdio/stdio.c \
|
||||
stdio/tempnam.c \
|
||||
stdio/tmpnam.c \
|
||||
stdio/ungetc.c \
|
||||
stdio/vasprintf.c \
|
||||
stdio/vfprintf.c \
|
||||
@@ -77,13 +43,11 @@ libc_common_src_files := \
|
||||
stdio/vscanf.c \
|
||||
stdio/vsscanf.c \
|
||||
stdio/wbuf.c \
|
||||
stdio/wsetup.c \
|
||||
stdlib/atexit.c \
|
||||
stdlib/ctype_.c \
|
||||
stdlib/exit.c \
|
||||
stdlib/getenv.c \
|
||||
stdlib/putenv.c \
|
||||
stdlib/qsort.c \
|
||||
stdlib/setenv.c \
|
||||
stdlib/strtod.c \
|
||||
stdlib/strtoimax.c \
|
||||
@@ -94,29 +58,17 @@ libc_common_src_files := \
|
||||
stdlib/strtoumax.c \
|
||||
stdlib/tolower_.c \
|
||||
stdlib/toupper_.c \
|
||||
string/index.c \
|
||||
string/strcasecmp.c \
|
||||
string/strcat.c \
|
||||
string/strchr.c \
|
||||
string/strcspn.c \
|
||||
string/strdup.c \
|
||||
string/strlcat.c \
|
||||
string/strlcpy.c \
|
||||
string/strncat.c \
|
||||
string/strncpy.c \
|
||||
string/strpbrk.c \
|
||||
string/strrchr.c \
|
||||
string/__strrchr_chk.c \
|
||||
string/strsep.c \
|
||||
string/strspn.c \
|
||||
string/strstr.c \
|
||||
string/strtok.c \
|
||||
wchar/wcswidth.c \
|
||||
wchar/wcsxfrm.c \
|
||||
tzcode/asctime.c \
|
||||
tzcode/difftime.c \
|
||||
tzcode/localtime.c \
|
||||
tzcode/strftime.c \
|
||||
tzcode/strptime.c \
|
||||
bionic/arc4random.c \
|
||||
bionic/atoi.c \
|
||||
bionic/atol.c \
|
||||
@@ -151,11 +103,8 @@ libc_common_src_files := \
|
||||
bionic/ldexp.c \
|
||||
bionic/lseek64.c \
|
||||
bionic/md5.c \
|
||||
bionic/memchr.c \
|
||||
bionic/memmem.c \
|
||||
bionic/memrchr.c \
|
||||
bionic/memswap.c \
|
||||
bionic/mmap.c \
|
||||
bionic/openat.c \
|
||||
bionic/open.c \
|
||||
bionic/pathconf.c \
|
||||
@@ -170,7 +119,6 @@ libc_common_src_files := \
|
||||
bionic/recv.c \
|
||||
bionic/sched_cpualloc.c \
|
||||
bionic/sched_cpucount.c \
|
||||
bionic/sched_getaffinity.c \
|
||||
bionic/sched_getcpu.c \
|
||||
bionic/semaphore.c \
|
||||
bionic/send.c \
|
||||
@@ -190,11 +138,11 @@ libc_common_src_files := \
|
||||
bionic/sleep.c \
|
||||
bionic/statfs.c \
|
||||
bionic/strndup.c \
|
||||
bionic/strnlen.c \
|
||||
bionic/strntoimax.c \
|
||||
bionic/strntoumax.c \
|
||||
bionic/strtotimeval.c \
|
||||
bionic/system_properties.c \
|
||||
bionic/system_properties_compat.c \
|
||||
bionic/tcgetpgrp.c \
|
||||
bionic/tcsetpgrp.c \
|
||||
bionic/thread_atexit.c \
|
||||
@@ -234,11 +182,13 @@ libc_common_src_files := \
|
||||
netbsd/nameser/ns_samedomain.c \
|
||||
|
||||
libc_bionic_src_files := \
|
||||
bionic/abort.cpp \
|
||||
bionic/assert.cpp \
|
||||
bionic/brk.cpp \
|
||||
bionic/dirent.cpp \
|
||||
bionic/__errno.c \
|
||||
bionic/eventfd.cpp \
|
||||
bionic/eventfd_read.cpp \
|
||||
bionic/eventfd_write.cpp \
|
||||
bionic/__fgets_chk.cpp \
|
||||
bionic/getauxval.cpp \
|
||||
bionic/getcwd.cpp \
|
||||
@@ -248,6 +198,7 @@ libc_bionic_src_files := \
|
||||
bionic/__memcpy_chk.cpp \
|
||||
bionic/__memmove_chk.cpp \
|
||||
bionic/__memset_chk.cpp \
|
||||
bionic/mmap.cpp \
|
||||
bionic/pthread_attr.cpp \
|
||||
bionic/pthread_detach.cpp \
|
||||
bionic/pthread_equal.cpp \
|
||||
@@ -263,11 +214,14 @@ libc_bionic_src_files := \
|
||||
bionic/raise.cpp \
|
||||
bionic/sbrk.cpp \
|
||||
bionic/scandir.cpp \
|
||||
bionic/sched_getaffinity.cpp \
|
||||
bionic/__set_errno.cpp \
|
||||
bionic/setlocale.cpp \
|
||||
bionic/signalfd.cpp \
|
||||
bionic/sigwait.cpp \
|
||||
bionic/statvfs.cpp \
|
||||
bionic/__strcat_chk.cpp \
|
||||
bionic/__strchr_chk.cpp \
|
||||
bionic/__strcpy_chk.cpp \
|
||||
bionic/strerror.cpp \
|
||||
bionic/strerror_r.cpp \
|
||||
@@ -287,32 +241,67 @@ libc_bionic_src_files := \
|
||||
bionic/wait.cpp \
|
||||
bionic/wchar.cpp \
|
||||
|
||||
libc_tzcode_src_files := \
|
||||
tzcode/asctime.c \
|
||||
tzcode/difftime.c \
|
||||
tzcode/localtime.c \
|
||||
tzcode/strftime.c \
|
||||
tzcode/strptime.c \
|
||||
|
||||
libc_upstream_freebsd_src_files := \
|
||||
upstream-freebsd/lib/libc/stdio/clrerr.c \
|
||||
upstream-freebsd/lib/libc/stdio/fclose.c \
|
||||
upstream-freebsd/lib/libc/stdio/fdopen.c \
|
||||
upstream-freebsd/lib/libc/stdio/feof.c \
|
||||
upstream-freebsd/lib/libc/stdio/ferror.c \
|
||||
upstream-freebsd/lib/libc/stdio/fgetln.c \
|
||||
upstream-freebsd/lib/libc/stdio/fgetpos.c \
|
||||
upstream-freebsd/lib/libc/stdio/fgets.c \
|
||||
upstream-freebsd/lib/libc/stdio/fileno.c \
|
||||
upstream-freebsd/lib/libc/stdio/flags.c \
|
||||
upstream-freebsd/lib/libc/stdio/fopen.c \
|
||||
upstream-freebsd/lib/libc/stdio/fpurge.c \
|
||||
upstream-freebsd/lib/libc/stdio/fputs.c \
|
||||
upstream-freebsd/lib/libc/stdio/fsetpos.c \
|
||||
upstream-freebsd/lib/libc/stdio/funopen.c \
|
||||
upstream-freebsd/lib/libc/stdio/fwalk.c \
|
||||
upstream-freebsd/lib/libc/stdio/fwrite.c \
|
||||
upstream-freebsd/lib/libc/stdio/getc.c \
|
||||
upstream-freebsd/lib/libc/stdio/getchar.c \
|
||||
upstream-freebsd/lib/libc/stdio/makebuf.c \
|
||||
upstream-freebsd/lib/libc/stdio/mktemp.c \
|
||||
upstream-freebsd/lib/libc/stdio/putc.c \
|
||||
upstream-freebsd/lib/libc/stdio/putchar.c \
|
||||
upstream-freebsd/lib/libc/stdio/puts.c \
|
||||
upstream-freebsd/lib/libc/stdio/putw.c \
|
||||
upstream-freebsd/lib/libc/stdio/remove.c \
|
||||
upstream-freebsd/lib/libc/stdio/rget.c \
|
||||
upstream-freebsd/lib/libc/stdio/setbuf.c \
|
||||
upstream-freebsd/lib/libc/stdio/setbuffer.c \
|
||||
upstream-freebsd/lib/libc/stdio/setvbuf.c \
|
||||
upstream-freebsd/lib/libc/stdio/tempnam.c \
|
||||
upstream-freebsd/lib/libc/stdio/tmpnam.c \
|
||||
upstream-freebsd/lib/libc/stdio/wsetup.c \
|
||||
upstream-freebsd/lib/libc/stdlib/getopt_long.c \
|
||||
upstream-freebsd/lib/libc/stdlib/qsort.c \
|
||||
upstream-freebsd/lib/libc/stdlib/realpath.c \
|
||||
upstream-freebsd/lib/libc/string/wcpcpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcpncpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcscasecmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcscat.c \
|
||||
upstream-freebsd/lib/libc/string/wcschr.c \
|
||||
upstream-freebsd/lib/libc/string/wcscmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcscpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcscspn.c \
|
||||
upstream-freebsd/lib/libc/string/wcsdup.c \
|
||||
upstream-freebsd/lib/libc/string/wcslcat.c \
|
||||
upstream-freebsd/lib/libc/string/wcslcpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcslen.c \
|
||||
upstream-freebsd/lib/libc/string/wcsncasecmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcsncat.c \
|
||||
upstream-freebsd/lib/libc/string/wcsncmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcsncpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcsnlen.c \
|
||||
upstream-freebsd/lib/libc/string/wcspbrk.c \
|
||||
upstream-freebsd/lib/libc/string/wcsrchr.c \
|
||||
upstream-freebsd/lib/libc/string/wcsspn.c \
|
||||
upstream-freebsd/lib/libc/string/wcsstr.c \
|
||||
upstream-freebsd/lib/libc/string/wcstok.c \
|
||||
upstream-freebsd/lib/libc/string/wmemchr.c \
|
||||
upstream-freebsd/lib/libc/string/wmemcmp.c \
|
||||
upstream-freebsd/lib/libc/string/wmemcpy.c \
|
||||
upstream-freebsd/lib/libc/string/wmemmove.c \
|
||||
upstream-freebsd/lib/libc/string/wmemset.c \
|
||||
@@ -368,6 +357,24 @@ libc_common_src_files += \
|
||||
bionic/memmove.c.arm \
|
||||
string/bcopy.c \
|
||||
string/strncmp.c \
|
||||
string/strcat.c \
|
||||
string/strncat.c \
|
||||
string/strncpy.c \
|
||||
bionic/strchr.cpp \
|
||||
string/strrchr.c \
|
||||
bionic/memchr.c \
|
||||
bionic/memrchr.c \
|
||||
string/index.c \
|
||||
bionic/strnlen.c \
|
||||
string/strlcat.c \
|
||||
string/strlcpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcschr.c \
|
||||
upstream-freebsd/lib/libc/string/wcsrchr.c \
|
||||
upstream-freebsd/lib/libc/string/wcscmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcscpy.c \
|
||||
upstream-freebsd/lib/libc/string/wmemcmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcslen.c \
|
||||
upstream-freebsd/lib/libc/string/wcscat.c
|
||||
|
||||
# These files need to be arm so that gdbserver
|
||||
# can set breakpoints in them without messing
|
||||
@@ -391,7 +398,6 @@ libc_common_src_files += \
|
||||
bionic/pthread-rwlocks.c \
|
||||
bionic/pthread-timers.c \
|
||||
bionic/ptrace.c \
|
||||
string/strcpy.c \
|
||||
|
||||
libc_static_common_src_files += \
|
||||
bionic/pthread.c \
|
||||
@@ -406,7 +412,25 @@ libc_common_src_files += \
|
||||
string/bcopy.c \
|
||||
string/strcmp.c \
|
||||
string/strcpy.c \
|
||||
string/strncmp.c
|
||||
string/strncmp.c \
|
||||
string/strcat.c \
|
||||
string/strncat.c \
|
||||
string/strncpy.c \
|
||||
bionic/strchr.cpp \
|
||||
string/strrchr.c \
|
||||
bionic/memchr.c \
|
||||
bionic/memrchr.c \
|
||||
string/index.c \
|
||||
bionic/strnlen.c \
|
||||
string/strlcat.c \
|
||||
string/strlcpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcschr.c \
|
||||
upstream-freebsd/lib/libc/string/wcsrchr.c \
|
||||
upstream-freebsd/lib/libc/string/wcscmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcscpy.c \
|
||||
upstream-freebsd/lib/libc/string/wmemcmp.c \
|
||||
upstream-freebsd/lib/libc/string/wcslen.c \
|
||||
upstream-freebsd/lib/libc/string/wcscat.c
|
||||
|
||||
libc_common_src_files += \
|
||||
bionic/pthread-atfork.c \
|
||||
@@ -468,14 +492,6 @@ libc_common_cflags := \
|
||||
-DLOG_ON_HEAP_ERROR \
|
||||
-Wall -Wextra
|
||||
|
||||
# these macro definitions are required to implement the
|
||||
# 'timezone' and 'daylight' global variables, as well as
|
||||
# properly update the 'tm_gmtoff' field in 'struct tm'.
|
||||
#
|
||||
libc_common_cflags += \
|
||||
-DTM_GMTOFF=tm_gmtoff \
|
||||
-DUSG_COMPAT=1
|
||||
|
||||
ifeq ($(strip $(DEBUG_BIONIC_LIBC)),true)
|
||||
libc_common_cflags += -DDEBUG
|
||||
endif
|
||||
@@ -553,23 +569,17 @@ libc_crt_target_cflags += \
|
||||
# static C++ destructors are properly called on dlclose().
|
||||
#
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
libc_crtbegin_extension := c
|
||||
libc_crt_target_so_cflags :=
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH),mips)
|
||||
libc_crtbegin_extension := S
|
||||
libc_crt_target_so_cflags := -fPIC
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
libc_crtbegin_extension := c
|
||||
libc_crt_target_so_cflags := -fPIC
|
||||
endif
|
||||
ifeq ($(libc_crtbegin_extension),)
|
||||
$(error $(TARGET_ARCH) not supported)
|
||||
endif
|
||||
libc_crt_target_so_cflags += $(libc_crt_target_cflags)
|
||||
libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.$(libc_crtbegin_extension)
|
||||
libc_crt_target_crtbegin_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.$(libc_crtbegin_extension)
|
||||
libc_crt_target_crtbegin_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin.c
|
||||
libc_crt_target_crtbegin_so_file := $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.c
|
||||
|
||||
# See the comment in crtbrand.c for the reason why we need to generate
|
||||
# crtbrand.s before generating crtbrand.o.
|
||||
@@ -685,6 +695,28 @@ LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
|
||||
# ========================================================
|
||||
# libc_tzcode.a - upstream 'tzcode' code
|
||||
# ========================================================
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := $(libc_tzcode_src_files)
|
||||
LOCAL_CFLAGS := \
|
||||
$(libc_common_cflags) \
|
||||
-std=gnu99 \
|
||||
-DSTD_INSPIRED=1 \
|
||||
-DTZDIR=\"/system/usr/share/zoneinfo\" \
|
||||
-DTM_GMTOFF=tm_gmtoff \
|
||||
-DUSG_COMPAT=1
|
||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||
LOCAL_MODULE := libc_tzcode
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
|
||||
# ========================================================
|
||||
# libc_freebsd.a - upstream FreeBSD C library code
|
||||
# ========================================================
|
||||
@@ -760,7 +792,12 @@ LOCAL_CFLAGS := $(libc_common_cflags) \
|
||||
LOCAL_C_INCLUDES := $(libc_common_c_includes)
|
||||
LOCAL_MODULE := libc_common
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := libbionic_ssp libc_bionic libc_freebsd libc_netbsd
|
||||
LOCAL_WHOLE_STATIC_LIBRARIES := \
|
||||
libbionic_ssp \
|
||||
libc_bionic \
|
||||
libc_freebsd \
|
||||
libc_netbsd \
|
||||
libc_tzcode
|
||||
LOCAL_SYSTEM_SHARED_LIBRARIES :=
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
163
libc/NOTICE
163
libc/NOTICE
@@ -1673,38 +1673,6 @@ SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1990, 1993
|
||||
The Regents of the University of California. All rights reserved.
|
||||
|
||||
This code is derived from software contributed to Berkeley by
|
||||
Chris Torek.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. 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.
|
||||
4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 1990, 1993
|
||||
The Regents of the University of California. All rights reserved.
|
||||
|
||||
@@ -2852,7 +2820,7 @@ are met:
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notices, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
4. Neither the name of the University nor the names of its contributors
|
||||
3. Neither the name of the University nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
@@ -3092,13 +3060,6 @@ are met:
|
||||
2. 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.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
This product includes software developed by the NetBSD
|
||||
Foundation, Inc. and its contributors.
|
||||
4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
@@ -3916,6 +3877,36 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010, 2011 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.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
@@ -3946,6 +3937,36 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2011 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.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2011 The Android Open Source Project
|
||||
Copyright (c) 2008 ARM Ltd
|
||||
All rights reserved.
|
||||
@@ -3975,6 +3996,36 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2011, VMware, Inc.
|
||||
All rights reserved.
|
||||
|
||||
@@ -4058,6 +4109,38 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2013, Linaro Limited
|
||||
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 Linaro Limited 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
|
||||
HOLDER 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.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
Copyright (c)1999 Citrus Project,
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
# this file is used to list all the syscalls that will be supported by
|
||||
# the Bionic C library. It is used to automatically generate the syscall
|
||||
# stubs, the list of syscall constants (__NR_xxxx) and the content of <linux/_unistd.h>
|
||||
# This file is used to automatically generate bionic's the system calls stubs.
|
||||
#
|
||||
# each non comment line has the following format:
|
||||
# Each non comment line has the following format:
|
||||
#
|
||||
# return_type func_name[:syscall_name[:call_id]]([parameter_list]) (syscall_number|"stub")
|
||||
# return_type func_name[:syscall_name[:call_id]]([parameter_list]) (1|-1|"stub")
|
||||
#
|
||||
# note that:
|
||||
# - syscall_name correspond to the name of the syscall, which may differ from
|
||||
# Note that:
|
||||
# - syscall_name corresponds to the name of the syscall, which may differ from
|
||||
# the exported function name (example: the exit syscall is implemented by the _exit()
|
||||
# function, which is not the same as the standard C exit() function which calls it)
|
||||
# The call_id parameter, given that func_name and syscall_name have
|
||||
@@ -18,302 +16,311 @@
|
||||
# - each parameter type is assumed to be stored on 32 bits, there is no plan to support
|
||||
# 64-bit architectures at the moment
|
||||
#
|
||||
# - it there is "stub" instead of a syscall number, the tool will not generate any
|
||||
# assembler template for the syscall; it's up to the bionic implementation to provide
|
||||
# a relevant C stub
|
||||
# - the final field can be "1", meaning: generate a stub for each architecture,
|
||||
# taking the constants from the kernel header files.
|
||||
#
|
||||
# - additionally, if the syscall number is different amoung ARM, and x86, MIPS use:
|
||||
# return_type funcname[:syscall_name](parameters) arm_number,x86_number,mips_number
|
||||
# - the final field can be "stub" meaning: do not generate any stubs ---
|
||||
# in this case, a hand-written custom stub must be provided.
|
||||
# TODO: replace this with something like "custom" or "none", or remove
|
||||
# it entirely.
|
||||
#
|
||||
# - the final field can be a three-element list of 1s and -1 meaning:
|
||||
# this system call is only available on some of the architectures (1),
|
||||
# and no stub should be generated for those architectures marked with -1.
|
||||
# the order is arm,x86,mips.
|
||||
# TODO: replace this with something more readable like "-arm,-mips" (meaning x86 only).
|
||||
#
|
||||
# This file is processed by a python script named gensyscalls.py.
|
||||
#
|
||||
# The checksyscalls.py script can check that the syscall numbers here are
|
||||
# correct by comparing them to the numbers in the Linux kernel headers.
|
||||
#
|
||||
|
||||
# process management
|
||||
void _exit:exit_group (int) 248,252,246
|
||||
void _exit:exit_group (int) 1
|
||||
void _exit_thread:exit (int) 1
|
||||
pid_t __fork:fork (void) 2
|
||||
pid_t _waitpid:waitpid (pid_t, int*, int, struct rusage*) -1,7,7
|
||||
int __waitid:waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284,278
|
||||
pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage) 114
|
||||
pid_t __fork:fork (void) 1
|
||||
pid_t _waitpid:waitpid (pid_t, int*, int, struct rusage*) -1,1,1
|
||||
int __waitid:waitid(int, pid_t, struct siginfo_t*, int,void*) 1
|
||||
pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage) 1
|
||||
|
||||
# NOTE: this system call is never called directly, but we list it there
|
||||
# to have __NR_clone properly defined.
|
||||
#
|
||||
pid_t __sys_clone:clone (int, void*, int*, void*, int*) 120
|
||||
pid_t __sys_clone:clone (int, void*, int*, void*, int*) 1
|
||||
|
||||
int execve (const char*, char* const*, char* const*) 11
|
||||
int execve (const char*, char* const*, char* const*) 1
|
||||
|
||||
int __setuid:setuid32 (uid_t) 213,213,-1
|
||||
int __setuid:setuid (uid_t) -1,-1,23
|
||||
uid_t getuid:getuid32 () 199,199,-1
|
||||
uid_t getuid:getuid () -1,-1,24
|
||||
gid_t getgid:getgid32 () 200,200,-1
|
||||
gid_t getgid:getgid () -1,-1,47
|
||||
uid_t geteuid:geteuid32 () 201,201,-1
|
||||
uid_t geteuid:geteuid () -1,-1,49
|
||||
gid_t getegid:getegid32 () 202,202,-1
|
||||
gid_t getegid:getegid () -1,-1,50
|
||||
uid_t getresuid:getresuid32 (uid_t *ruid, uid_t *euid, uid_t *suid) 209,209,-1
|
||||
uid_t getresuid:getresuid (uid_t *ruid, uid_t *euid, uid_t *suid) -1,-1,186
|
||||
gid_t getresgid:getresgid32 (gid_t *rgid, gid_t *egid, gid_t *sgid) 211,211,-1
|
||||
gid_t getresgid:getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid) -1,-1,191
|
||||
pid_t gettid() 224,224,222
|
||||
ssize_t readahead(int, off64_t, size_t) 225,225,223
|
||||
int getgroups:getgroups32(int, gid_t *) 205,205,-1
|
||||
int getgroups:getgroups(int, gid_t *) -1,-1,80
|
||||
pid_t getpgid(pid_t) 132
|
||||
pid_t getppid() 64
|
||||
pid_t getsid(pid_t) 147,147,151
|
||||
pid_t setsid() 66
|
||||
int setgid:setgid32(gid_t) 214,214,-1
|
||||
int setgid:setgid(gid_t) -1,-1,46
|
||||
int __setuid:setuid32 (uid_t) 1,1,-1
|
||||
int __setuid:setuid (uid_t) -1,-1,1
|
||||
uid_t getuid:getuid32 () 1,1,-1
|
||||
uid_t getuid:getuid () -1,-1,1
|
||||
gid_t getgid:getgid32 () 1,1,-1
|
||||
gid_t getgid:getgid () -1,-1,1
|
||||
uid_t geteuid:geteuid32 () 1,1,-1
|
||||
uid_t geteuid:geteuid () -1,-1,1
|
||||
gid_t getegid:getegid32 () 1,1,-1
|
||||
gid_t getegid:getegid () -1,-1,1
|
||||
uid_t getresuid:getresuid32 (uid_t *ruid, uid_t *euid, uid_t *suid) 1,1,-1
|
||||
uid_t getresuid:getresuid (uid_t *ruid, uid_t *euid, uid_t *suid) -1,-1,1
|
||||
gid_t getresgid:getresgid32 (gid_t *rgid, gid_t *egid, gid_t *sgid) 1,1,-1
|
||||
gid_t getresgid:getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid) -1,-1,1
|
||||
pid_t gettid() 1
|
||||
ssize_t readahead(int, off64_t, size_t) 1
|
||||
int getgroups:getgroups32(int, gid_t *) 1,1,-1
|
||||
int getgroups:getgroups(int, gid_t *) -1,-1,1
|
||||
pid_t getpgid(pid_t) 1
|
||||
pid_t getppid() 1
|
||||
pid_t getsid(pid_t) 1
|
||||
pid_t setsid() 1
|
||||
int setgid:setgid32(gid_t) 1,1,-1
|
||||
int setgid:setgid(gid_t) -1,-1,1
|
||||
int seteuid:seteuid32(uid_t) stub
|
||||
int __setreuid:setreuid32(uid_t, uid_t) 203,203,-1
|
||||
int __setreuid:setreuid(uid_t, uid_t) -1,-1,70
|
||||
int __setresuid:setresuid32(uid_t, uid_t, uid_t) 208,208,-1
|
||||
int __setresuid:setresuid(uid_t, uid_t, uid_t) -1,-1,185
|
||||
int setresgid:setresgid32(gid_t, gid_t, gid_t) 210,210,-1
|
||||
int setresgid:setresgid(gid_t, gid_t, gid_t) -1,-1,190
|
||||
void* __brk:brk(void*) 45
|
||||
int __setreuid:setreuid32(uid_t, uid_t) 1,1,-1
|
||||
int __setreuid:setreuid(uid_t, uid_t) -1,-1,1
|
||||
int __setresuid:setresuid32(uid_t, uid_t, uid_t) 1,1,-1
|
||||
int __setresuid:setresuid(uid_t, uid_t, uid_t) -1,-1,1
|
||||
int setresgid:setresgid32(gid_t, gid_t, gid_t) 1,1,-1
|
||||
int setresgid:setresgid(gid_t, gid_t, gid_t) -1,-1,1
|
||||
void* __brk:brk(void*) 1
|
||||
# see comments in arch-arm/bionic/kill.S to understand why we don't generate an ARM stub for kill/tkill
|
||||
int kill(pid_t, int) -1,37,37
|
||||
int tkill(pid_t tid, int sig) -1,238,236
|
||||
int tgkill(pid_t tgid, pid_t tid, int sig) -1,270,266
|
||||
int __ptrace:ptrace(int request, int pid, void* addr, void* data) 26
|
||||
int __set_thread_area:set_thread_area(void* user_desc) -1,243,283
|
||||
int __getpriority:getpriority(int, int) 96
|
||||
int setpriority(int, int, int) 97
|
||||
int setrlimit(int resource, const struct rlimit *rlp) 75
|
||||
int getrlimit:ugetrlimit(int resource, struct rlimit *rlp) 191,191,-1
|
||||
int getrlimit:getrlimit(int resource, struct rlimit *rlp) -1,-1,76
|
||||
int getrusage(int who, struct rusage* r_usage) 77
|
||||
int setgroups:setgroups32(int, const gid_t *) 206,206,-1
|
||||
int setgroups:setgroups(int, const gid_t *) -1,-1,81
|
||||
int kill(pid_t, int) -1,1,1
|
||||
int tkill(pid_t tid, int sig) -1,1,1
|
||||
int tgkill(pid_t tgid, pid_t tid, int sig) -1,1,1
|
||||
int __ptrace:ptrace(int request, int pid, void* addr, void* data) 1
|
||||
int __set_thread_area:set_thread_area(void* user_desc) -1,1,1
|
||||
int __getpriority:getpriority(int, int) 1
|
||||
int setpriority(int, int, int) 1
|
||||
int setrlimit(int resource, const struct rlimit *rlp) 1
|
||||
int getrlimit:ugetrlimit(int resource, struct rlimit *rlp) 1,1,-1
|
||||
int getrlimit:getrlimit(int resource, struct rlimit *rlp) -1,-1,1
|
||||
int getrusage(int who, struct rusage* r_usage) 1
|
||||
int setgroups:setgroups32(int, const gid_t *) 1,1,-1
|
||||
int setgroups:setgroups(int, const gid_t *) -1,-1,1
|
||||
pid_t getpgrp(void) stub
|
||||
int setpgid(pid_t, pid_t) 57
|
||||
pid_t vfork(void) 190,-1,-1
|
||||
int setregid:setregid32(gid_t, gid_t) 204,204,-1
|
||||
int setregid:setregid(gid_t, gid_t) -1,-1,71
|
||||
int chroot(const char *) 61
|
||||
int setpgid(pid_t, pid_t) 1
|
||||
pid_t vfork(void) 1,-1,-1
|
||||
int setregid:setregid32(gid_t, gid_t) 1,1,-1
|
||||
int setregid:setregid(gid_t, gid_t) -1,-1,1
|
||||
int chroot(const char *) 1
|
||||
# IMPORTANT: Even though <sys/prctl.h> declares prctl(int,...), the syscall stub must take 6 arguments
|
||||
# to match the kernel implementation.
|
||||
int prctl(int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5) 172,172,192
|
||||
int capget(cap_user_header_t header, cap_user_data_t data) 184,184,204
|
||||
int capset(cap_user_header_t header, const cap_user_data_t data) 185,185,205
|
||||
int sigaltstack(const stack_t*, stack_t*) 186,186,206
|
||||
int acct(const char* filepath) 51
|
||||
int prctl(int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5) 1
|
||||
int capget(cap_user_header_t header, cap_user_data_t data) 1
|
||||
int capset(cap_user_header_t header, const cap_user_data_t data) 1
|
||||
int sigaltstack(const stack_t*, stack_t*) 1
|
||||
int acct(const char* filepath) 1
|
||||
|
||||
# file descriptors
|
||||
ssize_t read (int, void*, size_t) 3
|
||||
ssize_t write (int, const void*, size_t) 4
|
||||
ssize_t pread64 (int, void *, size_t, off64_t) 180,180,200
|
||||
ssize_t pwrite64 (int, void *, size_t, off64_t) 181,181,201
|
||||
int __open:open (const char*, int, mode_t) 5
|
||||
int __openat:openat (int, const char*, int, mode_t) 322,295,288
|
||||
int close (int) 6
|
||||
ssize_t read (int, void*, size_t) 1
|
||||
ssize_t write (int, const void*, size_t) 1
|
||||
ssize_t pread64 (int, void *, size_t, off64_t) 1
|
||||
ssize_t pwrite64 (int, void *, size_t, off64_t) 1
|
||||
int __open:open (const char*, int, mode_t) 1
|
||||
int __openat:openat (int, const char*, int, mode_t) 1
|
||||
int close (int) 1
|
||||
int creat(const char*, mode_t) stub
|
||||
off_t lseek(int, off_t, int) 19
|
||||
int __llseek:_llseek (int, unsigned long, unsigned long, loff_t*, int) 140
|
||||
pid_t getpid () 20
|
||||
off_t lseek(int, off_t, int) 1
|
||||
int __llseek:_llseek (int, unsigned long, unsigned long, loff_t*, int) 1
|
||||
pid_t getpid () 1
|
||||
void * mmap(void *, size_t, int, int, int, long) stub
|
||||
void * __mmap2:mmap2(void*, size_t, int, int, int, long) 192,192,210
|
||||
int munmap(void *, size_t) 91
|
||||
void * mremap(void *, size_t, size_t, unsigned long) 163,163,167
|
||||
int msync(const void *, size_t, int) 144
|
||||
int mprotect(const void *, size_t, int) 125
|
||||
int madvise(const void *, size_t, int) 220,219,218
|
||||
int mlock(const void *addr, size_t len) 150,150,154
|
||||
int munlock(const void *addr, size_t len) 151,151,155
|
||||
int mlockall(int flags) 152,152,156
|
||||
int munlockall() 153,153,157
|
||||
int mincore(void* start, size_t length, unsigned char* vec) 219,218,217
|
||||
int __ioctl:ioctl(int, int, void *) 54
|
||||
int readv(int, const struct iovec *, int) 145
|
||||
int writev(int, const struct iovec *, int) 146
|
||||
int __fcntl:fcntl(int, int, void*) 55
|
||||
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,328
|
||||
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 ftruncate64(int, off64_t) 194,194,212
|
||||
int getdents:getdents64(unsigned int, struct dirent *, unsigned int) 217,220,219
|
||||
int fsync(int) 118
|
||||
int fdatasync(int) 148,148,152
|
||||
int fchown:fchown32(int, uid_t, gid_t) 207,207,-1
|
||||
int fchown:fchown(int, uid_t, gid_t) -1,-1,95
|
||||
void sync(void) 36
|
||||
int __fcntl64:fcntl64(int, int, void *) 221,221,220
|
||||
int __fstatfs64:fstatfs64(int, size_t, struct statfs *) 267,269,256
|
||||
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) 187,187,207
|
||||
int fstatat:fstatat64(int dirfd, const char *path, struct stat *buf, int flags) 327,300,293
|
||||
int mkdirat(int dirfd, const char *pathname, mode_t mode) 323,296,289
|
||||
int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags) 325,298,291
|
||||
int fchmodat(int dirfd, const char *path, mode_t mode, int flags) 333,306,299
|
||||
int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) 329,302,295
|
||||
int fsetxattr(int, const char *, const void *, size_t, int) 228,228,226
|
||||
ssize_t fgetxattr(int, const char *, void *, size_t) 231,231,229
|
||||
ssize_t flistxattr(int, char *, size_t) 234,234,232
|
||||
int fremovexattr(int, const char *) 237,237,235
|
||||
void * __mmap2:mmap2(void*, size_t, int, int, int, long) 1
|
||||
int munmap(void *, size_t) 1
|
||||
void * mremap(void *, size_t, size_t, unsigned long) 1
|
||||
int msync(const void *, size_t, int) 1
|
||||
int mprotect(const void *, size_t, int) 1
|
||||
int madvise(const void *, size_t, int) 1
|
||||
int mlock(const void *addr, size_t len) 1
|
||||
int munlock(const void *addr, size_t len) 1
|
||||
int mlockall(int flags) 1
|
||||
int munlockall() 1
|
||||
int mincore(void* start, size_t length, unsigned char* vec) 1
|
||||
int __ioctl:ioctl(int, int, void *) 1
|
||||
int readv(int, const struct iovec *, int) 1
|
||||
int writev(int, const struct iovec *, int) 1
|
||||
int __fcntl:fcntl(int, int, void*) 1
|
||||
int flock(int, int) 1
|
||||
int fchmod(int, mode_t) 1
|
||||
int dup(int) 1
|
||||
int pipe(int *) 1,1,-1
|
||||
int pipe2(int *, int) 1
|
||||
int dup2(int, int) 1
|
||||
int select:_newselect(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *) 1
|
||||
int ftruncate(int, off_t) 1
|
||||
int ftruncate64(int, off64_t) 1
|
||||
int getdents:getdents64(unsigned int, struct dirent *, unsigned int) 1
|
||||
int fsync(int) 1
|
||||
int fdatasync(int) 1
|
||||
int fchown:fchown32(int, uid_t, gid_t) 1,1,-1
|
||||
int fchown:fchown(int, uid_t, gid_t) -1,-1,1
|
||||
void sync(void) 1
|
||||
int __fcntl64:fcntl64(int, int, void *) 1
|
||||
int __fstatfs64:fstatfs64(int, size_t, struct statfs *) 1
|
||||
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) 1
|
||||
int fstatat:fstatat64(int dirfd, const char *path, struct stat *buf, int flags) 1
|
||||
int mkdirat(int dirfd, const char *pathname, mode_t mode) 1
|
||||
int fchownat(int dirfd, const char *path, uid_t owner, gid_t group, int flags) 1
|
||||
int fchmodat(int dirfd, const char *path, mode_t mode, int flags) 1
|
||||
int renameat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath) 1
|
||||
int fsetxattr(int, const char *, const void *, size_t, int) 1
|
||||
ssize_t fgetxattr(int, const char *, void *, size_t) 1
|
||||
ssize_t flistxattr(int, char *, size_t) 1
|
||||
int fremovexattr(int, const char *) 1
|
||||
|
||||
# file system
|
||||
int link (const char*, const char*) 9
|
||||
int unlink (const char*) 10
|
||||
int unlinkat (int, const char *, int) 328,301,294
|
||||
int chdir (const char*) 12
|
||||
int mknod (const char*, mode_t, dev_t) 14
|
||||
int chmod (const char*,mode_t) 15
|
||||
int chown:chown32(const char *, uid_t, gid_t) 212,212,-1
|
||||
int chown:chown(const char *, uid_t, gid_t) -1,-1,202
|
||||
int lchown:lchown32 (const char*, uid_t, gid_t) 198,198,-1
|
||||
int lchown:lchown (const char*, uid_t, gid_t) -1,-1,16
|
||||
int mount (const char*, const char*, const char*, unsigned long, const void*) 21
|
||||
int link (const char*, const char*) 1
|
||||
int unlink (const char*) 1
|
||||
int unlinkat (int, const char *, int) 1
|
||||
int chdir (const char*) 1
|
||||
int mknod (const char*, mode_t, dev_t) 1
|
||||
int chmod (const char*,mode_t) 1
|
||||
int chown:chown32(const char *, uid_t, gid_t) 1,1,-1
|
||||
int chown:chown(const char *, uid_t, gid_t) -1,-1,1
|
||||
int lchown:lchown32 (const char*, uid_t, gid_t) 1,1,-1
|
||||
int lchown:lchown (const char*, uid_t, gid_t) -1,-1,1
|
||||
int mount (const char*, const char*, const char*, unsigned long, const void*) 1
|
||||
int umount(const char*) stub
|
||||
int umount2 (const char*, int) 52
|
||||
int fstat:fstat64(int, struct stat*) 197,197,215
|
||||
int stat:stat64(const char *, struct stat *) 195,195,213
|
||||
int lstat:lstat64(const char *, struct stat *) 196,196,214
|
||||
int mkdir(const char *, mode_t) 39
|
||||
int readlink(const char *, char *, size_t) 85
|
||||
int rmdir(const char *) 40
|
||||
int rename(const char *, const char *) 38
|
||||
int __getcwd:getcwd(char * buf, size_t size) 183,183,203
|
||||
int access(const char *, int) 33
|
||||
int faccessat(int, const char *, int, int) 334,307,300
|
||||
int symlink(const char *, const char *) 83
|
||||
int fchdir(int) 133
|
||||
int truncate(const char*, off_t) 92
|
||||
int setxattr(const char *, const char *, const void *, size_t, int) 226,226,224
|
||||
int lsetxattr(const char *, const char *, const void *, size_t, int) 227,227,225
|
||||
ssize_t getxattr(const char *, const char *, void *, size_t) 229,229,227
|
||||
ssize_t lgetxattr(const char *, const char *, void *, size_t) 230,230,228
|
||||
ssize_t listxattr(const char *, char *, size_t) 232,232,230
|
||||
ssize_t llistxattr(const char *, char *, size_t) 233,233,231
|
||||
int removexattr(const char *, const char *) 235,235,233
|
||||
int lremovexattr(const char *, const char *) 236,236,234
|
||||
int __statfs64:statfs64(const char *, size_t, struct statfs *) 266,268,255
|
||||
long unshare(unsigned long) 337,310,303
|
||||
int umount2 (const char*, int) 1
|
||||
int fstat:fstat64(int, struct stat*) 1
|
||||
int stat:stat64(const char *, struct stat *) 1
|
||||
int lstat:lstat64(const char *, struct stat *) 1
|
||||
int mkdir(const char *, mode_t) 1
|
||||
int readlink(const char *, char *, size_t) 1
|
||||
int rmdir(const char *) 1
|
||||
int rename(const char *, const char *) 1
|
||||
int __getcwd:getcwd(char * buf, size_t size) 1
|
||||
int access(const char *, int) 1
|
||||
int faccessat(int, const char *, int, int) 1
|
||||
int symlink(const char *, const char *) 1
|
||||
int fchdir(int) 1
|
||||
int truncate(const char*, off_t) 1
|
||||
int setxattr(const char *, const char *, const void *, size_t, int) 1
|
||||
int lsetxattr(const char *, const char *, const void *, size_t, int) 1
|
||||
ssize_t getxattr(const char *, const char *, void *, size_t) 1
|
||||
ssize_t lgetxattr(const char *, const char *, void *, size_t) 1
|
||||
ssize_t listxattr(const char *, char *, size_t) 1
|
||||
ssize_t llistxattr(const char *, char *, size_t) 1
|
||||
int removexattr(const char *, const char *) 1
|
||||
int lremovexattr(const char *, const char *) 1
|
||||
int __statfs64:statfs64(const char *, size_t, struct statfs *) 1
|
||||
long unshare(unsigned long) 1
|
||||
int swapon(const char *, int) 1
|
||||
int swapoff(const char *) 1
|
||||
|
||||
# time
|
||||
int pause () 29
|
||||
int gettimeofday(struct timeval*, struct timezone*) 78
|
||||
int settimeofday(const struct timeval*, const struct timezone*) 79
|
||||
clock_t times(struct tms *) 43
|
||||
int nanosleep(const struct timespec *, struct timespec *) 162,162,166
|
||||
int clock_gettime(clockid_t clk_id, struct timespec *tp) 263,265,263
|
||||
int clock_settime(clockid_t clk_id, const struct timespec *tp) 262,264,262
|
||||
int clock_getres(clockid_t clk_id, struct timespec *res) 264,266,264
|
||||
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *req, struct timespec *rem) 265,267,265
|
||||
int getitimer(int, const struct itimerval *) 105
|
||||
int setitimer(int, const struct itimerval *, struct itimerval *) 104
|
||||
int __timer_create:timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) 257,259,257
|
||||
int __timer_settime:timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*) 258,260,258
|
||||
int __timer_gettime:timer_gettime(timer_t, struct itimerspec*) 259,261,259
|
||||
int __timer_getoverrun:timer_getoverrun(timer_t) 260,262,260
|
||||
int __timer_delete:timer_delete(timer_t) 261,263,261
|
||||
int utimes(const char*, const struct timeval tvp[2]) 269,271,267
|
||||
int utimensat(int, const char *, const struct timespec times[2], int) 348,320,316
|
||||
int pause () 1
|
||||
int gettimeofday(struct timeval*, struct timezone*) 1
|
||||
int settimeofday(const struct timeval*, const struct timezone*) 1
|
||||
clock_t times(struct tms *) 1
|
||||
int nanosleep(const struct timespec *, struct timespec *) 1
|
||||
int clock_gettime(clockid_t clk_id, struct timespec *tp) 1
|
||||
int clock_settime(clockid_t clk_id, const struct timespec *tp) 1
|
||||
int clock_getres(clockid_t clk_id, struct timespec *res) 1
|
||||
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *req, struct timespec *rem) 1
|
||||
int getitimer(int, const struct itimerval *) 1
|
||||
int setitimer(int, const struct itimerval *, struct itimerval *) 1
|
||||
int __timer_create:timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) 1
|
||||
int __timer_settime:timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*) 1
|
||||
int __timer_gettime:timer_gettime(timer_t, struct itimerspec*) 1
|
||||
int __timer_getoverrun:timer_getoverrun(timer_t) 1
|
||||
int __timer_delete:timer_delete(timer_t) 1
|
||||
int utimes(const char*, const struct timeval tvp[2]) 1
|
||||
int utimensat(int, const char *, const struct timespec times[2], int) 1
|
||||
int timerfd_create(clockid_t, int) 1
|
||||
int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *) 1
|
||||
int timerfd_gettime(int, struct itimerspec *) 1
|
||||
|
||||
# signals
|
||||
int sigaction(int, const struct sigaction *, struct sigaction *) 67
|
||||
int sigprocmask(int, const sigset_t *, sigset_t *) 126
|
||||
int __sigsuspend:sigsuspend(int unused1, int unused2, unsigned mask) 72,72,-1
|
||||
int __sigsuspend:sigsuspend(const sigset_t *mask) -1,-1,72
|
||||
int __rt_sigaction:rt_sigaction (int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize) 174,174,194
|
||||
int __rt_sigprocmask:rt_sigprocmask (int how, const sigset_t *set, sigset_t *oset, size_t sigsetsize) 175,175,195
|
||||
int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t *set, struct siginfo_t *info, struct timespec_t *timeout, size_t sigset_size) 177,177,197
|
||||
int sigpending(sigset_t *) 73
|
||||
int signalfd4(int fd, const sigset_t *mask, size_t sizemask, int flags) 355,327,324
|
||||
int sigaction(int, const struct sigaction *, struct sigaction *) 1
|
||||
int sigprocmask(int, const sigset_t *, sigset_t *) 1
|
||||
int __sigsuspend:sigsuspend(int unused1, int unused2, unsigned mask) 1,1,-1
|
||||
int __sigsuspend:sigsuspend(const sigset_t *mask) -1,-1,1
|
||||
int __rt_sigaction:rt_sigaction (int sig, const struct sigaction *act, struct sigaction *oact, size_t sigsetsize) 1
|
||||
int __rt_sigprocmask:rt_sigprocmask (int how, const sigset_t *set, sigset_t *oset, size_t sigsetsize) 1
|
||||
int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t *set, struct siginfo_t *info, struct timespec_t *timeout, size_t sigset_size) 1
|
||||
int sigpending(sigset_t *) 1
|
||||
int signalfd4(int fd, const sigset_t *mask, size_t sizemask, int flags) 1
|
||||
|
||||
# sockets
|
||||
int socket(int, int, int) 281,-1,183
|
||||
int socketpair(int, int, int, int*) 288,-1,184
|
||||
int bind(int, struct sockaddr *, int) 282,-1,169
|
||||
int connect(int, struct sockaddr *, socklen_t) 283,-1,170
|
||||
int listen(int, int) 284,-1,174
|
||||
int accept(int, struct sockaddr *, socklen_t *) 285,-1,168
|
||||
int getsockname(int, struct sockaddr *, socklen_t *) 286,-1,172
|
||||
int getpeername(int, struct sockaddr *, socklen_t *) 287,-1,171
|
||||
int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t) 290,-1,180
|
||||
int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *) 292,-1,176
|
||||
int shutdown(int, int) 293,-1,182
|
||||
int setsockopt(int, int, int, const void *, socklen_t) 294,-1,181
|
||||
int getsockopt(int, int, int, void *, socklen_t *) 295,-1,173
|
||||
int sendmsg(int, const struct msghdr *, unsigned int) 296,-1,179
|
||||
int recvmsg(int, struct msghdr *, unsigned int) 297,-1,177
|
||||
int socket(int, int, int) 1,-1,1
|
||||
int socketpair(int, int, int, int*) 1,-1,1
|
||||
int bind(int, struct sockaddr *, int) 1,-1,1
|
||||
int connect(int, struct sockaddr *, socklen_t) 1,-1,1
|
||||
int listen(int, int) 1,-1,1
|
||||
int accept(int, struct sockaddr *, socklen_t *) 1,-1,1
|
||||
int getsockname(int, struct sockaddr *, socklen_t *) 1,-1,1
|
||||
int getpeername(int, struct sockaddr *, socklen_t *) 1,-1,1
|
||||
int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t) 1,-1,1
|
||||
int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *) 1,-1,1
|
||||
int shutdown(int, int) 1,-1,1
|
||||
int setsockopt(int, int, int, const void *, socklen_t) 1,-1,1
|
||||
int getsockopt(int, int, int, void *, socklen_t *) 1,-1,1
|
||||
int sendmsg(int, const struct msghdr *, unsigned int) 1,-1,1
|
||||
int recvmsg(int, struct msghdr *, unsigned int) 1,-1,1
|
||||
|
||||
# sockets for x86. These are done as an "indexed" call to socketcall syscall.
|
||||
int socket:socketcall:1 (int, int, int) -1,102,-1
|
||||
int bind:socketcall:2 (int, struct sockaddr *, int) -1,102,-1
|
||||
int connect:socketcall:3(int, struct sockaddr *, socklen_t) -1,102,-1
|
||||
int listen:socketcall:4(int, int) -1,102,-1
|
||||
int accept:socketcall:5(int, struct sockaddr *, socklen_t *) -1,102,-1
|
||||
int getsockname:socketcall:6(int, struct sockaddr *, socklen_t *) -1,102,-1
|
||||
int getpeername:socketcall:7(int, struct sockaddr *, socklen_t *) -1,102,-1
|
||||
int socketpair:socketcall:8(int, int, int, int*) -1,102,-1
|
||||
int sendto:socketcall:11(int, const void *, size_t, int, const struct sockaddr *, socklen_t) -1,102,-1
|
||||
int recvfrom:socketcall:12(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *) -1,102,-1
|
||||
int shutdown:socketcall:13(int, int) -1,102,-1
|
||||
int setsockopt:socketcall:14(int, int, int, const void *, socklen_t) -1,102,-1
|
||||
int getsockopt:socketcall:15(int, int, int, void *, socklen_t *) -1,102,-1
|
||||
int sendmsg:socketcall:16(int, const struct msghdr *, unsigned int) -1,102,-1
|
||||
int recvmsg:socketcall:17(int, struct msghdr *, unsigned int) -1,102,-1
|
||||
int socket:socketcall:1 (int, int, int) -1,1,-1
|
||||
int bind:socketcall:2 (int, struct sockaddr *, int) -1,1,-1
|
||||
int connect:socketcall:3(int, struct sockaddr *, socklen_t) -1,1,-1
|
||||
int listen:socketcall:4(int, int) -1,1,-1
|
||||
int accept:socketcall:5(int, struct sockaddr *, socklen_t *) -1,1,-1
|
||||
int getsockname:socketcall:6(int, struct sockaddr *, socklen_t *) -1,1,-1
|
||||
int getpeername:socketcall:7(int, struct sockaddr *, socklen_t *) -1,1,-1
|
||||
int socketpair:socketcall:8(int, int, int, int*) -1,1,-1
|
||||
int sendto:socketcall:11(int, const void *, size_t, int, const struct sockaddr *, socklen_t) -1,1,-1
|
||||
int recvfrom:socketcall:12(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *) -1,1,-1
|
||||
int shutdown:socketcall:13(int, int) -1,1,-1
|
||||
int setsockopt:socketcall:14(int, int, int, const void *, socklen_t) -1,1,-1
|
||||
int getsockopt:socketcall:15(int, int, int, void *, socklen_t *) -1,1,-1
|
||||
int sendmsg:socketcall:16(int, const struct msghdr *, unsigned int) -1,1,-1
|
||||
int recvmsg:socketcall:17(int, struct msghdr *, unsigned int) -1,1,-1
|
||||
|
||||
# scheduler & real-time
|
||||
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param) 156,156,160
|
||||
int sched_getscheduler(pid_t pid) 157,157,161
|
||||
int sched_yield(void) 158,158,162
|
||||
int sched_setparam(pid_t pid, const struct sched_param *param) 154,154,158
|
||||
int sched_getparam(pid_t pid, struct sched_param *param) 155,155,159
|
||||
int sched_get_priority_max(int policy) 159,159,163
|
||||
int sched_get_priority_min(int policy) 160,160,164
|
||||
int sched_rr_get_interval(pid_t pid, struct timespec *interval) 161,161,165
|
||||
int sched_setaffinity(pid_t pid, size_t setsize, const cpu_set_t* set) 241,241,239
|
||||
int __sched_getaffinity:sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set) 242,242,240
|
||||
int __getcpu:getcpu(unsigned *cpu, unsigned *node, void *unused) 345,318,312
|
||||
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param) 1
|
||||
int sched_getscheduler(pid_t pid) 1
|
||||
int sched_yield(void) 1
|
||||
int sched_setparam(pid_t pid, const struct sched_param *param) 1
|
||||
int sched_getparam(pid_t pid, struct sched_param *param) 1
|
||||
int sched_get_priority_max(int policy) 1
|
||||
int sched_get_priority_min(int policy) 1
|
||||
int sched_rr_get_interval(pid_t pid, struct timespec *interval) 1
|
||||
int sched_setaffinity(pid_t pid, size_t setsize, const cpu_set_t* set) 1
|
||||
int __sched_getaffinity:sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set) 1
|
||||
int __getcpu:getcpu(unsigned *cpu, unsigned *node, void *unused) 1
|
||||
|
||||
# io priorities
|
||||
int ioprio_set(int which, int who, int ioprio) 314,289,314
|
||||
int ioprio_get(int which, int who) 315,290,315
|
||||
int ioprio_set(int which, int who, int ioprio) 1
|
||||
int ioprio_get(int which, int who) 1
|
||||
|
||||
# other
|
||||
int uname(struct utsname *) 122
|
||||
mode_t umask(mode_t) 60
|
||||
int __reboot:reboot(int, int, int, void *) 88
|
||||
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
|
||||
int personality(unsigned long) 136
|
||||
long perf_event_open(struct perf_event_attr *attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags) 364,336,333
|
||||
int uname(struct utsname *) 1
|
||||
mode_t umask(mode_t) 1
|
||||
int __reboot:reboot(int, int, int, void *) 1
|
||||
int __syslog:syslog(int, char *, int) 1
|
||||
int init_module(void *, unsigned long, const char *) 1
|
||||
int delete_module(const char*, unsigned int) 1
|
||||
int klogctl:syslog(int, char *, int) 1
|
||||
int sysinfo(struct sysinfo *) 1
|
||||
int personality(unsigned long) 1
|
||||
long perf_event_open(struct perf_event_attr *attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags) 1
|
||||
|
||||
# futex
|
||||
int futex(void *, int, int, void *, void *, int) 240,240,238
|
||||
int futex(void *, int, int, void *, void *, int) 1
|
||||
|
||||
# epoll
|
||||
int epoll_create(int size) 250,254,248
|
||||
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) 251,255,249
|
||||
int epoll_wait(int epfd, struct epoll_event *events, int max, int timeout) 252,256,250
|
||||
int epoll_create(int size) 1
|
||||
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) 1
|
||||
int epoll_wait(int epfd, struct epoll_event *events, int max, int timeout) 1
|
||||
|
||||
int inotify_init(void) 316,291,284
|
||||
int inotify_add_watch(int, const char *, unsigned int) 317,292,285
|
||||
int inotify_rm_watch(int, unsigned int) 318,293,286
|
||||
int inotify_init(void) 1
|
||||
int inotify_add_watch(int, const char *, unsigned int) 1
|
||||
int inotify_rm_watch(int, unsigned int) 1
|
||||
|
||||
int poll(struct pollfd *, unsigned int, long) 168,168,188
|
||||
int poll(struct pollfd *, unsigned int, long) 1
|
||||
|
||||
int eventfd:eventfd2(unsigned int, int) 356,328,325
|
||||
int eventfd:eventfd2(unsigned int, int) 1
|
||||
|
||||
# ARM-specific ARM_NR_BASE == 0x0f0000 == 983040
|
||||
int __set_tls:__ARM_NR_set_tls(void*) 983045,-1,-1
|
||||
int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) 983042,-1,-1
|
||||
int __set_tls:__ARM_NR_set_tls(void*) 1,-1,-1
|
||||
int cacheflush:__ARM_NR_cacheflush(long start, long end, long flags) 1,-1,-1
|
||||
|
||||
# MIPS-specific
|
||||
int _flush_cache:cacheflush(char *addr, const int nbytes, const int op) -1,-1,147
|
||||
int syscall(int number,...) -1,-1,0
|
||||
int _flush_cache:cacheflush(char *addr, const int nbytes, const int op) -1,-1,1
|
||||
int syscall(int number,...) -1,-1,1
|
||||
|
||||
@@ -15,7 +15,6 @@ _LIBC_ARCH_COMMON_SRC_FILES := \
|
||||
arch-arm/bionic/setjmp.S \
|
||||
arch-arm/bionic/sigsetjmp.S \
|
||||
arch-arm/bionic/strcpy.S \
|
||||
arch-arm/bionic/strlen.c.arm \
|
||||
arch-arm/bionic/syscall.S \
|
||||
arch-arm/bionic/tgkill.S \
|
||||
arch-arm/bionic/tkill.S \
|
||||
@@ -29,7 +28,7 @@ _LIBC_ARCH_DYNAMIC_SRC_FILES := \
|
||||
arch-arm/bionic/exidx_dynamic.c
|
||||
|
||||
ifeq ($(strip $(wildcard bionic/libc/arch-arm/$(TARGET_CPU_VARIANT)/$(TARGET_CPU_VARIANT).mk)),)
|
||||
$(error "TARGET_CPU_VARIANT not set or set to an unknown value. Possible values are cortex-a9, cortex-a15, krait. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
|
||||
$(error "TARGET_CPU_VARIANT not set or set to an unknown value. Possible values are cortex-a7, cortex-a8, cortex-a9, cortex-a15, krait. Use generic for devices that do not have a CPU similar to any of the supported cpu variants.")
|
||||
endif
|
||||
|
||||
include bionic/libc/arch-arm/$(TARGET_CPU_VARIANT)/$(TARGET_CPU_VARIANT).mk
|
||||
|
||||
@@ -38,5 +38,5 @@
|
||||
ENTRY(abort)
|
||||
.save {r3, r14}
|
||||
stmfd sp!, {r3, r14}
|
||||
blx PIC_SYM(_C_LABEL(__libc_android_abort), PLT)
|
||||
bl PIC_SYM(_C_LABEL(__libc_android_abort), PLT)
|
||||
END(abort)
|
||||
|
||||
@@ -32,33 +32,33 @@
|
||||
|
||||
// int __pthread_clone(void* (*fn)(void*), void* child_stack, int flags, void* arg);
|
||||
ENTRY(__pthread_clone)
|
||||
# Copy the args onto the new stack.
|
||||
# Push 'fn' and 'arg' onto 'child_stack'.
|
||||
stmdb r1!, {r0, r3}
|
||||
|
||||
# The sys_clone system call only takes two arguments: 'flags' and 'child_stack'.
|
||||
# 'child_stack' is already in r1, but we need to move 'flags' into position.
|
||||
mov r0, r2
|
||||
stmfd sp!, {r4, r7}
|
||||
|
||||
# System call.
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_clone
|
||||
swi #0
|
||||
|
||||
# Child?
|
||||
movs r0, r0
|
||||
beq 1f
|
||||
|
||||
# In parent, reload saved registers then either return or set errno.
|
||||
ldmfd sp!, {r4, r7}
|
||||
# Parent.
|
||||
mov r7, ip
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno
|
||||
|
||||
1: # The child.
|
||||
# pick the function arg and call address off the stack and jump
|
||||
# to the C __thread_entry function which does some setup and then
|
||||
# calls the thread's start function
|
||||
1: # Child.
|
||||
# Pop 'fn' and 'arg' back off the stack and call __thread_entry.
|
||||
pop {r0, r1}
|
||||
# __thread_entry needs the TLS pointer
|
||||
# __thread_entry also needs our stack pointer.
|
||||
mov r2, sp
|
||||
b __thread_entry
|
||||
END(__pthread_clone)
|
||||
|
||||
@@ -34,11 +34,10 @@
|
||||
|
||||
// __futex_syscall3(*ftx, op, val)
|
||||
ENTRY(__futex_syscall3)
|
||||
stmdb sp!, {r4, r7}
|
||||
.save {r4, r7}
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_futex
|
||||
swi #0
|
||||
ldmia sp!, {r4, r7}
|
||||
mov r7, ip
|
||||
bx lr
|
||||
END(__futex_syscall3)
|
||||
|
||||
@@ -49,25 +48,23 @@ END(__futex_syscall4)
|
||||
|
||||
// __futex_wait(*ftx, val, *timespec)
|
||||
ENTRY(__futex_wait)
|
||||
stmdb sp!, {r4, r7}
|
||||
.save {r4, r7}
|
||||
mov ip, r7
|
||||
mov r3, r2
|
||||
mov r2, r1
|
||||
mov r1, #FUTEX_WAIT
|
||||
ldr r7, =__NR_futex
|
||||
swi #0
|
||||
ldmia sp!, {r4, r7}
|
||||
mov r7, ip
|
||||
bx lr
|
||||
END(__futex_wait)
|
||||
|
||||
// __futex_wake(*ftx, counter)
|
||||
ENTRY(__futex_wake)
|
||||
.save {r4, r7}
|
||||
stmdb sp!, {r4, r7}
|
||||
mov ip, r7
|
||||
mov r2, r1
|
||||
mov r1, #FUTEX_WAKE
|
||||
ldr r7, =__NR_futex
|
||||
swi #0
|
||||
ldmia sp!, {r4, r7}
|
||||
mov r7, ip
|
||||
bx lr
|
||||
END(__futex_wake)
|
||||
|
||||
614
libc/arch-arm/bionic/memcpy.a9.S
Normal file
614
libc/arch-arm/bionic/memcpy.a9.S
Normal file
@@ -0,0 +1,614 @@
|
||||
/* Copyright (c) 2013, Linaro Limited
|
||||
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 Linaro Limited 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
|
||||
HOLDER 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 memcpy routine is optimised for Cortex-A15 cores and takes advantage
|
||||
of VFP or NEON when built with the appropriate flags.
|
||||
|
||||
Assumptions:
|
||||
|
||||
ARMv6 (ARMv7-a if using Neon)
|
||||
ARM state
|
||||
Unaligned accesses
|
||||
LDRD/STRD support unaligned word accesses
|
||||
|
||||
*/
|
||||
|
||||
#include <machine/cpu-features.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
.syntax unified
|
||||
/* This implementation requires ARM state. */
|
||||
.arm
|
||||
|
||||
#ifdef __ARM_NEON__
|
||||
|
||||
.fpu neon
|
||||
.arch armv7-a
|
||||
# define FRAME_SIZE 4
|
||||
# define USE_VFP
|
||||
# define USE_NEON
|
||||
|
||||
#elif !defined (__SOFTFP__)
|
||||
|
||||
.arch armv6
|
||||
.fpu vfpv2
|
||||
# define FRAME_SIZE 32
|
||||
# define USE_VFP
|
||||
|
||||
#else
|
||||
.arch armv6
|
||||
# define FRAME_SIZE 32
|
||||
|
||||
#endif
|
||||
|
||||
/* Old versions of GAS incorrectly implement the NEON align semantics. */
|
||||
#ifdef BROKEN_ASM_NEON_ALIGN
|
||||
#define ALIGN(addr, align) addr,:align
|
||||
#else
|
||||
#define ALIGN(addr, align) addr:align
|
||||
#endif
|
||||
|
||||
#define PC_OFFSET 8 /* PC pipeline compensation. */
|
||||
#define INSN_SIZE 4
|
||||
|
||||
/* Call parameters. */
|
||||
#define dstin r0
|
||||
#define src r1
|
||||
#define count r2
|
||||
|
||||
/* Locals. */
|
||||
#define tmp1 r3
|
||||
#define dst ip
|
||||
#define tmp2 r10
|
||||
|
||||
#ifndef USE_NEON
|
||||
/* For bulk copies using GP registers. */
|
||||
#define A_l r2 /* Call-clobbered. */
|
||||
#define A_h r3 /* Call-clobbered. */
|
||||
#define B_l r4
|
||||
#define B_h r5
|
||||
#define C_l r6
|
||||
#define C_h r7
|
||||
#define D_l r8
|
||||
#define D_h r9
|
||||
#endif
|
||||
|
||||
/* Number of lines ahead to pre-fetch data. If you change this the code
|
||||
below will need adjustment to compensate. */
|
||||
|
||||
#define prefetch_lines 5
|
||||
|
||||
#ifdef USE_VFP
|
||||
.macro cpy_line_vfp vreg, base
|
||||
vstr \vreg, [dst, #\base]
|
||||
vldr \vreg, [src, #\base]
|
||||
vstr d0, [dst, #\base + 8]
|
||||
vldr d0, [src, #\base + 8]
|
||||
vstr d1, [dst, #\base + 16]
|
||||
vldr d1, [src, #\base + 16]
|
||||
vstr d2, [dst, #\base + 24]
|
||||
vldr d2, [src, #\base + 24]
|
||||
vstr \vreg, [dst, #\base + 32]
|
||||
vldr \vreg, [src, #\base + prefetch_lines * 64 - 32]
|
||||
vstr d0, [dst, #\base + 40]
|
||||
vldr d0, [src, #\base + 40]
|
||||
vstr d1, [dst, #\base + 48]
|
||||
vldr d1, [src, #\base + 48]
|
||||
vstr d2, [dst, #\base + 56]
|
||||
vldr d2, [src, #\base + 56]
|
||||
.endm
|
||||
|
||||
.macro cpy_tail_vfp vreg, base
|
||||
vstr \vreg, [dst, #\base]
|
||||
vldr \vreg, [src, #\base]
|
||||
vstr d0, [dst, #\base + 8]
|
||||
vldr d0, [src, #\base + 8]
|
||||
vstr d1, [dst, #\base + 16]
|
||||
vldr d1, [src, #\base + 16]
|
||||
vstr d2, [dst, #\base + 24]
|
||||
vldr d2, [src, #\base + 24]
|
||||
vstr \vreg, [dst, #\base + 32]
|
||||
vstr d0, [dst, #\base + 40]
|
||||
vldr d0, [src, #\base + 40]
|
||||
vstr d1, [dst, #\base + 48]
|
||||
vldr d1, [src, #\base + 48]
|
||||
vstr d2, [dst, #\base + 56]
|
||||
vldr d2, [src, #\base + 56]
|
||||
.endm
|
||||
#endif
|
||||
|
||||
.p2align 6
|
||||
ENTRY(memcpy)
|
||||
|
||||
mov dst, dstin /* Preserve dstin, we need to return it. */
|
||||
cmp count, #64
|
||||
bge .Lcpy_not_short
|
||||
/* Deal with small copies quickly by dropping straight into the
|
||||
exit block. */
|
||||
|
||||
.Ltail63unaligned:
|
||||
#ifdef USE_NEON
|
||||
and tmp1, count, #0x38
|
||||
rsb tmp1, tmp1, #(56 - PC_OFFSET + INSN_SIZE)
|
||||
add pc, pc, tmp1
|
||||
vld1.8 {d0}, [src]! /* 14 words to go. */
|
||||
vst1.8 {d0}, [dst]!
|
||||
vld1.8 {d0}, [src]! /* 12 words to go. */
|
||||
vst1.8 {d0}, [dst]!
|
||||
vld1.8 {d0}, [src]! /* 10 words to go. */
|
||||
vst1.8 {d0}, [dst]!
|
||||
vld1.8 {d0}, [src]! /* 8 words to go. */
|
||||
vst1.8 {d0}, [dst]!
|
||||
vld1.8 {d0}, [src]! /* 6 words to go. */
|
||||
vst1.8 {d0}, [dst]!
|
||||
vld1.8 {d0}, [src]! /* 4 words to go. */
|
||||
vst1.8 {d0}, [dst]!
|
||||
vld1.8 {d0}, [src]! /* 2 words to go. */
|
||||
vst1.8 {d0}, [dst]!
|
||||
|
||||
tst count, #4
|
||||
ldrne tmp1, [src], #4
|
||||
strne tmp1, [dst], #4
|
||||
#else
|
||||
/* Copy up to 15 full words of data. May not be aligned. */
|
||||
/* Cannot use VFP for unaligned data. */
|
||||
and tmp1, count, #0x3c
|
||||
add dst, dst, tmp1
|
||||
add src, src, tmp1
|
||||
rsb tmp1, tmp1, #(60 - PC_OFFSET/2 + INSN_SIZE/2)
|
||||
/* Jump directly into the sequence below at the correct offset. */
|
||||
add pc, pc, tmp1, lsl #1
|
||||
|
||||
ldr tmp1, [src, #-60] /* 15 words to go. */
|
||||
str tmp1, [dst, #-60]
|
||||
|
||||
ldr tmp1, [src, #-56] /* 14 words to go. */
|
||||
str tmp1, [dst, #-56]
|
||||
ldr tmp1, [src, #-52]
|
||||
str tmp1, [dst, #-52]
|
||||
|
||||
ldr tmp1, [src, #-48] /* 12 words to go. */
|
||||
str tmp1, [dst, #-48]
|
||||
ldr tmp1, [src, #-44]
|
||||
str tmp1, [dst, #-44]
|
||||
|
||||
ldr tmp1, [src, #-40] /* 10 words to go. */
|
||||
str tmp1, [dst, #-40]
|
||||
ldr tmp1, [src, #-36]
|
||||
str tmp1, [dst, #-36]
|
||||
|
||||
ldr tmp1, [src, #-32] /* 8 words to go. */
|
||||
str tmp1, [dst, #-32]
|
||||
ldr tmp1, [src, #-28]
|
||||
str tmp1, [dst, #-28]
|
||||
|
||||
ldr tmp1, [src, #-24] /* 6 words to go. */
|
||||
str tmp1, [dst, #-24]
|
||||
ldr tmp1, [src, #-20]
|
||||
str tmp1, [dst, #-20]
|
||||
|
||||
ldr tmp1, [src, #-16] /* 4 words to go. */
|
||||
str tmp1, [dst, #-16]
|
||||
ldr tmp1, [src, #-12]
|
||||
str tmp1, [dst, #-12]
|
||||
|
||||
ldr tmp1, [src, #-8] /* 2 words to go. */
|
||||
str tmp1, [dst, #-8]
|
||||
ldr tmp1, [src, #-4]
|
||||
str tmp1, [dst, #-4]
|
||||
#endif
|
||||
|
||||
lsls count, count, #31
|
||||
ldrhcs tmp1, [src], #2
|
||||
ldrbne src, [src] /* Src is dead, use as a scratch. */
|
||||
strhcs tmp1, [dst], #2
|
||||
strbne src, [dst]
|
||||
bx lr
|
||||
|
||||
.Lcpy_not_short:
|
||||
/* At least 64 bytes to copy, but don't know the alignment yet. */
|
||||
str tmp2, [sp, #-FRAME_SIZE]!
|
||||
and tmp2, src, #7
|
||||
and tmp1, dst, #7
|
||||
cmp tmp1, tmp2
|
||||
bne .Lcpy_notaligned
|
||||
|
||||
#ifdef USE_VFP
|
||||
/* Magic dust alert! Force VFP on Cortex-A9. Experiments show
|
||||
that the FP pipeline is much better at streaming loads and
|
||||
stores. This is outside the critical loop. */
|
||||
vmov.f32 s0, s0
|
||||
#endif
|
||||
|
||||
/* SRC and DST have the same mutual 32-bit alignment, but we may
|
||||
still need to pre-copy some bytes to get to natural alignment.
|
||||
We bring DST into full 64-bit alignment. */
|
||||
lsls tmp2, dst, #29
|
||||
beq 1f
|
||||
rsbs tmp2, tmp2, #0
|
||||
sub count, count, tmp2, lsr #29
|
||||
ldrmi tmp1, [src], #4
|
||||
strmi tmp1, [dst], #4
|
||||
lsls tmp2, tmp2, #2
|
||||
ldrhcs tmp1, [src], #2
|
||||
ldrbne tmp2, [src], #1
|
||||
strhcs tmp1, [dst], #2
|
||||
strbne tmp2, [dst], #1
|
||||
|
||||
1:
|
||||
subs tmp2, count, #64 /* Use tmp2 for count. */
|
||||
blt .Ltail63aligned
|
||||
|
||||
cmp tmp2, #512
|
||||
bge .Lcpy_body_long
|
||||
|
||||
.Lcpy_body_medium: /* Count in tmp2. */
|
||||
#ifdef USE_VFP
|
||||
1:
|
||||
vldr d0, [src, #0]
|
||||
subs tmp2, tmp2, #64
|
||||
vldr d1, [src, #8]
|
||||
vstr d0, [dst, #0]
|
||||
vldr d0, [src, #16]
|
||||
vstr d1, [dst, #8]
|
||||
vldr d1, [src, #24]
|
||||
vstr d0, [dst, #16]
|
||||
vldr d0, [src, #32]
|
||||
vstr d1, [dst, #24]
|
||||
vldr d1, [src, #40]
|
||||
vstr d0, [dst, #32]
|
||||
vldr d0, [src, #48]
|
||||
vstr d1, [dst, #40]
|
||||
vldr d1, [src, #56]
|
||||
vstr d0, [dst, #48]
|
||||
add src, src, #64
|
||||
vstr d1, [dst, #56]
|
||||
add dst, dst, #64
|
||||
bge 1b
|
||||
tst tmp2, #0x3f
|
||||
beq .Ldone
|
||||
|
||||
.Ltail63aligned: /* Count in tmp2. */
|
||||
and tmp1, tmp2, #0x38
|
||||
add dst, dst, tmp1
|
||||
add src, src, tmp1
|
||||
rsb tmp1, tmp1, #(56 - PC_OFFSET + INSN_SIZE)
|
||||
add pc, pc, tmp1
|
||||
|
||||
vldr d0, [src, #-56] /* 14 words to go. */
|
||||
vstr d0, [dst, #-56]
|
||||
vldr d0, [src, #-48] /* 12 words to go. */
|
||||
vstr d0, [dst, #-48]
|
||||
vldr d0, [src, #-40] /* 10 words to go. */
|
||||
vstr d0, [dst, #-40]
|
||||
vldr d0, [src, #-32] /* 8 words to go. */
|
||||
vstr d0, [dst, #-32]
|
||||
vldr d0, [src, #-24] /* 6 words to go. */
|
||||
vstr d0, [dst, #-24]
|
||||
vldr d0, [src, #-16] /* 4 words to go. */
|
||||
vstr d0, [dst, #-16]
|
||||
vldr d0, [src, #-8] /* 2 words to go. */
|
||||
vstr d0, [dst, #-8]
|
||||
#else
|
||||
sub src, src, #8
|
||||
sub dst, dst, #8
|
||||
1:
|
||||
ldrd A_l, A_h, [src, #8]
|
||||
strd A_l, A_h, [dst, #8]
|
||||
ldrd A_l, A_h, [src, #16]
|
||||
strd A_l, A_h, [dst, #16]
|
||||
ldrd A_l, A_h, [src, #24]
|
||||
strd A_l, A_h, [dst, #24]
|
||||
ldrd A_l, A_h, [src, #32]
|
||||
strd A_l, A_h, [dst, #32]
|
||||
ldrd A_l, A_h, [src, #40]
|
||||
strd A_l, A_h, [dst, #40]
|
||||
ldrd A_l, A_h, [src, #48]
|
||||
strd A_l, A_h, [dst, #48]
|
||||
ldrd A_l, A_h, [src, #56]
|
||||
strd A_l, A_h, [dst, #56]
|
||||
ldrd A_l, A_h, [src, #64]!
|
||||
strd A_l, A_h, [dst, #64]!
|
||||
subs tmp2, tmp2, #64
|
||||
bge 1b
|
||||
tst tmp2, #0x3f
|
||||
bne 1f
|
||||
ldr tmp2,[sp], #FRAME_SIZE
|
||||
bx lr
|
||||
1:
|
||||
add src, src, #8
|
||||
add dst, dst, #8
|
||||
|
||||
.Ltail63aligned: /* Count in tmp2. */
|
||||
/* Copy up to 7 d-words of data. Similar to Ltail63unaligned, but
|
||||
we know that the src and dest are 32-bit aligned so we can use
|
||||
LDRD/STRD to improve efficiency. */
|
||||
/* TMP2 is now negative, but we don't care about that. The bottom
|
||||
six bits still tell us how many bytes are left to copy. */
|
||||
|
||||
and tmp1, tmp2, #0x38
|
||||
add dst, dst, tmp1
|
||||
add src, src, tmp1
|
||||
rsb tmp1, tmp1, #(56 - PC_OFFSET + INSN_SIZE)
|
||||
add pc, pc, tmp1
|
||||
ldrd A_l, A_h, [src, #-56] /* 14 words to go. */
|
||||
strd A_l, A_h, [dst, #-56]
|
||||
ldrd A_l, A_h, [src, #-48] /* 12 words to go. */
|
||||
strd A_l, A_h, [dst, #-48]
|
||||
ldrd A_l, A_h, [src, #-40] /* 10 words to go. */
|
||||
strd A_l, A_h, [dst, #-40]
|
||||
ldrd A_l, A_h, [src, #-32] /* 8 words to go. */
|
||||
strd A_l, A_h, [dst, #-32]
|
||||
ldrd A_l, A_h, [src, #-24] /* 6 words to go. */
|
||||
strd A_l, A_h, [dst, #-24]
|
||||
ldrd A_l, A_h, [src, #-16] /* 4 words to go. */
|
||||
strd A_l, A_h, [dst, #-16]
|
||||
ldrd A_l, A_h, [src, #-8] /* 2 words to go. */
|
||||
strd A_l, A_h, [dst, #-8]
|
||||
|
||||
#endif
|
||||
tst tmp2, #4
|
||||
ldrne tmp1, [src], #4
|
||||
strne tmp1, [dst], #4
|
||||
lsls tmp2, tmp2, #31 /* Count (tmp2) now dead. */
|
||||
ldrhcs tmp1, [src], #2
|
||||
ldrbne tmp2, [src]
|
||||
strhcs tmp1, [dst], #2
|
||||
strbne tmp2, [dst]
|
||||
|
||||
.Ldone:
|
||||
ldr tmp2, [sp], #FRAME_SIZE
|
||||
bx lr
|
||||
|
||||
.Lcpy_body_long: /* Count in tmp2. */
|
||||
|
||||
/* Long copy. We know that there's at least (prefetch_lines * 64)
|
||||
bytes to go. */
|
||||
#ifdef USE_VFP
|
||||
/* Don't use PLD. Instead, read some data in advance of the current
|
||||
copy position into a register. This should act like a PLD
|
||||
operation but we won't have to repeat the transfer. */
|
||||
|
||||
vldr d3, [src, #0]
|
||||
vldr d4, [src, #64]
|
||||
vldr d5, [src, #128]
|
||||
vldr d6, [src, #192]
|
||||
vldr d7, [src, #256]
|
||||
|
||||
vldr d0, [src, #8]
|
||||
vldr d1, [src, #16]
|
||||
vldr d2, [src, #24]
|
||||
add src, src, #32
|
||||
|
||||
subs tmp2, tmp2, #prefetch_lines * 64 * 2
|
||||
blt 2f
|
||||
1:
|
||||
cpy_line_vfp d3, 0
|
||||
cpy_line_vfp d4, 64
|
||||
cpy_line_vfp d5, 128
|
||||
add dst, dst, #3 * 64
|
||||
add src, src, #3 * 64
|
||||
cpy_line_vfp d6, 0
|
||||
cpy_line_vfp d7, 64
|
||||
add dst, dst, #2 * 64
|
||||
add src, src, #2 * 64
|
||||
subs tmp2, tmp2, #prefetch_lines * 64
|
||||
bge 1b
|
||||
|
||||
2:
|
||||
cpy_tail_vfp d3, 0
|
||||
cpy_tail_vfp d4, 64
|
||||
cpy_tail_vfp d5, 128
|
||||
add src, src, #3 * 64
|
||||
add dst, dst, #3 * 64
|
||||
cpy_tail_vfp d6, 0
|
||||
vstr d7, [dst, #64]
|
||||
vldr d7, [src, #64]
|
||||
vstr d0, [dst, #64 + 8]
|
||||
vldr d0, [src, #64 + 8]
|
||||
vstr d1, [dst, #64 + 16]
|
||||
vldr d1, [src, #64 + 16]
|
||||
vstr d2, [dst, #64 + 24]
|
||||
vldr d2, [src, #64 + 24]
|
||||
vstr d7, [dst, #64 + 32]
|
||||
add src, src, #96
|
||||
vstr d0, [dst, #64 + 40]
|
||||
vstr d1, [dst, #64 + 48]
|
||||
vstr d2, [dst, #64 + 56]
|
||||
add dst, dst, #128
|
||||
add tmp2, tmp2, #prefetch_lines * 64
|
||||
b .Lcpy_body_medium
|
||||
#else
|
||||
/* Long copy. Use an SMS style loop to maximize the I/O
|
||||
bandwidth of the core. We don't have enough spare registers
|
||||
to synthesise prefetching, so use PLD operations. */
|
||||
/* Pre-bias src and dst. */
|
||||
sub src, src, #8
|
||||
sub dst, dst, #8
|
||||
pld [src, #8]
|
||||
pld [src, #72]
|
||||
subs tmp2, tmp2, #64
|
||||
pld [src, #136]
|
||||
ldrd A_l, A_h, [src, #8]
|
||||
strd B_l, B_h, [sp, #8]
|
||||
ldrd B_l, B_h, [src, #16]
|
||||
strd C_l, C_h, [sp, #16]
|
||||
ldrd C_l, C_h, [src, #24]
|
||||
strd D_l, D_h, [sp, #24]
|
||||
pld [src, #200]
|
||||
ldrd D_l, D_h, [src, #32]!
|
||||
b 1f
|
||||
.p2align 6
|
||||
2:
|
||||
pld [src, #232]
|
||||
strd A_l, A_h, [dst, #40]
|
||||
ldrd A_l, A_h, [src, #40]
|
||||
strd B_l, B_h, [dst, #48]
|
||||
ldrd B_l, B_h, [src, #48]
|
||||
strd C_l, C_h, [dst, #56]
|
||||
ldrd C_l, C_h, [src, #56]
|
||||
strd D_l, D_h, [dst, #64]!
|
||||
ldrd D_l, D_h, [src, #64]!
|
||||
subs tmp2, tmp2, #64
|
||||
1:
|
||||
strd A_l, A_h, [dst, #8]
|
||||
ldrd A_l, A_h, [src, #8]
|
||||
strd B_l, B_h, [dst, #16]
|
||||
ldrd B_l, B_h, [src, #16]
|
||||
strd C_l, C_h, [dst, #24]
|
||||
ldrd C_l, C_h, [src, #24]
|
||||
strd D_l, D_h, [dst, #32]
|
||||
ldrd D_l, D_h, [src, #32]
|
||||
bcs 2b
|
||||
/* Save the remaining bytes and restore the callee-saved regs. */
|
||||
strd A_l, A_h, [dst, #40]
|
||||
add src, src, #40
|
||||
strd B_l, B_h, [dst, #48]
|
||||
ldrd B_l, B_h, [sp, #8]
|
||||
strd C_l, C_h, [dst, #56]
|
||||
ldrd C_l, C_h, [sp, #16]
|
||||
strd D_l, D_h, [dst, #64]
|
||||
ldrd D_l, D_h, [sp, #24]
|
||||
add dst, dst, #72
|
||||
tst tmp2, #0x3f
|
||||
bne .Ltail63aligned
|
||||
ldr tmp2, [sp], #FRAME_SIZE
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
.Lcpy_notaligned:
|
||||
pld [src]
|
||||
pld [src, #64]
|
||||
/* There's at least 64 bytes to copy, but there is no mutual
|
||||
alignment. */
|
||||
/* Bring DST to 64-bit alignment. */
|
||||
lsls tmp2, dst, #29
|
||||
pld [src, #(2 * 64)]
|
||||
beq 1f
|
||||
rsbs tmp2, tmp2, #0
|
||||
sub count, count, tmp2, lsr #29
|
||||
ldrmi tmp1, [src], #4
|
||||
strmi tmp1, [dst], #4
|
||||
lsls tmp2, tmp2, #2
|
||||
ldrbne tmp1, [src], #1
|
||||
ldrhcs tmp2, [src], #2
|
||||
strbne tmp1, [dst], #1
|
||||
strhcs tmp2, [dst], #2
|
||||
1:
|
||||
pld [src, #(3 * 64)]
|
||||
subs count, count, #64
|
||||
ldrmi tmp2, [sp], #FRAME_SIZE
|
||||
bmi .Ltail63unaligned
|
||||
pld [src, #(4 * 64)]
|
||||
|
||||
#ifdef USE_NEON
|
||||
vld1.8 {d0-d3}, [src]!
|
||||
vld1.8 {d4-d7}, [src]!
|
||||
subs count, count, #64
|
||||
bmi 2f
|
||||
1:
|
||||
pld [src, #(4 * 64)]
|
||||
vst1.8 {d0-d3}, [ALIGN (dst, 64)]!
|
||||
vld1.8 {d0-d3}, [src]!
|
||||
vst1.8 {d4-d7}, [ALIGN (dst, 64)]!
|
||||
vld1.8 {d4-d7}, [src]!
|
||||
subs count, count, #64
|
||||
bpl 1b
|
||||
2:
|
||||
vst1.8 {d0-d3}, [ALIGN (dst, 64)]!
|
||||
vst1.8 {d4-d7}, [ALIGN (dst, 64)]!
|
||||
ands count, count, #0x3f
|
||||
#else
|
||||
/* Use an SMS style loop to maximize the I/O bandwidth. */
|
||||
sub src, src, #4
|
||||
sub dst, dst, #8
|
||||
subs tmp2, count, #64 /* Use tmp2 for count. */
|
||||
ldr A_l, [src, #4]
|
||||
ldr A_h, [src, #8]
|
||||
strd B_l, B_h, [sp, #8]
|
||||
ldr B_l, [src, #12]
|
||||
ldr B_h, [src, #16]
|
||||
strd C_l, C_h, [sp, #16]
|
||||
ldr C_l, [src, #20]
|
||||
ldr C_h, [src, #24]
|
||||
strd D_l, D_h, [sp, #24]
|
||||
ldr D_l, [src, #28]
|
||||
ldr D_h, [src, #32]!
|
||||
b 1f
|
||||
.p2align 6
|
||||
2:
|
||||
pld [src, #(5 * 64) - (32 - 4)]
|
||||
strd A_l, A_h, [dst, #40]
|
||||
ldr A_l, [src, #36]
|
||||
ldr A_h, [src, #40]
|
||||
strd B_l, B_h, [dst, #48]
|
||||
ldr B_l, [src, #44]
|
||||
ldr B_h, [src, #48]
|
||||
strd C_l, C_h, [dst, #56]
|
||||
ldr C_l, [src, #52]
|
||||
ldr C_h, [src, #56]
|
||||
strd D_l, D_h, [dst, #64]!
|
||||
ldr D_l, [src, #60]
|
||||
ldr D_h, [src, #64]!
|
||||
subs tmp2, tmp2, #64
|
||||
1:
|
||||
strd A_l, A_h, [dst, #8]
|
||||
ldr A_l, [src, #4]
|
||||
ldr A_h, [src, #8]
|
||||
strd B_l, B_h, [dst, #16]
|
||||
ldr B_l, [src, #12]
|
||||
ldr B_h, [src, #16]
|
||||
strd C_l, C_h, [dst, #24]
|
||||
ldr C_l, [src, #20]
|
||||
ldr C_h, [src, #24]
|
||||
strd D_l, D_h, [dst, #32]
|
||||
ldr D_l, [src, #28]
|
||||
ldr D_h, [src, #32]
|
||||
bcs 2b
|
||||
|
||||
/* Save the remaining bytes and restore the callee-saved regs. */
|
||||
strd A_l, A_h, [dst, #40]
|
||||
add src, src, #36
|
||||
strd B_l, B_h, [dst, #48]
|
||||
ldrd B_l, B_h, [sp, #8]
|
||||
strd C_l, C_h, [dst, #56]
|
||||
ldrd C_l, C_h, [sp, #16]
|
||||
strd D_l, D_h, [dst, #64]
|
||||
ldrd D_l, D_h, [sp, #24]
|
||||
add dst, dst, #72
|
||||
ands count, tmp2, #0x3f
|
||||
#endif
|
||||
ldr tmp2, [sp], #FRAME_SIZE
|
||||
bne .Ltail63unaligned
|
||||
bx lr
|
||||
END(memcpy)
|
||||
@@ -39,6 +39,7 @@
|
||||
*/
|
||||
|
||||
ENTRY(tgkill)
|
||||
.save {r4-r7, ip, lr}
|
||||
stmfd sp!, {r4-r7, ip, lr}
|
||||
ldr r7, =__NR_tgkill
|
||||
swi #0
|
||||
|
||||
@@ -24,81 +24,110 @@
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2013 ARM Ltd
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. The name of the company may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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.
|
||||
*/
|
||||
|
||||
/* Assumes neon instructions and a cache line size of 64 bytes. */
|
||||
/* Prototype: void *memcpy (void *dst, const void *src, size_t count). */
|
||||
|
||||
// This version is tuned for the Cortex-A15 processor.
|
||||
|
||||
#include <machine/cpu-features.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
/*
|
||||
* This code assumes it is running on a processor that supports all arm v7
|
||||
* instructions, that supports neon instructions, and that has a 64 byte
|
||||
* cache line.
|
||||
*/
|
||||
|
||||
.text
|
||||
.syntax unified
|
||||
.fpu neon
|
||||
|
||||
#define CACHE_LINE_SIZE 64
|
||||
|
||||
ENTRY(memcpy)
|
||||
// Assumes that n >= 0, and dst, src are valid pointers.
|
||||
// For any sizes less than 832 use the neon code that doesn't
|
||||
// care about the src alignment. This avoids any checks
|
||||
// for src alignment, and offers the best improvement since
|
||||
// smaller sized copies are dominated by the overhead of
|
||||
// the pre and post main loop.
|
||||
// For larger copies, if src and dst cannot both be aligned to
|
||||
// word boundaries, use the neon code.
|
||||
// For all other copies, align dst to a double word boundary
|
||||
// and copy using LDRD/STRD instructions.
|
||||
|
||||
// Save registers (r0 holds the return value):
|
||||
// optimized push {r0, lr}.
|
||||
.save {r0, lr}
|
||||
/* start preloading as early as possible */
|
||||
pld [r1, #(CACHE_LINE_SIZE*0)]
|
||||
stmfd sp!, {r0, lr}
|
||||
pld [r1, #(CACHE_LINE_SIZE*1)]
|
||||
pld [r1, #(CACHE_LINE_SIZE*16)]
|
||||
push {r0, lr}
|
||||
|
||||
/* do we have at least 16-bytes to copy (needed for alignment below) */
|
||||
cmp r2, #16
|
||||
blo 5f
|
||||
blo copy_less_than_16_unknown_align
|
||||
|
||||
/* align destination to cache-line for the write-buffer */
|
||||
cmp r2, #832
|
||||
bge check_alignment
|
||||
|
||||
copy_unknown_alignment:
|
||||
// Unknown alignment of src and dst.
|
||||
// Assumes that the first few bytes have already been prefetched.
|
||||
|
||||
// Align destination to 128 bits. The mainloop store instructions
|
||||
// require this alignment or they will throw an exception.
|
||||
rsb r3, r0, #0
|
||||
ands r3, r3, #0xF
|
||||
beq 0f
|
||||
beq 2f
|
||||
|
||||
/* copy up to 15-bytes (count in r3) */
|
||||
// Copy up to 15 bytes (count in r3).
|
||||
sub r2, r2, r3
|
||||
movs ip, r3, lsl #31
|
||||
ldrmib lr, [r1], #1
|
||||
strmib lr, [r0], #1
|
||||
ldrcsb ip, [r1], #1
|
||||
ldrcsb lr, [r1], #1
|
||||
strcsb ip, [r0], #1
|
||||
strcsb lr, [r0], #1
|
||||
|
||||
itt mi
|
||||
ldrbmi lr, [r1], #1
|
||||
strbmi lr, [r0], #1
|
||||
itttt cs
|
||||
ldrbcs ip, [r1], #1
|
||||
ldrbcs lr, [r1], #1
|
||||
strbcs ip, [r0], #1
|
||||
strbcs lr, [r0], #1
|
||||
|
||||
movs ip, r3, lsl #29
|
||||
bge 1f
|
||||
// copies 4 bytes, destination 32-bits aligned
|
||||
// Copies 4 bytes, dst 32 bits aligned before, at least 64 bits after.
|
||||
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
|
||||
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0, :32]!
|
||||
1: bcc 2f
|
||||
// copies 8 bytes, destination 64-bits aligned
|
||||
// Copies 8 bytes, dst 64 bits aligned before, at least 128 bits after.
|
||||
vld1.8 {d0}, [r1]!
|
||||
vst1.8 {d0}, [r0, :64]!
|
||||
2:
|
||||
|
||||
0: /* preload immediately the next cache line, which we may need */
|
||||
pld [r1, #(CACHE_LINE_SIZE*0)]
|
||||
pld [r1, #(CACHE_LINE_SIZE*1)]
|
||||
|
||||
/* make sure we have at least 64 bytes to copy */
|
||||
2: // Make sure we have at least 64 bytes to copy.
|
||||
subs r2, r2, #64
|
||||
blo 2f
|
||||
|
||||
/* Preload all the cache lines we need.
|
||||
* NOTE: The number of pld below depends on CACHE_LINE_SIZE,
|
||||
* ideally we would increase the distance in the main loop to
|
||||
* avoid the goofy code below. In practice this doesn't seem to make
|
||||
* a big difference.
|
||||
* NOTE: The value CACHE_LINE_SIZE * 4 was chosen through
|
||||
* experimentation.
|
||||
*/
|
||||
pld [r1, #(CACHE_LINE_SIZE*2)]
|
||||
pld [r1, #(CACHE_LINE_SIZE*3)]
|
||||
pld [r1, #(CACHE_LINE_SIZE*4)]
|
||||
|
||||
1: /* The main loop copies 64 bytes at a time */
|
||||
1: // The main loop copies 64 bytes at a time.
|
||||
vld1.8 {d0 - d3}, [r1]!
|
||||
vld1.8 {d4 - d7}, [r1]!
|
||||
pld [r1, #(CACHE_LINE_SIZE*4)]
|
||||
@@ -107,25 +136,24 @@ ENTRY(memcpy)
|
||||
vst1.8 {d4 - d7}, [r0, :128]!
|
||||
bhs 1b
|
||||
|
||||
2: /* fix-up the remaining count and make sure we have >= 32 bytes left */
|
||||
add r2, r2, #64
|
||||
subs r2, r2, #32
|
||||
blo 4f
|
||||
2: // Fix-up the remaining count and make sure we have >= 32 bytes left.
|
||||
adds r2, r2, #32
|
||||
blo 3f
|
||||
|
||||
3: /* 32 bytes at a time. These cache lines were already preloaded */
|
||||
// 32 bytes. These cache lines were already preloaded.
|
||||
vld1.8 {d0 - d3}, [r1]!
|
||||
subs r2, r2, #32
|
||||
sub r2, r2, #32
|
||||
vst1.8 {d0 - d3}, [r0, :128]!
|
||||
bhs 3b
|
||||
4: /* less than 32 left */
|
||||
3: // Less than 32 left.
|
||||
add r2, r2, #32
|
||||
tst r2, #0x10
|
||||
beq 5f
|
||||
// copies 16 bytes, 128-bits aligned
|
||||
beq copy_less_than_16_unknown_align
|
||||
// Copies 16 bytes, destination 128 bits aligned.
|
||||
vld1.8 {d0, d1}, [r1]!
|
||||
vst1.8 {d0, d1}, [r0, :128]!
|
||||
|
||||
5: /* copy up to 15-bytes (count in r2) */
|
||||
copy_less_than_16_unknown_align:
|
||||
// Copy up to 15 bytes (count in r2).
|
||||
movs ip, r2, lsl #29
|
||||
bcc 1f
|
||||
vld1.8 {d0}, [r1]!
|
||||
@@ -133,14 +161,164 @@ ENTRY(memcpy)
|
||||
1: bge 2f
|
||||
vld4.8 {d0[0], d1[0], d2[0], d3[0]}, [r1]!
|
||||
vst4.8 {d0[0], d1[0], d2[0], d3[0]}, [r0]!
|
||||
2: movs ip, r2, lsl #31
|
||||
ldrmib r3, [r1], #1
|
||||
ldrcsb ip, [r1], #1
|
||||
ldrcsb lr, [r1], #1
|
||||
strmib r3, [r0], #1
|
||||
strcsb ip, [r0], #1
|
||||
strcsb lr, [r0], #1
|
||||
|
||||
ldmfd sp!, {r0, lr}
|
||||
bx lr
|
||||
2: // Copy 0 to 4 bytes.
|
||||
lsls r2, r2, #31
|
||||
itt ne
|
||||
ldrbne lr, [r1], #1
|
||||
strbne lr, [r0], #1
|
||||
itttt cs
|
||||
ldrbcs ip, [r1], #1
|
||||
ldrbcs lr, [r1]
|
||||
strbcs ip, [r0], #1
|
||||
strbcs lr, [r0]
|
||||
|
||||
pop {r0, pc}
|
||||
|
||||
check_alignment:
|
||||
// If src and dst cannot both be aligned to a word boundary,
|
||||
// use the unaligned copy version.
|
||||
eor r3, r0, r1
|
||||
ands r3, r3, #0x3
|
||||
bne copy_unknown_alignment
|
||||
|
||||
// To try and improve performance, stack layout changed,
|
||||
// i.e., not keeping the stack looking like users expect
|
||||
// (highest numbered register at highest address).
|
||||
// TODO: Add debug frame directives.
|
||||
// We don't need exception unwind directives, because the code below
|
||||
// does not throw any exceptions and does not call any other functions.
|
||||
// Generally, newlib functions like this lack debug information for
|
||||
// assembler source.
|
||||
.save {r4, r5}
|
||||
strd r4, r5, [sp, #-8]!
|
||||
.save {r6, r7}
|
||||
strd r6, r7, [sp, #-8]!
|
||||
.save {r8, r9}
|
||||
strd r8, r9, [sp, #-8]!
|
||||
|
||||
// Optimized for already aligned dst code.
|
||||
ands ip, r0, #3
|
||||
bne dst_not_word_aligned
|
||||
|
||||
word_aligned:
|
||||
// Align the destination buffer to 8 bytes, to make sure double
|
||||
// loads and stores don't cross a cache line boundary,
|
||||
// as they are then more expensive even if the data is in the cache
|
||||
// (require two load/store issue cycles instead of one).
|
||||
// If only one of the buffers is not 8 bytes aligned,
|
||||
// then it's more important to align dst than src,
|
||||
// because there is more penalty for stores
|
||||
// than loads that cross a cacheline boundary.
|
||||
// This check and realignment are only done if there is >= 832
|
||||
// bytes to copy.
|
||||
|
||||
// Dst is word aligned, but check if it is already double word aligned.
|
||||
ands r3, r0, #4
|
||||
beq 1f
|
||||
ldr r3, [r1], #4
|
||||
str r3, [r0], #4
|
||||
sub r2, #4
|
||||
|
||||
1: // Can only get here if > 64 bytes to copy, so don't do check r2.
|
||||
sub r2, #64
|
||||
|
||||
2: // Every loop iteration copies 64 bytes.
|
||||
.irp offset, #0, #8, #16, #24, #32
|
||||
ldrd r4, r5, [r1, \offset]
|
||||
strd r4, r5, [r0, \offset]
|
||||
.endr
|
||||
|
||||
ldrd r4, r5, [r1, #40]
|
||||
ldrd r6, r7, [r1, #48]
|
||||
ldrd r8, r9, [r1, #56]
|
||||
|
||||
// Keep the pld as far from the next load as possible.
|
||||
// The amount to prefetch was determined experimentally using
|
||||
// large sizes, and verifying the prefetch size does not affect
|
||||
// the smaller copies too much.
|
||||
// WARNING: If the ldrd and strd instructions get too far away
|
||||
// from each other, performance suffers. Three loads
|
||||
// in a row is the best tradeoff.
|
||||
pld [r1, #(CACHE_LINE_SIZE*16)]
|
||||
strd r4, r5, [r0, #40]
|
||||
strd r6, r7, [r0, #48]
|
||||
strd r8, r9, [r0, #56]
|
||||
|
||||
add r0, r0, #64
|
||||
add r1, r1, #64
|
||||
subs r2, r2, #64
|
||||
bge 2b
|
||||
|
||||
// Fix-up the remaining count and make sure we have >= 32 bytes left.
|
||||
adds r2, r2, #32
|
||||
blo 4f
|
||||
|
||||
// Copy 32 bytes. These cache lines were already preloaded.
|
||||
.irp offset, #0, #8, #16, #24
|
||||
ldrd r4, r5, [r1, \offset]
|
||||
strd r4, r5, [r0, \offset]
|
||||
.endr
|
||||
add r1, r1, #32
|
||||
add r0, r0, #32
|
||||
sub r2, r2, #32
|
||||
4: // Less than 32 left.
|
||||
add r2, r2, #32
|
||||
tst r2, #0x10
|
||||
beq 5f
|
||||
// Copy 16 bytes.
|
||||
.irp offset, #0, #8
|
||||
ldrd r4, r5, [r1, \offset]
|
||||
strd r4, r5, [r0, \offset]
|
||||
.endr
|
||||
add r1, r1, #16
|
||||
add r0, r0, #16
|
||||
|
||||
5: // Copy up to 15 bytes (count in r2).
|
||||
movs ip, r2, lsl #29
|
||||
bcc 1f
|
||||
// Copy 8 bytes.
|
||||
ldrd r4, r5, [r1], #8
|
||||
strd r4, r5, [r0], #8
|
||||
1: bge 2f
|
||||
// Copy 4 bytes.
|
||||
ldr r4, [r1], #4
|
||||
str r4, [r0], #4
|
||||
2: // Copy 0 to 4 bytes.
|
||||
lsls r2, r2, #31
|
||||
itt ne
|
||||
ldrbne lr, [r1], #1
|
||||
strbne lr, [r0], #1
|
||||
itttt cs
|
||||
ldrbcs ip, [r1], #1
|
||||
ldrbcs lr, [r1]
|
||||
strbcs ip, [r0], #1
|
||||
strbcs lr, [r0]
|
||||
|
||||
// Restore registers: optimized pop {r0, pc}
|
||||
ldrd r8, r9, [sp], #8
|
||||
ldrd r6, r7, [sp], #8
|
||||
ldrd r4, r5, [sp], #8
|
||||
pop {r0, pc}
|
||||
|
||||
dst_not_word_aligned:
|
||||
// Align dst to word.
|
||||
rsb ip, ip, #4
|
||||
cmp ip, #2
|
||||
|
||||
itt gt
|
||||
ldrbgt lr, [r1], #1
|
||||
strbgt lr, [r0], #1
|
||||
|
||||
itt ge
|
||||
ldrbge lr, [r1], #1
|
||||
strbge lr, [r0], #1
|
||||
|
||||
ldrb lr, [r1], #1
|
||||
strb lr, [r0], #1
|
||||
|
||||
sub r2, r2, ip
|
||||
|
||||
// Src is guaranteed to be at least word aligned by this point.
|
||||
b word_aligned
|
||||
END(memcpy)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -36,6 +36,7 @@
|
||||
*/
|
||||
|
||||
.fpu neon
|
||||
.syntax unified
|
||||
|
||||
ENTRY(bzero)
|
||||
mov r2, r1
|
||||
@@ -47,60 +48,117 @@ ENTRY(memset)
|
||||
.save {r0}
|
||||
stmfd sp!, {r0}
|
||||
|
||||
vdup.8 q0, r1
|
||||
|
||||
/* do we have at least 16-bytes to write (needed for alignment below) */
|
||||
// The new algorithm is slower for copies < 16 so use the old
|
||||
// neon code in that case.
|
||||
cmp r2, #16
|
||||
blo 3f
|
||||
blo set_less_than_16_unknown_align
|
||||
|
||||
/* align destination to 16 bytes for the write-buffer */
|
||||
rsb r3, r0, #0
|
||||
ands r3, r3, #0xF
|
||||
beq 2f
|
||||
// Use strd which requires an even and odd register so move the
|
||||
// values so that:
|
||||
// r0 and r1 contain the memset value
|
||||
// r2 is the number of bytes to set
|
||||
// r3 is the destination pointer
|
||||
mov r3, r0
|
||||
|
||||
/* write up to 15-bytes (count in r3) */
|
||||
sub r2, r2, r3
|
||||
movs ip, r3, lsl #31
|
||||
strmib r1, [r0], #1
|
||||
strcsb r1, [r0], #1
|
||||
strcsb r1, [r0], #1
|
||||
movs ip, r3, lsl #29
|
||||
bge 1f
|
||||
// Copy the byte value in every byte of r1.
|
||||
mov r1, r1, lsl #24
|
||||
orr r1, r1, r1, lsr #8
|
||||
orr r1, r1, r1, lsr #16
|
||||
|
||||
// writes 4 bytes, 32-bits aligned
|
||||
vst1.32 {d0[0]}, [r0, :32]!
|
||||
1: bcc 2f
|
||||
check_alignment:
|
||||
// Align destination to a double word to avoid the strd crossing
|
||||
// a cache line boundary.
|
||||
ands ip, r3, #7
|
||||
bne do_double_word_align
|
||||
|
||||
// writes 8 bytes, 64-bits aligned
|
||||
vst1.8 {d0}, [r0, :64]!
|
||||
2:
|
||||
/* make sure we have at least 32 bytes to write */
|
||||
subs r2, r2, #32
|
||||
blo 2f
|
||||
vmov q1, q0
|
||||
double_word_aligned:
|
||||
mov r0, r1
|
||||
|
||||
1: /* The main loop writes 32 bytes at a time */
|
||||
subs r2, r2, #32
|
||||
vst1.8 {d0 - d3}, [r0, :128]!
|
||||
bhs 1b
|
||||
subs r2, #64
|
||||
blo set_less_than_64
|
||||
|
||||
2: /* less than 32 left */
|
||||
add r2, r2, #32
|
||||
tst r2, #0x10
|
||||
beq 3f
|
||||
1: // Main loop sets 64 bytes at a time.
|
||||
.irp offset, #0, #8, #16, #24, #32, #40, #48, #56
|
||||
strd r0, r1, [r3, \offset]
|
||||
.endr
|
||||
|
||||
// writes 16 bytes, 128-bits aligned
|
||||
vst1.8 {d0, d1}, [r0, :128]!
|
||||
3: /* write up to 15-bytes (count in r2) */
|
||||
add r3, #64
|
||||
subs r2, #64
|
||||
bge 1b
|
||||
|
||||
set_less_than_64:
|
||||
// Restore r2 to the count of bytes left to set.
|
||||
add r2, #64
|
||||
lsls ip, r2, #27
|
||||
bcc set_less_than_32
|
||||
// Set 32 bytes.
|
||||
.irp offset, #0, #8, #16, #24
|
||||
strd r0, r1, [r3, \offset]
|
||||
.endr
|
||||
add r3, #32
|
||||
|
||||
set_less_than_32:
|
||||
bpl set_less_than_16
|
||||
// Set 16 bytes.
|
||||
.irp offset, #0, #8
|
||||
strd r0, r1, [r3, \offset]
|
||||
.endr
|
||||
add r3, #16
|
||||
|
||||
set_less_than_16:
|
||||
// Less than 16 bytes to set.
|
||||
lsls ip, r2, #29
|
||||
bcc set_less_than_8
|
||||
|
||||
// Set 8 bytes.
|
||||
strd r0, r1, [r3], #8
|
||||
|
||||
set_less_than_8:
|
||||
bpl set_less_than_4
|
||||
// Set 4 bytes
|
||||
str r1, [r3], #4
|
||||
|
||||
set_less_than_4:
|
||||
lsls ip, r2, #31
|
||||
it ne
|
||||
strbne r1, [r3], #1
|
||||
itt cs
|
||||
strbcs r1, [r3], #1
|
||||
strbcs r1, [r3]
|
||||
|
||||
ldmfd sp!, {r0}
|
||||
bx lr
|
||||
|
||||
do_double_word_align:
|
||||
rsb ip, ip, #8
|
||||
sub r2, r2, ip
|
||||
movs r0, ip, lsl #31
|
||||
it mi
|
||||
strbmi r1, [r3], #1
|
||||
itt cs
|
||||
strbcs r1, [r3], #1
|
||||
strbcs r1, [r3], #1
|
||||
|
||||
// Dst is at least word aligned by this point.
|
||||
cmp ip, #4
|
||||
blo double_word_aligned
|
||||
str r1, [r3], #4
|
||||
b double_word_aligned
|
||||
|
||||
set_less_than_16_unknown_align:
|
||||
// Set up to 15 bytes.
|
||||
vdup.8 d0, r1
|
||||
movs ip, r2, lsl #29
|
||||
bcc 1f
|
||||
vst1.8 {d0}, [r0]!
|
||||
1: bge 2f
|
||||
vst1.32 {d0[0]}, [r0]!
|
||||
2: movs ip, r2, lsl #31
|
||||
strmib r1, [r0], #1
|
||||
strcsb r1, [r0], #1
|
||||
strcsb r1, [r0], #1
|
||||
it mi
|
||||
strbmi r1, [r0], #1
|
||||
itt cs
|
||||
strbcs r1, [r0], #1
|
||||
strbcs r1, [r0], #1
|
||||
ldmfd sp!, {r0}
|
||||
bx lr
|
||||
END(memset)
|
||||
|
||||
151
libc/arch-arm/cortex-a15/bionic/strlen.S
Normal file
151
libc/arch-arm/cortex-a15/bionic/strlen.S
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2013 ARM Ltd
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. The name of the company may not be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 <machine/asm.h>
|
||||
|
||||
.syntax unified
|
||||
|
||||
.thumb
|
||||
.thumb_func
|
||||
|
||||
ENTRY(strlen)
|
||||
pld [r1, #128]
|
||||
mov r1, r0
|
||||
|
||||
rsb r3, r0, #0
|
||||
ands r3, r3, #7
|
||||
beq mainloop
|
||||
|
||||
// Align to a double word (64 bits).
|
||||
ands ip, r3, #1
|
||||
beq align_to_32
|
||||
|
||||
ldrb r2, [r1], #1
|
||||
cmp r2, #0
|
||||
beq update_count_and_return
|
||||
|
||||
align_to_32:
|
||||
ands ip, r3, #2
|
||||
beq align_to_64
|
||||
|
||||
ldrb r2, [r1], #1
|
||||
cmp r2, #0
|
||||
beq update_count_and_return
|
||||
ldrb r2, [r1], #1
|
||||
cmp r2, #0
|
||||
beq update_count_and_return
|
||||
|
||||
align_to_64:
|
||||
ands ip, r3, #4
|
||||
beq mainloop
|
||||
ldr r3, [r1], #4
|
||||
|
||||
sub ip, r3, #0x01010101
|
||||
bic ip, ip, r3
|
||||
ands ip, ip, #0x80808080
|
||||
bne zero_in_second_register
|
||||
|
||||
mainloop:
|
||||
ldrd r2, r3, [r1], #8
|
||||
|
||||
pld [r1, #64]
|
||||
|
||||
sub ip, r2, #0x01010101
|
||||
bic ip, ip, r2
|
||||
ands ip, ip, #0x80808080
|
||||
bne zero_in_first_register
|
||||
|
||||
sub ip, r3, #0x01010101
|
||||
bic ip, ip, r3
|
||||
ands ip, ip, #0x80808080
|
||||
bne zero_in_second_register
|
||||
b mainloop
|
||||
|
||||
zero_in_first_register:
|
||||
sub r1, r1, #4
|
||||
|
||||
zero_in_second_register:
|
||||
sub r0, r1, r0
|
||||
|
||||
// Check for zero in byte 0.
|
||||
ands r1, ip, #0x80
|
||||
beq check_byte1
|
||||
|
||||
sub r0, r0, #4
|
||||
bx lr
|
||||
|
||||
check_byte1:
|
||||
// Check for zero in byte 1.
|
||||
ands r1, ip, #0x8000
|
||||
beq check_byte2
|
||||
|
||||
sub r0, r0, #3
|
||||
bx lr
|
||||
|
||||
check_byte2:
|
||||
// Check for zero in byte 2.
|
||||
ands r1, ip, #0x800000
|
||||
beq return
|
||||
|
||||
sub r0, r0, #2
|
||||
bx lr
|
||||
|
||||
update_count_and_return:
|
||||
sub r0, r1, r0
|
||||
|
||||
return:
|
||||
sub r0, r0, #1
|
||||
bx lr
|
||||
END(strlen)
|
||||
@@ -1,5 +1,6 @@
|
||||
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/cortex-a15/bionic/memcpy.S)
|
||||
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/cortex-a15/bionic/memset.S)
|
||||
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/cortex-a15/bionic/strcmp.S)
|
||||
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/cortex-a15/bionic/strlen.S)
|
||||
|
||||
include bionic/libc/arch-arm/generic/generic.mk
|
||||
|
||||
1
libc/arch-arm/cortex-a8/cortex-a8.mk
Normal file
1
libc/arch-arm/cortex-a8/cortex-a8.mk
Normal file
@@ -0,0 +1 @@
|
||||
include bionic/libc/arch-arm/cortex-a15/cortex-a15.mk
|
||||
@@ -1,5 +1,7 @@
|
||||
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/cortex-a9/bionic/memcpy.S)
|
||||
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/cortex-a9/bionic/memset.S)
|
||||
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/cortex-a9/bionic/strcmp.S)
|
||||
# Use cortex-a15 version of strlen.
|
||||
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/cortex-a15/bionic/strlen.S)
|
||||
|
||||
include bionic/libc/arch-arm/generic/generic.mk
|
||||
|
||||
@@ -60,52 +60,60 @@ size_t strlen(const char *s)
|
||||
// We need to process 32 bytes per loop to schedule PLD properly
|
||||
// and achieve the maximum bus speed.
|
||||
asm(
|
||||
"ldr %[v], [ %[s] ], #4 \n"
|
||||
"ldr %[v], [%[s]], #4 \n"
|
||||
"sub %[l], %[l], %[s] \n"
|
||||
"0: \n"
|
||||
#if __ARM_HAVE_PLD
|
||||
"pld [ %[s], #64 ] \n"
|
||||
"pld [%[s], #64] \n"
|
||||
#endif
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
#if !defined(__OPTIMIZE_SIZE__)
|
||||
"bne 1f \n"
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
"bne 1f \n"
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
"bne 1f \n"
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
"bne 1f \n"
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
"bne 1f \n"
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
"bne 1f \n"
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
"bne 1f \n"
|
||||
"sub %[t], %[v], %[mask], lsr #7\n"
|
||||
"and %[t], %[t], %[mask] \n"
|
||||
"bics %[t], %[t], %[v] \n"
|
||||
"ldreq %[v], [ %[s] ], #4 \n"
|
||||
"it eq \n"
|
||||
"ldreq %[v], [%[s]], #4 \n"
|
||||
#endif
|
||||
"beq 0b \n"
|
||||
"1: \n"
|
||||
@@ -117,6 +125,7 @@ size_t strlen(const char *s)
|
||||
"beq 2f \n"
|
||||
"add %[l], %[l], #1 \n"
|
||||
"tst %[v], #0xFF0000 \n"
|
||||
"it ne \n"
|
||||
"addne %[l], %[l], #1 \n"
|
||||
"2: \n"
|
||||
: [l]"=&r"(l), [v]"=&r"(v), [t]"=&r"(t), [s]"=&r"(u.b)
|
||||
@@ -1,3 +1,4 @@
|
||||
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/generic/bionic/memcpy.S)
|
||||
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/generic/bionic/memset.S)
|
||||
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/generic/bionic/strcmp.S)
|
||||
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/generic/bionic/strlen.c)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
$(call libc-add-cpu-variant-src,MEMCPY,arch-arm/krait/bionic/memcpy.S)
|
||||
$(call libc-add-cpu-variant-src,MEMSET,arch-arm/krait/bionic/memset.S)
|
||||
$(call libc-add-cpu-variant-src,STRCMP,arch-arm/krait/bionic/strcmp.S)
|
||||
# Use cortex-a15 version of strlen.
|
||||
$(call libc-add-cpu-variant-src,STRLEN,arch-arm/cortex-a15/bionic/strlen.S)
|
||||
|
||||
include bionic/libc/arch-arm/generic/generic.mk
|
||||
|
||||
@@ -126,6 +126,8 @@ syscall_src += arch-arm/syscalls/removexattr.S
|
||||
syscall_src += arch-arm/syscalls/lremovexattr.S
|
||||
syscall_src += arch-arm/syscalls/__statfs64.S
|
||||
syscall_src += arch-arm/syscalls/unshare.S
|
||||
syscall_src += arch-arm/syscalls/swapon.S
|
||||
syscall_src += arch-arm/syscalls/swapoff.S
|
||||
syscall_src += arch-arm/syscalls/pause.S
|
||||
syscall_src += arch-arm/syscalls/gettimeofday.S
|
||||
syscall_src += arch-arm/syscalls/settimeofday.S
|
||||
@@ -144,6 +146,9 @@ syscall_src += arch-arm/syscalls/__timer_getoverrun.S
|
||||
syscall_src += arch-arm/syscalls/__timer_delete.S
|
||||
syscall_src += arch-arm/syscalls/utimes.S
|
||||
syscall_src += arch-arm/syscalls/utimensat.S
|
||||
syscall_src += arch-arm/syscalls/timerfd_create.S
|
||||
syscall_src += arch-arm/syscalls/timerfd_settime.S
|
||||
syscall_src += arch-arm/syscalls/timerfd_gettime.S
|
||||
syscall_src += arch-arm/syscalls/sigaction.S
|
||||
syscall_src += arch-arm/syscalls/sigprocmask.S
|
||||
syscall_src += arch-arm/syscalls/__sigsuspend.S
|
||||
|
||||
15
libc/arch-arm/syscalls/swapoff.S
Normal file
15
libc/arch-arm/syscalls/swapoff.S
Normal file
@@ -0,0 +1,15 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(swapoff)
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_swapoff
|
||||
swi #0
|
||||
mov r7, ip
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno
|
||||
END(swapoff)
|
||||
15
libc/arch-arm/syscalls/swapon.S
Normal file
15
libc/arch-arm/syscalls/swapon.S
Normal file
@@ -0,0 +1,15 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(swapon)
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_swapon
|
||||
swi #0
|
||||
mov r7, ip
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno
|
||||
END(swapon)
|
||||
15
libc/arch-arm/syscalls/timerfd_create.S
Normal file
15
libc/arch-arm/syscalls/timerfd_create.S
Normal file
@@ -0,0 +1,15 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(timerfd_create)
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_timerfd_create
|
||||
swi #0
|
||||
mov r7, ip
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno
|
||||
END(timerfd_create)
|
||||
15
libc/arch-arm/syscalls/timerfd_gettime.S
Normal file
15
libc/arch-arm/syscalls/timerfd_gettime.S
Normal file
@@ -0,0 +1,15 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(timerfd_gettime)
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_timerfd_gettime
|
||||
swi #0
|
||||
mov r7, ip
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno
|
||||
END(timerfd_gettime)
|
||||
15
libc/arch-arm/syscalls/timerfd_settime.S
Normal file
15
libc/arch-arm/syscalls/timerfd_settime.S
Normal file
@@ -0,0 +1,15 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(timerfd_settime)
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_timerfd_settime
|
||||
swi #0
|
||||
mov r7, ip
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno
|
||||
END(timerfd_settime)
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -25,17 +25,12 @@
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
#define _GNU_SOURCE 1
|
||||
#include <sched.h>
|
||||
|
||||
int sched_getaffinity(pid_t pid, size_t setsize, cpu_set_t* set)
|
||||
extern void *__dso_handle;
|
||||
extern int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
|
||||
|
||||
__attribute__ ((visibility ("hidden")))
|
||||
int atexit(void (*func)(void))
|
||||
{
|
||||
int ret = __sched_getaffinity(pid, setsize, set);
|
||||
if (ret >= 0) {
|
||||
if ((size_t)ret < setsize) {
|
||||
memset((char*)set + ret, '\0', setsize - (size_t)ret);
|
||||
}
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
return (__cxa_atexit((void (*)(void *))func, (void *)0, &__dso_handle));
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
.text
|
||||
.align 4
|
||||
.type __start,@function
|
||||
.globl __start
|
||||
.globl _start
|
||||
|
||||
# this is the small startup code that is first run when
|
||||
# any executable that is statically-linked with Bionic
|
||||
# runs.
|
||||
#
|
||||
# it's purpose is to call __libc_init with appropriate
|
||||
# arguments, which are:
|
||||
#
|
||||
# - the address of the raw data block setup by the Linux
|
||||
# kernel ELF loader
|
||||
#
|
||||
# - address of an "onexit" function, not used on any
|
||||
# platform supported by Bionic
|
||||
#
|
||||
# - address of the "main" function of the program.
|
||||
#
|
||||
# - address of the constructor list
|
||||
#
|
||||
|
||||
.ent __start
|
||||
__start:
|
||||
_start:
|
||||
bal 1f
|
||||
1:
|
||||
.set noreorder
|
||||
.cpload $ra
|
||||
.set reorder
|
||||
|
||||
move $a0, $sp
|
||||
move $a1, $0
|
||||
la $a2, main
|
||||
la $a3, 1f
|
||||
subu $sp, 32
|
||||
la $t9, __libc_init
|
||||
j $t9
|
||||
.end __start
|
||||
|
||||
1: .long __PREINIT_ARRAY__
|
||||
.long __INIT_ARRAY__
|
||||
.long __FINI_ARRAY__
|
||||
|
||||
.section .preinit_array, "aw"
|
||||
.type __PREINIT_ARRAY__, @object
|
||||
.globl __PREINIT_ARRAY__
|
||||
__PREINIT_ARRAY__:
|
||||
.long -1
|
||||
|
||||
.section .init_array, "aw"
|
||||
.type __INIT_ARRAY__, @object
|
||||
.globl __INIT_ARRAY__
|
||||
__INIT_ARRAY__:
|
||||
.long -1
|
||||
|
||||
.section .fini_array, "aw"
|
||||
.type __FINI_ARRAY__, @object
|
||||
.globl __FINI_ARRAY__
|
||||
__FINI_ARRAY__:
|
||||
.long -1
|
||||
.long __do_global_dtors_aux
|
||||
|
||||
.abicalls
|
||||
.text
|
||||
.align 2
|
||||
.set nomips16
|
||||
.ent __do_global_dtors_aux
|
||||
.type __do_global_dtors_aux, @function
|
||||
__do_global_dtors_aux:
|
||||
.frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8
|
||||
.mask 0x80000000,-4
|
||||
.fmask 0x00000000,0
|
||||
.set noreorder
|
||||
.cpload $25
|
||||
.set nomacro
|
||||
addiu $sp,$sp,-32
|
||||
sw $31,28($sp)
|
||||
.cprestore 16
|
||||
lw $2,%got(completed.1269)($28)
|
||||
lbu $2,%lo(completed.1269)($2)
|
||||
bne $2,$0,$L8
|
||||
nop
|
||||
|
||||
$L4:
|
||||
lw $2,%got(__cxa_finalize)($28)
|
||||
beq $2,$0,$L6
|
||||
nop
|
||||
|
||||
lw $2,%got(__dso_handle)($28)
|
||||
lw $4,0($2)
|
||||
lw $25,%call16(__cxa_finalize)($28)
|
||||
.reloc 1f,R_MIPS_JALR,__cxa_finalize
|
||||
1: jalr $25
|
||||
nop
|
||||
|
||||
lw $28,16($sp)
|
||||
$L6:
|
||||
lw $2,%got(completed.1269)($28)
|
||||
li $3,1 # 0x1
|
||||
sb $3,%lo(completed.1269)($2)
|
||||
$L8:
|
||||
lw $31,28($sp)
|
||||
addiu $sp,$sp,32
|
||||
j $31
|
||||
nop
|
||||
|
||||
.set macro
|
||||
.set reorder
|
||||
.end __do_global_dtors_aux
|
||||
.size __do_global_dtors_aux, .-__do_global_dtors_aux
|
||||
.local completed.1269
|
||||
.comm completed.1269,1,1
|
||||
.weak __cxa_finalize
|
||||
|
||||
#include "__dso_handle.S"
|
||||
#include "atexit.S"
|
||||
94
libc/arch-mips/bionic/crtbegin.c
Normal file
94
libc/arch-mips/bionic/crtbegin.c
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2013 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 "../../bionic/libc_init_common.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__attribute__ ((section (".preinit_array")))
|
||||
void (*__PREINIT_ARRAY__)(void) = (void (*)(void)) -1;
|
||||
|
||||
__attribute__ ((section (".init_array")))
|
||||
void (*__INIT_ARRAY__)(void) = (void (*)(void)) -1;
|
||||
|
||||
__attribute__ ((section (".fini_array")))
|
||||
void (*__FINI_ARRAY__)(void) = (void (*)(void)) -1;
|
||||
|
||||
|
||||
__LIBC_HIDDEN__ void do_mips_start(void *raw_args) {
|
||||
structors_array_t array;
|
||||
array.preinit_array = &__PREINIT_ARRAY__;
|
||||
array.init_array = &__INIT_ARRAY__;
|
||||
array.fini_array = &__FINI_ARRAY__;
|
||||
|
||||
__libc_init(raw_args, NULL, &main, &array);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function prepares the return address with a branch-and-link
|
||||
* instruction (bal) and then uses a .cpload to compute the Global
|
||||
* Offset Table (GOT) pointer ($gp). The $gp is then used to load
|
||||
* the address of _do_start() into $t9 just before calling it.
|
||||
* Terminating the stack with a NULL return address.
|
||||
*/
|
||||
__asm__ (
|
||||
" .set push \n"
|
||||
" \n"
|
||||
" .text \n"
|
||||
" .align 4 \n"
|
||||
" .type __start,@function \n"
|
||||
" .globl __start \n"
|
||||
" .globl _start \n"
|
||||
" \n"
|
||||
" .ent __start \n"
|
||||
"__start: \n"
|
||||
" _start: \n"
|
||||
" .frame $sp,32,$ra \n"
|
||||
" .mask 0x80000000,-4 \n"
|
||||
" \n"
|
||||
" .set noreorder \n"
|
||||
" bal 1f \n"
|
||||
" nop \n"
|
||||
"1: \n"
|
||||
" .cpload $ra \n"
|
||||
" .set reorder \n"
|
||||
" \n"
|
||||
" move $a0, $sp \n"
|
||||
" addiu $sp, $sp, (-32) \n"
|
||||
" sw $0, 28($sp) \n"
|
||||
" la $t9, do_mips_start \n"
|
||||
" jalr $t9 \n"
|
||||
" \n"
|
||||
"2: b 2b \n"
|
||||
" .end __start \n"
|
||||
" \n"
|
||||
" .set pop \n"
|
||||
);
|
||||
|
||||
#include "__dso_handle.h"
|
||||
#include "atexit.h"
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
.section .init_array, "aw"
|
||||
.type __INIT_ARRAY__, @object
|
||||
.globl __INIT_ARRAY__
|
||||
__INIT_ARRAY__:
|
||||
.long -1
|
||||
|
||||
.section .fini_array, "aw"
|
||||
.type __FINI_ARRAY__, @object
|
||||
.globl __FINI_ARRAY__
|
||||
__FINI_ARRAY__:
|
||||
.long -1
|
||||
.long __do_global_dtors_aux
|
||||
|
||||
.abicalls
|
||||
.text
|
||||
.align 2
|
||||
.set nomips16
|
||||
.ent __do_global_dtors_aux
|
||||
.type __do_global_dtors_aux, @function
|
||||
__do_global_dtors_aux:
|
||||
.frame $sp,32,$31 # vars= 0, regs= 1/0, args= 16, gp= 8
|
||||
.mask 0x80000000,-4
|
||||
.fmask 0x00000000,0
|
||||
.set noreorder
|
||||
.cpload $25
|
||||
.set nomacro
|
||||
addiu $sp,$sp,-32
|
||||
sw $31,28($sp)
|
||||
.cprestore 16
|
||||
lw $2,%got(completed.1269)($28)
|
||||
lbu $2,%lo(completed.1269)($2)
|
||||
bne $2,$0,$L8
|
||||
nop
|
||||
|
||||
$L4:
|
||||
lw $2,%got(__cxa_finalize)($28)
|
||||
beq $2,$0,$L6
|
||||
nop
|
||||
|
||||
lw $2,%got(__dso_handle)($28)
|
||||
lw $4,0($2)
|
||||
lw $25,%call16(__cxa_finalize)($28)
|
||||
.reloc 1f,R_MIPS_JALR,__cxa_finalize
|
||||
1: jalr $25
|
||||
nop
|
||||
|
||||
lw $28,16($sp)
|
||||
$L6:
|
||||
lw $2,%got(completed.1269)($28)
|
||||
li $3,1 # 0x1
|
||||
sb $3,%lo(completed.1269)($2)
|
||||
$L8:
|
||||
lw $31,28($sp)
|
||||
addiu $sp,$sp,32
|
||||
j $31
|
||||
nop
|
||||
|
||||
.set macro
|
||||
.set reorder
|
||||
.end __do_global_dtors_aux
|
||||
.size __do_global_dtors_aux, .-__do_global_dtors_aux
|
||||
.local completed.1269
|
||||
.comm completed.1269,1,1
|
||||
.weak __cxa_finalize
|
||||
|
||||
#include "__dso_handle_so.S"
|
||||
#include "atexit.S"
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -25,19 +25,14 @@
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
.text
|
||||
.globl atexit
|
||||
.hidden atexit
|
||||
.type atexit, @function
|
||||
.align 4
|
||||
.ent atexit
|
||||
atexit:
|
||||
.set noreorder
|
||||
.cpload $t9
|
||||
.set reorder
|
||||
la $t9, __cxa_atexit
|
||||
move $a1, $0
|
||||
la $a2, __dso_handle
|
||||
j $t9
|
||||
.size atexit, .-atexit
|
||||
.end atexit
|
||||
|
||||
extern void __cxa_finalize(void *);
|
||||
extern void *__dso_handle;
|
||||
|
||||
__attribute__((visibility("hidden"),destructor))
|
||||
void __on_dlclose() {
|
||||
__cxa_finalize(&__dso_handle);
|
||||
}
|
||||
|
||||
#include "__dso_handle_so.h"
|
||||
#include "atexit.h"
|
||||
@@ -129,6 +129,8 @@ syscall_src += arch-mips/syscalls/removexattr.S
|
||||
syscall_src += arch-mips/syscalls/lremovexattr.S
|
||||
syscall_src += arch-mips/syscalls/__statfs64.S
|
||||
syscall_src += arch-mips/syscalls/unshare.S
|
||||
syscall_src += arch-mips/syscalls/swapon.S
|
||||
syscall_src += arch-mips/syscalls/swapoff.S
|
||||
syscall_src += arch-mips/syscalls/pause.S
|
||||
syscall_src += arch-mips/syscalls/gettimeofday.S
|
||||
syscall_src += arch-mips/syscalls/settimeofday.S
|
||||
@@ -147,6 +149,9 @@ syscall_src += arch-mips/syscalls/__timer_getoverrun.S
|
||||
syscall_src += arch-mips/syscalls/__timer_delete.S
|
||||
syscall_src += arch-mips/syscalls/utimes.S
|
||||
syscall_src += arch-mips/syscalls/utimensat.S
|
||||
syscall_src += arch-mips/syscalls/timerfd_create.S
|
||||
syscall_src += arch-mips/syscalls/timerfd_settime.S
|
||||
syscall_src += arch-mips/syscalls/timerfd_gettime.S
|
||||
syscall_src += arch-mips/syscalls/sigaction.S
|
||||
syscall_src += arch-mips/syscalls/sigprocmask.S
|
||||
syscall_src += arch-mips/syscalls/__sigsuspend.S
|
||||
|
||||
22
libc/arch-mips/syscalls/swapoff.S
Normal file
22
libc/arch-mips/syscalls/swapoff.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
.text
|
||||
.globl swapoff
|
||||
.align 4
|
||||
.ent swapoff
|
||||
|
||||
swapoff:
|
||||
.set noreorder
|
||||
.cpload $t9
|
||||
li $v0, __NR_swapoff
|
||||
syscall
|
||||
bnez $a3, 1f
|
||||
move $a0, $v0
|
||||
j $ra
|
||||
nop
|
||||
1:
|
||||
la $t9,__set_errno
|
||||
j $t9
|
||||
nop
|
||||
.set reorder
|
||||
.end swapoff
|
||||
22
libc/arch-mips/syscalls/swapon.S
Normal file
22
libc/arch-mips/syscalls/swapon.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
.text
|
||||
.globl swapon
|
||||
.align 4
|
||||
.ent swapon
|
||||
|
||||
swapon:
|
||||
.set noreorder
|
||||
.cpload $t9
|
||||
li $v0, __NR_swapon
|
||||
syscall
|
||||
bnez $a3, 1f
|
||||
move $a0, $v0
|
||||
j $ra
|
||||
nop
|
||||
1:
|
||||
la $t9,__set_errno
|
||||
j $t9
|
||||
nop
|
||||
.set reorder
|
||||
.end swapon
|
||||
22
libc/arch-mips/syscalls/timerfd_create.S
Normal file
22
libc/arch-mips/syscalls/timerfd_create.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
.text
|
||||
.globl timerfd_create
|
||||
.align 4
|
||||
.ent timerfd_create
|
||||
|
||||
timerfd_create:
|
||||
.set noreorder
|
||||
.cpload $t9
|
||||
li $v0, __NR_timerfd_create
|
||||
syscall
|
||||
bnez $a3, 1f
|
||||
move $a0, $v0
|
||||
j $ra
|
||||
nop
|
||||
1:
|
||||
la $t9,__set_errno
|
||||
j $t9
|
||||
nop
|
||||
.set reorder
|
||||
.end timerfd_create
|
||||
22
libc/arch-mips/syscalls/timerfd_gettime.S
Normal file
22
libc/arch-mips/syscalls/timerfd_gettime.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
.text
|
||||
.globl timerfd_gettime
|
||||
.align 4
|
||||
.ent timerfd_gettime
|
||||
|
||||
timerfd_gettime:
|
||||
.set noreorder
|
||||
.cpload $t9
|
||||
li $v0, __NR_timerfd_gettime
|
||||
syscall
|
||||
bnez $a3, 1f
|
||||
move $a0, $v0
|
||||
j $ra
|
||||
nop
|
||||
1:
|
||||
la $t9,__set_errno
|
||||
j $t9
|
||||
nop
|
||||
.set reorder
|
||||
.end timerfd_gettime
|
||||
22
libc/arch-mips/syscalls/timerfd_settime.S
Normal file
22
libc/arch-mips/syscalls/timerfd_settime.S
Normal file
@@ -0,0 +1,22 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <asm/unistd.h>
|
||||
.text
|
||||
.globl timerfd_settime
|
||||
.align 4
|
||||
.ent timerfd_settime
|
||||
|
||||
timerfd_settime:
|
||||
.set noreorder
|
||||
.cpload $t9
|
||||
li $v0, __NR_timerfd_settime
|
||||
syscall
|
||||
bnez $a3, 1f
|
||||
move $a0, $v0
|
||||
j $ra
|
||||
nop
|
||||
1:
|
||||
la $t9,__set_errno
|
||||
j $t9
|
||||
nop
|
||||
.set reorder
|
||||
.end timerfd_settime
|
||||
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: endian.h,v 1.14 2005/12/13 00:35:23 millert Exp $ */
|
||||
/* $OpenBSD: endian.h,v 1.17 2011/03/12 04:03:04 guenther Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 Niklas Hallqvist. All rights reserved.
|
||||
@@ -24,38 +24,28 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _I386_ENDIAN_H_
|
||||
#define _I386_ENDIAN_H_
|
||||
#ifndef _MACHINE_ENDIAN_H_
|
||||
#define _MACHINE_ENDIAN_H_
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#if defined(_KERNEL) && !defined(I386_CPU)
|
||||
#define __swap32md(x) ({ \
|
||||
#define __swap32md(x) __statement({ \
|
||||
uint32_t __swap32md_x = (x); \
|
||||
\
|
||||
__asm ("bswap %1" : "+r" (__swap32md_x)); \
|
||||
__asm ("bswap %0" : "+r" (__swap32md_x)); \
|
||||
__swap32md_x; \
|
||||
})
|
||||
#else
|
||||
#define __swap32md(x) ({ \
|
||||
uint32_t __swap32md_x = (x); \
|
||||
\
|
||||
__asm ("rorw $8, %w1; rorl $16, %1; rorw $8, %w1" : \
|
||||
"+r" (__swap32md_x)); \
|
||||
__swap32md_x; \
|
||||
})
|
||||
#endif /* _KERNEL && !I386_CPU */
|
||||
|
||||
#define __swap64md(x) ({ \
|
||||
#define __swap64md(x) __statement({ \
|
||||
uint64_t __swap64md_x = (x); \
|
||||
\
|
||||
(uint64_t)__swap32md(__swap64md_x >> 32) | \
|
||||
(uint64_t)__swap32md(__swap64md_x & 0xffffffff) << 32; \
|
||||
})
|
||||
#define __swap16md(x) ({ \
|
||||
#define __swap16md(x) __statement({ \
|
||||
uint16_t __swap16md_x = (x); \
|
||||
\
|
||||
__asm ("rorw $8, %w1" : "+r" (__swap16md_x)); \
|
||||
__asm ("rorw $8, %w0" : "+r" (__swap16md_x)); \
|
||||
__swap16md_x; \
|
||||
})
|
||||
|
||||
@@ -68,4 +58,4 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/endian.h>
|
||||
|
||||
#endif /* _I386_ENDIAN_H_ */
|
||||
#endif /* _MACHINE_ENDIAN_H_ */
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
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
|
||||
@@ -1,26 +0,0 @@
|
||||
/* $OpenBSD: index.S,v 1.4 2005/08/07 11:30:38 espie Exp $ */
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#ifdef STRCHR
|
||||
ENTRY(strchr)
|
||||
#else
|
||||
ENTRY(index)
|
||||
#endif
|
||||
movl 4(%esp),%eax
|
||||
movb 8(%esp),%cl
|
||||
.align 2,0x90
|
||||
L1:
|
||||
movb (%eax),%dl
|
||||
cmpb %dl,%cl /* found char??? */
|
||||
je L2
|
||||
incl %eax
|
||||
testb %dl,%dl /* null terminator??? */
|
||||
jnz L1
|
||||
xorl %eax,%eax
|
||||
L2:
|
||||
ret
|
||||
@@ -1,27 +0,0 @@
|
||||
/* $OpenBSD: memchr.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
ENTRY(memchr)
|
||||
pushl %edi
|
||||
movl 8(%esp),%edi /* string address */
|
||||
movl 12(%esp),%eax /* set character to search for */
|
||||
movl 16(%esp),%ecx /* set length of search */
|
||||
testl %ecx,%ecx /* test for len == 0 */
|
||||
jz L1
|
||||
cld /* set search forward */
|
||||
repne /* search! */
|
||||
scasb
|
||||
jne L1 /* scan failed, return null */
|
||||
leal -1(%edi),%eax /* adjust result of scan */
|
||||
popl %edi
|
||||
ret
|
||||
.align 2,0x90
|
||||
L1: xorl %eax,%eax
|
||||
popl %edi
|
||||
ret
|
||||
END(memchr)
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
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
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
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
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
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
|
||||
@@ -28,15 +28,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
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
|
||||
|
||||
#define USE_AS_BZERO
|
||||
#define MEMSET bzero
|
||||
#include "sse2-memset-atom.S"
|
||||
32
libc/arch-x86/string/sse2-index-atom.S
Normal file
32
libc/arch-x86/string/sse2-index-atom.S
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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.
|
||||
*/
|
||||
|
||||
#define strchr index
|
||||
#include "sse2-strchr-atom.S"
|
||||
556
libc/arch-x86/string/sse2-memchr-atom.S
Normal file
556
libc/arch-x86/string/sse2-memchr-atom.S
Normal file
@@ -0,0 +1,556 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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 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)
|
||||
|
||||
#define ENTRANCE PUSH (%edi);
|
||||
#define PARMS 8
|
||||
#define RETURN POP (%edi); ret; CFI_PUSH (%edi);
|
||||
|
||||
#define STR1 PARMS
|
||||
#define STR2 STR1+4
|
||||
#define LEN STR2+4
|
||||
|
||||
.text
|
||||
ENTRY (memchr)
|
||||
ENTRANCE
|
||||
mov STR1(%esp), %ecx
|
||||
movd STR2(%esp), %xmm1
|
||||
mov LEN(%esp), %edx
|
||||
test %edx, %edx
|
||||
jz L(return_null)
|
||||
|
||||
punpcklbw %xmm1, %xmm1
|
||||
mov %ecx, %edi
|
||||
punpcklbw %xmm1, %xmm1
|
||||
|
||||
and $63, %ecx
|
||||
pshufd $0, %xmm1, %xmm1
|
||||
cmp $48, %ecx
|
||||
ja L(crosscache)
|
||||
|
||||
movdqu (%edi), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case2_prolog)
|
||||
|
||||
sub $16, %edx
|
||||
jbe L(return_null)
|
||||
lea 16(%edi), %edi
|
||||
and $15, %ecx
|
||||
and $-16, %edi
|
||||
add %ecx, %edx
|
||||
sub $64, %edx
|
||||
jbe L(exit_loop)
|
||||
jmp L(loop_prolog)
|
||||
|
||||
.p2align 4
|
||||
L(crosscache):
|
||||
and $15, %ecx
|
||||
and $-16, %edi
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
sar %cl, %eax
|
||||
test %eax, %eax
|
||||
|
||||
jnz L(match_case2_prolog1)
|
||||
lea -16(%edx), %edx
|
||||
add %ecx, %edx
|
||||
jle L(return_null)
|
||||
lea 16(%edi), %edi
|
||||
sub $64, %edx
|
||||
jbe L(exit_loop)
|
||||
|
||||
.p2align 4
|
||||
L(loop_prolog):
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
xor %ecx, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
movdqa 16(%edi), %xmm2
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm2, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
movdqa 32(%edi), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
movdqa 48(%edi), %xmm4
|
||||
pcmpeqb %xmm1, %xmm4
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm4, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
lea 64(%edi), %edi
|
||||
sub $64, %edx
|
||||
jbe L(exit_loop)
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
xor %ecx, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
movdqa 16(%edi), %xmm2
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm2, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
movdqa 32(%edi), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
movdqa 48(%edi), %xmm4
|
||||
pcmpeqb %xmm1, %xmm4
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm4, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
lea 64(%edi), %edi
|
||||
mov %edi, %ecx
|
||||
and $-64, %edi
|
||||
and $63, %ecx
|
||||
add %ecx, %edx
|
||||
|
||||
.p2align 4
|
||||
L(align64_loop):
|
||||
sub $64, %edx
|
||||
jbe L(exit_loop)
|
||||
movdqa (%edi), %xmm0
|
||||
movdqa 16(%edi), %xmm2
|
||||
movdqa 32(%edi), %xmm3
|
||||
movdqa 48(%edi), %xmm4
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pcmpeqb %xmm1, %xmm4
|
||||
|
||||
pmaxub %xmm0, %xmm3
|
||||
pmaxub %xmm2, %xmm4
|
||||
pmaxub %xmm3, %xmm4
|
||||
add $64, %edi
|
||||
pmovmskb %xmm4, %eax
|
||||
|
||||
test %eax, %eax
|
||||
jz L(align64_loop)
|
||||
|
||||
sub $64, %edi
|
||||
|
||||
pmovmskb %xmm0, %eax
|
||||
xor %ecx, %ecx
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
pmovmskb %xmm2, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
movdqa 32(%edi), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pmovmskb %xmm3, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
test %eax, %eax
|
||||
jnz L(match_case1)
|
||||
|
||||
pcmpeqb 48(%edi), %xmm1
|
||||
pmovmskb %xmm1, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
|
||||
.p2align 4
|
||||
L(match_case1):
|
||||
add %ecx, %edi
|
||||
test %al, %al
|
||||
jz L(match_case1_high)
|
||||
mov %al, %cl
|
||||
and $15, %cl
|
||||
jz L(match_case1_8)
|
||||
test $0x01, %al
|
||||
jnz L(exit_case1_1)
|
||||
test $0x02, %al
|
||||
jnz L(exit_case1_2)
|
||||
test $0x04, %al
|
||||
jnz L(exit_case1_3)
|
||||
lea 3(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case1_8):
|
||||
test $0x10, %al
|
||||
jnz L(exit_case1_5)
|
||||
test $0x20, %al
|
||||
jnz L(exit_case1_6)
|
||||
test $0x40, %al
|
||||
jnz L(exit_case1_7)
|
||||
lea 7(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case1_high):
|
||||
mov %ah, %ch
|
||||
and $15, %ch
|
||||
jz L(match_case1_high_8)
|
||||
test $0x01, %ah
|
||||
jnz L(exit_case1_9)
|
||||
test $0x02, %ah
|
||||
jnz L(exit_case1_10)
|
||||
test $0x04, %ah
|
||||
jnz L(exit_case1_11)
|
||||
lea 11(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case1_high_8):
|
||||
test $0x10, %ah
|
||||
jnz L(exit_case1_13)
|
||||
test $0x20, %ah
|
||||
jnz L(exit_case1_14)
|
||||
test $0x40, %ah
|
||||
jnz L(exit_case1_15)
|
||||
lea 15(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_loop):
|
||||
add $64, %edx
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
xor %ecx, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case2)
|
||||
cmp $16, %edx
|
||||
jbe L(return_null)
|
||||
|
||||
movdqa 16(%edi), %xmm2
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm2, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case2)
|
||||
cmp $32, %edx
|
||||
jbe L(return_null)
|
||||
|
||||
movdqa 32(%edi), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case2)
|
||||
cmp $48, %edx
|
||||
jbe L(return_null)
|
||||
|
||||
pcmpeqb 48(%edi), %xmm1
|
||||
lea 16(%ecx), %ecx
|
||||
pmovmskb %xmm1, %eax
|
||||
test %eax, %eax
|
||||
jnz L(match_case2)
|
||||
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_1):
|
||||
mov %edi, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_2):
|
||||
lea 1(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_3):
|
||||
lea 2(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_5):
|
||||
lea 4(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_6):
|
||||
lea 5(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_7):
|
||||
lea 6(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_9):
|
||||
lea 8(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_10):
|
||||
lea 9(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_11):
|
||||
lea 10(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_13):
|
||||
lea 12(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_14):
|
||||
lea 13(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case1_15):
|
||||
lea 14(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case2):
|
||||
sub %ecx, %edx
|
||||
L(match_case2_prolog1):
|
||||
add %ecx, %edi
|
||||
L(match_case2_prolog):
|
||||
test %al, %al
|
||||
jz L(match_case2_high)
|
||||
mov %al, %cl
|
||||
and $15, %cl
|
||||
jz L(match_case2_8)
|
||||
test $0x01, %al
|
||||
jnz L(exit_case2_1)
|
||||
test $0x02, %al
|
||||
jnz L(exit_case2_2)
|
||||
test $0x04, %al
|
||||
jnz L(exit_case2_3)
|
||||
sub $4, %edx
|
||||
jb L(return_null)
|
||||
lea 3(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case2_8):
|
||||
test $0x10, %al
|
||||
jnz L(exit_case2_5)
|
||||
test $0x20, %al
|
||||
jnz L(exit_case2_6)
|
||||
test $0x40, %al
|
||||
jnz L(exit_case2_7)
|
||||
sub $8, %edx
|
||||
jb L(return_null)
|
||||
lea 7(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case2_high):
|
||||
mov %ah, %ch
|
||||
and $15, %ch
|
||||
jz L(match_case2_high_8)
|
||||
test $0x01, %ah
|
||||
jnz L(exit_case2_9)
|
||||
test $0x02, %ah
|
||||
jnz L(exit_case2_10)
|
||||
test $0x04, %ah
|
||||
jnz L(exit_case2_11)
|
||||
sub $12, %edx
|
||||
jb L(return_null)
|
||||
lea 11(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case2_high_8):
|
||||
test $0x10, %ah
|
||||
jnz L(exit_case2_13)
|
||||
test $0x20, %ah
|
||||
jnz L(exit_case2_14)
|
||||
test $0x40, %ah
|
||||
jnz L(exit_case2_15)
|
||||
sub $16, %edx
|
||||
jb L(return_null)
|
||||
lea 15(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_1):
|
||||
mov %edi, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_2):
|
||||
sub $2, %edx
|
||||
jb L(return_null)
|
||||
lea 1(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_3):
|
||||
sub $3, %edx
|
||||
jb L(return_null)
|
||||
lea 2(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_5):
|
||||
sub $5, %edx
|
||||
jb L(return_null)
|
||||
lea 4(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_6):
|
||||
sub $6, %edx
|
||||
jb L(return_null)
|
||||
lea 5(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_7):
|
||||
sub $7, %edx
|
||||
jb L(return_null)
|
||||
lea 6(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_9):
|
||||
sub $9, %edx
|
||||
jb L(return_null)
|
||||
lea 8(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_10):
|
||||
sub $10, %edx
|
||||
jb L(return_null)
|
||||
lea 9(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_11):
|
||||
sub $11, %edx
|
||||
jb L(return_null)
|
||||
lea 10(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_13):
|
||||
sub $13, %edx
|
||||
jb L(return_null)
|
||||
lea 12(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_14):
|
||||
sub $14, %edx
|
||||
jb L(return_null)
|
||||
lea 13(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_case2_15):
|
||||
sub $15, %edx
|
||||
jb L(return_null)
|
||||
lea 14(%edi), %eax
|
||||
RETURN
|
||||
.p2align 4
|
||||
L(return_null):
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
END (memchr)
|
||||
778
libc/arch-x86/string/sse2-memrchr-atom.S
Normal file
778
libc/arch-x86/string/sse2-memrchr-atom.S
Normal file
@@ -0,0 +1,778 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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 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)
|
||||
|
||||
#define PARMS 4
|
||||
#define STR1 PARMS
|
||||
#define STR2 STR1+4
|
||||
#define LEN STR2+4
|
||||
|
||||
.text
|
||||
ENTRY (memrchr)
|
||||
mov STR1(%esp), %ecx
|
||||
movd STR2(%esp), %xmm1
|
||||
mov LEN(%esp), %edx
|
||||
|
||||
test %edx, %edx
|
||||
jz L(return_null)
|
||||
sub $16, %edx
|
||||
jbe L(length_less16)
|
||||
|
||||
punpcklbw %xmm1, %xmm1
|
||||
add %edx, %ecx
|
||||
punpcklbw %xmm1, %xmm1
|
||||
|
||||
movdqu (%ecx), %xmm0
|
||||
pshufd $0, %xmm1, %xmm1
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(exit_dispatch)
|
||||
|
||||
sub $64, %ecx
|
||||
mov %ecx, %eax
|
||||
and $15, %eax
|
||||
jz L(loop_prolog)
|
||||
|
||||
add $16, %ecx
|
||||
add $16, %edx
|
||||
and $-16, %ecx
|
||||
sub %eax, %edx
|
||||
|
||||
.p2align 4
|
||||
/* Loop start on aligned string. */
|
||||
L(loop_prolog):
|
||||
sub $64, %edx
|
||||
jbe L(exit_loop)
|
||||
|
||||
movdqa 48(%ecx), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches48)
|
||||
|
||||
movdqa 32(%ecx), %xmm2
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
pmovmskb %xmm2, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches32)
|
||||
|
||||
movdqa 16(%ecx), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches16)
|
||||
|
||||
movdqa (%ecx), %xmm4
|
||||
pcmpeqb %xmm1, %xmm4
|
||||
pmovmskb %xmm4, %eax
|
||||
test %eax, %eax
|
||||
jnz L(exit_dispatch)
|
||||
|
||||
sub $64, %ecx
|
||||
sub $64, %edx
|
||||
jbe L(exit_loop)
|
||||
|
||||
movdqa 48(%ecx), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches48)
|
||||
|
||||
movdqa 32(%ecx), %xmm2
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
pmovmskb %xmm2, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches32)
|
||||
|
||||
movdqa 16(%ecx), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches16)
|
||||
|
||||
movdqa (%ecx), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(exit_dispatch)
|
||||
|
||||
mov %ecx, %eax
|
||||
and $63, %eax
|
||||
test %eax, %eax
|
||||
jz L(align64_loop)
|
||||
|
||||
add $64, %ecx
|
||||
add $64, %edx
|
||||
and $-64, %ecx
|
||||
sub %eax, %edx
|
||||
|
||||
.p2align 4
|
||||
L(align64_loop):
|
||||
sub $64, %ecx
|
||||
sub $64, %edx
|
||||
jbe L(exit_loop)
|
||||
|
||||
movdqa (%ecx), %xmm0
|
||||
movdqa 16(%ecx), %xmm2
|
||||
movdqa 32(%ecx), %xmm3
|
||||
movdqa 48(%ecx), %xmm4
|
||||
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pcmpeqb %xmm1, %xmm4
|
||||
|
||||
pmaxub %xmm3, %xmm0
|
||||
pmaxub %xmm4, %xmm2
|
||||
pmaxub %xmm0, %xmm2
|
||||
pmovmskb %xmm2, %eax
|
||||
|
||||
test %eax, %eax
|
||||
jz L(align64_loop)
|
||||
|
||||
pmovmskb %xmm4, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches48)
|
||||
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches32)
|
||||
|
||||
movdqa 16(%ecx), %xmm2
|
||||
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
pcmpeqb (%ecx), %xmm1
|
||||
|
||||
pmovmskb %xmm2, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches16)
|
||||
|
||||
pmovmskb %xmm1, %eax
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_high)
|
||||
mov %al, %dl
|
||||
and $15 << 4, %dl
|
||||
jnz L(exit_dispatch_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_2)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_loop):
|
||||
add $64, %edx
|
||||
cmp $32, %edx
|
||||
jbe L(exit_loop_32)
|
||||
|
||||
movdqa 48(%ecx), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches48)
|
||||
|
||||
movdqa 32(%ecx), %xmm2
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
pmovmskb %xmm2, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches32)
|
||||
|
||||
movdqa 16(%ecx), %xmm3
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pmovmskb %xmm3, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches16_1)
|
||||
cmp $48, %edx
|
||||
jbe L(return_null)
|
||||
|
||||
pcmpeqb (%ecx), %xmm1
|
||||
pmovmskb %xmm1, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches0_1)
|
||||
xor %eax, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_loop_32):
|
||||
movdqa 48(%ecx), %xmm0
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches48_1)
|
||||
cmp $16, %edx
|
||||
jbe L(return_null)
|
||||
|
||||
pcmpeqb 32(%ecx), %xmm1
|
||||
pmovmskb %xmm1, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches32_1)
|
||||
xor %eax, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(matches16):
|
||||
lea 16(%ecx), %ecx
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_high)
|
||||
mov %al, %dl
|
||||
and $15 << 4, %dl
|
||||
jnz L(exit_dispatch_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_2)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(matches32):
|
||||
lea 32(%ecx), %ecx
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_high)
|
||||
mov %al, %dl
|
||||
and $15 << 4, %dl
|
||||
jnz L(exit_dispatch_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_2)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(matches48):
|
||||
lea 48(%ecx), %ecx
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch):
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_high)
|
||||
mov %al, %dl
|
||||
and $15 << 4, %dl
|
||||
jnz L(exit_dispatch_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_2)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch_8):
|
||||
test $0x80, %al
|
||||
jnz L(exit_8)
|
||||
test $0x40, %al
|
||||
jnz L(exit_7)
|
||||
test $0x20, %al
|
||||
jnz L(exit_6)
|
||||
lea 4(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch_high):
|
||||
mov %ah, %dh
|
||||
and $15 << 4, %dh
|
||||
jnz L(exit_dispatch_high_8)
|
||||
test $0x08, %ah
|
||||
jnz L(exit_12)
|
||||
test $0x04, %ah
|
||||
jnz L(exit_11)
|
||||
test $0x02, %ah
|
||||
jnz L(exit_10)
|
||||
lea 8(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch_high_8):
|
||||
test $0x80, %ah
|
||||
jnz L(exit_16)
|
||||
test $0x40, %ah
|
||||
jnz L(exit_15)
|
||||
test $0x20, %ah
|
||||
jnz L(exit_14)
|
||||
lea 12(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_2):
|
||||
lea 1(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_3):
|
||||
lea 2(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_4):
|
||||
lea 3(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_6):
|
||||
lea 5(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_7):
|
||||
lea 6(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_8):
|
||||
lea 7(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_10):
|
||||
lea 9(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_11):
|
||||
lea 10(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_12):
|
||||
lea 11(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_14):
|
||||
lea 13(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_15):
|
||||
lea 14(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_16):
|
||||
lea 15(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(matches0_1):
|
||||
lea -64(%edx), %edx
|
||||
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_1_high)
|
||||
mov %al, %ah
|
||||
and $15 << 4, %ah
|
||||
jnz L(exit_dispatch_1_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_1_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_1_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_1_2)
|
||||
|
||||
add $0, %edx
|
||||
jl L(return_null)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(matches16_1):
|
||||
lea -48(%edx), %edx
|
||||
lea 16(%ecx), %ecx
|
||||
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_1_high)
|
||||
mov %al, %ah
|
||||
and $15 << 4, %ah
|
||||
jnz L(exit_dispatch_1_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_1_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_1_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_1_2)
|
||||
|
||||
add $0, %edx
|
||||
jl L(return_null)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(matches32_1):
|
||||
lea -32(%edx), %edx
|
||||
lea 32(%ecx), %ecx
|
||||
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_1_high)
|
||||
mov %al, %ah
|
||||
and $15 << 4, %ah
|
||||
jnz L(exit_dispatch_1_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_1_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_1_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_1_2)
|
||||
|
||||
add $0, %edx
|
||||
jl L(return_null)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(matches48_1):
|
||||
lea -16(%edx), %edx
|
||||
lea 48(%ecx), %ecx
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch_1):
|
||||
test %ah, %ah
|
||||
jnz L(exit_dispatch_1_high)
|
||||
mov %al, %ah
|
||||
and $15 << 4, %ah
|
||||
jnz L(exit_dispatch_1_8)
|
||||
test $0x08, %al
|
||||
jnz L(exit_1_4)
|
||||
test $0x04, %al
|
||||
jnz L(exit_1_3)
|
||||
test $0x02, %al
|
||||
jnz L(exit_1_2)
|
||||
|
||||
add $0, %edx
|
||||
jl L(return_null)
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch_1_8):
|
||||
test $0x80, %al
|
||||
jnz L(exit_1_8)
|
||||
test $0x40, %al
|
||||
jnz L(exit_1_7)
|
||||
test $0x20, %al
|
||||
jnz L(exit_1_6)
|
||||
|
||||
add $4, %edx
|
||||
jl L(return_null)
|
||||
lea 4(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch_1_high):
|
||||
mov %ah, %al
|
||||
and $15 << 4, %al
|
||||
jnz L(exit_dispatch_1_high_8)
|
||||
test $0x08, %ah
|
||||
jnz L(exit_1_12)
|
||||
test $0x04, %ah
|
||||
jnz L(exit_1_11)
|
||||
test $0x02, %ah
|
||||
jnz L(exit_1_10)
|
||||
|
||||
add $8, %edx
|
||||
jl L(return_null)
|
||||
lea 8(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_dispatch_1_high_8):
|
||||
test $0x80, %ah
|
||||
jnz L(exit_1_16)
|
||||
test $0x40, %ah
|
||||
jnz L(exit_1_15)
|
||||
test $0x20, %ah
|
||||
jnz L(exit_1_14)
|
||||
|
||||
add $12, %edx
|
||||
jl L(return_null)
|
||||
lea 12(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_2):
|
||||
add $1, %edx
|
||||
jl L(return_null)
|
||||
lea 1(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_3):
|
||||
add $2, %edx
|
||||
jl L(return_null)
|
||||
lea 2(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_4):
|
||||
add $3, %edx
|
||||
jl L(return_null)
|
||||
lea 3(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_6):
|
||||
add $5, %edx
|
||||
jl L(return_null)
|
||||
lea 5(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_7):
|
||||
add $6, %edx
|
||||
jl L(return_null)
|
||||
lea 6(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_8):
|
||||
add $7, %edx
|
||||
jl L(return_null)
|
||||
lea 7(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_10):
|
||||
add $9, %edx
|
||||
jl L(return_null)
|
||||
lea 9(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_11):
|
||||
add $10, %edx
|
||||
jl L(return_null)
|
||||
lea 10(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_12):
|
||||
add $11, %edx
|
||||
jl L(return_null)
|
||||
lea 11(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_14):
|
||||
add $13, %edx
|
||||
jl L(return_null)
|
||||
lea 13(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_15):
|
||||
add $14, %edx
|
||||
jl L(return_null)
|
||||
lea 14(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit_1_16):
|
||||
add $15, %edx
|
||||
jl L(return_null)
|
||||
lea 15(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(return_null):
|
||||
xor %eax, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(length_less16_offset0):
|
||||
mov %dl, %cl
|
||||
pcmpeqb (%eax), %xmm1
|
||||
|
||||
mov $1, %edx
|
||||
sal %cl, %edx
|
||||
sub $1, %edx
|
||||
|
||||
mov %eax, %ecx
|
||||
pmovmskb %xmm1, %eax
|
||||
|
||||
and %edx, %eax
|
||||
test %eax, %eax
|
||||
jnz L(exit_dispatch)
|
||||
|
||||
xor %eax, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(length_less16):
|
||||
punpcklbw %xmm1, %xmm1
|
||||
add $16, %edx
|
||||
punpcklbw %xmm1, %xmm1
|
||||
|
||||
mov %ecx, %eax
|
||||
pshufd $0, %xmm1, %xmm1
|
||||
|
||||
and $15, %ecx
|
||||
jz L(length_less16_offset0)
|
||||
|
||||
PUSH (%edi)
|
||||
|
||||
mov %cl, %dh
|
||||
add %dl, %dh
|
||||
and $-16, %eax
|
||||
|
||||
sub $16, %dh
|
||||
ja L(length_less16_part2)
|
||||
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edi
|
||||
|
||||
sar %cl, %edi
|
||||
add %ecx, %eax
|
||||
mov %dl, %cl
|
||||
|
||||
mov $1, %edx
|
||||
sal %cl, %edx
|
||||
sub $1, %edx
|
||||
|
||||
and %edx, %edi
|
||||
test %edi, %edi
|
||||
jz L(ret_null)
|
||||
|
||||
bsr %edi, %edi
|
||||
add %edi, %eax
|
||||
POP (%edi)
|
||||
ret
|
||||
|
||||
CFI_PUSH (%edi)
|
||||
|
||||
.p2align 4
|
||||
L(length_less16_part2):
|
||||
movdqa 16(%eax), %xmm2
|
||||
pcmpeqb %xmm1, %xmm2
|
||||
pmovmskb %xmm2, %edi
|
||||
|
||||
mov %cl, %ch
|
||||
|
||||
mov %dh, %cl
|
||||
mov $1, %edx
|
||||
sal %cl, %edx
|
||||
sub $1, %edx
|
||||
|
||||
and %edx, %edi
|
||||
|
||||
test %edi, %edi
|
||||
jnz L(length_less16_part2_return)
|
||||
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edi
|
||||
|
||||
mov %ch, %cl
|
||||
sar %cl, %edi
|
||||
test %edi, %edi
|
||||
jz L(ret_null)
|
||||
|
||||
bsr %edi, %edi
|
||||
add %edi, %eax
|
||||
xor %ch, %ch
|
||||
add %ecx, %eax
|
||||
POP (%edi)
|
||||
ret
|
||||
|
||||
CFI_PUSH (%edi)
|
||||
|
||||
.p2align 4
|
||||
L(length_less16_part2_return):
|
||||
bsr %edi, %edi
|
||||
lea 16(%eax, %edi), %eax
|
||||
POP (%edi)
|
||||
ret
|
||||
|
||||
CFI_PUSH (%edi)
|
||||
|
||||
.p2align 4
|
||||
L(ret_null):
|
||||
xor %eax, %eax
|
||||
POP (%edi)
|
||||
ret
|
||||
|
||||
END (memrchr)
|
||||
@@ -28,6 +28,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#undef __i686
|
||||
|
||||
#ifndef L
|
||||
# define L(label) .L##label
|
||||
#endif
|
||||
@@ -136,9 +139,13 @@ __i686.get_pc_thunk.bx:
|
||||
jmp *TABLE(,%ecx,4)
|
||||
#endif
|
||||
|
||||
#ifndef MEMSET
|
||||
# define MEMSET memset
|
||||
#endif
|
||||
|
||||
.section .text.sse2,"ax",@progbits
|
||||
ALIGN (4)
|
||||
ENTRY (sse2_memset5_atom)
|
||||
ENTRY (MEMSET)
|
||||
ENTRANCE
|
||||
|
||||
movl LEN(%esp), %ecx
|
||||
@@ -911,4 +918,4 @@ L(aligned_16_15bytes):
|
||||
SETRTNVAL
|
||||
RETURN_END
|
||||
|
||||
END (sse2_memset5_atom)
|
||||
END (MEMSET)
|
||||
391
libc/arch-x86/string/sse2-strchr-atom.S
Normal file
391
libc/arch-x86/string/sse2-strchr-atom.S
Normal file
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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 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)
|
||||
|
||||
#define PARMS 8
|
||||
#define ENTRANCE PUSH(%edi)
|
||||
#define RETURN POP (%edi); ret; CFI_PUSH (%edi);
|
||||
|
||||
|
||||
#define STR1 PARMS
|
||||
#define STR2 STR1+4
|
||||
|
||||
.text
|
||||
ENTRY (strchr)
|
||||
|
||||
ENTRANCE
|
||||
mov STR1(%esp), %ecx
|
||||
movd STR2(%esp), %xmm1
|
||||
|
||||
pxor %xmm2, %xmm2
|
||||
mov %ecx, %edi
|
||||
punpcklbw %xmm1, %xmm1
|
||||
punpcklbw %xmm1, %xmm1
|
||||
/* ECX has OFFSET. */
|
||||
and $15, %ecx
|
||||
pshufd $0, %xmm1, %xmm1
|
||||
je L(loop)
|
||||
|
||||
/* Handle unaligned string. */
|
||||
and $-16, %edi
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
/* Find where NULL is. */
|
||||
pmovmskb %xmm2, %edx
|
||||
/* Check if there is a match. */
|
||||
pmovmskb %xmm0, %eax
|
||||
/* Remove the leading bytes. */
|
||||
sarl %cl, %edx
|
||||
sarl %cl, %eax
|
||||
test %eax, %eax
|
||||
jz L(unaligned_no_match)
|
||||
add %ecx, %edi
|
||||
test %edx, %edx
|
||||
jz L(match_case1)
|
||||
jmp L(match_case2)
|
||||
|
||||
.p2align 4
|
||||
L(unaligned_no_match):
|
||||
test %edx, %edx
|
||||
jne L(return_null)
|
||||
|
||||
pxor %xmm2, %xmm2
|
||||
add $16, %edi
|
||||
|
||||
.p2align 4
|
||||
/* Loop start on aligned string. */
|
||||
L(loop):
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches)
|
||||
test %edx, %edx
|
||||
jnz L(return_null)
|
||||
add $16, %edi
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches)
|
||||
test %edx, %edx
|
||||
jnz L(return_null)
|
||||
add $16, %edi
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches)
|
||||
test %edx, %edx
|
||||
jnz L(return_null)
|
||||
add $16, %edi
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(matches)
|
||||
test %edx, %edx
|
||||
jnz L(return_null)
|
||||
add $16, %edi
|
||||
jmp L(loop)
|
||||
|
||||
L(matches):
|
||||
/* There is a match. First find where NULL is. */
|
||||
test %edx, %edx
|
||||
jz L(match_case1)
|
||||
|
||||
.p2align 4
|
||||
L(match_case2):
|
||||
test %al, %al
|
||||
jz L(match_higth_case2)
|
||||
|
||||
mov %al, %cl
|
||||
and $15, %cl
|
||||
jnz L(match_case2_4)
|
||||
|
||||
mov %dl, %ch
|
||||
and $15, %ch
|
||||
jnz L(return_null)
|
||||
|
||||
test $0x10, %al
|
||||
jnz L(Exit5)
|
||||
test $0x10, %dl
|
||||
jnz L(return_null)
|
||||
test $0x20, %al
|
||||
jnz L(Exit6)
|
||||
test $0x20, %dl
|
||||
jnz L(return_null)
|
||||
test $0x40, %al
|
||||
jnz L(Exit7)
|
||||
test $0x40, %dl
|
||||
jnz L(return_null)
|
||||
lea 7(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case2_4):
|
||||
test $0x01, %al
|
||||
jnz L(Exit1)
|
||||
test $0x01, %dl
|
||||
jnz L(return_null)
|
||||
test $0x02, %al
|
||||
jnz L(Exit2)
|
||||
test $0x02, %dl
|
||||
jnz L(return_null)
|
||||
test $0x04, %al
|
||||
jnz L(Exit3)
|
||||
test $0x04, %dl
|
||||
jnz L(return_null)
|
||||
lea 3(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_higth_case2):
|
||||
test %dl, %dl
|
||||
jnz L(return_null)
|
||||
|
||||
mov %ah, %cl
|
||||
and $15, %cl
|
||||
jnz L(match_case2_12)
|
||||
|
||||
mov %dh, %ch
|
||||
and $15, %ch
|
||||
jnz L(return_null)
|
||||
|
||||
test $0x10, %ah
|
||||
jnz L(Exit13)
|
||||
test $0x10, %dh
|
||||
jnz L(return_null)
|
||||
test $0x20, %ah
|
||||
jnz L(Exit14)
|
||||
test $0x20, %dh
|
||||
jnz L(return_null)
|
||||
test $0x40, %ah
|
||||
jnz L(Exit15)
|
||||
test $0x40, %dh
|
||||
jnz L(return_null)
|
||||
lea 15(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case2_12):
|
||||
test $0x01, %ah
|
||||
jnz L(Exit9)
|
||||
test $0x01, %dh
|
||||
jnz L(return_null)
|
||||
test $0x02, %ah
|
||||
jnz L(Exit10)
|
||||
test $0x02, %dh
|
||||
jnz L(return_null)
|
||||
test $0x04, %ah
|
||||
jnz L(Exit11)
|
||||
test $0x04, %dh
|
||||
jnz L(return_null)
|
||||
lea 11(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case1):
|
||||
test %al, %al
|
||||
jz L(match_higth_case1)
|
||||
|
||||
test $0x01, %al
|
||||
jnz L(Exit1)
|
||||
test $0x02, %al
|
||||
jnz L(Exit2)
|
||||
test $0x04, %al
|
||||
jnz L(Exit3)
|
||||
test $0x08, %al
|
||||
jnz L(Exit4)
|
||||
test $0x10, %al
|
||||
jnz L(Exit5)
|
||||
test $0x20, %al
|
||||
jnz L(Exit6)
|
||||
test $0x40, %al
|
||||
jnz L(Exit7)
|
||||
lea 7(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_higth_case1):
|
||||
test $0x01, %ah
|
||||
jnz L(Exit9)
|
||||
test $0x02, %ah
|
||||
jnz L(Exit10)
|
||||
test $0x04, %ah
|
||||
jnz L(Exit11)
|
||||
test $0x08, %ah
|
||||
jnz L(Exit12)
|
||||
test $0x10, %ah
|
||||
jnz L(Exit13)
|
||||
test $0x20, %ah
|
||||
jnz L(Exit14)
|
||||
test $0x40, %ah
|
||||
jnz L(Exit15)
|
||||
lea 15(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit1):
|
||||
lea (%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit2):
|
||||
lea 1(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit3):
|
||||
lea 2(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit4):
|
||||
lea 3(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit5):
|
||||
lea 4(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit6):
|
||||
lea 5(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit7):
|
||||
lea 6(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit9):
|
||||
lea 8(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit10):
|
||||
lea 9(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit11):
|
||||
lea 10(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit12):
|
||||
lea 11(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit13):
|
||||
lea 12(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit14):
|
||||
lea 13(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit15):
|
||||
lea 14(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(return_null):
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
END (strchr)
|
||||
@@ -1,71 +1,112 @@
|
||||
#define STRLEN sse2_strlen_atom
|
||||
/*
|
||||
Copyright (c) 2011, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
#ifndef L
|
||||
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 USE_AS_STRCAT
|
||||
|
||||
# ifndef STRLEN
|
||||
# define STRLEN strlen
|
||||
# endif
|
||||
|
||||
# ifndef L
|
||||
# define L(label) .L##label
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#ifndef cfi_startproc
|
||||
# ifndef cfi_startproc
|
||||
# define cfi_startproc .cfi_startproc
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#ifndef cfi_endproc
|
||||
# ifndef cfi_endproc
|
||||
# define cfi_endproc .cfi_endproc
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#ifndef cfi_rel_offset
|
||||
/* calee safe register only for strnlen is required */
|
||||
|
||||
# ifdef USE_AS_STRNLEN
|
||||
# ifndef cfi_rel_offset
|
||||
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#ifndef cfi_restore
|
||||
# ifndef cfi_restore
|
||||
# define cfi_restore(reg) .cfi_restore reg
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#ifndef cfi_adjust_cfa_offset
|
||||
# ifndef cfi_adjust_cfa_offset
|
||||
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
|
||||
#endif
|
||||
# endif
|
||||
# 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
|
||||
# ifndef ENTRY
|
||||
# define ENTRY(name) \
|
||||
.type name, @function; \
|
||||
.globl name; \
|
||||
.p2align 4; \
|
||||
name: \
|
||||
cfi_startproc
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#ifndef END
|
||||
# ifndef END
|
||||
# define END(name) \
|
||||
cfi_endproc; \
|
||||
.size name, .-name
|
||||
#endif
|
||||
# endif
|
||||
|
||||
#define CFI_PUSH(REG) \
|
||||
# define PARMS 4
|
||||
# define STR PARMS
|
||||
# define RETURN ret
|
||||
|
||||
# ifdef USE_AS_STRNLEN
|
||||
# define LEN PARMS + 8
|
||||
# define CFI_PUSH(REG) \
|
||||
cfi_adjust_cfa_offset (4); \
|
||||
cfi_rel_offset (REG, 0)
|
||||
|
||||
#define CFI_POP(REG) \
|
||||
# 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
|
||||
# define PUSH(REG) pushl REG; CFI_PUSH (REG)
|
||||
# define POP(REG) popl REG; CFI_POP (REG)
|
||||
# undef RETURN
|
||||
# define RETURN POP (%edi); ret; CFI_PUSH(%edi);
|
||||
# endif
|
||||
|
||||
.text
|
||||
ENTRY (STRLEN)
|
||||
ENTRANCE
|
||||
mov STR(%esp), %edx
|
||||
# ifdef USE_AS_STRNLEN
|
||||
PUSH (%edi)
|
||||
movl LEN(%esp), %edi
|
||||
sub $4, %edi
|
||||
jbe L(len_less4_prolog)
|
||||
# endif
|
||||
#endif
|
||||
xor %eax, %eax
|
||||
cmpb $0, (%edx)
|
||||
jz L(exit_tail0)
|
||||
@@ -75,6 +116,12 @@ ENTRY (STRLEN)
|
||||
jz L(exit_tail2)
|
||||
cmpb $0, 3(%edx)
|
||||
jz L(exit_tail3)
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
sub $4, %edi
|
||||
jbe L(len_less8_prolog)
|
||||
#endif
|
||||
|
||||
cmpb $0, 4(%edx)
|
||||
jz L(exit_tail4)
|
||||
cmpb $0, 5(%edx)
|
||||
@@ -83,6 +130,12 @@ ENTRY (STRLEN)
|
||||
jz L(exit_tail6)
|
||||
cmpb $0, 7(%edx)
|
||||
jz L(exit_tail7)
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
sub $4, %edi
|
||||
jbe L(len_less12_prolog)
|
||||
#endif
|
||||
|
||||
cmpb $0, 8(%edx)
|
||||
jz L(exit_tail8)
|
||||
cmpb $0, 9(%edx)
|
||||
@@ -91,6 +144,12 @@ ENTRY (STRLEN)
|
||||
jz L(exit_tail10)
|
||||
cmpb $0, 11(%edx)
|
||||
jz L(exit_tail11)
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
sub $4, %edi
|
||||
jbe L(len_less16_prolog)
|
||||
#endif
|
||||
|
||||
cmpb $0, 12(%edx)
|
||||
jz L(exit_tail12)
|
||||
cmpb $0, 13(%edx)
|
||||
@@ -99,211 +158,531 @@ ENTRY (STRLEN)
|
||||
jz L(exit_tail14)
|
||||
cmpb $0, 15(%edx)
|
||||
jz L(exit_tail15)
|
||||
|
||||
pxor %xmm0, %xmm0
|
||||
mov %edx, %eax
|
||||
mov %edx, %ecx
|
||||
lea 16(%edx), %eax
|
||||
mov %eax, %ecx
|
||||
and $-16, %eax
|
||||
add $16, %ecx
|
||||
add $16, %eax
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
and $15, %edx
|
||||
add %edx, %edi
|
||||
sub $64, %edi
|
||||
jbe L(len_less64)
|
||||
#endif
|
||||
|
||||
pcmpeqb (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
pxor %xmm1, %xmm1
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
pxor %xmm2, %xmm2
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
|
||||
pcmpeqb (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
pxor %xmm3, %xmm3
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
sub $64, %edi
|
||||
jbe L(len_less64)
|
||||
#endif
|
||||
|
||||
pcmpeqb (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
sub $64, %edi
|
||||
jbe L(len_less64)
|
||||
#endif
|
||||
|
||||
pcmpeqb (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
sub $64, %edi
|
||||
jbe L(len_less64)
|
||||
#endif
|
||||
|
||||
pcmpeqb (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
test %edx, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
#ifdef USE_AS_STRNLEN
|
||||
mov %eax, %edx
|
||||
and $63, %edx
|
||||
add %edx, %edi
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
.p2align 4
|
||||
L(aligned_64_loop):
|
||||
#ifdef USE_AS_STRNLEN
|
||||
sub $64, %edi
|
||||
jbe L(len_less64)
|
||||
#endif
|
||||
movaps (%eax), %xmm0
|
||||
movaps 16(%eax), %xmm1
|
||||
movaps 32(%eax), %xmm2
|
||||
movaps 48(%eax), %xmm6
|
||||
pminub %xmm1, %xmm0
|
||||
pminub %xmm6, %xmm2
|
||||
pminub %xmm0, %xmm2
|
||||
pcmpeqb %xmm3, %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
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)
|
||||
jz L(aligned_64_loop)
|
||||
|
||||
pcmpeqb -64(%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea 48(%ecx), %ecx
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb %xmm1, %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea -16(%ecx), %ecx
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb -32(%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea -16(%ecx), %ecx
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqb %xmm6, %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea -16(%ecx), %ecx
|
||||
L(exit):
|
||||
sub %ecx, %eax
|
||||
test %dl, %dl
|
||||
jz L(exit_high)
|
||||
|
||||
mov %dl, %cl
|
||||
and $15, %cl
|
||||
jz L(exit_8)
|
||||
test $0x01, %dl
|
||||
jnz L(exit_tail0)
|
||||
|
||||
test $0x02, %dl
|
||||
jnz L(exit_tail1)
|
||||
|
||||
test $0x04, %dl
|
||||
jnz L(exit_tail2)
|
||||
add $3, %eax
|
||||
RETURN
|
||||
|
||||
test $0x08, %dl
|
||||
jnz L(exit_tail3)
|
||||
|
||||
.p2align 4
|
||||
L(exit_8):
|
||||
test $0x10, %dl
|
||||
jnz L(exit_tail4)
|
||||
|
||||
test $0x20, %dl
|
||||
jnz L(exit_tail5)
|
||||
|
||||
test $0x40, %dl
|
||||
jnz L(exit_tail6)
|
||||
add $7, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_high):
|
||||
mov %dh, %ch
|
||||
and $15, %ch
|
||||
jz L(exit_high_8)
|
||||
test $0x01, %dh
|
||||
jnz L(exit_tail8)
|
||||
test $0x02, %dh
|
||||
jnz L(exit_tail9)
|
||||
test $0x04, %dh
|
||||
jnz L(exit_tail10)
|
||||
add $11, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_high_8):
|
||||
test $0x10, %dh
|
||||
jnz L(exit_tail12)
|
||||
test $0x20, %dh
|
||||
jnz L(exit_tail13)
|
||||
test $0x40, %dh
|
||||
jnz L(exit_tail14)
|
||||
add $15, %eax
|
||||
L(exit_tail0):
|
||||
RETURN
|
||||
|
||||
L(exit_high):
|
||||
add $8, %eax
|
||||
test $0x01, %dh
|
||||
jnz L(exit_tail0)
|
||||
#ifdef USE_AS_STRNLEN
|
||||
|
||||
test $0x02, %dh
|
||||
jnz L(exit_tail1)
|
||||
.p2align 4
|
||||
L(len_less64):
|
||||
pxor %xmm0, %xmm0
|
||||
add $64, %edi
|
||||
|
||||
test $0x04, %dh
|
||||
jnz L(exit_tail2)
|
||||
pcmpeqb (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
pxor %xmm1, %xmm1
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(strnlen_exit)
|
||||
|
||||
test $0x08, %dh
|
||||
jnz L(exit_tail3)
|
||||
sub $16, %edi
|
||||
jbe L(return_start_len)
|
||||
|
||||
test $0x10, %dh
|
||||
jnz L(exit_tail4)
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(strnlen_exit)
|
||||
|
||||
test $0x20, %dh
|
||||
jnz L(exit_tail5)
|
||||
sub $16, %edi
|
||||
jbe L(return_start_len)
|
||||
|
||||
test $0x40, %dh
|
||||
jnz L(exit_tail6)
|
||||
add $7, %eax
|
||||
pcmpeqb (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(strnlen_exit)
|
||||
|
||||
sub $16, %edi
|
||||
jbe L(return_start_len)
|
||||
|
||||
pcmpeqb (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(strnlen_exit)
|
||||
|
||||
#ifndef USE_AS_STRLCAT
|
||||
movl LEN(%esp), %eax
|
||||
RETURN
|
||||
#else
|
||||
jmp L(return_start_len)
|
||||
#endif
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit):
|
||||
sub %ecx, %eax
|
||||
|
||||
test %dl, %dl
|
||||
jz L(strnlen_exit_high)
|
||||
mov %dl, %cl
|
||||
and $15, %cl
|
||||
jz L(strnlen_exit_8)
|
||||
test $0x01, %dl
|
||||
jnz L(exit_tail0)
|
||||
test $0x02, %dl
|
||||
jnz L(strnlen_exit_tail1)
|
||||
test $0x04, %dl
|
||||
jnz L(strnlen_exit_tail2)
|
||||
sub $4, %edi
|
||||
jb L(return_start_len)
|
||||
lea 3(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_8):
|
||||
test $0x10, %dl
|
||||
jnz L(strnlen_exit_tail4)
|
||||
test $0x20, %dl
|
||||
jnz L(strnlen_exit_tail5)
|
||||
test $0x40, %dl
|
||||
jnz L(strnlen_exit_tail6)
|
||||
sub $8, %edi
|
||||
jb L(return_start_len)
|
||||
lea 7(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_high):
|
||||
mov %dh, %ch
|
||||
and $15, %ch
|
||||
jz L(strnlen_exit_high_8)
|
||||
test $0x01, %dh
|
||||
jnz L(strnlen_exit_tail8)
|
||||
test $0x02, %dh
|
||||
jnz L(strnlen_exit_tail9)
|
||||
test $0x04, %dh
|
||||
jnz L(strnlen_exit_tail10)
|
||||
sub $12, %edi
|
||||
jb L(return_start_len)
|
||||
lea 11(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_high_8):
|
||||
test $0x10, %dh
|
||||
jnz L(strnlen_exit_tail12)
|
||||
test $0x20, %dh
|
||||
jnz L(strnlen_exit_tail13)
|
||||
test $0x40, %dh
|
||||
jnz L(strnlen_exit_tail14)
|
||||
sub $16, %edi
|
||||
jb L(return_start_len)
|
||||
lea 15(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail1):
|
||||
sub $2, %edi
|
||||
jb L(return_start_len)
|
||||
lea 1(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail2):
|
||||
sub $3, %edi
|
||||
jb L(return_start_len)
|
||||
lea 2(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail4):
|
||||
sub $5, %edi
|
||||
jb L(return_start_len)
|
||||
lea 4(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail5):
|
||||
sub $6, %edi
|
||||
jb L(return_start_len)
|
||||
lea 5(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail6):
|
||||
sub $7, %edi
|
||||
jb L(return_start_len)
|
||||
lea 6(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail8):
|
||||
sub $9, %edi
|
||||
jb L(return_start_len)
|
||||
lea 8(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail9):
|
||||
sub $10, %edi
|
||||
jb L(return_start_len)
|
||||
lea 9(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail10):
|
||||
sub $11, %edi
|
||||
jb L(return_start_len)
|
||||
lea 10(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail12):
|
||||
sub $13, %edi
|
||||
jb L(return_start_len)
|
||||
lea 12(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail13):
|
||||
sub $14, %edi
|
||||
jb L(return_start_len)
|
||||
lea 13(%eax), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(strnlen_exit_tail14):
|
||||
sub $15, %edi
|
||||
jb L(return_start_len)
|
||||
lea 14(%eax), %eax
|
||||
RETURN
|
||||
|
||||
#ifndef USE_AS_STRLCAT
|
||||
.p2align 4
|
||||
L(return_start_len):
|
||||
movl LEN(%esp), %eax
|
||||
RETURN
|
||||
#endif
|
||||
|
||||
/* for prolog only */
|
||||
|
||||
.p2align 4
|
||||
L(len_less4_prolog):
|
||||
xor %eax, %eax
|
||||
|
||||
add $4, %edi
|
||||
jz L(exit_tail0)
|
||||
|
||||
cmpb $0, (%edx)
|
||||
jz L(exit_tail0)
|
||||
cmp $1, %edi
|
||||
je L(exit_tail1)
|
||||
|
||||
cmpb $0, 1(%edx)
|
||||
jz L(exit_tail1)
|
||||
cmp $2, %edi
|
||||
je L(exit_tail2)
|
||||
|
||||
cmpb $0, 2(%edx)
|
||||
jz L(exit_tail2)
|
||||
cmp $3, %edi
|
||||
je L(exit_tail3)
|
||||
|
||||
cmpb $0, 3(%edx)
|
||||
jz L(exit_tail3)
|
||||
mov %edi, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(len_less8_prolog):
|
||||
add $4, %edi
|
||||
|
||||
cmpb $0, 4(%edx)
|
||||
jz L(exit_tail4)
|
||||
cmp $1, %edi
|
||||
je L(exit_tail5)
|
||||
|
||||
cmpb $0, 5(%edx)
|
||||
jz L(exit_tail5)
|
||||
cmp $2, %edi
|
||||
je L(exit_tail6)
|
||||
|
||||
cmpb $0, 6(%edx)
|
||||
jz L(exit_tail6)
|
||||
cmp $3, %edi
|
||||
je L(exit_tail7)
|
||||
|
||||
cmpb $0, 7(%edx)
|
||||
jz L(exit_tail7)
|
||||
mov $8, %eax
|
||||
RETURN
|
||||
|
||||
|
||||
.p2align 4
|
||||
L(len_less12_prolog):
|
||||
add $4, %edi
|
||||
|
||||
cmpb $0, 8(%edx)
|
||||
jz L(exit_tail8)
|
||||
cmp $1, %edi
|
||||
je L(exit_tail9)
|
||||
|
||||
cmpb $0, 9(%edx)
|
||||
jz L(exit_tail9)
|
||||
cmp $2, %edi
|
||||
je L(exit_tail10)
|
||||
|
||||
cmpb $0, 10(%edx)
|
||||
jz L(exit_tail10)
|
||||
cmp $3, %edi
|
||||
je L(exit_tail11)
|
||||
|
||||
cmpb $0, 11(%edx)
|
||||
jz L(exit_tail11)
|
||||
mov $12, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(len_less16_prolog):
|
||||
add $4, %edi
|
||||
|
||||
cmpb $0, 12(%edx)
|
||||
jz L(exit_tail12)
|
||||
cmp $1, %edi
|
||||
je L(exit_tail13)
|
||||
|
||||
cmpb $0, 13(%edx)
|
||||
jz L(exit_tail13)
|
||||
cmp $2, %edi
|
||||
je L(exit_tail14)
|
||||
|
||||
cmpb $0, 14(%edx)
|
||||
jz L(exit_tail14)
|
||||
cmp $3, %edi
|
||||
je L(exit_tail15)
|
||||
|
||||
cmpb $0, 15(%edx)
|
||||
jz L(exit_tail15)
|
||||
mov $16, %eax
|
||||
RETURN
|
||||
#endif
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail1):
|
||||
@@ -364,6 +743,7 @@ L(exit_tail14):
|
||||
|
||||
L(exit_tail15):
|
||||
add $15, %eax
|
||||
ret
|
||||
|
||||
#ifndef USE_AS_STRCAT
|
||||
RETURN
|
||||
END (STRLEN)
|
||||
#endif
|
||||
|
||||
33
libc/arch-x86/string/sse2-strnlen-atom.S
Normal file
33
libc/arch-x86/string/sse2-strnlen-atom.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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.
|
||||
*/
|
||||
|
||||
#define USE_AS_STRNLEN 1
|
||||
#define STRLEN strnlen
|
||||
#include "sse2-strlen-atom.S"
|
||||
753
libc/arch-x86/string/sse2-strrchr-atom.S
Normal file
753
libc/arch-x86/string/sse2-strrchr-atom.S
Normal file
@@ -0,0 +1,753 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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 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)
|
||||
|
||||
#define PARMS 8
|
||||
#define ENTRANCE PUSH(%edi);
|
||||
#define RETURN POP (%edi); ret; CFI_PUSH (%edi);
|
||||
|
||||
#define STR1 PARMS
|
||||
#define STR2 STR1+4
|
||||
|
||||
.text
|
||||
ENTRY (strrchr)
|
||||
|
||||
ENTRANCE
|
||||
mov STR1(%esp), %ecx
|
||||
movd STR2(%esp), %xmm1
|
||||
|
||||
pxor %xmm2, %xmm2
|
||||
mov %ecx, %edi
|
||||
punpcklbw %xmm1, %xmm1
|
||||
punpcklbw %xmm1, %xmm1
|
||||
/* ECX has OFFSET. */
|
||||
and $63, %ecx
|
||||
pshufd $0, %xmm1, %xmm1
|
||||
cmp $48, %ecx
|
||||
ja L(crosscache)
|
||||
|
||||
/* unaligned string. */
|
||||
movdqu (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
/* Find where NULL is. */
|
||||
pmovmskb %xmm2, %ecx
|
||||
/* Check if there is a match. */
|
||||
pmovmskb %xmm0, %eax
|
||||
add $16, %edi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(unaligned_match1)
|
||||
|
||||
test %ecx, %ecx
|
||||
jnz L(return_null)
|
||||
|
||||
and $-16, %edi
|
||||
|
||||
PUSH (%esi)
|
||||
PUSH (%ebx)
|
||||
|
||||
xor %ebx, %ebx
|
||||
jmp L(loop)
|
||||
|
||||
CFI_POP (%esi)
|
||||
CFI_POP (%ebx)
|
||||
|
||||
.p2align 4
|
||||
L(unaligned_match1):
|
||||
test %ecx, %ecx
|
||||
jnz L(prolog_find_zero_1)
|
||||
|
||||
PUSH (%esi)
|
||||
PUSH (%ebx)
|
||||
|
||||
mov %eax, %ebx
|
||||
mov %edi, %esi
|
||||
and $-16, %edi
|
||||
jmp L(loop)
|
||||
|
||||
CFI_POP (%esi)
|
||||
CFI_POP (%ebx)
|
||||
|
||||
.p2align 4
|
||||
L(crosscache):
|
||||
/* Hancle unaligned string. */
|
||||
and $15, %ecx
|
||||
and $-16, %edi
|
||||
pxor %xmm3, %xmm3
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm3
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
/* Find where NULL is. */
|
||||
pmovmskb %xmm3, %edx
|
||||
/* Check if there is a match. */
|
||||
pmovmskb %xmm0, %eax
|
||||
/* Remove the leading bytes. */
|
||||
shr %cl, %edx
|
||||
shr %cl, %eax
|
||||
add $16, %edi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(unaligned_match)
|
||||
|
||||
test %edx, %edx
|
||||
jnz L(return_null)
|
||||
|
||||
PUSH (%esi)
|
||||
PUSH (%ebx)
|
||||
|
||||
xor %ebx, %ebx
|
||||
jmp L(loop)
|
||||
|
||||
CFI_POP (%esi)
|
||||
CFI_POP (%ebx)
|
||||
|
||||
.p2align 4
|
||||
L(unaligned_match):
|
||||
test %edx, %edx
|
||||
jnz L(prolog_find_zero)
|
||||
|
||||
PUSH (%esi)
|
||||
PUSH (%ebx)
|
||||
|
||||
mov %eax, %ebx
|
||||
lea (%edi, %ecx), %esi
|
||||
|
||||
/* Loop start on aligned string. */
|
||||
.p2align 4
|
||||
L(loop):
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %ecx
|
||||
jnz L(matches)
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %ecx
|
||||
jnz L(matches)
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %ecx
|
||||
jnz L(matches)
|
||||
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqb %xmm0, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqb %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %ecx
|
||||
jz L(loop)
|
||||
|
||||
L(matches):
|
||||
test %eax, %eax
|
||||
jnz L(match)
|
||||
L(return_value):
|
||||
test %ebx, %ebx
|
||||
jz L(return_null_1)
|
||||
mov %ebx, %eax
|
||||
mov %esi, %edi
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(return_null_1):
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(match):
|
||||
pmovmskb %xmm2, %ecx
|
||||
test %ecx, %ecx
|
||||
jnz L(find_zero)
|
||||
mov %eax, %ebx
|
||||
mov %edi, %esi
|
||||
jmp L(loop)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero):
|
||||
test %cl, %cl
|
||||
jz L(find_zero_high)
|
||||
mov %cl, %dl
|
||||
and $15, %dl
|
||||
jz L(find_zero_8)
|
||||
test $0x01, %cl
|
||||
jnz L(FindZeroExit1)
|
||||
test $0x02, %cl
|
||||
jnz L(FindZeroExit2)
|
||||
test $0x04, %cl
|
||||
jnz L(FindZeroExit3)
|
||||
and $1 << 4 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero_8):
|
||||
test $0x10, %cl
|
||||
jnz L(FindZeroExit5)
|
||||
test $0x20, %cl
|
||||
jnz L(FindZeroExit6)
|
||||
test $0x40, %cl
|
||||
jnz L(FindZeroExit7)
|
||||
and $1 << 8 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero_high):
|
||||
mov %ch, %dh
|
||||
and $15, %dh
|
||||
jz L(find_zero_high_8)
|
||||
test $0x01, %ch
|
||||
jnz L(FindZeroExit9)
|
||||
test $0x02, %ch
|
||||
jnz L(FindZeroExit10)
|
||||
test $0x04, %ch
|
||||
jnz L(FindZeroExit11)
|
||||
and $1 << 12 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero_high_8):
|
||||
test $0x10, %ch
|
||||
jnz L(FindZeroExit13)
|
||||
test $0x20, %ch
|
||||
jnz L(FindZeroExit14)
|
||||
test $0x40, %ch
|
||||
jnz L(FindZeroExit15)
|
||||
and $1 << 16 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit1):
|
||||
and $1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit2):
|
||||
and $1 << 2 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit3):
|
||||
and $1 << 3 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit5):
|
||||
and $1 << 5 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit6):
|
||||
and $1 << 6 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit7):
|
||||
and $1 << 7 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit9):
|
||||
and $1 << 9 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit10):
|
||||
and $1 << 10 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit11):
|
||||
and $1 << 11 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit13):
|
||||
and $1 << 13 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit14):
|
||||
and $1 << 14 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
jmp L(match_case1)
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(FindZeroExit15):
|
||||
and $1 << 15 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%ebx)
|
||||
POP (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(match_case1):
|
||||
test %ah, %ah
|
||||
jnz L(match_case1_high)
|
||||
mov %al, %dl
|
||||
and $15 << 4, %dl
|
||||
jnz L(match_case1_8)
|
||||
test $0x08, %al
|
||||
jnz L(Exit4)
|
||||
test $0x04, %al
|
||||
jnz L(Exit3)
|
||||
test $0x02, %al
|
||||
jnz L(Exit2)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case1_8):
|
||||
test $0x80, %al
|
||||
jnz L(Exit8)
|
||||
test $0x40, %al
|
||||
jnz L(Exit7)
|
||||
test $0x20, %al
|
||||
jnz L(Exit6)
|
||||
lea -12(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case1_high):
|
||||
mov %ah, %dh
|
||||
and $15 << 4, %dh
|
||||
jnz L(match_case1_high_8)
|
||||
test $0x08, %ah
|
||||
jnz L(Exit12)
|
||||
test $0x04, %ah
|
||||
jnz L(Exit11)
|
||||
test $0x02, %ah
|
||||
jnz L(Exit10)
|
||||
lea -8(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_case1_high_8):
|
||||
test $0x80, %ah
|
||||
jnz L(Exit16)
|
||||
test $0x40, %ah
|
||||
jnz L(Exit15)
|
||||
test $0x20, %ah
|
||||
jnz L(Exit14)
|
||||
lea -4(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit2):
|
||||
lea -15(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit3):
|
||||
lea -14(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit4):
|
||||
lea -13(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit6):
|
||||
lea -11(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit7):
|
||||
lea -10(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit8):
|
||||
lea -9(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit10):
|
||||
lea -7(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit11):
|
||||
lea -6(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit12):
|
||||
lea -5(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit14):
|
||||
lea -3(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit15):
|
||||
lea -2(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit16):
|
||||
lea -1(%edi), %eax
|
||||
RETURN
|
||||
|
||||
/* Return NULL. */
|
||||
.p2align 4
|
||||
L(return_null):
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero):
|
||||
add %ecx, %edi
|
||||
mov %edx, %ecx
|
||||
L(prolog_find_zero_1):
|
||||
test %cl, %cl
|
||||
jz L(prolog_find_zero_high)
|
||||
mov %cl, %dl
|
||||
and $15, %dl
|
||||
jz L(prolog_find_zero_8)
|
||||
test $0x01, %cl
|
||||
jnz L(PrologFindZeroExit1)
|
||||
test $0x02, %cl
|
||||
jnz L(PrologFindZeroExit2)
|
||||
test $0x04, %cl
|
||||
jnz L(PrologFindZeroExit3)
|
||||
and $1 << 4 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero_8):
|
||||
test $0x10, %cl
|
||||
jnz L(PrologFindZeroExit5)
|
||||
test $0x20, %cl
|
||||
jnz L(PrologFindZeroExit6)
|
||||
test $0x40, %cl
|
||||
jnz L(PrologFindZeroExit7)
|
||||
and $1 << 8 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero_high):
|
||||
mov %ch, %dh
|
||||
and $15, %dh
|
||||
jz L(prolog_find_zero_high_8)
|
||||
test $0x01, %ch
|
||||
jnz L(PrologFindZeroExit9)
|
||||
test $0x02, %ch
|
||||
jnz L(PrologFindZeroExit10)
|
||||
test $0x04, %ch
|
||||
jnz L(PrologFindZeroExit11)
|
||||
and $1 << 12 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero_high_8):
|
||||
test $0x10, %ch
|
||||
jnz L(PrologFindZeroExit13)
|
||||
test $0x20, %ch
|
||||
jnz L(PrologFindZeroExit14)
|
||||
test $0x40, %ch
|
||||
jnz L(PrologFindZeroExit15)
|
||||
and $1 << 16 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit1):
|
||||
and $1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit2):
|
||||
and $1 << 2 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit3):
|
||||
and $1 << 3 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit5):
|
||||
and $1 << 5 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit6):
|
||||
and $1 << 6 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit7):
|
||||
and $1 << 7 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit9):
|
||||
and $1 << 9 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit10):
|
||||
and $1 << 10 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit11):
|
||||
and $1 << 11 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit13):
|
||||
and $1 << 13 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit14):
|
||||
and $1 << 14 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(PrologFindZeroExit15):
|
||||
and $1 << 15 - 1, %eax
|
||||
jnz L(match_case1)
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
END (strrchr)
|
||||
267
libc/arch-x86/string/sse2-wcschr-atom.S
Normal file
267
libc/arch-x86/string/sse2-wcschr-atom.S
Normal file
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
Copyright (c) 2011 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 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)
|
||||
|
||||
#define PARMS 4
|
||||
|
||||
|
||||
#define STR1 PARMS
|
||||
#define STR2 STR1+4
|
||||
|
||||
.text
|
||||
ENTRY (wcschr)
|
||||
|
||||
mov STR1(%esp), %ecx
|
||||
movd STR2(%esp), %xmm1
|
||||
|
||||
mov %ecx, %eax
|
||||
punpckldq %xmm1, %xmm1
|
||||
pxor %xmm2, %xmm2
|
||||
punpckldq %xmm1, %xmm1
|
||||
|
||||
and $63, %eax
|
||||
cmp $48, %eax
|
||||
ja L(cross_cache)
|
||||
|
||||
movdqu (%ecx), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %edx
|
||||
jnz L(matches)
|
||||
and $-16, %ecx
|
||||
jmp L(loop)
|
||||
|
||||
.p2align 4
|
||||
L(cross_cache):
|
||||
PUSH (%edi)
|
||||
mov %ecx, %edi
|
||||
mov %eax, %ecx
|
||||
and $-16, %edi
|
||||
and $15, %ecx
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
|
||||
sarl %cl, %edx
|
||||
sarl %cl, %eax
|
||||
test %eax, %eax
|
||||
jz L(unaligned_no_match)
|
||||
|
||||
add %edi, %ecx
|
||||
POP (%edi)
|
||||
|
||||
test %edx, %edx
|
||||
jz L(match_case1)
|
||||
test %al, %al
|
||||
jz L(match_higth_case2)
|
||||
test $15, %al
|
||||
jnz L(match_case2_4)
|
||||
test $15, %dl
|
||||
jnz L(return_null)
|
||||
lea 4(%ecx), %eax
|
||||
ret
|
||||
|
||||
CFI_PUSH (%edi)
|
||||
|
||||
.p2align 4
|
||||
L(unaligned_no_match):
|
||||
mov %edi, %ecx
|
||||
POP (%edi)
|
||||
|
||||
test %edx, %edx
|
||||
jnz L(return_null)
|
||||
|
||||
pxor %xmm2, %xmm2
|
||||
|
||||
/* Loop start on aligned string. */
|
||||
.p2align 4
|
||||
L(loop):
|
||||
add $16, %ecx
|
||||
movdqa (%ecx), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %edx
|
||||
jnz L(matches)
|
||||
add $16, %ecx
|
||||
|
||||
movdqa (%ecx), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %edx
|
||||
jnz L(matches)
|
||||
add $16, %ecx
|
||||
|
||||
movdqa (%ecx), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %edx
|
||||
jnz L(matches)
|
||||
add $16, %ecx
|
||||
|
||||
movdqa (%ecx), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %edx
|
||||
jz L(loop)
|
||||
|
||||
.p2align 4
|
||||
L(matches):
|
||||
pmovmskb %xmm2, %edx
|
||||
test %eax, %eax
|
||||
jz L(return_null)
|
||||
test %edx, %edx
|
||||
jz L(match_case1)
|
||||
|
||||
.p2align 4
|
||||
L(match_case2):
|
||||
test %al, %al
|
||||
jz L(match_higth_case2)
|
||||
test $15, %al
|
||||
jnz L(match_case2_4)
|
||||
test $15, %dl
|
||||
jnz L(return_null)
|
||||
lea 4(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(match_case2_4):
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(match_higth_case2):
|
||||
test %dl, %dl
|
||||
jnz L(return_null)
|
||||
test $15, %ah
|
||||
jnz L(match_case2_12)
|
||||
test $15, %dh
|
||||
jnz L(return_null)
|
||||
lea 12(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(match_case2_12):
|
||||
lea 8(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(match_case1):
|
||||
test %al, %al
|
||||
jz L(match_higth_case1)
|
||||
|
||||
test $0x01, %al
|
||||
jnz L(exit0)
|
||||
lea 4(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(match_higth_case1):
|
||||
test $0x01, %ah
|
||||
jnz L(exit3)
|
||||
lea 12(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit0):
|
||||
mov %ecx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(exit3):
|
||||
lea 8(%ecx), %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(return_null):
|
||||
xor %eax, %eax
|
||||
ret
|
||||
|
||||
END (wcschr)
|
||||
1062
libc/arch-x86/string/sse2-wcscmp-atom.S
Normal file
1062
libc/arch-x86/string/sse2-wcscmp-atom.S
Normal file
File diff suppressed because it is too large
Load Diff
306
libc/arch-x86/string/sse2-wcslen-atom.S
Normal file
306
libc/arch-x86/string/sse2-wcslen-atom.S
Normal file
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
Copyright (c) 2011 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 USE_AS_WCSCAT
|
||||
|
||||
# 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 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 PARMS 4
|
||||
# define STR PARMS
|
||||
# define RETURN ret
|
||||
|
||||
.text
|
||||
ENTRY (wcslen)
|
||||
mov STR(%esp), %edx
|
||||
#endif
|
||||
cmp $0, (%edx)
|
||||
jz L(exit_tail0)
|
||||
cmp $0, 4(%edx)
|
||||
jz L(exit_tail1)
|
||||
cmp $0, 8(%edx)
|
||||
jz L(exit_tail2)
|
||||
cmp $0, 12(%edx)
|
||||
jz L(exit_tail3)
|
||||
cmp $0, 16(%edx)
|
||||
jz L(exit_tail4)
|
||||
cmp $0, 20(%edx)
|
||||
jz L(exit_tail5)
|
||||
cmp $0, 24(%edx)
|
||||
jz L(exit_tail6)
|
||||
cmp $0, 28(%edx)
|
||||
jz L(exit_tail7)
|
||||
|
||||
pxor %xmm0, %xmm0
|
||||
|
||||
lea 32(%edx), %eax
|
||||
lea -16(%eax), %ecx
|
||||
and $-16, %eax
|
||||
|
||||
pcmpeqd (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
pxor %xmm1, %xmm1
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
pxor %xmm2, %xmm2
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
pxor %xmm3, %xmm3
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm0
|
||||
pmovmskb %xmm0, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm1
|
||||
pmovmskb %xmm1, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd (%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea 16(%eax), %eax
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
and $-0x40, %eax
|
||||
|
||||
.p2align 4
|
||||
L(aligned_64_loop):
|
||||
movaps (%eax), %xmm0
|
||||
movaps 16(%eax), %xmm1
|
||||
movaps 32(%eax), %xmm2
|
||||
movaps 48(%eax), %xmm6
|
||||
|
||||
pminub %xmm1, %xmm0
|
||||
pminub %xmm6, %xmm2
|
||||
pminub %xmm0, %xmm2
|
||||
pcmpeqd %xmm3, %xmm2
|
||||
pmovmskb %xmm2, %edx
|
||||
lea 64(%eax), %eax
|
||||
test %edx, %edx
|
||||
jz L(aligned_64_loop)
|
||||
|
||||
pcmpeqd -64(%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea 48(%ecx), %ecx
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd %xmm1, %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea -16(%ecx), %ecx
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd -32(%eax), %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea -16(%ecx), %ecx
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
pcmpeqd %xmm6, %xmm3
|
||||
pmovmskb %xmm3, %edx
|
||||
lea -16(%ecx), %ecx
|
||||
test %edx, %edx
|
||||
jnz L(exit)
|
||||
|
||||
jmp L(aligned_64_loop)
|
||||
|
||||
.p2align 4
|
||||
L(exit):
|
||||
sub %ecx, %eax
|
||||
shr $2, %eax
|
||||
test %dl, %dl
|
||||
jz L(exit_high)
|
||||
|
||||
mov %dl, %cl
|
||||
and $15, %cl
|
||||
jz L(exit_1)
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_high):
|
||||
mov %dh, %ch
|
||||
and $15, %ch
|
||||
jz L(exit_3)
|
||||
add $2, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_1):
|
||||
add $1, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_3):
|
||||
add $3, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail0):
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail1):
|
||||
mov $1, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail2):
|
||||
mov $2, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail3):
|
||||
mov $3, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail4):
|
||||
mov $4, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail5):
|
||||
mov $5, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail6):
|
||||
mov $6, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(exit_tail7):
|
||||
mov $7, %eax
|
||||
#ifndef USE_AS_WCSCAT
|
||||
RETURN
|
||||
|
||||
END (wcslen)
|
||||
#endif
|
||||
402
libc/arch-x86/string/sse2-wcsrchr-atom.S
Normal file
402
libc/arch-x86/string/sse2-wcsrchr-atom.S
Normal file
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
Copyright (c) 2011 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 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)
|
||||
|
||||
#define PARMS 8
|
||||
#define ENTRANCE PUSH(%edi);
|
||||
#define RETURN POP(%edi); ret; CFI_PUSH(%edi);
|
||||
|
||||
#define STR1 PARMS
|
||||
#define STR2 STR1+4
|
||||
|
||||
.text
|
||||
ENTRY (wcsrchr)
|
||||
|
||||
ENTRANCE
|
||||
mov STR1(%esp), %ecx
|
||||
movd STR2(%esp), %xmm1
|
||||
|
||||
mov %ecx, %edi
|
||||
punpckldq %xmm1, %xmm1
|
||||
pxor %xmm2, %xmm2
|
||||
punpckldq %xmm1, %xmm1
|
||||
|
||||
/* ECX has OFFSET. */
|
||||
and $63, %ecx
|
||||
cmp $48, %ecx
|
||||
ja L(crosscache)
|
||||
|
||||
/* unaligned string. */
|
||||
movdqu (%edi), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
/* Find where NULL is. */
|
||||
pmovmskb %xmm2, %ecx
|
||||
/* Check if there is a match. */
|
||||
pmovmskb %xmm0, %eax
|
||||
add $16, %edi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(unaligned_match1)
|
||||
|
||||
test %ecx, %ecx
|
||||
jnz L(return_null)
|
||||
|
||||
and $-16, %edi
|
||||
|
||||
PUSH (%esi)
|
||||
|
||||
xor %edx, %edx
|
||||
jmp L(loop)
|
||||
|
||||
CFI_POP (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(unaligned_match1):
|
||||
test %ecx, %ecx
|
||||
jnz L(prolog_find_zero_1)
|
||||
|
||||
PUSH (%esi)
|
||||
|
||||
/* Save current match */
|
||||
mov %eax, %edx
|
||||
mov %edi, %esi
|
||||
and $-16, %edi
|
||||
jmp L(loop)
|
||||
|
||||
CFI_POP (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(crosscache):
|
||||
/* Hancle unaligned string. */
|
||||
and $15, %ecx
|
||||
and $-16, %edi
|
||||
pxor %xmm3, %xmm3
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqd %xmm0, %xmm3
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
/* Find where NULL is. */
|
||||
pmovmskb %xmm3, %edx
|
||||
/* Check if there is a match. */
|
||||
pmovmskb %xmm0, %eax
|
||||
/* Remove the leading bytes. */
|
||||
shr %cl, %edx
|
||||
shr %cl, %eax
|
||||
add $16, %edi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(unaligned_match)
|
||||
|
||||
test %edx, %edx
|
||||
jnz L(return_null)
|
||||
|
||||
PUSH (%esi)
|
||||
|
||||
xor %edx, %edx
|
||||
jmp L(loop)
|
||||
|
||||
CFI_POP (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(unaligned_match):
|
||||
test %edx, %edx
|
||||
jnz L(prolog_find_zero)
|
||||
|
||||
PUSH (%esi)
|
||||
|
||||
mov %eax, %edx
|
||||
lea (%edi, %ecx), %esi
|
||||
|
||||
/* Loop start on aligned string. */
|
||||
.p2align 4
|
||||
L(loop):
|
||||
movdqa (%edi), %xmm0
|
||||
pcmpeqd %xmm0, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm0, %eax
|
||||
or %eax, %ecx
|
||||
jnz L(matches)
|
||||
|
||||
movdqa (%edi), %xmm3
|
||||
pcmpeqd %xmm3, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqd %xmm1, %xmm3
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm3, %eax
|
||||
or %eax, %ecx
|
||||
jnz L(matches)
|
||||
|
||||
movdqa (%edi), %xmm4
|
||||
pcmpeqd %xmm4, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqd %xmm1, %xmm4
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm4, %eax
|
||||
or %eax, %ecx
|
||||
jnz L(matches)
|
||||
|
||||
movdqa (%edi), %xmm5
|
||||
pcmpeqd %xmm5, %xmm2
|
||||
add $16, %edi
|
||||
pcmpeqd %xmm1, %xmm5
|
||||
pmovmskb %xmm2, %ecx
|
||||
pmovmskb %xmm5, %eax
|
||||
or %eax, %ecx
|
||||
jz L(loop)
|
||||
|
||||
.p2align 4
|
||||
L(matches):
|
||||
test %eax, %eax
|
||||
jnz L(match)
|
||||
L(return_value):
|
||||
test %edx, %edx
|
||||
jz L(return_null_1)
|
||||
mov %edx, %eax
|
||||
mov %esi, %edi
|
||||
|
||||
POP (%esi)
|
||||
|
||||
test %ah, %ah
|
||||
jnz L(match_third_or_fourth_wchar)
|
||||
test $15 << 4, %al
|
||||
jnz L(match_second_wchar)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(return_null_1):
|
||||
POP (%esi)
|
||||
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(match):
|
||||
pmovmskb %xmm2, %ecx
|
||||
test %ecx, %ecx
|
||||
jnz L(find_zero)
|
||||
/* save match info */
|
||||
mov %eax, %edx
|
||||
mov %edi, %esi
|
||||
jmp L(loop)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero):
|
||||
test %cl, %cl
|
||||
jz L(find_zero_in_third_or_fourth_wchar)
|
||||
test $15, %cl
|
||||
jz L(find_zero_in_second_wchar)
|
||||
and $1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%esi)
|
||||
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero_in_second_wchar):
|
||||
and $1 << 5 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%esi)
|
||||
|
||||
test $15 << 4, %al
|
||||
jnz L(match_second_wchar)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero_in_third_or_fourth_wchar):
|
||||
test $15, %ch
|
||||
jz L(find_zero_in_fourth_wchar)
|
||||
and $1 << 9 - 1, %eax
|
||||
jz L(return_value)
|
||||
|
||||
POP (%esi)
|
||||
|
||||
test %ah, %ah
|
||||
jnz L(match_third_wchar)
|
||||
test $15 << 4, %al
|
||||
jnz L(match_second_wchar)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(find_zero_in_fourth_wchar):
|
||||
|
||||
POP (%esi)
|
||||
|
||||
test %ah, %ah
|
||||
jnz L(match_third_or_fourth_wchar)
|
||||
test $15 << 4, %al
|
||||
jnz L(match_second_wchar)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(match_second_wchar):
|
||||
lea -12(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_third_or_fourth_wchar):
|
||||
test $15 << 4, %ah
|
||||
jnz L(match_fourth_wchar)
|
||||
lea -8(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_third_wchar):
|
||||
lea -8(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(match_fourth_wchar):
|
||||
lea -4(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(return_null):
|
||||
xor %eax, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero):
|
||||
add %ecx, %edi
|
||||
mov %edx, %ecx
|
||||
L(prolog_find_zero_1):
|
||||
test %cl, %cl
|
||||
jz L(prolog_find_zero_in_third_or_fourth_wchar)
|
||||
test $15, %cl
|
||||
jz L(prolog_find_zero_in_second_wchar)
|
||||
and $1, %eax
|
||||
jz L(return_null)
|
||||
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero_in_second_wchar):
|
||||
and $1 << 5 - 1, %eax
|
||||
jz L(return_null)
|
||||
|
||||
test $15 << 4, %al
|
||||
jnz L(match_second_wchar)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero_in_third_or_fourth_wchar):
|
||||
test $15, %ch
|
||||
jz L(prolog_find_zero_in_fourth_wchar)
|
||||
and $1 << 9 - 1, %eax
|
||||
jz L(return_null)
|
||||
|
||||
test %ah, %ah
|
||||
jnz L(match_third_wchar)
|
||||
test $15 << 4, %al
|
||||
jnz L(match_second_wchar)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(prolog_find_zero_in_fourth_wchar):
|
||||
test %ah, %ah
|
||||
jnz L(match_third_or_fourth_wchar)
|
||||
test $15 << 4, %al
|
||||
jnz L(match_second_wchar)
|
||||
lea -16(%edi), %eax
|
||||
RETURN
|
||||
|
||||
END (wcsrchr)
|
||||
@@ -28,13 +28,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
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
|
||||
#define MEMCPY bcopy
|
||||
#define USE_AS_MEMMOVE
|
||||
#define USE_AS_BCOPY
|
||||
#include "ssse3-memcpy-atom.S"
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
Copyright (c) 2010, 2011 Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,18 +28,10 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MEMCMP
|
||||
# define MEMCMP ssse3_memcmp3_new
|
||||
#endif
|
||||
|
||||
#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
|
||||
@@ -83,6 +75,10 @@ name: \
|
||||
.size name, .-name
|
||||
#endif
|
||||
|
||||
#ifndef MEMCMP
|
||||
# define MEMCMP memcmp
|
||||
#endif
|
||||
|
||||
#define CFI_PUSH(REG) \
|
||||
cfi_adjust_cfa_offset (4); \
|
||||
cfi_rel_offset (REG, 0)
|
||||
@@ -101,22 +97,39 @@ name: \
|
||||
#define RETURN_END POP (%edi); POP (%esi); POP (%ebx); ret
|
||||
#define RETURN RETURN_END; cfi_restore_state; cfi_remember_state
|
||||
|
||||
.section .text.ssse3,"ax",@progbits
|
||||
/* Warning!
|
||||
wmemcmp has to use SIGNED comparison for elements.
|
||||
memcmp has to use UNSIGNED comparison for elemnts.
|
||||
*/
|
||||
|
||||
.text
|
||||
ENTRY (MEMCMP)
|
||||
movl LEN(%esp), %ecx
|
||||
|
||||
#ifdef USE_AS_WMEMCMP
|
||||
shl $2, %ecx
|
||||
jz L(zero)
|
||||
#endif
|
||||
|
||||
movl BLK1(%esp), %eax
|
||||
cmp $48, %ecx
|
||||
movl BLK2(%esp), %edx
|
||||
jae L(48bytesormore)
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $1, %ecx
|
||||
jbe L(less1bytes)
|
||||
#endif
|
||||
|
||||
PUSH (%ebx)
|
||||
add %ecx, %edx
|
||||
add %ecx, %eax
|
||||
jmp L(less48bytes)
|
||||
|
||||
CFI_POP (%ebx)
|
||||
ALIGN (4)
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
.p2align 4
|
||||
L(less1bytes):
|
||||
jb L(zero)
|
||||
movb (%eax), %cl
|
||||
@@ -127,13 +140,14 @@ L(less1bytes):
|
||||
neg %eax
|
||||
L(1bytesend):
|
||||
ret
|
||||
#endif
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(zero):
|
||||
mov $0, %eax
|
||||
xor %eax, %eax
|
||||
ret
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(48bytesormore):
|
||||
PUSH (%ebx)
|
||||
PUSH (%esi)
|
||||
@@ -160,6 +174,7 @@ L(48bytesormore):
|
||||
jz L(shr_0)
|
||||
xor %edx, %esi
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $8, %edx
|
||||
jae L(next_unaligned_table)
|
||||
cmp $0, %edx
|
||||
@@ -178,7 +193,7 @@ L(48bytesormore):
|
||||
je L(shr_6)
|
||||
jmp L(shr_7)
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 2
|
||||
L(next_unaligned_table):
|
||||
cmp $8, %edx
|
||||
je L(shr_8)
|
||||
@@ -195,8 +210,17 @@ L(next_unaligned_table):
|
||||
cmp $14, %edx
|
||||
je L(shr_14)
|
||||
jmp L(shr_15)
|
||||
#else
|
||||
cmp $0, %edx
|
||||
je L(shr_0)
|
||||
cmp $4, %edx
|
||||
je L(shr_4)
|
||||
cmp $8, %edx
|
||||
je L(shr_8)
|
||||
jmp L(shr_12)
|
||||
#endif
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_0):
|
||||
cmp $80, %ecx
|
||||
jae L(shr_0_gobble)
|
||||
@@ -221,7 +245,7 @@ L(shr_0):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_0_gobble):
|
||||
lea -48(%ecx), %ecx
|
||||
movdqa (%esi), %xmm0
|
||||
@@ -265,9 +289,10 @@ L(shr_0_gobble_loop_next):
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_1):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -297,7 +322,7 @@ L(shr_1):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_1_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -348,9 +373,10 @@ L(shr_1_gobble_next):
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_2):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -380,7 +406,7 @@ L(shr_2):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_2_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -433,7 +459,7 @@ L(shr_2_gobble_next):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_3):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -463,7 +489,7 @@ L(shr_3):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_3_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -513,10 +539,11 @@ L(shr_3_gobble_next):
|
||||
POP (%edi)
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
#endif
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_4):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -546,7 +573,7 @@ L(shr_4):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_4_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -597,9 +624,10 @@ L(shr_4_gobble_next):
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_5):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -629,7 +657,7 @@ L(shr_5):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_5_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -682,7 +710,7 @@ L(shr_5_gobble_next):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_6):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -712,7 +740,7 @@ L(shr_6):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_6_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -765,7 +793,7 @@ L(shr_6_gobble_next):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_7):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -795,7 +823,7 @@ L(shr_7):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_7_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -845,10 +873,11 @@ L(shr_7_gobble_next):
|
||||
POP (%edi)
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
#endif
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_8):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -878,7 +907,7 @@ L(shr_8):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_8_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -929,9 +958,10 @@ L(shr_8_gobble_next):
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_9):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -961,7 +991,7 @@ L(shr_9):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_9_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -1014,7 +1044,7 @@ L(shr_9_gobble_next):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_10):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -1044,7 +1074,7 @@ L(shr_10):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_10_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -1097,7 +1127,7 @@ L(shr_10_gobble_next):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_11):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -1127,7 +1157,7 @@ L(shr_11):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_11_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -1177,10 +1207,11 @@ L(shr_11_gobble_next):
|
||||
POP (%edi)
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
#endif
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_12):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -1210,7 +1241,7 @@ L(shr_12):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_12_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -1261,9 +1292,10 @@ L(shr_12_gobble_next):
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_13):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -1293,7 +1325,7 @@ L(shr_13):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_13_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -1346,7 +1378,7 @@ L(shr_13_gobble_next):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_14):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -1376,7 +1408,7 @@ L(shr_14):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_14_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -1429,7 +1461,7 @@ L(shr_14_gobble_next):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_15):
|
||||
cmp $80, %ecx
|
||||
lea -48(%ecx), %ecx
|
||||
@@ -1459,7 +1491,7 @@ L(shr_15):
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(shr_15_gobble):
|
||||
sub $32, %ecx
|
||||
movdqa 16(%esi), %xmm0
|
||||
@@ -1509,10 +1541,11 @@ L(shr_15_gobble_next):
|
||||
POP (%edi)
|
||||
POP (%esi)
|
||||
jmp L(less48bytes)
|
||||
#endif
|
||||
|
||||
cfi_restore_state
|
||||
cfi_remember_state
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(exit):
|
||||
pmovmskb %xmm1, %ebx
|
||||
sub $0xffff, %ebx
|
||||
@@ -1520,9 +1553,12 @@ L(exit):
|
||||
lea -16(%esi), %esi
|
||||
lea -16(%edi), %edi
|
||||
mov %ebx, %edx
|
||||
|
||||
L(first16bytes):
|
||||
add %eax, %esi
|
||||
L(less16bytes):
|
||||
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
test %dl, %dl
|
||||
jz L(next_24_bytes)
|
||||
|
||||
@@ -1552,56 +1588,56 @@ L(Byte23):
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte16):
|
||||
movzbl -16(%edi), %eax
|
||||
movzbl -16(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte17):
|
||||
movzbl -15(%edi), %eax
|
||||
movzbl -15(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte18):
|
||||
movzbl -14(%edi), %eax
|
||||
movzbl -14(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte19):
|
||||
movzbl -13(%edi), %eax
|
||||
movzbl -13(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte20):
|
||||
movzbl -12(%edi), %eax
|
||||
movzbl -12(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte21):
|
||||
movzbl -11(%edi), %eax
|
||||
movzbl -11(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte22):
|
||||
movzbl -10(%edi), %eax
|
||||
movzbl -10(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(next_24_bytes):
|
||||
lea 8(%edi), %edi
|
||||
lea 8(%esi), %esi
|
||||
@@ -1626,20 +1662,70 @@ L(next_24_bytes):
|
||||
test $0x40, %dh
|
||||
jnz L(Byte22)
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(Byte31):
|
||||
movzbl -9(%edi), %eax
|
||||
movzbl -9(%esi), %edx
|
||||
sub %edx, %eax
|
||||
RETURN_END
|
||||
#else
|
||||
|
||||
/* special for wmemcmp */
|
||||
test %dl, %dl
|
||||
jz L(next_two_double_words)
|
||||
and $15, %dl
|
||||
jz L(second_double_word)
|
||||
mov -16(%edi), %ecx
|
||||
cmp -16(%esi), %ecx
|
||||
mov $1, %eax
|
||||
jg L(nequal_bigger)
|
||||
neg %eax
|
||||
RETURN
|
||||
|
||||
|
||||
.p2align 4
|
||||
L(second_double_word):
|
||||
mov -12(%edi), %ecx
|
||||
cmp -12(%esi), %ecx
|
||||
mov $1, %eax
|
||||
jg L(nequal_bigger)
|
||||
neg %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(next_two_double_words):
|
||||
and $15, %dh
|
||||
jz L(fourth_double_word)
|
||||
mov -8(%edi), %ecx
|
||||
cmp -8(%esi), %ecx
|
||||
mov $1, %eax
|
||||
jg L(nequal_bigger)
|
||||
neg %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(fourth_double_word):
|
||||
mov -4(%edi), %ecx
|
||||
cmp -4(%esi), %ecx
|
||||
mov $1, %eax
|
||||
jg L(nequal_bigger)
|
||||
neg %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(nequal_bigger):
|
||||
RETURN_END
|
||||
#endif
|
||||
|
||||
CFI_PUSH (%ebx)
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(more8bytes):
|
||||
cmp $16, %ecx
|
||||
jae L(more16bytes)
|
||||
cmp $8, %ecx
|
||||
je L(8bytes)
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $9, %ecx
|
||||
je L(9bytes)
|
||||
cmp $10, %ecx
|
||||
@@ -1653,13 +1739,17 @@ L(more8bytes):
|
||||
cmp $14, %ecx
|
||||
je L(14bytes)
|
||||
jmp L(15bytes)
|
||||
#else
|
||||
jmp L(12bytes)
|
||||
#endif
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(more16bytes):
|
||||
cmp $24, %ecx
|
||||
jae L(more24bytes)
|
||||
cmp $16, %ecx
|
||||
je L(16bytes)
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $17, %ecx
|
||||
je L(17bytes)
|
||||
cmp $18, %ecx
|
||||
@@ -1673,13 +1763,17 @@ L(more16bytes):
|
||||
cmp $22, %ecx
|
||||
je L(22bytes)
|
||||
jmp L(23bytes)
|
||||
#else
|
||||
jmp L(20bytes)
|
||||
#endif
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(more24bytes):
|
||||
cmp $32, %ecx
|
||||
jae L(more32bytes)
|
||||
cmp $24, %ecx
|
||||
je L(24bytes)
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $25, %ecx
|
||||
je L(25bytes)
|
||||
cmp $26, %ecx
|
||||
@@ -1693,13 +1787,17 @@ L(more24bytes):
|
||||
cmp $30, %ecx
|
||||
je L(30bytes)
|
||||
jmp L(31bytes)
|
||||
#else
|
||||
jmp L(28bytes)
|
||||
#endif
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(more32bytes):
|
||||
cmp $40, %ecx
|
||||
jae L(more40bytes)
|
||||
cmp $32, %ecx
|
||||
je L(32bytes)
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $33, %ecx
|
||||
je L(33bytes)
|
||||
cmp $34, %ecx
|
||||
@@ -1713,11 +1811,35 @@ L(more32bytes):
|
||||
cmp $38, %ecx
|
||||
je L(38bytes)
|
||||
jmp L(39bytes)
|
||||
#else
|
||||
jmp L(36bytes)
|
||||
#endif
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(less48bytes):
|
||||
cmp $8, %ecx
|
||||
jae L(more8bytes)
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $2, %ecx
|
||||
je L(2bytes)
|
||||
cmp $3, %ecx
|
||||
je L(3bytes)
|
||||
cmp $4, %ecx
|
||||
je L(4bytes)
|
||||
cmp $5, %ecx
|
||||
je L(5bytes)
|
||||
cmp $6, %ecx
|
||||
je L(6bytes)
|
||||
jmp L(7bytes)
|
||||
#else
|
||||
jmp L(4bytes)
|
||||
#endif
|
||||
|
||||
.p2align 4
|
||||
L(more40bytes):
|
||||
cmp $40, %ecx
|
||||
je L(40bytes)
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
cmp $41, %ecx
|
||||
je L(41bytes)
|
||||
cmp $42, %ecx
|
||||
@@ -1732,24 +1854,7 @@ L(more40bytes):
|
||||
je L(46bytes)
|
||||
jmp L(47bytes)
|
||||
|
||||
ALIGN (4)
|
||||
L(less48bytes):
|
||||
cmp $8, %ecx
|
||||
jae L(more8bytes)
|
||||
cmp $2, %ecx
|
||||
je L(2bytes)
|
||||
cmp $3, %ecx
|
||||
je L(3bytes)
|
||||
cmp $4, %ecx
|
||||
je L(4bytes)
|
||||
cmp $5, %ecx
|
||||
je L(5bytes)
|
||||
cmp $6, %ecx
|
||||
je L(6bytes)
|
||||
jmp L(7bytes)
|
||||
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(44bytes):
|
||||
mov -44(%eax), %ecx
|
||||
mov -44(%edx), %ebx
|
||||
@@ -1809,8 +1914,61 @@ L(4bytes):
|
||||
POP (%ebx)
|
||||
ret
|
||||
CFI_PUSH (%ebx)
|
||||
#else
|
||||
.p2align 4
|
||||
L(44bytes):
|
||||
mov -44(%eax), %ecx
|
||||
cmp -44(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(40bytes):
|
||||
mov -40(%eax), %ecx
|
||||
cmp -40(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(36bytes):
|
||||
mov -36(%eax), %ecx
|
||||
cmp -36(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(32bytes):
|
||||
mov -32(%eax), %ecx
|
||||
cmp -32(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(28bytes):
|
||||
mov -28(%eax), %ecx
|
||||
cmp -28(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(24bytes):
|
||||
mov -24(%eax), %ecx
|
||||
cmp -24(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(20bytes):
|
||||
mov -20(%eax), %ecx
|
||||
cmp -20(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(16bytes):
|
||||
mov -16(%eax), %ecx
|
||||
cmp -16(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(12bytes):
|
||||
mov -12(%eax), %ecx
|
||||
cmp -12(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(8bytes):
|
||||
mov -8(%eax), %ecx
|
||||
cmp -8(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
L(4bytes):
|
||||
mov -4(%eax), %ecx
|
||||
xor %eax, %eax
|
||||
cmp -4(%edx), %ecx
|
||||
jne L(find_diff)
|
||||
POP (%ebx)
|
||||
ret
|
||||
CFI_PUSH (%ebx)
|
||||
#endif
|
||||
|
||||
ALIGN (4)
|
||||
#ifndef USE_AS_WMEMCMP
|
||||
|
||||
.p2align 4
|
||||
L(45bytes):
|
||||
mov -45(%eax), %ecx
|
||||
mov -45(%edx), %ebx
|
||||
@@ -1874,7 +2032,7 @@ L(5bytes):
|
||||
ret
|
||||
CFI_PUSH (%ebx)
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(46bytes):
|
||||
mov -46(%eax), %ecx
|
||||
mov -46(%edx), %ebx
|
||||
@@ -1942,7 +2100,7 @@ L(2bytes):
|
||||
ret
|
||||
CFI_PUSH (%ebx)
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(47bytes):
|
||||
movl -47(%eax), %ecx
|
||||
movl -47(%edx), %ebx
|
||||
@@ -2013,7 +2171,7 @@ L(3bytes):
|
||||
ret
|
||||
CFI_PUSH (%ebx)
|
||||
|
||||
ALIGN (4)
|
||||
.p2align 4
|
||||
L(find_diff):
|
||||
cmpb %bl, %cl
|
||||
jne L(end)
|
||||
@@ -2024,6 +2182,8 @@ L(find_diff):
|
||||
cmp %bl, %cl
|
||||
jne L(end)
|
||||
cmp %bx, %cx
|
||||
|
||||
.p2align 4
|
||||
L(end):
|
||||
POP (%ebx)
|
||||
mov $1, %eax
|
||||
@@ -2031,5 +2191,20 @@ L(end):
|
||||
neg %eax
|
||||
L(bigger):
|
||||
ret
|
||||
#else
|
||||
|
||||
/* for wmemcmp */
|
||||
.p2align 4
|
||||
L(find_diff):
|
||||
POP (%ebx)
|
||||
mov $1, %eax
|
||||
jg L(find_diff_bigger)
|
||||
neg %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(find_diff_bigger):
|
||||
ret
|
||||
|
||||
#endif
|
||||
END (MEMCMP)
|
||||
@@ -28,8 +28,11 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#undef __i686
|
||||
|
||||
#ifndef MEMCPY
|
||||
# define MEMCPY ssse3_memcpy5
|
||||
# define MEMCPY memcpy
|
||||
#endif
|
||||
|
||||
#ifndef L
|
||||
@@ -28,13 +28,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
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
|
||||
#define MEMCPY memmove
|
||||
#define USE_AS_MEMMOVE
|
||||
#include "ssse3-memcpy-atom.S"
|
||||
620
libc/arch-x86/string/ssse3-strcat-atom.S
Normal file
620
libc/arch-x86/string/ssse3-strcat-atom.S
Normal file
@@ -0,0 +1,620 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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 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)
|
||||
|
||||
#ifndef STRCAT
|
||||
# define STRCAT strcat
|
||||
#endif
|
||||
|
||||
#define PARMS 4
|
||||
#define STR1 PARMS+4
|
||||
#define STR2 STR1+4
|
||||
|
||||
#ifdef USE_AS_STRNCAT
|
||||
# define LEN STR2+8
|
||||
#endif
|
||||
|
||||
#define USE_AS_STRCAT
|
||||
|
||||
.section .text.ssse3,"ax",@progbits
|
||||
ENTRY (STRCAT)
|
||||
PUSH (%edi)
|
||||
mov STR1(%esp), %edi
|
||||
mov %edi, %edx
|
||||
|
||||
#define RETURN jmp L(StrcpyAtom)
|
||||
#include "sse2-strlen-atom.S"
|
||||
|
||||
L(StrcpyAtom):
|
||||
mov STR2(%esp), %ecx
|
||||
lea (%edi, %eax), %edx
|
||||
#ifdef USE_AS_STRNCAT
|
||||
PUSH (%ebx)
|
||||
mov LEN(%esp), %ebx
|
||||
test %ebx, %ebx
|
||||
jz L(StrncatExit0)
|
||||
cmp $8, %ebx
|
||||
jbe L(StrncpyExit8Bytes)
|
||||
#endif
|
||||
cmpb $0, (%ecx)
|
||||
jz L(Exit1)
|
||||
cmpb $0, 1(%ecx)
|
||||
jz L(Exit2)
|
||||
cmpb $0, 2(%ecx)
|
||||
jz L(Exit3)
|
||||
cmpb $0, 3(%ecx)
|
||||
jz L(Exit4)
|
||||
cmpb $0, 4(%ecx)
|
||||
jz L(Exit5)
|
||||
cmpb $0, 5(%ecx)
|
||||
jz L(Exit6)
|
||||
cmpb $0, 6(%ecx)
|
||||
jz L(Exit7)
|
||||
cmpb $0, 7(%ecx)
|
||||
jz L(Exit8)
|
||||
cmpb $0, 8(%ecx)
|
||||
jz L(Exit9)
|
||||
#ifdef USE_AS_STRNCAT
|
||||
cmp $16, %ebx
|
||||
jb L(StrncpyExit15Bytes)
|
||||
#endif
|
||||
cmpb $0, 9(%ecx)
|
||||
jz L(Exit10)
|
||||
cmpb $0, 10(%ecx)
|
||||
jz L(Exit11)
|
||||
cmpb $0, 11(%ecx)
|
||||
jz L(Exit12)
|
||||
cmpb $0, 12(%ecx)
|
||||
jz L(Exit13)
|
||||
cmpb $0, 13(%ecx)
|
||||
jz L(Exit14)
|
||||
cmpb $0, 14(%ecx)
|
||||
jz L(Exit15)
|
||||
cmpb $0, 15(%ecx)
|
||||
jz L(Exit16)
|
||||
#ifdef USE_AS_STRNCAT
|
||||
cmp $16, %ebx
|
||||
je L(StrncatExit16)
|
||||
|
||||
# define RETURN1 POP (%ebx); POP (%edi); ret; \
|
||||
CFI_PUSH (%ebx); CFI_PUSH (%edi)
|
||||
# define USE_AS_STRNCPY
|
||||
#else
|
||||
# define RETURN1 POP(%edi); ret; CFI_PUSH(%edi)
|
||||
#endif
|
||||
#include "ssse3-strcpy-atom.S"
|
||||
|
||||
.p2align 4
|
||||
L(CopyFrom1To16Bytes):
|
||||
add %esi, %edx
|
||||
add %esi, %ecx
|
||||
|
||||
POP (%esi)
|
||||
test %al, %al
|
||||
jz L(ExitHigh)
|
||||
test $0x01, %al
|
||||
jnz L(Exit1)
|
||||
test $0x02, %al
|
||||
jnz L(Exit2)
|
||||
test $0x04, %al
|
||||
jnz L(Exit3)
|
||||
test $0x08, %al
|
||||
jnz L(Exit4)
|
||||
test $0x10, %al
|
||||
jnz L(Exit5)
|
||||
test $0x20, %al
|
||||
jnz L(Exit6)
|
||||
test $0x40, %al
|
||||
jnz L(Exit7)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(ExitHigh):
|
||||
test $0x01, %ah
|
||||
jnz L(Exit9)
|
||||
test $0x02, %ah
|
||||
jnz L(Exit10)
|
||||
test $0x04, %ah
|
||||
jnz L(Exit11)
|
||||
test $0x08, %ah
|
||||
jnz L(Exit12)
|
||||
test $0x10, %ah
|
||||
jnz L(Exit13)
|
||||
test $0x20, %ah
|
||||
jnz L(Exit14)
|
||||
test $0x40, %ah
|
||||
jnz L(Exit15)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd 8(%ecx), %xmm1
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd %xmm1, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit1):
|
||||
movb %bh, 1(%edx)
|
||||
L(Exit1):
|
||||
movb (%ecx), %al
|
||||
movb %al, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit2):
|
||||
movb %bh, 2(%edx)
|
||||
L(Exit2):
|
||||
movw (%ecx), %ax
|
||||
movw %ax, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit3):
|
||||
movb %bh, 3(%edx)
|
||||
L(Exit3):
|
||||
movw (%ecx), %ax
|
||||
movw %ax, (%edx)
|
||||
movb 2(%ecx), %al
|
||||
movb %al, 2(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit4):
|
||||
movb %bh, 4(%edx)
|
||||
L(Exit4):
|
||||
movl (%ecx), %eax
|
||||
movl %eax, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit5):
|
||||
movb %bh, 5(%edx)
|
||||
L(Exit5):
|
||||
movl (%ecx), %eax
|
||||
movl %eax, (%edx)
|
||||
movb 4(%ecx), %al
|
||||
movb %al, 4(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit6):
|
||||
movb %bh, 6(%edx)
|
||||
L(Exit6):
|
||||
movl (%ecx), %eax
|
||||
movl %eax, (%edx)
|
||||
movw 4(%ecx), %ax
|
||||
movw %ax, 4(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit7):
|
||||
movb %bh, 7(%edx)
|
||||
L(Exit7):
|
||||
movl (%ecx), %eax
|
||||
movl %eax, (%edx)
|
||||
movl 3(%ecx), %eax
|
||||
movl %eax, 3(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit8):
|
||||
movb %bh, 8(%edx)
|
||||
L(Exit8):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit9):
|
||||
movb %bh, 9(%edx)
|
||||
L(Exit9):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movb 8(%ecx), %al
|
||||
movb %al, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit10):
|
||||
movb %bh, 10(%edx)
|
||||
L(Exit10):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movw 8(%ecx), %ax
|
||||
movw %ax, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit11):
|
||||
movb %bh, 11(%edx)
|
||||
L(Exit11):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl 7(%ecx), %eax
|
||||
movl %eax, 7(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit12):
|
||||
movb %bh, 12(%edx)
|
||||
L(Exit12):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl 8(%ecx), %eax
|
||||
movl %eax, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit13):
|
||||
movb %bh, 13(%edx)
|
||||
L(Exit13):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd 5(%ecx), %xmm0
|
||||
movlpd %xmm0, 5(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit14):
|
||||
movb %bh, 14(%edx)
|
||||
L(Exit14):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd 6(%ecx), %xmm0
|
||||
movlpd %xmm0, 6(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit15):
|
||||
movb %bh, 15(%edx)
|
||||
L(Exit15):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd 7(%ecx), %xmm0
|
||||
movlpd %xmm0, 7(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit16):
|
||||
movb %bh, 16(%edx)
|
||||
L(Exit16):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd 8(%ecx), %xmm1
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd %xmm1, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
#ifdef USE_AS_STRNCPY
|
||||
|
||||
CFI_PUSH(%esi)
|
||||
|
||||
.p2align 4
|
||||
L(CopyFrom1To16BytesCase2):
|
||||
add $16, %ebx
|
||||
add %esi, %ecx
|
||||
lea (%esi, %edx), %esi
|
||||
lea -9(%ebx), %edx
|
||||
and $1<<7, %dh
|
||||
or %al, %dh
|
||||
lea (%esi), %edx
|
||||
POP (%esi)
|
||||
jz L(ExitHighCase2)
|
||||
|
||||
test $0x01, %al
|
||||
jnz L(Exit1)
|
||||
cmp $1, %ebx
|
||||
je L(StrncatExit1)
|
||||
test $0x02, %al
|
||||
jnz L(Exit2)
|
||||
cmp $2, %ebx
|
||||
je L(StrncatExit2)
|
||||
test $0x04, %al
|
||||
jnz L(Exit3)
|
||||
cmp $3, %ebx
|
||||
je L(StrncatExit3)
|
||||
test $0x08, %al
|
||||
jnz L(Exit4)
|
||||
cmp $4, %ebx
|
||||
je L(StrncatExit4)
|
||||
test $0x10, %al
|
||||
jnz L(Exit5)
|
||||
cmp $5, %ebx
|
||||
je L(StrncatExit5)
|
||||
test $0x20, %al
|
||||
jnz L(Exit6)
|
||||
cmp $6, %ebx
|
||||
je L(StrncatExit6)
|
||||
test $0x40, %al
|
||||
jnz L(Exit7)
|
||||
cmp $7, %ebx
|
||||
je L(StrncatExit7)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
lea 7(%edx), %eax
|
||||
cmpb $1, (%eax)
|
||||
sbb $-1, %eax
|
||||
xor %cl, %cl
|
||||
movb %cl, (%eax)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(ExitHighCase2):
|
||||
test $0x01, %ah
|
||||
jnz L(Exit9)
|
||||
cmp $9, %ebx
|
||||
je L(StrncatExit9)
|
||||
test $0x02, %ah
|
||||
jnz L(Exit10)
|
||||
cmp $10, %ebx
|
||||
je L(StrncatExit10)
|
||||
test $0x04, %ah
|
||||
jnz L(Exit11)
|
||||
cmp $11, %ebx
|
||||
je L(StrncatExit11)
|
||||
test $0x8, %ah
|
||||
jnz L(Exit12)
|
||||
cmp $12, %ebx
|
||||
je L(StrncatExit12)
|
||||
test $0x10, %ah
|
||||
jnz L(Exit13)
|
||||
cmp $13, %ebx
|
||||
je L(StrncatExit13)
|
||||
test $0x20, %ah
|
||||
jnz L(Exit14)
|
||||
cmp $14, %ebx
|
||||
je L(StrncatExit14)
|
||||
test $0x40, %ah
|
||||
jnz L(Exit15)
|
||||
cmp $15, %ebx
|
||||
je L(StrncatExit15)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd 8(%ecx), %xmm1
|
||||
movlpd %xmm1, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
CFI_PUSH(%esi)
|
||||
|
||||
L(CopyFrom1To16BytesCase2OrCase3):
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16BytesCase2)
|
||||
|
||||
.p2align 4
|
||||
L(CopyFrom1To16BytesCase3):
|
||||
add $16, %ebx
|
||||
add %esi, %edx
|
||||
add %esi, %ecx
|
||||
|
||||
POP (%esi)
|
||||
|
||||
cmp $8, %ebx
|
||||
ja L(ExitHighCase3)
|
||||
cmp $1, %ebx
|
||||
je L(StrncatExit1)
|
||||
cmp $2, %ebx
|
||||
je L(StrncatExit2)
|
||||
cmp $3, %ebx
|
||||
je L(StrncatExit3)
|
||||
cmp $4, %ebx
|
||||
je L(StrncatExit4)
|
||||
cmp $5, %ebx
|
||||
je L(StrncatExit5)
|
||||
cmp $6, %ebx
|
||||
je L(StrncatExit6)
|
||||
cmp $7, %ebx
|
||||
je L(StrncatExit7)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movb %bh, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(ExitHighCase3):
|
||||
cmp $9, %ebx
|
||||
je L(StrncatExit9)
|
||||
cmp $10, %ebx
|
||||
je L(StrncatExit10)
|
||||
cmp $11, %ebx
|
||||
je L(StrncatExit11)
|
||||
cmp $12, %ebx
|
||||
je L(StrncatExit12)
|
||||
cmp $13, %ebx
|
||||
je L(StrncatExit13)
|
||||
cmp $14, %ebx
|
||||
je L(StrncatExit14)
|
||||
cmp $15, %ebx
|
||||
je L(StrncatExit15)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd 8(%ecx), %xmm1
|
||||
movlpd %xmm1, 8(%edx)
|
||||
movb %bh, 16(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncatExit0):
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncpyExit15Bytes):
|
||||
cmp $9, %ebx
|
||||
je L(StrncatExit9)
|
||||
cmpb $0, 9(%ecx)
|
||||
jz L(Exit10)
|
||||
cmp $10, %ebx
|
||||
je L(StrncatExit10)
|
||||
cmpb $0, 10(%ecx)
|
||||
jz L(Exit11)
|
||||
cmp $11, %ebx
|
||||
je L(StrncatExit11)
|
||||
cmpb $0, 11(%ecx)
|
||||
jz L(Exit12)
|
||||
cmp $12, %ebx
|
||||
je L(StrncatExit12)
|
||||
cmpb $0, 12(%ecx)
|
||||
jz L(Exit13)
|
||||
cmp $13, %ebx
|
||||
je L(StrncatExit13)
|
||||
cmpb $0, 13(%ecx)
|
||||
jz L(Exit14)
|
||||
cmp $14, %ebx
|
||||
je L(StrncatExit14)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movlpd 7(%ecx), %xmm0
|
||||
movlpd %xmm0, 7(%edx)
|
||||
lea 14(%edx), %eax
|
||||
cmpb $1, (%eax)
|
||||
sbb $-1, %eax
|
||||
movb %bh, (%eax)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
.p2align 4
|
||||
L(StrncpyExit8Bytes):
|
||||
cmpb $0, (%ecx)
|
||||
jz L(Exit1)
|
||||
cmp $1, %ebx
|
||||
je L(StrncatExit1)
|
||||
cmpb $0, 1(%ecx)
|
||||
jz L(Exit2)
|
||||
cmp $2, %ebx
|
||||
je L(StrncatExit2)
|
||||
cmpb $0, 2(%ecx)
|
||||
jz L(Exit3)
|
||||
cmp $3, %ebx
|
||||
je L(StrncatExit3)
|
||||
cmpb $0, 3(%ecx)
|
||||
jz L(Exit4)
|
||||
cmp $4, %ebx
|
||||
je L(StrncatExit4)
|
||||
cmpb $0, 4(%ecx)
|
||||
jz L(Exit5)
|
||||
cmp $5, %ebx
|
||||
je L(StrncatExit5)
|
||||
cmpb $0, 5(%ecx)
|
||||
jz L(Exit6)
|
||||
cmp $6, %ebx
|
||||
je L(StrncatExit6)
|
||||
cmpb $0, 6(%ecx)
|
||||
jz L(Exit7)
|
||||
cmp $7, %ebx
|
||||
je L(StrncatExit7)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
lea 7(%edx), %eax
|
||||
cmpb $1, (%eax)
|
||||
sbb $-1, %eax
|
||||
movb %bh, (%eax)
|
||||
movl %edi, %eax
|
||||
RETURN1
|
||||
|
||||
#endif
|
||||
END (STRCAT)
|
||||
@@ -107,8 +107,12 @@ name: \
|
||||
sub %esi, %ebp
|
||||
#endif
|
||||
|
||||
#ifndef STRCMP
|
||||
# define STRCMP strcmp
|
||||
#endif
|
||||
|
||||
.section .text.ssse3,"ax",@progbits
|
||||
ENTRY (ssse3_strcmp_latest)
|
||||
ENTRY (STRCMP)
|
||||
#ifdef USE_AS_STRNCMP
|
||||
PUSH (%ebp)
|
||||
#endif
|
||||
@@ -2271,4 +2275,4 @@ L(less16bytes_sncmp):
|
||||
ret
|
||||
#endif
|
||||
|
||||
END (ssse3_strcmp_latest)
|
||||
END (STRCMP)
|
||||
3955
libc/arch-x86/string/ssse3-strcpy-atom.S
Normal file
3955
libc/arch-x86/string/ssse3-strcpy-atom.S
Normal file
File diff suppressed because it is too large
Load Diff
1225
libc/arch-x86/string/ssse3-strlcat-atom.S
Normal file
1225
libc/arch-x86/string/ssse3-strlcat-atom.S
Normal file
File diff suppressed because it is too large
Load Diff
1403
libc/arch-x86/string/ssse3-strlcpy-atom.S
Normal file
1403
libc/arch-x86/string/ssse3-strlcpy-atom.S
Normal file
File diff suppressed because it is too large
Load Diff
34
libc/arch-x86/string/ssse3-strncat-atom.S
Normal file
34
libc/arch-x86/string/ssse3-strncat-atom.S
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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.
|
||||
*/
|
||||
|
||||
#define STRCAT strncat
|
||||
#define USE_AS_STRNCAT
|
||||
|
||||
#include "ssse3-strcat-atom.S"
|
||||
@@ -28,13 +28,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(USE_SSSE3)
|
||||
|
||||
# define MEMCMP memcmp
|
||||
# include "ssse3-memcmp3-new.S"
|
||||
#define USE_AS_STRNCMP
|
||||
#define STRCMP strncmp
|
||||
#include "ssse3-strcmp-atom.S"
|
||||
|
||||
#else
|
||||
|
||||
# include "memcmp.S"
|
||||
|
||||
#endif
|
||||
33
libc/arch-x86/string/ssse3-strncpy-atom.S
Normal file
33
libc/arch-x86/string/ssse3-strncpy-atom.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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.
|
||||
*/
|
||||
|
||||
#define USE_AS_STRNCPY
|
||||
#define STRCPY strncpy
|
||||
#include "ssse3-strcpy-atom.S"
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2010, Intel Corporation
|
||||
Copyright (c) 2011 Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,18 +28,87 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
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"
|
||||
|
||||
#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 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 STR1 PARMS+4
|
||||
#define STR2 STR1+4
|
||||
|
||||
#define USE_AS_WCSCAT
|
||||
|
||||
.text
|
||||
ENTRY (wcscat)
|
||||
PUSH (%edi)
|
||||
mov STR1(%esp), %edi
|
||||
mov %edi, %edx
|
||||
|
||||
#define RETURN jmp L(WcscpyAtom)
|
||||
#include "sse2-wcslen-atom.S"
|
||||
|
||||
L(WcscpyAtom):
|
||||
shl $2, %eax
|
||||
mov STR2(%esp), %ecx
|
||||
lea (%edi, %eax), %edx
|
||||
|
||||
cmp $0, (%ecx)
|
||||
jz L(Exit4)
|
||||
cmp $0, 4(%ecx)
|
||||
jz L(Exit8)
|
||||
cmp $0, 8(%ecx)
|
||||
jz L(Exit12)
|
||||
cmp $0, 12(%ecx)
|
||||
jz L(Exit16)
|
||||
|
||||
#undef RETURN
|
||||
#define RETURN POP(%edi); ret; CFI_PUSH(%edi)
|
||||
#include "ssse3-wcscpy-atom.S"
|
||||
|
||||
END (wcscat)
|
||||
652
libc/arch-x86/string/ssse3-wcscpy-atom.S
Normal file
652
libc/arch-x86/string/ssse3-wcscpy-atom.S
Normal file
@@ -0,0 +1,652 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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 USE_AS_WCSCAT
|
||||
|
||||
# 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 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 RETURN POP (%edi); ret; CFI_PUSH (%edi)
|
||||
|
||||
# define STR1 PARMS
|
||||
# define STR2 STR1+4
|
||||
# define LEN STR2+4
|
||||
|
||||
.text
|
||||
ENTRY (wcscpy)
|
||||
mov STR1(%esp), %edx
|
||||
mov STR2(%esp), %ecx
|
||||
|
||||
cmp $0, (%ecx)
|
||||
jz L(ExitTail4)
|
||||
cmp $0, 4(%ecx)
|
||||
jz L(ExitTail8)
|
||||
cmp $0, 8(%ecx)
|
||||
jz L(ExitTail12)
|
||||
cmp $0, 12(%ecx)
|
||||
jz L(ExitTail16)
|
||||
|
||||
PUSH (%edi)
|
||||
mov %edx, %edi
|
||||
#endif
|
||||
PUSH (%esi)
|
||||
lea 16(%ecx), %esi
|
||||
|
||||
and $-16, %esi
|
||||
|
||||
pxor %xmm0, %xmm0
|
||||
pcmpeqd (%esi), %xmm0
|
||||
movdqu (%ecx), %xmm1
|
||||
movdqu %xmm1, (%edx)
|
||||
|
||||
pmovmskb %xmm0, %eax
|
||||
sub %ecx, %esi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
mov %edx, %eax
|
||||
lea 16(%edx), %edx
|
||||
and $-16, %edx
|
||||
sub %edx, %eax
|
||||
|
||||
sub %eax, %ecx
|
||||
mov %ecx, %eax
|
||||
and $0xf, %eax
|
||||
mov $0, %esi
|
||||
|
||||
jz L(Align16Both)
|
||||
cmp $4, %eax
|
||||
je L(Shl4)
|
||||
cmp $8, %eax
|
||||
je L(Shl8)
|
||||
jmp L(Shl12)
|
||||
|
||||
L(Align16Both):
|
||||
movaps (%ecx), %xmm1
|
||||
movaps 16(%ecx), %xmm2
|
||||
movaps %xmm1, (%edx)
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%esi), %esi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
movaps 16(%ecx, %esi), %xmm3
|
||||
movaps %xmm2, (%edx, %esi)
|
||||
pcmpeqd %xmm3, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%esi), %esi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
movaps 16(%ecx, %esi), %xmm4
|
||||
movaps %xmm3, (%edx, %esi)
|
||||
pcmpeqd %xmm4, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%esi), %esi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
movaps 16(%ecx, %esi), %xmm1
|
||||
movaps %xmm4, (%edx, %esi)
|
||||
pcmpeqd %xmm1, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%esi), %esi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
movaps 16(%ecx, %esi), %xmm2
|
||||
movaps %xmm1, (%edx, %esi)
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%esi), %esi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
movaps 16(%ecx, %esi), %xmm3
|
||||
movaps %xmm2, (%edx, %esi)
|
||||
pcmpeqd %xmm3, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%esi), %esi
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
movaps %xmm3, (%edx, %esi)
|
||||
mov %ecx, %eax
|
||||
lea 16(%ecx, %esi), %ecx
|
||||
and $-0x40, %ecx
|
||||
sub %ecx, %eax
|
||||
sub %eax, %edx
|
||||
|
||||
mov $-0x40, %esi
|
||||
|
||||
L(Aligned64Loop):
|
||||
movaps (%ecx), %xmm2
|
||||
movaps 32(%ecx), %xmm3
|
||||
movaps %xmm2, %xmm4
|
||||
movaps 16(%ecx), %xmm5
|
||||
movaps %xmm3, %xmm6
|
||||
movaps 48(%ecx), %xmm7
|
||||
pminub %xmm5, %xmm2
|
||||
pminub %xmm7, %xmm3
|
||||
pminub %xmm2, %xmm3
|
||||
lea 64(%edx), %edx
|
||||
pcmpeqd %xmm0, %xmm3
|
||||
lea 64(%ecx), %ecx
|
||||
pmovmskb %xmm3, %eax
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Aligned64Leave)
|
||||
movaps %xmm4, -64(%edx)
|
||||
movaps %xmm5, -48(%edx)
|
||||
movaps %xmm6, -32(%edx)
|
||||
movaps %xmm7, -16(%edx)
|
||||
jmp L(Aligned64Loop)
|
||||
|
||||
L(Aligned64Leave):
|
||||
pcmpeqd %xmm4, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
pcmpeqd %xmm5, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
movaps %xmm4, -64(%edx)
|
||||
lea 16(%esi), %esi
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
pcmpeqd %xmm6, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
movaps %xmm5, -48(%edx)
|
||||
lea 16(%esi), %esi
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
movaps %xmm6, -32(%edx)
|
||||
pcmpeqd %xmm7, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%esi), %esi
|
||||
test %eax, %eax
|
||||
jnz L(CopyFrom1To16Bytes)
|
||||
|
||||
mov $-0x40, %esi
|
||||
movaps %xmm7, -16(%edx)
|
||||
jmp L(Aligned64Loop)
|
||||
|
||||
.p2align 4
|
||||
L(Shl4):
|
||||
movaps -4(%ecx), %xmm1
|
||||
movaps 12(%ecx), %xmm2
|
||||
L(Shl4Start):
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
movaps %xmm2, %xmm3
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl4LoopExit)
|
||||
|
||||
palignr $4, %xmm1, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 28(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
movaps %xmm2, %xmm1
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl4LoopExit)
|
||||
|
||||
palignr $4, %xmm3, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 28(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
movaps %xmm2, %xmm3
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl4LoopExit)
|
||||
|
||||
palignr $4, %xmm1, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 28(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl4LoopExit)
|
||||
|
||||
palignr $4, %xmm3, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
lea 28(%ecx), %ecx
|
||||
lea 16(%edx), %edx
|
||||
|
||||
mov %ecx, %eax
|
||||
and $-0x40, %ecx
|
||||
sub %ecx, %eax
|
||||
lea -12(%ecx), %ecx
|
||||
sub %eax, %edx
|
||||
|
||||
movaps -4(%ecx), %xmm1
|
||||
|
||||
L(Shl4LoopStart):
|
||||
movaps 12(%ecx), %xmm2
|
||||
movaps 28(%ecx), %xmm3
|
||||
movaps %xmm3, %xmm6
|
||||
movaps 44(%ecx), %xmm4
|
||||
movaps %xmm4, %xmm7
|
||||
movaps 60(%ecx), %xmm5
|
||||
pminub %xmm2, %xmm6
|
||||
pminub %xmm5, %xmm7
|
||||
pminub %xmm6, %xmm7
|
||||
pcmpeqd %xmm0, %xmm7
|
||||
pmovmskb %xmm7, %eax
|
||||
movaps %xmm5, %xmm7
|
||||
palignr $4, %xmm4, %xmm5
|
||||
palignr $4, %xmm3, %xmm4
|
||||
test %eax, %eax
|
||||
jnz L(Shl4Start)
|
||||
|
||||
palignr $4, %xmm2, %xmm3
|
||||
lea 64(%ecx), %ecx
|
||||
palignr $4, %xmm1, %xmm2
|
||||
movaps %xmm7, %xmm1
|
||||
movaps %xmm5, 48(%edx)
|
||||
movaps %xmm4, 32(%edx)
|
||||
movaps %xmm3, 16(%edx)
|
||||
movaps %xmm2, (%edx)
|
||||
lea 64(%edx), %edx
|
||||
jmp L(Shl4LoopStart)
|
||||
|
||||
L(Shl4LoopExit):
|
||||
movlpd (%ecx), %xmm0
|
||||
movl 8(%ecx), %esi
|
||||
movlpd %xmm0, (%edx)
|
||||
movl %esi, 8(%edx)
|
||||
POP (%esi)
|
||||
add $12, %edx
|
||||
add $12, %ecx
|
||||
test %al, %al
|
||||
jz L(ExitHigh)
|
||||
test $0x01, %al
|
||||
jnz L(Exit4)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(Shl8):
|
||||
movaps -8(%ecx), %xmm1
|
||||
movaps 8(%ecx), %xmm2
|
||||
L(Shl8Start):
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
movaps %xmm2, %xmm3
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl8LoopExit)
|
||||
|
||||
palignr $8, %xmm1, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 24(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
movaps %xmm2, %xmm1
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl8LoopExit)
|
||||
|
||||
palignr $8, %xmm3, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 24(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
movaps %xmm2, %xmm3
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl8LoopExit)
|
||||
|
||||
palignr $8, %xmm1, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 24(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl8LoopExit)
|
||||
|
||||
palignr $8, %xmm3, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
lea 24(%ecx), %ecx
|
||||
lea 16(%edx), %edx
|
||||
|
||||
mov %ecx, %eax
|
||||
and $-0x40, %ecx
|
||||
sub %ecx, %eax
|
||||
lea -8(%ecx), %ecx
|
||||
sub %eax, %edx
|
||||
|
||||
movaps -8(%ecx), %xmm1
|
||||
|
||||
L(Shl8LoopStart):
|
||||
movaps 8(%ecx), %xmm2
|
||||
movaps 24(%ecx), %xmm3
|
||||
movaps %xmm3, %xmm6
|
||||
movaps 40(%ecx), %xmm4
|
||||
movaps %xmm4, %xmm7
|
||||
movaps 56(%ecx), %xmm5
|
||||
pminub %xmm2, %xmm6
|
||||
pminub %xmm5, %xmm7
|
||||
pminub %xmm6, %xmm7
|
||||
pcmpeqd %xmm0, %xmm7
|
||||
pmovmskb %xmm7, %eax
|
||||
movaps %xmm5, %xmm7
|
||||
palignr $8, %xmm4, %xmm5
|
||||
palignr $8, %xmm3, %xmm4
|
||||
test %eax, %eax
|
||||
jnz L(Shl8Start)
|
||||
|
||||
palignr $8, %xmm2, %xmm3
|
||||
lea 64(%ecx), %ecx
|
||||
palignr $8, %xmm1, %xmm2
|
||||
movaps %xmm7, %xmm1
|
||||
movaps %xmm5, 48(%edx)
|
||||
movaps %xmm4, 32(%edx)
|
||||
movaps %xmm3, 16(%edx)
|
||||
movaps %xmm2, (%edx)
|
||||
lea 64(%edx), %edx
|
||||
jmp L(Shl8LoopStart)
|
||||
|
||||
L(Shl8LoopExit):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
POP (%esi)
|
||||
add $8, %edx
|
||||
add $8, %ecx
|
||||
test %al, %al
|
||||
jz L(ExitHigh)
|
||||
test $0x01, %al
|
||||
jnz L(Exit4)
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN
|
||||
|
||||
CFI_PUSH (%esi)
|
||||
|
||||
.p2align 4
|
||||
L(Shl12):
|
||||
movaps -12(%ecx), %xmm1
|
||||
movaps 4(%ecx), %xmm2
|
||||
L(Shl12Start):
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
pmovmskb %xmm0, %eax
|
||||
movaps %xmm2, %xmm3
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl12LoopExit)
|
||||
|
||||
palignr $12, %xmm1, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 20(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
movaps %xmm2, %xmm1
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl12LoopExit)
|
||||
|
||||
palignr $12, %xmm3, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 20(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
movaps %xmm2, %xmm3
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl12LoopExit)
|
||||
|
||||
palignr $12, %xmm1, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
movaps 20(%ecx), %xmm2
|
||||
|
||||
pcmpeqd %xmm2, %xmm0
|
||||
lea 16(%edx), %edx
|
||||
pmovmskb %xmm0, %eax
|
||||
lea 16(%ecx), %ecx
|
||||
|
||||
test %eax, %eax
|
||||
jnz L(Shl12LoopExit)
|
||||
|
||||
palignr $12, %xmm3, %xmm2
|
||||
movaps %xmm2, (%edx)
|
||||
lea 20(%ecx), %ecx
|
||||
lea 16(%edx), %edx
|
||||
|
||||
mov %ecx, %eax
|
||||
and $-0x40, %ecx
|
||||
sub %ecx, %eax
|
||||
lea -4(%ecx), %ecx
|
||||
sub %eax, %edx
|
||||
|
||||
movaps -12(%ecx), %xmm1
|
||||
|
||||
L(Shl12LoopStart):
|
||||
movaps 4(%ecx), %xmm2
|
||||
movaps 20(%ecx), %xmm3
|
||||
movaps %xmm3, %xmm6
|
||||
movaps 36(%ecx), %xmm4
|
||||
movaps %xmm4, %xmm7
|
||||
movaps 52(%ecx), %xmm5
|
||||
pminub %xmm2, %xmm6
|
||||
pminub %xmm5, %xmm7
|
||||
pminub %xmm6, %xmm7
|
||||
pcmpeqd %xmm0, %xmm7
|
||||
pmovmskb %xmm7, %eax
|
||||
movaps %xmm5, %xmm7
|
||||
palignr $12, %xmm4, %xmm5
|
||||
palignr $12, %xmm3, %xmm4
|
||||
test %eax, %eax
|
||||
jnz L(Shl12Start)
|
||||
|
||||
palignr $12, %xmm2, %xmm3
|
||||
lea 64(%ecx), %ecx
|
||||
palignr $12, %xmm1, %xmm2
|
||||
movaps %xmm7, %xmm1
|
||||
movaps %xmm5, 48(%edx)
|
||||
movaps %xmm4, 32(%edx)
|
||||
movaps %xmm3, 16(%edx)
|
||||
movaps %xmm2, (%edx)
|
||||
lea 64(%edx), %edx
|
||||
jmp L(Shl12LoopStart)
|
||||
|
||||
L(Shl12LoopExit):
|
||||
movl (%ecx), %esi
|
||||
movl %esi, (%edx)
|
||||
mov $4, %esi
|
||||
|
||||
.p2align 4
|
||||
L(CopyFrom1To16Bytes):
|
||||
add %esi, %edx
|
||||
add %esi, %ecx
|
||||
|
||||
POP (%esi)
|
||||
test %al, %al
|
||||
jz L(ExitHigh)
|
||||
test $0x01, %al
|
||||
jnz L(Exit4)
|
||||
L(Exit8):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(ExitHigh):
|
||||
test $0x01, %ah
|
||||
jnz L(Exit12)
|
||||
L(Exit16):
|
||||
movdqu (%ecx), %xmm0
|
||||
movdqu %xmm0, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit4):
|
||||
movl (%ecx), %eax
|
||||
movl %eax, (%edx)
|
||||
movl %edi, %eax
|
||||
RETURN
|
||||
|
||||
.p2align 4
|
||||
L(Exit12):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl 8(%ecx), %eax
|
||||
movl %eax, 8(%edx)
|
||||
movl %edi, %eax
|
||||
RETURN
|
||||
|
||||
CFI_POP (%edi)
|
||||
|
||||
.p2align 4
|
||||
L(ExitTail4):
|
||||
movl (%ecx), %eax
|
||||
movl %eax, (%edx)
|
||||
movl %edx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(ExitTail8):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl %edx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(ExitTail12):
|
||||
movlpd (%ecx), %xmm0
|
||||
movlpd %xmm0, (%edx)
|
||||
movl 8(%ecx), %eax
|
||||
movl %eax, 8(%edx)
|
||||
movl %edx, %eax
|
||||
ret
|
||||
|
||||
.p2align 4
|
||||
L(ExitTail16):
|
||||
movdqu (%ecx), %xmm0
|
||||
movdqu %xmm0, (%edx)
|
||||
movl %edx, %eax
|
||||
ret
|
||||
|
||||
#ifndef USE_AS_WCSCAT
|
||||
END (wcscpy)
|
||||
#endif
|
||||
33
libc/arch-x86/string/ssse3-wmemcmp-atom.S
Normal file
33
libc/arch-x86/string/ssse3-wmemcmp-atom.S
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (c) 2011, 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.
|
||||
*/
|
||||
|
||||
#define MEMCMP wmemcmp
|
||||
#define USE_AS_WMEMCMP 1
|
||||
#include "ssse3-memcmp-atom.S"
|
||||
@@ -1,3 +0,0 @@
|
||||
/* $OpenBSD: strchr.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */
|
||||
#define STRCHR
|
||||
#include "index.S"
|
||||
@@ -1,64 +0,0 @@
|
||||
/* $OpenBSD: strcpy.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
|
||||
/*
|
||||
* Written by J.T. Conklin <jtc@netbsd.org>.
|
||||
* Public domain.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
||||
#if defined(APIWARN)
|
||||
#APP
|
||||
.section .gnu.warning.strcpy
|
||||
.ascii "warning: strcpy() is almost always misused, please use strlcpy()"
|
||||
#NO_APP
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: I've unrolled the loop eight times: large enough to make a
|
||||
* significant difference, and small enough not to totally trash the
|
||||
* cache.
|
||||
*/
|
||||
|
||||
ENTRY(strcpy)
|
||||
movl 4(%esp),%ecx /* dst address */
|
||||
movl 8(%esp),%edx /* src address */
|
||||
pushl %ecx /* push dst address */
|
||||
|
||||
.align 2,0x90
|
||||
L1: movb (%edx),%al /* unroll loop, but not too much */
|
||||
movb %al,(%ecx)
|
||||
testb %al,%al
|
||||
jz L2
|
||||
movb 1(%edx),%al
|
||||
movb %al,1(%ecx)
|
||||
testb %al,%al
|
||||
jz L2
|
||||
movb 2(%edx),%al
|
||||
movb %al,2(%ecx)
|
||||
testb %al,%al
|
||||
jz L2
|
||||
movb 3(%edx),%al
|
||||
movb %al,3(%ecx)
|
||||
testb %al,%al
|
||||
jz L2
|
||||
movb 4(%edx),%al
|
||||
movb %al,4(%ecx)
|
||||
testb %al,%al
|
||||
jz L2
|
||||
movb 5(%edx),%al
|
||||
movb %al,5(%ecx)
|
||||
testb %al,%al
|
||||
jz L2
|
||||
movb 6(%edx),%al
|
||||
movb %al,6(%ecx)
|
||||
testb %al,%al
|
||||
jz L2
|
||||
movb 7(%edx),%al
|
||||
movb %al,7(%ecx)
|
||||
addl $8,%edx
|
||||
addl $8,%ecx
|
||||
testb %al,%al
|
||||
jnz L1
|
||||
L2: popl %eax /* pop dst address */
|
||||
ret
|
||||
END(strcpy)
|
||||
@@ -130,6 +130,8 @@ syscall_src += arch-x86/syscalls/removexattr.S
|
||||
syscall_src += arch-x86/syscalls/lremovexattr.S
|
||||
syscall_src += arch-x86/syscalls/__statfs64.S
|
||||
syscall_src += arch-x86/syscalls/unshare.S
|
||||
syscall_src += arch-x86/syscalls/swapon.S
|
||||
syscall_src += arch-x86/syscalls/swapoff.S
|
||||
syscall_src += arch-x86/syscalls/pause.S
|
||||
syscall_src += arch-x86/syscalls/gettimeofday.S
|
||||
syscall_src += arch-x86/syscalls/settimeofday.S
|
||||
@@ -148,6 +150,9 @@ syscall_src += arch-x86/syscalls/__timer_getoverrun.S
|
||||
syscall_src += arch-x86/syscalls/__timer_delete.S
|
||||
syscall_src += arch-x86/syscalls/utimes.S
|
||||
syscall_src += arch-x86/syscalls/utimensat.S
|
||||
syscall_src += arch-x86/syscalls/timerfd_create.S
|
||||
syscall_src += arch-x86/syscalls/timerfd_settime.S
|
||||
syscall_src += arch-x86/syscalls/timerfd_gettime.S
|
||||
syscall_src += arch-x86/syscalls/sigaction.S
|
||||
syscall_src += arch-x86/syscalls/sigprocmask.S
|
||||
syscall_src += arch-x86/syscalls/__sigsuspend.S
|
||||
|
||||
21
libc/arch-x86/syscalls/swapoff.S
Normal file
21
libc/arch-x86/syscalls/swapoff.S
Normal file
@@ -0,0 +1,21 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
ENTRY(swapoff)
|
||||
pushl %ebx
|
||||
mov 8(%esp), %ebx
|
||||
movl $__NR_swapoff, %eax
|
||||
int $0x80
|
||||
cmpl $-MAX_ERRNO, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ebx
|
||||
ret
|
||||
END(swapoff)
|
||||
24
libc/arch-x86/syscalls/swapon.S
Normal file
24
libc/arch-x86/syscalls/swapon.S
Normal file
@@ -0,0 +1,24 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
ENTRY(swapon)
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
mov 12(%esp), %ebx
|
||||
mov 16(%esp), %ecx
|
||||
movl $__NR_swapon, %eax
|
||||
int $0x80
|
||||
cmpl $-MAX_ERRNO, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
ret
|
||||
END(swapon)
|
||||
24
libc/arch-x86/syscalls/timerfd_create.S
Normal file
24
libc/arch-x86/syscalls/timerfd_create.S
Normal file
@@ -0,0 +1,24 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
ENTRY(timerfd_create)
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
mov 12(%esp), %ebx
|
||||
mov 16(%esp), %ecx
|
||||
movl $__NR_timerfd_create, %eax
|
||||
int $0x80
|
||||
cmpl $-MAX_ERRNO, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
ret
|
||||
END(timerfd_create)
|
||||
24
libc/arch-x86/syscalls/timerfd_gettime.S
Normal file
24
libc/arch-x86/syscalls/timerfd_gettime.S
Normal file
@@ -0,0 +1,24 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
ENTRY(timerfd_gettime)
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
mov 12(%esp), %ebx
|
||||
mov 16(%esp), %ecx
|
||||
movl $__NR_timerfd_gettime, %eax
|
||||
int $0x80
|
||||
cmpl $-MAX_ERRNO, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
ret
|
||||
END(timerfd_gettime)
|
||||
30
libc/arch-x86/syscalls/timerfd_settime.S
Normal file
30
libc/arch-x86/syscalls/timerfd_settime.S
Normal file
@@ -0,0 +1,30 @@
|
||||
/* autogenerated by gensyscalls.py */
|
||||
#include <linux/err.h>
|
||||
#include <machine/asm.h>
|
||||
#include <asm/unistd.h>
|
||||
|
||||
ENTRY(timerfd_settime)
|
||||
pushl %ebx
|
||||
pushl %ecx
|
||||
pushl %edx
|
||||
pushl %esi
|
||||
mov 20(%esp), %ebx
|
||||
mov 24(%esp), %ecx
|
||||
mov 28(%esp), %edx
|
||||
mov 32(%esp), %esi
|
||||
movl $__NR_timerfd_settime, %eax
|
||||
int $0x80
|
||||
cmpl $-MAX_ERRNO, %eax
|
||||
jb 1f
|
||||
negl %eax
|
||||
pushl %eax
|
||||
call __set_errno
|
||||
addl $4, %esp
|
||||
orl $-1, %eax
|
||||
1:
|
||||
popl %esi
|
||||
popl %edx
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
ret
|
||||
END(timerfd_settime)
|
||||
@@ -10,16 +10,75 @@ _LIBC_ARCH_COMMON_SRC_FILES := \
|
||||
arch-x86/bionic/sigsetjmp.S \
|
||||
arch-x86/bionic/syscall.S \
|
||||
arch-x86/bionic/vfork.S \
|
||||
arch-x86/string/bcopy_wrapper.S \
|
||||
arch-x86/string/bzero_wrapper.S \
|
||||
arch-x86/string/ffs.S \
|
||||
arch-x86/string/memcmp_wrapper.S \
|
||||
arch-x86/string/memcpy_wrapper.S \
|
||||
arch-x86/string/memmove_wrapper.S \
|
||||
arch-x86/string/memset_wrapper.S \
|
||||
arch-x86/string/strcmp_wrapper.S \
|
||||
arch-x86/string/strlen_wrapper.S \
|
||||
arch-x86/string/strncmp_wrapper.S \
|
||||
arch-x86/string/ffs.S
|
||||
|
||||
ifeq ($(ARCH_X86_HAVE_SSSE3),true)
|
||||
_LIBC_ARCH_COMMON_SRC_FILES += \
|
||||
arch-x86/string/ssse3-memcpy-atom.S \
|
||||
arch-x86/string/ssse3-memmove-atom.S \
|
||||
arch-x86/string/ssse3-bcopy-atom.S \
|
||||
arch-x86/string/ssse3-strncat-atom.S \
|
||||
arch-x86/string/ssse3-strncpy-atom.S \
|
||||
arch-x86/string/ssse3-strlcat-atom.S \
|
||||
arch-x86/string/ssse3-strlcpy-atom.S \
|
||||
arch-x86/string/ssse3-strcmp-atom.S \
|
||||
arch-x86/string/ssse3-strncmp-atom.S \
|
||||
arch-x86/string/ssse3-strcat-atom.S \
|
||||
arch-x86/string/ssse3-strcpy-atom.S \
|
||||
arch-x86/string/ssse3-memcmp-atom.S \
|
||||
arch-x86/string/ssse3-wmemcmp-atom.S \
|
||||
arch-x86/string/ssse3-wcscat-atom.S \
|
||||
arch-x86/string/ssse3-wcscpy-atom.S
|
||||
else
|
||||
_LIBC_ARCH_COMMON_SRC_FILES += \
|
||||
arch-x86/string/memcpy.S \
|
||||
arch-x86/string/memmove.S \
|
||||
arch-x86/string/bcopy.S \
|
||||
arch-x86/string/strcmp.S \
|
||||
arch-x86/string/strncmp.S \
|
||||
arch-x86/string/strcat.S \
|
||||
arch-x86/string/memcmp.S \
|
||||
string/strcpy.c \
|
||||
string/strncat.c \
|
||||
string/strncpy.c \
|
||||
string/strlcat.c \
|
||||
string/strlcpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcscpy.c \
|
||||
upstream-freebsd/lib/libc/string/wcscat.c \
|
||||
upstream-freebsd/lib/libc/string/wmemcmp.c
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH_X86_HAVE_SSE2),true)
|
||||
_LIBC_ARCH_COMMON_SRC_FILES += \
|
||||
arch-x86/string/sse2-memset-atom.S \
|
||||
arch-x86/string/sse2-bzero-atom.S \
|
||||
arch-x86/string/sse2-memchr-atom.S \
|
||||
arch-x86/string/sse2-memrchr-atom.S \
|
||||
arch-x86/string/sse2-strchr-atom.S \
|
||||
arch-x86/string/sse2-strrchr-atom.S \
|
||||
arch-x86/string/sse2-index-atom.S \
|
||||
arch-x86/string/sse2-strlen-atom.S \
|
||||
arch-x86/string/sse2-strnlen-atom.S \
|
||||
arch-x86/string/sse2-wcschr-atom.S \
|
||||
arch-x86/string/sse2-wcsrchr-atom.S \
|
||||
arch-x86/string/sse2-wcslen-atom.S \
|
||||
arch-x86/string/sse2-wcscmp-atom.S
|
||||
else
|
||||
_LIBC_ARCH_COMMON_SRC_FILES += \
|
||||
arch-x86/string/memset.S \
|
||||
arch-x86/string/strlen.S \
|
||||
arch-x86/string/bzero.S \
|
||||
bionic/memrchr.c \
|
||||
bionic/memchr.c \
|
||||
string/strchr.cpp \
|
||||
string/strrchr.c \
|
||||
string/index.c \
|
||||
bionic/strnlen.c \
|
||||
upstream-freebsd/lib/libc/string/wcschr.c \
|
||||
upstream-freebsd/lib/libc/string/wcsrchr.c \
|
||||
upstream-freebsd/lib/libc/string/wcslen.c \
|
||||
upstream-freebsd/lib/libc/string/wcscmp.c
|
||||
endif
|
||||
|
||||
_LIBC_ARCH_STATIC_SRC_FILES := \
|
||||
bionic/dl_iterate_phdr_static.c \
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
extern "C" void *__memcpy_chk(void *dest, const void *src,
|
||||
size_t copy_amount, size_t dest_len)
|
||||
{
|
||||
if (__builtin_expect(copy_amount > dest_len, 0)) {
|
||||
if (__predict_false(copy_amount > dest_len)) {
|
||||
__fortify_chk_fail("memcpy buffer overflow",
|
||||
BIONIC_EVENT_MEMCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
extern "C" void *__memmove_chk (void *dest, const void *src,
|
||||
size_t len, size_t dest_len)
|
||||
{
|
||||
if (len > dest_len) {
|
||||
if (__predict_false(len > dest_len)) {
|
||||
__fortify_chk_fail("memmove buffer overflow",
|
||||
BIONIC_EVENT_MEMMOVE_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" void *__memset_chk (void *dest, int c, size_t n, size_t dest_len) {
|
||||
if (n > dest_len) {
|
||||
if (__predict_false(n > dest_len)) {
|
||||
__fortify_chk_fail("memset buffer overflow",
|
||||
BIONIC_EVENT_MEMSET_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,5 @@
|
||||
#include "libc_logging.h"
|
||||
|
||||
void __stack_chk_fail() {
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", "stack corruption detected");
|
||||
abort();
|
||||
__libc_fatal("stack corruption detected");
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libc_logging.h"
|
||||
#include <safe_iop.h>
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____strcat_chk.
|
||||
@@ -42,22 +41,24 @@
|
||||
* This strcat check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" char *__strcat_chk (char *dest, const char *src, size_t dest_buf_size) {
|
||||
// TODO: optimize so we don't scan src/dest twice.
|
||||
size_t src_len = strlen(src);
|
||||
size_t dest_len = strlen(dest);
|
||||
size_t sum;
|
||||
extern "C" char* __strcat_chk(
|
||||
char* __restrict dest,
|
||||
const char* __restrict src,
|
||||
size_t dest_buf_size)
|
||||
{
|
||||
char* save = dest;
|
||||
size_t dest_len = __strlen_chk(dest, dest_buf_size);
|
||||
|
||||
// sum = src_len + dest_len + 1 (with overflow protection)
|
||||
if (!safe_add3(&sum, src_len, dest_len, 1U)) {
|
||||
__fortify_chk_fail("strcat integer overflow",
|
||||
BIONIC_EVENT_STRCAT_INTEGER_OVERFLOW);
|
||||
}
|
||||
dest += dest_len;
|
||||
dest_buf_size -= dest_len;
|
||||
|
||||
if (sum > dest_buf_size) {
|
||||
while ((*dest++ = *src++) != '\0') {
|
||||
dest_buf_size--;
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strcat buffer overflow",
|
||||
BIONIC_EVENT_STRCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
}
|
||||
|
||||
return strcat(dest, src);
|
||||
return save;
|
||||
}
|
||||
|
||||
46
libc/bionic/__strchr_chk.cpp
Normal file
46
libc/bionic/__strchr_chk.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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 <string.h>
|
||||
#include "libc_logging.h"
|
||||
|
||||
extern "C" char* __strchr_chk(const char* p, int ch, size_t s_len) {
|
||||
for (;; ++p, s_len--) {
|
||||
if (__predict_false(s_len == 0)) {
|
||||
__fortify_chk_fail("read beyond buffer", 0);
|
||||
}
|
||||
if (*p == static_cast<char>(ch)) {
|
||||
return const_cast<char*>(p);
|
||||
}
|
||||
if (*p == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
@@ -44,7 +44,7 @@
|
||||
extern "C" char *__strcpy_chk (char *dest, const char *src, size_t dest_len) {
|
||||
// TODO: optimize so we don't scan src twice.
|
||||
size_t src_len = strlen(src) + 1;
|
||||
if (src_len > dest_len) {
|
||||
if (__predict_false(src_len > dest_len)) {
|
||||
__fortify_chk_fail("strcpy buffer overflow",
|
||||
BIONIC_EVENT_STRCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
extern "C" size_t __strlcat_chk(char *dest, const char *src,
|
||||
size_t supplied_size, size_t dest_len_from_compiler)
|
||||
{
|
||||
if (supplied_size > dest_len_from_compiler) {
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("strlcat buffer overflow", 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
extern "C" size_t __strlcpy_chk(char *dest, const char *src,
|
||||
size_t supplied_size, size_t dest_len_from_compiler)
|
||||
{
|
||||
if (supplied_size > dest_len_from_compiler) {
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("strlcpy buffer overflow", 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
extern "C" size_t __strlen_chk(const char *s, size_t s_len) {
|
||||
size_t ret = strlen(s);
|
||||
|
||||
if (__builtin_expect(ret >= s_len, 0)) {
|
||||
if (__predict_false(ret >= s_len)) {
|
||||
__fortify_chk_fail("strlen read overflow", 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libc_logging.h"
|
||||
#include <safe_iop.h>
|
||||
|
||||
/*
|
||||
* Runtime implementation of __builtin____strncat_chk.
|
||||
@@ -42,27 +41,33 @@
|
||||
* This strncat check is called if _FORTIFY_SOURCE is defined and
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" char *__strncat_chk (char *dest, const char *src,
|
||||
extern "C" char *__strncat_chk(
|
||||
char* __restrict dest,
|
||||
const char* __restrict src,
|
||||
size_t len, size_t dest_buf_size)
|
||||
{
|
||||
// TODO: optimize so we don't scan src/dest twice.
|
||||
size_t dest_len = strlen(dest);
|
||||
size_t src_len = strlen(src);
|
||||
if (src_len > len) {
|
||||
src_len = len;
|
||||
if (len == 0) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
size_t sum;
|
||||
// sum = src_len + dest_len + 1 (with overflow protection)
|
||||
if (!safe_add3(&sum, src_len, dest_len, 1U)) {
|
||||
__fortify_chk_fail("strncat integer overflow",
|
||||
BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW);
|
||||
}
|
||||
size_t dest_len = __strlen_chk(dest, dest_buf_size);
|
||||
char *d = dest + dest_len;
|
||||
dest_buf_size -= dest_len;
|
||||
|
||||
if (sum > dest_buf_size) {
|
||||
while (*src != '\0') {
|
||||
*d++ = *src++;
|
||||
len--; dest_buf_size--;
|
||||
|
||||
if (__predict_false(dest_buf_size == 0)) {
|
||||
__fortify_chk_fail("strncat buffer overflow",
|
||||
BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
return strncat(dest, src, len);
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*d = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
extern "C" char *__strncpy_chk (char *dest, const char *src,
|
||||
size_t len, size_t dest_len)
|
||||
{
|
||||
if (len > dest_len) {
|
||||
if (__predict_false(len > dest_len)) {
|
||||
__fortify_chk_fail("strncpy buffer overflow",
|
||||
BIONIC_EVENT_STRNCPY_BUFFER_OVERFLOW);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* greater than 0.
|
||||
*/
|
||||
extern "C" mode_t __umask_chk(mode_t mode) {
|
||||
if ((mode & 0777) != mode) {
|
||||
if (__predict_false((mode & 0777) != mode)) {
|
||||
__fortify_chk_fail("umask called with invalid mask", 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ extern "C" int __vsnprintf_chk(
|
||||
const char *format,
|
||||
va_list va)
|
||||
{
|
||||
if (supplied_size > dest_len_from_compiler) {
|
||||
if (__predict_false(supplied_size > dest_len_from_compiler)) {
|
||||
__fortify_chk_fail("vsnprintf buffer overflow", 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* $OpenBSD: abort.c,v 1.14 2005/08/08 08:05:36 espie Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1985 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
@@ -31,74 +30,38 @@
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "thread_private.h"
|
||||
#include "atexit.h"
|
||||
|
||||
__LIBC_HIDDEN__ void (*__cleanup)();
|
||||
|
||||
#ifdef __arm__
|
||||
__LIBC_HIDDEN__ void
|
||||
__libc_android_abort(void)
|
||||
extern "C" __LIBC_HIDDEN__ void __libc_android_abort()
|
||||
#else
|
||||
void
|
||||
abort(void)
|
||||
void abort()
|
||||
#endif
|
||||
{
|
||||
struct atexit *p = __atexit;
|
||||
static int cleanup_called = 0;
|
||||
// Don't block SIGABRT to give any signal handler a chance; we ignore
|
||||
// any errors -- X311J doesn't allow abort to return anyway.
|
||||
sigset_t mask;
|
||||
|
||||
|
||||
sigfillset(&mask);
|
||||
/*
|
||||
* don't block SIGABRT to give any handler a chance; we ignore
|
||||
* any errors -- X311J doesn't allow abort to return anyway.
|
||||
*/
|
||||
sigdelset(&mask, SIGABRT);
|
||||
/* temporary, so deliberate seg fault can be caught by debuggerd */
|
||||
sigdelset(&mask, SIGSEGV);
|
||||
/* -- */
|
||||
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
|
||||
sigprocmask(SIG_SETMASK, &mask, NULL);
|
||||
|
||||
/*
|
||||
* POSIX requires we flush stdio buffers on abort
|
||||
*/
|
||||
if (cleanup_called == 0) {
|
||||
while (p != NULL && p->next != NULL)
|
||||
p = p->next;
|
||||
/* the check for fn_dso == NULL is mostly paranoia */
|
||||
if (p != NULL && p->fns[0].fn_dso == NULL &&
|
||||
p->fns[0].fn_ptr.std_func != NULL) {
|
||||
cleanup_called = 1;
|
||||
(*p->fns[0].fn_ptr.std_func)();
|
||||
}
|
||||
// POSIX requires we flush stdio buffers on abort.
|
||||
if (__cleanup) {
|
||||
(*__cleanup)();
|
||||
}
|
||||
|
||||
/* temporary, for bug hunting */
|
||||
/* seg fault seems to produce better debuggerd results than SIGABRT */
|
||||
#ifdef __mips__
|
||||
/* An access that will generate SIGSEGV rather than SIGBUS. */
|
||||
*((char*)0xdeadc0c0) = 39;
|
||||
#else
|
||||
*((char*)0xdeadbaad) = 39;
|
||||
#endif
|
||||
/* -- */
|
||||
raise(SIGABRT);
|
||||
|
||||
(void)kill(getpid(), SIGABRT);
|
||||
|
||||
/*
|
||||
* if SIGABRT ignored, or caught and the handler returns, do
|
||||
* it again, only harder.
|
||||
*/
|
||||
{
|
||||
// If SIGABRT ignored, or caught and the handler returns,
|
||||
// remove the SIGABRT signal handler and raise SIGABRT again.
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
(void)sigaction( SIGABRT, &sa, &sa );
|
||||
}
|
||||
|
||||
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL);
|
||||
(void)kill(getpid(), SIGABRT);
|
||||
sigaction(SIGABRT, &sa, &sa);
|
||||
sigprocmask(SIG_SETMASK, &mask, NULL);
|
||||
raise(SIGABRT);
|
||||
_exit(1);
|
||||
}
|
||||
@@ -28,27 +28,16 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libc_logging.h"
|
||||
|
||||
// We log to stderr for the benefit of "adb shell" users, and the log for the benefit
|
||||
// of regular app developers who want to see their asserts.
|
||||
|
||||
void __assert(const char* file, int line, const char* failed_expression) {
|
||||
const char* fmt = "%s:%d: assertion \"%s\" failed\n";
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", fmt, file, line, failed_expression);
|
||||
fprintf(stderr, fmt, file, line, failed_expression);
|
||||
abort();
|
||||
__libc_fatal("%s:%d: assertion \"%s\" failed", file, line, failed_expression);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void __assert2(const char* file, int line, const char* function, const char* failed_expression) {
|
||||
const char* fmt = "%s:%d: %s: assertion \"%s\" failed\n";
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", fmt, file, line, function, failed_expression);
|
||||
fprintf(stderr, fmt, file, line, function, failed_expression);
|
||||
abort();
|
||||
__libc_fatal("%s:%d: %s: assertion \"%s\" failed", file, line, function, failed_expression);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
@@ -91,6 +91,24 @@ static _Unwind_Reason_Code trace_function(__unwind_context* context, void* arg)
|
||||
return _URC_NO_REASON;
|
||||
}
|
||||
|
||||
#ifdef __arm__
|
||||
/*
|
||||
* The instruction pointer is pointing at the instruction after the bl(x), and
|
||||
* the _Unwind_Backtrace routine already masks the Thumb mode indicator (LSB
|
||||
* in PC). So we need to do a quick check here to find out if the previous
|
||||
* instruction is a Thumb-mode BLX(2). If so subtract 2 otherwise 4 from PC.
|
||||
*/
|
||||
if (ip != 0) {
|
||||
short* ptr = reinterpret_cast<short*>(ip);
|
||||
// Thumb BLX(2)
|
||||
if ((*(ptr-1) & 0xff80) == 0x4780) {
|
||||
ip -= 2;
|
||||
} else {
|
||||
ip -= 4;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
state->frames[state->frame_count++] = ip;
|
||||
return (state->frame_count >= state->max_depth) ? _URC_END_OF_STACK : _URC_NO_REASON;
|
||||
}
|
||||
|
||||
@@ -27,39 +27,56 @@
|
||||
*/
|
||||
|
||||
#include <elf.h>
|
||||
#include <sys/auxv.h>
|
||||
#include <sys/types.h>
|
||||
#include <link.h>
|
||||
|
||||
/* Dynamic binaries get this from the dynamic linker (system/linker), which
|
||||
* we don't pull in for static bins. We also don't have a list of so's to
|
||||
* iterate over, since there's really only a single monolithic blob of
|
||||
* code/data.
|
||||
*
|
||||
* All we need to do is to find where the executable is in memory, and grab the
|
||||
* phdr and phnum from there.
|
||||
*/
|
||||
|
||||
/* ld provides this to us in the default link script */
|
||||
extern void *__executable_start;
|
||||
extern void* __executable_start;
|
||||
|
||||
int
|
||||
dl_iterate_phdr(int (*cb)(struct dl_phdr_info *info, size_t size, void *data),
|
||||
void *data)
|
||||
{
|
||||
struct dl_phdr_info dl_info;
|
||||
Elf32_Ehdr *ehdr = (Elf32_Ehdr *) &__executable_start;
|
||||
Elf32_Phdr *phdr = (Elf32_Phdr *)((unsigned long)ehdr + ehdr->e_phoff);
|
||||
int dl_iterate_phdr(int (*cb)(struct dl_phdr_info* info, size_t size, void* data), void* data) {
|
||||
Elf32_Ehdr* ehdr = (Elf32_Ehdr*) &__executable_start;
|
||||
|
||||
/* TODO: again, copied from linker.c. Find a better home for this
|
||||
* later. */
|
||||
// TODO: again, copied from linker.c. Find a better home for this later.
|
||||
if (ehdr->e_ident[EI_MAG0] != ELFMAG0) return -1;
|
||||
if (ehdr->e_ident[EI_MAG1] != ELFMAG1) return -1;
|
||||
if (ehdr->e_ident[EI_MAG2] != ELFMAG2) return -1;
|
||||
if (ehdr->e_ident[EI_MAG3] != ELFMAG3) return -1;
|
||||
|
||||
dl_info.dlpi_addr = 0;
|
||||
dl_info.dlpi_name = NULL;
|
||||
dl_info.dlpi_phdr = phdr;
|
||||
dl_info.dlpi_phnum = ehdr->e_phnum;
|
||||
return cb(&dl_info, sizeof (struct dl_phdr_info), data);
|
||||
// Dynamic binaries get their dl_iterate_phdr from the dynamic linker, but
|
||||
// static binaries get this. We don't have a list of shared objects to
|
||||
// iterate over, since there's really only a single monolithic blob of
|
||||
// code/data, plus optionally a VDSO.
|
||||
|
||||
struct dl_phdr_info exe_info;
|
||||
exe_info.dlpi_addr = 0;
|
||||
exe_info.dlpi_name = NULL;
|
||||
exe_info.dlpi_phdr = (Elf32_Phdr*) ((unsigned long) ehdr + ehdr->e_phoff);
|
||||
exe_info.dlpi_phnum = ehdr->e_phnum;
|
||||
|
||||
#ifdef AT_SYSINFO_EHDR
|
||||
// Try the executable first.
|
||||
int rc = cb(&exe_info, sizeof(exe_info), data);
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Try the VDSO if that didn't work.
|
||||
Elf32_Ehdr* ehdr_vdso = (Elf32_Ehdr*) getauxval(AT_SYSINFO_EHDR);
|
||||
struct dl_phdr_info vdso_info;
|
||||
vdso_info.dlpi_addr = 0;
|
||||
vdso_info.dlpi_name = NULL;
|
||||
vdso_info.dlpi_phdr = (Elf32_Phdr*) ((char*) ehdr_vdso + ehdr_vdso->e_phoff);
|
||||
vdso_info.dlpi_phnum = ehdr_vdso->e_phnum;
|
||||
for (size_t i = 0; i < vdso_info.dlpi_phnum; ++i) {
|
||||
if (vdso_info.dlpi_phdr[i].p_type == PT_LOAD) {
|
||||
vdso_info.dlpi_addr = (Elf32_Addr) ehdr_vdso - vdso_info.dlpi_phdr[i].p_vaddr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cb(&vdso_info, sizeof(vdso_info), data);
|
||||
#else
|
||||
// There's only the executable to try.
|
||||
return cb(&exe_info, sizeof(exe_info), data);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -16,15 +16,7 @@
|
||||
|
||||
#include "dlmalloc.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <linux/ashmem.h>
|
||||
|
||||
#include <private/libc_logging.h>
|
||||
#include "private/libc_logging.h"
|
||||
|
||||
// Send dlmalloc errors to the log.
|
||||
static void __bionic_heap_corruption_error(const char* function);
|
||||
@@ -33,51 +25,20 @@ static void __bionic_heap_usage_error(const char* function, void* address);
|
||||
#define CORRUPTION_ERROR_ACTION(m) __bionic_heap_corruption_error(__FUNCTION__)
|
||||
#define USAGE_ERROR_ACTION(m,p) __bionic_heap_usage_error(__FUNCTION__, p)
|
||||
|
||||
// We use ashmem to name the anonymous private regions created by dlmalloc.
|
||||
static void* __bionic_named_anonymous_mmap(size_t length);
|
||||
#define MMAP(s) __bionic_named_anonymous_mmap(s)
|
||||
|
||||
// Ugly inclusion of C file so that bionic specific #defines configure dlmalloc.
|
||||
#include "../upstream-dlmalloc/malloc.c"
|
||||
|
||||
extern void (*__cleanup)();
|
||||
|
||||
static void __bionic_heap_corruption_error(const char* function) {
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc", "@@@ ABORTING: heap corruption detected by %s",
|
||||
function);
|
||||
abort();
|
||||
__cleanup = NULL; // The heap is corrupt. We can forget trying to shut down stdio.
|
||||
__libc_fatal("heap corruption detected by %s", function);
|
||||
}
|
||||
|
||||
static void __bionic_heap_usage_error(const char* function, void* address) {
|
||||
__libc_format_log(ANDROID_LOG_FATAL, "libc",
|
||||
"@@@ ABORTING: invalid address or address of corrupt block %p passed to %s",
|
||||
__libc_fatal_no_abort("invalid address or address of corrupt block %p passed to %s",
|
||||
address, function);
|
||||
// So that we can get a memory dump around the specific address.
|
||||
// So that debuggerd gives us a memory dump around the specific address.
|
||||
// TODO: improve the debuggerd protocol so we can tell it to dump an address when we abort.
|
||||
*((int**) 0xdeadbaad) = (int*) address;
|
||||
}
|
||||
|
||||
static int __ashmem_create_region(const char* name, size_t size) {
|
||||
int fd = open("/dev/ashmem", O_RDWR);
|
||||
if (fd == -1) {
|
||||
return fd;
|
||||
}
|
||||
int rc = ioctl(fd, ASHMEM_SET_NAME, name);
|
||||
if (rc < 0) {
|
||||
close(fd);
|
||||
return rc;
|
||||
}
|
||||
rc = ioctl(fd, ASHMEM_SET_SIZE, size);
|
||||
if (rc < 0) {
|
||||
close(fd);
|
||||
return rc;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void* __bionic_named_anonymous_mmap(size_t length) {
|
||||
int fd = __ashmem_create_region("libc malloc", length);
|
||||
if (fd < 0) {
|
||||
return MAP_FAILED;
|
||||
}
|
||||
void* result = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
|
||||
close (fd);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define LOCK_AT_FORK 1
|
||||
#define USE_RECURSIVE_LOCK 0
|
||||
#define USE_SPIN_LOCKS 0
|
||||
#define DEFAULT_MMAP_THRESHOLD (64U * 1024U)
|
||||
|
||||
/* Include the proper definitions. */
|
||||
#include "../upstream-dlmalloc/malloc.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user