1/*
2 * Support Functions
3 */
4
5#include <errno.h>
6#include <machine/asm.h>
7
8.text
9
10// copy_unsafe(to, from, len)
11FUNC_BEGIN(copy_unsafe)
12    movq %rdx, %rcx
13    rep movsb
14.globl copy_unsafe_done
15copy_unsafe_done:
16    xorq %rax, %rax
17    retq
18.globl copy_unsafe_fault
19copy_unsafe_fault:
20    movq $EFAULT, %rax
21    retq
22FUNC_END(copy_unsafe)
23
24// copystr_unsafe(to, from, len)
25FUNC_BEGIN(copystr_unsafe)
26    movq %rdx, %rcx
271:
28    decq %rcx
29    jz copystr_unsafe_toolong
30    lodsb
31    stosb
32    orb %al, %al
33    jnz 1b
34.globl copystr_unsafe_done
35copystr_unsafe_done:
36    xorq %rax, %rax
37    retq
38.globl copystr_unsafe_fault
39copystr_unsafe_fault:
40    movq $EFAULT, %rax
41    retq
42.globl copystr_unsafe_toolong
43    copystr_unsafe_toolong:
44    movq $ENAMETOOLONG, %rax
45    retq
46FUNC_END(copystr_unsafe)
47
48