mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-27 13:00:28 +00:00
Make improvements
This commit is contained in:
parent
3e4fd4b0ad
commit
e44a0cf6f8
256 changed files with 23100 additions and 2294 deletions
|
@ -1,39 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Returns true if architecture guarantees atomicity.
|
||||
/
|
||||
/ @param rdi is byte width of type
|
||||
/ @param rsi is optional pointer for alignment check
|
||||
/ @see Intel's Six Thousand Page Manual V.3A §8.2.3.1
|
||||
__atomic_is_lock_free:
|
||||
.leafprologue
|
||||
.profilable
|
||||
xor %ecx,%ecx
|
||||
pushpop 1,%rax
|
||||
cmp $7,%rdi
|
||||
cmova %ecx,%eax
|
||||
dec %edi
|
||||
and %edi,%esi
|
||||
cmovnz %ecx,%eax
|
||||
.leafepilogue
|
||||
.endfn __atomic_is_lock_free,globl,hidden
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares memory.
|
||||
/
|
||||
/ This API was thought to be nearly extinct until recent versions
|
||||
/ of Clang (c. 2019) started generating synthetic calls to it.
|
||||
/
|
||||
/ @param edi first string
|
||||
/ @param esi second string
|
||||
/ @param edx byte size
|
||||
/ @return 0 if equal or nonzero
|
||||
bcmp: jmp *__memcmp(%rip)
|
||||
.endfn bcmp,globl
|
||||
.source __FILE__
|
|
@ -1,31 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Copies memory.
|
||||
/
|
||||
/ DEST and SRC may overlap.
|
||||
/
|
||||
/ @param rdi is dest
|
||||
/ @param rsi is src
|
||||
/ @param rdx is number of bytes
|
||||
bcopy: jmp memmove
|
||||
.endfn bcopy,globl
|
||||
.source __FILE__
|
|
@ -1,35 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
.initbss 300,_init_kToUpper
|
||||
kToUpper:
|
||||
.zero 256
|
||||
.endobj kToUpper,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_kToUpper
|
||||
lea 'a(%rdi),%r8
|
||||
call imapxlatab
|
||||
pushpop 'z-'a,%rcx
|
||||
0: subb $0x20,(%r8,%rcx)
|
||||
.loop 0b
|
||||
.init.end 300,_init_kToUpper
|
||||
.source __FILE__
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_MACROS_H_
|
||||
#define COSMOPOLITAN_LIBC_NEXGEN32E_MACROS_H_
|
||||
#ifdef __ASSEMBLER__
|
||||
#include "libc/nexgen32e/macros.inc"
|
||||
#include "libc/nexgen32e/macros.internal.inc"
|
||||
#else
|
||||
|
||||
/* let's give auto-import tooling a helping hand */
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares memory bytes.
|
||||
/
|
||||
/ @param rdi is first uint8_t array
|
||||
/ @param rsi is second uint8_t array
|
||||
/ @param rdx is max bytes to consider
|
||||
/ @return unsigned char subtraction at stop index
|
||||
/ @note AVX2 requires Haswell (2014+) or Excavator (2015+)
|
||||
/ @see libc/nexgen32e/memcmp.S (for benchmarks)
|
||||
/ @asyncsignalsafe
|
||||
.align 16
|
||||
memcmp$avx2:
|
||||
.leafprologue
|
||||
.profilable
|
||||
cmp %rsi,%rdi
|
||||
je 7f
|
||||
test %rdx,%rdx
|
||||
jz 7f
|
||||
mov %rdx,%r8
|
||||
shr $5,%r8
|
||||
add $1,%r8
|
||||
mov $-32,%rcx
|
||||
1: add $32,%rcx
|
||||
sub $1,%r8
|
||||
jz 5f
|
||||
vmovdqu (%rdi,%rcx),%ymm0
|
||||
vpcmpeqb (%rsi,%rcx),%ymm0,%ymm0
|
||||
vpmovmskb %ymm0,%eax
|
||||
sub $0xffffffff,%eax
|
||||
jz 1b
|
||||
tzcnt %eax,%eax
|
||||
add %rax,%rcx
|
||||
5: cmp %rcx,%rdx
|
||||
je 7f
|
||||
inc %rcx
|
||||
movzbl -1(%rdi,%rcx),%eax
|
||||
movzbl -1(%rsi,%rcx),%r8d
|
||||
sub %r8d,%eax
|
||||
jz 5b
|
||||
jmp 8f
|
||||
7: xor %eax,%eax
|
||||
8: vpxor %ymm0,%ymm0,%ymm0
|
||||
.leafepilogue
|
||||
.endfn memcmp$avx2,globl,hidden
|
||||
.source __FILE__
|
|
@ -1,50 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Dispatches to fastest memcmp() implementation.
|
||||
/
|
||||
/ @param edi first string
|
||||
/ @param esi second string
|
||||
/ @param edx byte size
|
||||
/ @return unsigned char subtraction at stop index
|
||||
/ @asyncsignalsafe
|
||||
.initbss 300,_init_memcmp
|
||||
__memcmp:
|
||||
.quad 0
|
||||
.endobj __memcmp,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_memcmp
|
||||
#if !IsTiny()
|
||||
ezlea memcmp$avx2,ax
|
||||
#if !X86_NEED(AVX2)
|
||||
ezlea memcmp$sse2,dx
|
||||
testb X86_HAVE(AVX2)+kCpuids(%rip)
|
||||
cmovz %rdx,%rax
|
||||
#endif /* AVX */
|
||||
#else
|
||||
ezlea memcmp$sse2,ax
|
||||
#endif /* TINY */
|
||||
stosq
|
||||
.init.end 300,_init_memcmp
|
||||
.source __FILE__
|
|
@ -1,62 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares memory.
|
||||
/
|
||||
/ @param rdi is first uint8_t array
|
||||
/ @param rsi is second uint8_t array
|
||||
/ @param rdx is max bytes to consider
|
||||
/ @return unsigned char subtraction at stop index
|
||||
/ @asyncsignalsafe
|
||||
memcmp$sse2:
|
||||
.leafprologue
|
||||
.profilable
|
||||
cmp %rsi,%rdi
|
||||
je 7f
|
||||
test %rdx,%rdx
|
||||
jz 7f
|
||||
mov %rdx,%r8
|
||||
shr $4,%r8
|
||||
add $1,%r8
|
||||
mov $-16,%rcx
|
||||
1: add $16,%rcx
|
||||
sub $1,%r8
|
||||
jz 5f
|
||||
movdqu (%rdi,%rcx),%xmm0
|
||||
movdqu (%rsi,%rcx),%xmm1
|
||||
pcmpeqb %xmm1,%xmm0
|
||||
pmovmskb %xmm0,%eax
|
||||
sub $0xffff,%eax
|
||||
jz 1b
|
||||
bsf %eax,%eax
|
||||
add %rax,%rcx
|
||||
5: cmp %rcx,%rdx
|
||||
je 7f
|
||||
inc %rcx
|
||||
movzbl -1(%rdi,%rcx),%eax
|
||||
movzbl -1(%rsi,%rcx),%r8d
|
||||
sub %r8d,%eax
|
||||
jz 5b
|
||||
jmp 8f
|
||||
7: xor %eax,%eax
|
||||
8: .leafepilogue
|
||||
.endfn memcmp$sse2,globl,hidden
|
||||
.source __FILE__
|
|
@ -1,206 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares memory.
|
||||
/
|
||||
/ @param edi first string
|
||||
/ @param esi second string
|
||||
/ @param edx byte size
|
||||
/ @return unsigned char subtraction at stop index
|
||||
/ @asyncsignalsafe
|
||||
memcmp: jmp *__memcmp(%rip)
|
||||
.endfn memcmp,globl
|
||||
.source __FILE__
|
||||
|
||||
/* cosmo memcmp() avx2 for #c per n where c ≈ 0.273ns
|
||||
N x1 x8 x64 mBps
|
||||
------------------------------------------------------------
|
||||
1 61.000 39.375 36.984 95
|
||||
1 37.000 37.625 37.391 94
|
||||
2 28.500 19.688 19.930 175
|
||||
3 20.333 13.625 14.411 243
|
||||
4 30.250 10.656 10.426 335
|
||||
7 15.000 7.304 6.136 570
|
||||
8 10.125 6.234 5.525 633
|
||||
15 9.133 3.542 3.570 980
|
||||
16 6.062 4.398 3.577 977
|
||||
31 4.548 2.931 2.340 1494
|
||||
32 2.594 1.520 1.492 2344
|
||||
63 3.444 1.240 1.221 2864
|
||||
64 1.328 0.736 0.742 4713
|
||||
127 1.661 0.710 0.605 5778
|
||||
128 0.820 0.452 0.396 8822
|
||||
255 0.639 0.360 0.347 10080
|
||||
256 0.434 0.250 0.220 15874
|
||||
511 0.413 0.218 0.199 17612
|
||||
512 0.201 0.176 0.138 25377
|
||||
1023 0.216 0.142 0.125 28031
|
||||
1024 0.132 0.097 0.096 36276
|
||||
2047 0.125 0.091 0.091 38466
|
||||
2048 0.093 0.079 0.075 46365
|
||||
4095 0.084 0.081 0.078 44705
|
||||
4096 0.069 0.069 0.069 50819
|
||||
8191 0.070 0.068 0.067 51841
|
||||
8192 0.063 0.062 0.062 56633
|
||||
16383 0.066 0.063 0.061 56994
|
||||
16384 0.059 0.058 0.058 60021
|
||||
32767 0.131 0.104 0.100 34909
|
||||
32768 0.120 0.084 0.079 44282
|
||||
|
||||
cosmo memcmp() sse2 (old cpu) for #c per n where c ≈ 0.273ns
|
||||
N x1 x8 x64 mBps
|
||||
------------------------------------------------------------
|
||||
1 59.000 37.125 37.328 94
|
||||
1 35.000 37.375 36.359 96
|
||||
2 28.500 18.938 20.461 171
|
||||
3 19.000 12.875 13.234 264
|
||||
4 29.250 10.906 10.348 338
|
||||
7 11.571 6.304 6.404 546
|
||||
8 8.125 5.672 5.713 612
|
||||
15 11.533 4.492 3.759 930
|
||||
16 5.812 3.227 2.876 1216
|
||||
31 5.516 2.367 1.797 1946
|
||||
32 2.969 1.816 1.481 2361
|
||||
63 3.413 0.990 0.929 3763
|
||||
64 1.703 0.850 0.763 4580
|
||||
127 1.614 0.531 0.533 6556
|
||||
128 0.961 0.438 0.426 8205
|
||||
255 0.922 0.378 0.325 10745
|
||||
256 0.457 0.322 0.268 13035
|
||||
511 0.331 0.253 0.216 16223
|
||||
512 0.287 0.212 0.189 18460
|
||||
1023 0.220 0.172 0.164 21378
|
||||
1024 0.198 0.159 0.150 23357
|
||||
2047 0.161 0.152 0.150 23271
|
||||
2048 0.147 0.139 0.136 25732
|
||||
4095 0.135 0.130 0.129 27157
|
||||
4096 0.129 0.123 0.123 28499
|
||||
8191 0.122 0.116 0.116 30110
|
||||
8192 0.116 0.113 0.113 30863
|
||||
16383 0.117 0.112 0.112 31311
|
||||
16384 0.111 0.110 0.110 31802
|
||||
32767 0.157 0.138 0.136 25653
|
||||
32768 0.144 0.121 0.118 29590
|
||||
|
||||
glibc memcmp() for #c per n where c ≈ 0.273ns
|
||||
N x1 x8 x64 mBps
|
||||
------------------------------------------------------------
|
||||
1 6875.000 39.125 35.141 100
|
||||
1 33.000 35.375 35.078 100
|
||||
2 138.500 20.312 18.570 188
|
||||
3 26.333 13.958 12.536 279
|
||||
4 53.250 12.094 9.512 368
|
||||
7 13.571 5.554 5.708 613
|
||||
8 19.625 5.328 5.057 691
|
||||
15 6.867 3.075 2.801 1248
|
||||
16 9.062 2.555 2.526 1384
|
||||
31 4.484 1.319 1.313 2663
|
||||
32 3.906 1.285 1.299 2691
|
||||
63 2.143 0.863 0.719 4867
|
||||
64 1.234 0.814 0.718 4873
|
||||
127 2.071 0.493 0.428 8174
|
||||
128 0.523 0.427 0.421 8310
|
||||
255 0.882 0.302 0.250 13983
|
||||
256 0.465 0.258 0.266 13143
|
||||
511 0.417 0.189 0.164 21339
|
||||
512 0.209 0.170 0.160 21862
|
||||
1023 0.320 0.120 0.111 31391
|
||||
1024 0.128 0.115 0.112 31106
|
||||
2047 0.110 0.092 0.088 39803
|
||||
2048 0.098 0.088 0.086 40837
|
||||
4095 0.093 0.078 0.076 46281
|
||||
4096 0.081 0.076 0.075 46400
|
||||
8191 0.080 0.071 0.069 50984
|
||||
8192 0.075 0.069 0.069 50970
|
||||
16383 0.083 0.071 0.068 51591
|
||||
16384 0.072 0.071 0.068 51736
|
||||
32767 0.145 0.136 0.121 28805
|
||||
32768 0.145 0.139 0.137 25469
|
||||
|
||||
musl memcmp() for #c per n where c ≈ 0.273ns
|
||||
N x1 x8 x64 mBps
|
||||
------------------------------------------------------------
|
||||
1 55.000 37.625 34.484 101
|
||||
1 35.000 33.625 34.203 102
|
||||
2 37.500 24.562 18.648 188
|
||||
3 20.333 13.625 12.766 274
|
||||
4 32.750 11.531 9.527 367
|
||||
7 12.714 8.482 5.828 600
|
||||
8 13.125 6.234 5.330 656
|
||||
15 9.000 4.892 3.391 1031
|
||||
16 5.188 4.102 3.335 1048
|
||||
31 4.806 2.899 2.295 1524
|
||||
32 4.406 2.801 2.208 1584
|
||||
63 3.794 1.808 1.689 2070
|
||||
64 2.672 1.994 1.675 2088
|
||||
127 1.961 1.739 1.648 2122
|
||||
128 2.055 1.610 1.614 2167
|
||||
255 1.463 1.381 1.401 2496
|
||||
256 1.457 1.362 1.385 2525
|
||||
511 1.286 1.351 1.226 2853
|
||||
512 1.256 1.255 1.253 2791
|
||||
1023 1.207 1.184 1.180 2964
|
||||
1024 1.204 1.146 1.174 2978
|
||||
2047 1.134 1.126 1.152 3036
|
||||
2048 1.134 1.123 1.149 3044
|
||||
4095 1.124 1.108 1.138 3074
|
||||
4096 1.117 1.107 1.136 3077
|
||||
8191 1.106 1.103 1.102 3174
|
||||
8192 1.105 1.102 1.267 2760
|
||||
16383 1.110 1.103 1.099 3182
|
||||
16384 1.108 1.100 1.098 3184
|
||||
32767 1.101 1.097 1.126 3105
|
||||
32768 1.128 1.130 1.126 3105
|
||||
|
||||
newlib memcmp() for #c per n where c ≈ 0.273ns
|
||||
N x1 x8 x64 mBps
|
||||
------------------------------------------------------------
|
||||
1 73.000 39.625 36.297 96
|
||||
1 35.000 35.375 35.328 99
|
||||
2 41.500 19.438 18.508 189
|
||||
3 29.667 13.542 13.005 269
|
||||
4 22.750 10.656 10.332 338
|
||||
7 14.714 6.875 6.248 560
|
||||
8 18.125 6.453 5.846 598
|
||||
15 11.533 3.575 3.547 986
|
||||
16 8.062 3.461 2.880 1214
|
||||
31 3.839 2.931 2.689 1300
|
||||
32 5.594 1.848 1.589 2200
|
||||
63 3.667 2.387 2.242 1560
|
||||
64 2.078 1.170 0.842 4153
|
||||
127 2.228 2.111 2.126 1644
|
||||
128 1.617 0.669 0.510 6858
|
||||
255 2.059 1.960 1.964 1781
|
||||
256 0.590 0.398 0.335 10452
|
||||
511 1.841 1.814 1.811 1931
|
||||
512 0.373 0.275 0.252 13860
|
||||
1023 1.788 1.748 2.426 1441
|
||||
1024 0.261 0.230 0.226 15474
|
||||
2047 1.745 1.731 1.774 1971
|
||||
2048 0.218 0.199 0.197 17741
|
||||
4095 1.771 1.764 1.763 1983
|
||||
4096 0.187 0.177 0.181 19353
|
||||
8191 1.722 1.714 1.714 2040
|
||||
8192 0.173 0.174 0.173 20252
|
||||
16383 1.754 1.754 1.845 1895
|
||||
16384 0.175 0.171 0.169 20692
|
||||
32767 1.753 1.753 1.753 1995
|
||||
32768 0.186 0.173 0.170 20510 */
|
|
@ -1,49 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/macros.h"
|
||||
#include "libc/nexgen32e/uart.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
.real
|
||||
.code16 # ∩ .code32 ∩ .code64
|
||||
|
||||
/ Receives byte over serial line.
|
||||
/
|
||||
/ This is both blocking and asynchronous.
|
||||
/
|
||||
/ @param di serial port
|
||||
/ @return ax character received
|
||||
/ @mode long,legacy,real
|
||||
/ @see ttytxr
|
||||
sgetc: push %bp
|
||||
mov %sp,%bp
|
||||
mov %di,%dx
|
||||
add $UART_LSR,%dx
|
||||
mov $UART_TTYDA,%ah
|
||||
1: in %dx,%al
|
||||
and %ah,%al
|
||||
rep nop # todo(jart): interrupts are better
|
||||
jz 1b
|
||||
mov %di,%dx
|
||||
xor %ax,%ax
|
||||
in %dx,%al
|
||||
pop %bp
|
||||
ret
|
||||
.endfn sgetc,globl
|
||||
.source __FILE__
|
|
@ -1,66 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated strings, ignoring ASCII case.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note char is treated as unsigned
|
||||
strcasecmp:
|
||||
or $-1,%rdx
|
||||
/ fallthrough
|
||||
.endfn strcasecmp,globl
|
||||
|
||||
/ Compares NUL-terminated strings w/ limit ignoring ASCII case.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @param rdx max bytes
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note char is treated as unsigned
|
||||
strncasecmp:
|
||||
.leafprologue
|
||||
.profilable
|
||||
push %rbx
|
||||
cmp %rdi,%rsi
|
||||
je 3f
|
||||
ezlea kToLower,bx
|
||||
or $-1,%rcx
|
||||
1: add $1,%rcx
|
||||
cmp %rcx,%rdx
|
||||
je 3f
|
||||
movzbl (%rdi,%rcx),%r8d
|
||||
movzbl (%rsi,%rcx),%eax
|
||||
xlat
|
||||
xchg %r8d,%eax
|
||||
xlat
|
||||
cmp %r8b,%al
|
||||
jne 2f
|
||||
test %al,%al
|
||||
jnz 1b
|
||||
2: sub %r8d,%eax
|
||||
jmp 4f
|
||||
3: xor %eax,%eax
|
||||
4: pop %rbx
|
||||
.leafepilogue
|
||||
.endfn strncasecmp,globl
|
||||
.source __FILE__
|
|
@ -1,72 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated char16_t strings, ignoring ASCII case.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note char16_t is an unsigned type
|
||||
strcasecmp16:
|
||||
or $-1,%rdx
|
||||
/ fallthrough
|
||||
.endfn strcasecmp16,globl
|
||||
|
||||
/ Compares NUL-terminated char16_t strings w/ limit ignoring ASCII case.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @param rdx max shorts
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note char16_t is an unsigned type
|
||||
strncasecmp16:
|
||||
.leafprologue
|
||||
.profilable
|
||||
push %rbx
|
||||
cmp %rdi,%rsi
|
||||
je 3f
|
||||
or $-1,%rcx
|
||||
1: add $1,%rcx
|
||||
cmp %rcx,%rdx
|
||||
je 3f
|
||||
movzwl (%rsi,%rcx,2),%eax
|
||||
mov %eax,%ebx
|
||||
and $0x7f,%ebx
|
||||
cmp %eax,%ebx
|
||||
cmove kToLower16(,%rbx,2),%ax
|
||||
push %rax
|
||||
movzwl (%rdi,%rcx,2),%eax
|
||||
mov %eax,%ebx
|
||||
and $0x7f,%ebx
|
||||
cmp %eax,%ebx
|
||||
cmove kToLower16(,%rbx,2),%ax
|
||||
pop %rbx
|
||||
cmp %ebx,%eax
|
||||
jne 2f
|
||||
test %eax,%eax
|
||||
jnz 1b
|
||||
2: sub %ebx,%eax
|
||||
jmp 4f
|
||||
3: xor %eax,%eax
|
||||
4: pop %rbx
|
||||
.leafepilogue
|
||||
.endfn strncasecmp16,globl
|
||||
.source __FILE__
|
|
@ -1,90 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated strings w/ AVX (2011+)
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @asyncsignalsafe
|
||||
strcmp$avx:
|
||||
or $-1,%rdx
|
||||
/ fallthrough
|
||||
.endfn strcmp$avx,globl,hidden
|
||||
|
||||
/ Compares NUL-terminated strings, with byte limit.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @param rdx maximum number of bytes to compare
|
||||
/ @return 0 if equal, etc.
|
||||
/ @asyncsignalsafe
|
||||
strncmp$avx:
|
||||
.leafprologue
|
||||
.profilable
|
||||
cmp %rsi,%rdi
|
||||
je 1f
|
||||
mov $-16,%rcx
|
||||
vpxor %xmm0,%xmm0,%xmm0
|
||||
vpcmpeqd %xmm1,%xmm1,%xmm1
|
||||
3: add $16,%rcx
|
||||
4: lea 16(%rcx),%rax
|
||||
cmp %rdx,%rax
|
||||
ja 9f
|
||||
lea (%rdi,%rcx),%eax
|
||||
and $0xfff,%eax
|
||||
cmp $0xff0,%eax
|
||||
ja 9f
|
||||
lea (%rsi,%rcx),%eax
|
||||
and $0xfff,%eax
|
||||
cmp $0xff0,%eax
|
||||
jbe 7f
|
||||
9: cmpq %rcx,%rdx
|
||||
je 1f
|
||||
movzbl (%rdi,%rcx),%r8d
|
||||
movzbl (%rsi,%rcx),%r9d
|
||||
mov %r8d,%eax
|
||||
sub %r9d,%eax
|
||||
testl %r8d,%r8d
|
||||
je 5f
|
||||
incq %rcx
|
||||
testl %eax,%eax
|
||||
je 4b
|
||||
jmp 5f
|
||||
1: xor %eax,%eax
|
||||
5: .leafepilogue
|
||||
7: vmovdqu (%rsi,%rcx),%xmm3
|
||||
vpcmpeqb (%rdi,%rcx),%xmm3,%xmm2
|
||||
vpcmpeqb %xmm0,%xmm3,%xmm3
|
||||
vpandn %xmm1,%xmm2,%xmm2
|
||||
vpor %xmm3,%xmm2,%xmm2
|
||||
vpmovmskb %xmm2,%eax
|
||||
bsf %eax,%eax
|
||||
jz 3b
|
||||
mov %eax,%edx
|
||||
add %rdx,%rdi
|
||||
movzbl (%rcx,%rdi),%eax
|
||||
add %rdx,%rsi
|
||||
movzbl (%rcx,%rsi),%ecx
|
||||
sub %ecx,%eax
|
||||
jmp 5b
|
||||
.endfn strncmp$avx,globl,hidden
|
||||
.source __FILE__
|
|
@ -1,49 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Dispatches to fastest strcmp() implementation.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated string pointer
|
||||
/ @param rsi is second non-null NUL-terminated string pointer
|
||||
/ @return rax is <0, 0, or >0 based on uint8_t comparison
|
||||
/ @asyncsignalsafe
|
||||
.initbss 300,_init_strcmp
|
||||
hook$strcmp:
|
||||
.quad 0
|
||||
.endobj hook$strcmp,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_strcmp
|
||||
#if !IsTiny()
|
||||
ezlea strcmp$avx,ax
|
||||
#if !X86_NEED(AVX)
|
||||
ezlea tinystrcmp,dx
|
||||
testb X86_HAVE(AVX)+kCpuids(%rip)
|
||||
cmovz %rdx,%rax
|
||||
#endif /* AVX */
|
||||
#else
|
||||
ezlea tinystrcmp,ax
|
||||
#endif /* TINY */
|
||||
stosq
|
||||
.init.end 300,_init_strcmp
|
||||
.source __FILE__
|
|
@ -1,31 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated strings.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated string pointer
|
||||
/ @param rsi is second non-null NUL-terminated string pointer
|
||||
/ @return rax is <0, 0, or >0 based on uint8_t comparison
|
||||
/ @note cosmopolitan headers optimize away this indirection
|
||||
/ @asyncsignalsafe
|
||||
strcmp: jmp *hook$strcmp(%rip)
|
||||
.endfn strcmp,globl
|
||||
.source __FILE__
|
|
@ -1,39 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
/ Dispatches to fastest strcmp16() implementation.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated char16_t string
|
||||
/ @param rsi is second non-null NUL-terminated char16_t string
|
||||
/ @return rax is <0, 0, or >0 based on uint16_t comparison
|
||||
/ @asyncsignalsafe
|
||||
.initbss 300,_init_strcmp16
|
||||
hook$strcmp16:
|
||||
.quad 0
|
||||
.endobj hook$strcmp16,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_strcmp16
|
||||
ezlea strcmp16$k8,ax
|
||||
stosq
|
||||
.init.end 300,_init_strcmp16
|
||||
.source __FILE__
|
|
@ -1,66 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated char16_t strings.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note char16_t is an unsigned type
|
||||
/ @asyncsignalsafe
|
||||
strcmp16$k8:
|
||||
or $-1,%rdx
|
||||
/ fallthrough
|
||||
.endfn strcmp16$k8,globl,hidden
|
||||
|
||||
/ Compares NUL-terminated char16_t strings w/ limit.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @param rdx max shorts
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note char16_t is an unsigned type
|
||||
/ @asyncsignalsafe
|
||||
strncmp16$k8:
|
||||
.leafprologue
|
||||
.profilable
|
||||
push %rbx
|
||||
xor %eax,%eax
|
||||
xor %ebx,%ebx
|
||||
xor %ecx,%ecx
|
||||
cmp %rdi,%rsi
|
||||
je 1f
|
||||
test %rdx,%rdx
|
||||
jz 1f
|
||||
0: inc %rcx
|
||||
movzwl -2(%rdi,%rcx,2),%eax
|
||||
movzwl -2(%rsi,%rcx,2),%ebx
|
||||
cmp %rcx,%rdx
|
||||
je 1f
|
||||
cmp %ebx,%eax
|
||||
jne 1f
|
||||
test %eax,%eax
|
||||
jne 0b
|
||||
1: sub %ebx,%eax
|
||||
pop %rbx
|
||||
.leafepilogue
|
||||
.endfn strncmp16$k8,globl,hidden
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated char16_t strings.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated char16_t string
|
||||
/ @param rsi is second non-null NUL-terminated char16_t string
|
||||
/ @param rdx is maximum shorts to consider
|
||||
/ @return rax is <0, 0, or >0 based on uint16_t comparison
|
||||
/ @note cosmopolitan headers optimize away this indirection
|
||||
/ @asyncsignalsafe
|
||||
strcmp16:
|
||||
jmp *hook$strcmp16(%rip)
|
||||
.endfn strcmp16,globl
|
||||
.source __FILE__
|
|
@ -1,49 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Dispatches to fastest strncmp() implementation.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated string pointer
|
||||
/ @param rsi is second non-null NUL-terminated string pointer
|
||||
/ @param rdx is maximum bytes to consider
|
||||
/ @return rax is <0, 0, or >0 based on uint8_t comparison
|
||||
.initbss 300,_init_strncmp
|
||||
hook$strncmp:
|
||||
.quad 0
|
||||
.endobj hook$strncmp,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_strncmp
|
||||
#if !IsTiny()
|
||||
ezlea strncmp$avx,ax
|
||||
#if !X86_NEED(AVX)
|
||||
ezlea tinystrncmp,dx
|
||||
testb X86_HAVE(AVX)+kCpuids(%rip)
|
||||
cmovz %rdx,%rax
|
||||
#endif /* AVX */
|
||||
#else
|
||||
ezlea tinystrncmp,ax
|
||||
#endif /* TINY */
|
||||
stosq
|
||||
.init.end 300,_init_strncmp
|
||||
.source __FILE__
|
|
@ -1,31 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated strings, with btye limit.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated string pointer
|
||||
/ @param rsi is second non-null NUL-terminated string pointer
|
||||
/ @return rax is <0, 0, or >0 based on uint8_t comparison
|
||||
/ @note cosmopolitan headers optimize away this indirection
|
||||
/ @asyncsignalsafe
|
||||
strncmp:jmp *hook$strncmp(%rip)
|
||||
.endfn strncmp,globl
|
||||
.source __FILE__
|
|
@ -1,39 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
#include "libc/notice.inc"
|
||||
|
||||
/ Dispatches to fastest strncmp16() implementation.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated char16_t string
|
||||
/ @param rsi is second non-null NUL-terminated char16_t string
|
||||
/ @param rdx is maximum shorts to consider
|
||||
/ @return rax is <0, 0, or >0 based on uint16_t comparison
|
||||
.initbss 300,_init_strncmp16
|
||||
hook$strncmp16:
|
||||
.quad 0
|
||||
.endobj hook$strncmp16,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_strncmp16
|
||||
ezlea strncmp16$k8,ax
|
||||
stosq
|
||||
.init.end 300,_init_strncmp16
|
||||
.source __FILE__
|
|
@ -1,32 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated char16_t strings w/ limit.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated char16_t string
|
||||
/ @param rsi is second non-null NUL-terminated char16_t string
|
||||
/ @param rdx is maximum shorts to consider
|
||||
/ @return rax is <0, 0, or >0 based on uint16_t comparison
|
||||
/ @note cosmopolitan headers optimize away this indirection
|
||||
strncmp16:
|
||||
jmp *hook$strncmp16(%rip)
|
||||
.endfn strncmp16,globl
|
||||
.source __FILE__
|
|
@ -1,51 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares strings w/ no-clobber greg abi.
|
||||
/
|
||||
/ @param rdi is first non-null NUL-terminated string pointer
|
||||
/ @param rsi is second non-null NUL-terminated string pointer
|
||||
/ @return rax is <0, 0, or >0 based on uint8_t comparison
|
||||
/ @clob flags only
|
||||
/ @asyncsignalsafe
|
||||
tinystrcmp:
|
||||
.leafprologue
|
||||
push %rcx
|
||||
push %rdx
|
||||
xor %eax,%eax
|
||||
xor %edx,%edx
|
||||
xor %ecx,%ecx
|
||||
cmp %rdi,%rsi
|
||||
je 1f
|
||||
0: movzbl (%rdi,%rcx,1),%eax
|
||||
movzbl (%rsi,%rcx,1),%edx
|
||||
test %al,%al
|
||||
jz 1f
|
||||
cmp %dl,%al
|
||||
jne 1f
|
||||
inc %rcx
|
||||
jmp 0b
|
||||
1: sub %edx,%eax
|
||||
pop %rdx
|
||||
pop %rcx
|
||||
.leafepilogue
|
||||
.endfn tinystrcmp,globl
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_TINYSTRCMP_H_
|
||||
#define COSMOPOLITAN_LIBC_NEXGEN32E_TINYSTRCMP_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int tinystrcmp(const char *, const char *) nothrow nocallback
|
||||
paramsnonnull() nosideeffect;
|
||||
int tinystrncmp(const char *, const char *, size_t) nothrow nocallback
|
||||
paramsnonnull() nosideeffect;
|
||||
|
||||
#define tinystrcmp(s1, s2) \
|
||||
({ \
|
||||
int Res; \
|
||||
asm("call\ttinystrcmp" \
|
||||
: "=a"(Res) \
|
||||
: "D"(&(s1)[0]), "S"(&(s2)[0]), "m"(*(s1)), "m"(*(s2)) \
|
||||
: "cc"); \
|
||||
Res; \
|
||||
})
|
||||
|
||||
#define tinystrncmp(s1, s2, n) \
|
||||
({ \
|
||||
int Res; \
|
||||
asm("call\ttinystrncmp" \
|
||||
: "=a"(Res) \
|
||||
: "D"(&(s1)[0]), "S"(&(s2)[0]), "d"(n), "m"(*(s1)), "m"(*(s2)) \
|
||||
: "cc"); \
|
||||
Res; \
|
||||
})
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_TINYSTRCMP_H_ */
|
|
@ -1,32 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
towlower:
|
||||
.leafprologue
|
||||
.profilable
|
||||
movslq %edi,%rax
|
||||
cmpl $127,%eax
|
||||
ja 1f
|
||||
ezlea kToLower,cx
|
||||
movzbl (%rcx,%rax),%eax
|
||||
1: .leafepilogue
|
||||
.endfn towlower,globl
|
||||
.source __FILE__
|
|
@ -17,7 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "ape/macros.h"
|
||||
#include "ape/macros.internal.h"
|
||||
#include "libc/nexgen32e/vidya.internal.h"
|
||||
#include "libc/notice.inc"
|
||||
.real
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated wchar_t strings, ignoring ASCII case.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note wchar_t is a 32-bit signed type
|
||||
wcscasecmp:
|
||||
or $-1,%rdx
|
||||
/ fallthrough
|
||||
.endfn wcscasecmp,globl
|
||||
|
||||
/ Compares NUL-terminated wchar_t strings w/ limit ignoring ASCII case.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @param rdx max shorts
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note wchar_t is a 32-bit signed type
|
||||
wcsncasecmp:
|
||||
.leafprologue
|
||||
.profilable
|
||||
push %rbx
|
||||
cmp %rdi,%rsi
|
||||
je 3f
|
||||
lea kToLower16(%rip),%r8
|
||||
or $-1,%rcx
|
||||
1: add $1,%rcx
|
||||
cmp %rcx,%rdx
|
||||
je 3f
|
||||
mov (%rsi,%rcx,4),%eax
|
||||
mov %eax,%ebx
|
||||
and $0x7f,%ebx
|
||||
cmp %eax,%ebx
|
||||
cmove (%r8,%rbx,2),%ax
|
||||
push %rax
|
||||
mov (%rdi,%rcx,4),%eax
|
||||
mov %eax,%ebx
|
||||
and $0x7f,%ebx
|
||||
cmp %eax,%ebx
|
||||
cmove (%r8,%rbx,2),%ax
|
||||
pop %rbx
|
||||
cmp %ebx,%eax
|
||||
jne 2f
|
||||
test %eax,%eax
|
||||
jnz 1b
|
||||
2: sub %ebx,%eax
|
||||
jmp 4f
|
||||
3: xor %eax,%eax
|
||||
4: pop %rbx
|
||||
.leafepilogue
|
||||
.endfn wcsncasecmp,globl
|
||||
|
||||
.source __FILE__
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Dispatches to fastest wcscmp() implementation.
|
||||
.initbss 300,_init_wcscmp
|
||||
hook$wcscmp:
|
||||
.quad 0
|
||||
.endobj hook$wcscmp,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_wcscmp
|
||||
ezlea wcscmp$k8,ax
|
||||
stosq
|
||||
.init.end 300,_init_wcscmp
|
||||
|
||||
.source __FILE__
|
|
@ -1,68 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
.source __FILE__
|
||||
|
||||
/ Compares NUL-terminated wchar_t strings.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note wchar_t is a 32-bit signed type
|
||||
wcscmp$k8:
|
||||
or $-1,%rdx
|
||||
/ fallthrough
|
||||
.endfn wcscmp$k8,globl
|
||||
|
||||
/ Compares NUL-terminated wchar_t strings w/ limit.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @param rdx max shorts
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note wchar_t is a 32-bit signed type
|
||||
wcsncmp$k8:
|
||||
.leafprologue
|
||||
.profilable
|
||||
push %rbx
|
||||
xor %eax,%eax
|
||||
cmp %rdi,%rsi
|
||||
je 3f
|
||||
or $-1,%rcx
|
||||
1: add $1,%rcx
|
||||
cmp %rcx,%rdx
|
||||
je 3f
|
||||
mov (%rsi,%rcx,4),%ebx
|
||||
cmp (%rdi,%rcx,4),%ebx
|
||||
jne 2f
|
||||
test %ebx,%ebx
|
||||
jnz 1b
|
||||
2: cmovl .Lone(%rip),%eax
|
||||
cmovg .Lneg1(%rip),%eax
|
||||
3: pop %rbx
|
||||
.leafepilogue
|
||||
.endfn wcsncmp$k8,globl
|
||||
|
||||
.rodata.cst4
|
||||
.Lone: .long 1
|
||||
.endobj .Lone
|
||||
.Lneg1: .long -1
|
||||
.endobj .Lneg1
|
||||
.previous
|
|
@ -1,31 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated wchar_t strings.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note wchar_t is a 32-bit signed type
|
||||
/ @note this stub is provided for abi compatibility
|
||||
wcscmp: jmp *hook$wcscmp(%rip)
|
||||
.endfn wcscmp,globl
|
||||
.source __FILE__
|
|
@ -1,33 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Dispatches to fastest wcscmp() implementation.
|
||||
.initbss 300,_init_wcsncmp
|
||||
hook$wcsncmp:
|
||||
.quad 0
|
||||
.endobj hook$wcsncmp,globl,hidden
|
||||
.previous
|
||||
|
||||
.init.start 300,_init_wcsncmp
|
||||
ezlea wcsncmp$k8,ax
|
||||
stosq
|
||||
.init.end 300,_init_wcsncmp
|
||||
.source __FILE__
|
|
@ -1,31 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Compares NUL-terminated wchar_t strings.
|
||||
/
|
||||
/ @param rdi first string
|
||||
/ @param rsi second string
|
||||
/ @return 0 if equal, etc.
|
||||
/ @note wchar_t is a 32-bit signed type
|
||||
/ @note this stub is provided for abi compatibility
|
||||
wcsncmp:jmp *hook$wcsncmp(%rip)
|
||||
.endfn wcsncmp,globl
|
||||
.source __FILE__
|
Loading…
Add table
Add a link
Reference in a new issue