diff options
Diffstat (limited to 'zap/src/strcpy.c')
-rw-r--r-- | zap/src/strcpy.c | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/zap/src/strcpy.c b/zap/src/strcpy.c deleted file mode 100644 index 616af7f..0000000 --- a/zap/src/strcpy.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright 2022 Gabriel Jensen. - This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. - If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -*/ - -#include <zap/priv.h> - -#include <zap/mem.h> - -#include <stddef.h> - -#if zap_priv_fastimpl -__asm__ ( - ".globl zap_strcpy\n" - - "zap_strcpy:\n" - /* - char const * in - char const * out - */ -#if defined(sus_arch_amd64) - /* rax: Address of the current input character. */ - "movq %rdi,%rax\n" - /* rsi: Address of the current output character. */ - "movq %rsi,%rsi\n" - /* rdx: Current character. */ - ".loop:\n" - "movb (%rax),%dl\n" /* Move current the character into a register... */ - "movb %dl,(%rsi)\n" /* ... and then back into memory. */ - "testb %dl,%dl\n" /* Check if we have reached the null-terminator... */ - "jz .done\n" /* ... and if so, we are finished copying. */ - "incq %rax\n" /* Increment the positions. */ - "incq %rsi\n" - "jmp .loop\n" /* Restart the loop. */ - ".done:\n" - "subq %rdi,%rax\n" /* Get the length of the string we copyied. */ - "decq %rdi\n" /* We do not count the null-terminator in the string length. */ - "ret\n" -#elif defined(sus_arch_ia32) - /* eax: Address of the current input character. */ - "movl 0x4(%esp),%eax\n" - /* ecx: Address of the current output character. */ - "movl 0x8(%esp),%ecx\n" - /* edx: Current character. */ - ".loop:\n" - "movb (%eax),%dl\n" /* Move current the character into a register... */ - "movb %dl,(%ecx)\n" /* ... and then back into memory. */ - "testb %dl,%dl\n" /* Check if we have reached the null-terminator... */ - "jz .done\n" /* ... and if so, we are finished copying. */ - "incl %eax\n" /* Increment the positions. */ - "incl %ecx\n" - "jmp .loop\n" /* Restart the loop. */ - ".done:\n" - "subl 0x4(%esp),%eax\n" /* Get the length of the string we copyied. */ - "decl %ecx \n" /* We do not count the null-terminator in the string length. */ - "ret\n" -#endif -); -#else -size_t zap_strcpy(char const * const _in,char * const _out) { - char const * inpos = _in; - char * outpos = _out; - for (;;++inpos,++outpos) { - char const chr = *inpos; - *outpos = chr; - if (chr == '\x0') {return inpos - _in;} - } - sus_unreach(); -} -#endif |