lib: Completely drop neatlibc

It's of no use anymore, we have our own libc.

Signed-off-by: Ivaylo Ivanov <ivo.ivanov.ivanov1@gmail.com>
This commit is contained in:
Ivaylo Ivanov 2024-10-10 16:38:42 +03:00
parent 3b517ba95a
commit a244bad67f
10 changed files with 0 additions and 1014 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "lib/neatlibc"]
path = lib/neatlibc
url = https://github.com/aligrudi/neatlibc.git

@ -1 +0,0 @@
Subproject commit d111f5115422bd527cb0034a0a697fd487e98e2d

View File

@ -1,20 +0,0 @@
.global htonl
.global ntohl
ntohl:
htonl:
eor x1, x0, x0, ror #16
bic x1, x1, #0x00ff0000
mov x0, x0, ror #8
eor x0, x0, x1, lsr #8
ret
.global htons
.global ntohs
ntohs:
htons:
mov x1, x0, lsr #8
and x0, x0, #255
and x1, x1, #255
mov x0, x0, lsl #8
orr x0, x0, x1
ret

View File

@ -1,26 +0,0 @@
.global __memcpylong
__memcpylong:
mov x12, x0 // Save the base address in x12
memcpylong_loop:
subs x2, x2, #4 // Decrement the counter (in bytes)
bmi memcpylong_ret // If the counter is negative, exit
ldr w3, [x1], #4 // Load 4 bytes from address in x1 into w3 and increment x1
str w3, [x0], #4 // Store 4 bytes from w3 to address in x0 and increment x0
b memcpylong_loop // Repeat the loop
memcpylong_ret:
mov x0, x12 // Restore the original base address
ret // Return from function
.global __memsetlong
__memsetlong:
mov x12, x0 // Save the base address in x12
memsetlong_loop:
subs x2, x2, #4 // Decrement the counter (in bytes)
bmi memsetlong_ret // If the counter is negative, exit
str w1, [x0], #4 // Store 4 bytes of the value in w1 to address in x0 and increment x0
b memsetlong_loop // Repeat the loop
memsetlong_ret:
mov x0, x12 // Restore the original base address
ret // Return from function

View File

@ -1,167 +0,0 @@
.global memcpy
memcpy:
mov x12, x0
memcpy_loop:
subs x2, x2, #1
bmi memcpy_ret
ldrb w3, [x1], #1
strb w3, [x0], #1
b memcpy_loop
memcpy_ret:
mov x0, x12
ret
.global memset
memset:
mov x12, x0
memset_loop:
subs x2, x2, #1
bmi memset_ret
strb w1, [x0], #1
b memset_loop
memset_ret:
mov x0, x12
ret
.global memmove
memmove:
mov x12, x0
cmp x0, x1
ble memmove_fw
add x3, x1, x2
cmp x0, x3
bgt memmove_fw
// copying the memory in reverse order
add x0, x0, x2
add x1, x1, x2
memmove_bw:
subs x2, x2, #1
bmi memmove_ret
ldrb w3, [x1, #-1]!
strb w3, [x0, #-1]!
b memmove_bw
memmove_fw:
subs x2, x2, #1
bmi memmove_ret
ldrb w3, [x1], #1
strb w3, [x0], #1
b memmove_fw
memmove_ret:
mov x0, x12
ret
.global memchr
memchr:
subs x2, x2, #1
bmi memchr_failed
ldrb w3, [x0], #1
cmp w3, w1
bne memchr
sub x0, x0, #1
b memchr_ret
memchr_failed:
mov x0, #0
memchr_ret:
ret
.global memrchr
memrchr:
mov x12, #0
memrchr_loop:
subs x2, x2, #1
bmi memrchr_ret
ldrb w3, [x0], #1
cmp w3, w1
cset x12, eq
b memrchr_loop
memrchr_ret:
mov x0, x12
ret
.global memcmp
memcmp:
subs x2, x2, #1
bmi memcmp_match
ldrb w3, [x0], #1
ldrb w12, [x1], #1
subs w3, w3, w12
cset x0, ne
bne memcmp_ret
b memcmp
memcmp_match:
mov x0, #0
memcmp_ret:
ret
.global strlen
strlen:
mov x2, x0
strlen_loop:
ldrb w1, [x0], #1
tst w1, w1
bne strlen_loop
sub x0, x0, x2
sub x0, x0, #1
ret
.global strchr
strchr:
ldrb w2, [x0], #1
cmp w1, w2
sub x0, x0, #1
beq strchr_ret
tst w2, w2
bne strchr
mov x0, #0
strchr_ret:
ret
.global strrchr
strrchr:
mov x3, #0
strrchr_loop:
ldrb w2, [x0], #1
cmp w1, w2
cset x3, eq
tst w2, w2
bne strrchr_loop
strrchr_ret:
mov x0, x3
ret
.global strcmp
strcmp:
ldrb w2, [x0], #1
ldrb w3, [x1], #1
cmp w2, w3
beq strcmp
sub x0, x2, x3
ret
.global strcpy
strcpy:
mov x3, x0
strcpy_loop:
ldrb w2, [x1], #1
strb w2, [x0], #1
tst w2, w2
bne strcpy_loop
mov x0, x3
ret
.global strncmp
strncmp:
mov x12, x2
strncmp_loop:
subs x12, x12, #1
cset x0, mi
bmi strncmp_ret
ldrb w2, [x0], #1
ldrb w3, [x1], #1
cmp w2, w3
beq strncmp_loop
sub x0, x2, x3
strncmp_ret:
ret

View File

@ -1,294 +0,0 @@
__syscall:
stp x4, x5, [sp, #-16]!
stp x7, lr, [sp, #-16]!
ldr x4, [sp, #32]
ldr x5, [sp, #40]
mov x7, x12
svc #0
cmn x0, #4096
csneg x2, x0, x0, cs
ldr x3, =errno
cset x0, cs
str x2, [x3], cs
ldp x4, x5, [sp], #16
ldp x7, lr, [sp], #16
ret
.extern errno
.global _exit
_exit:
mov x12, #1
b __syscall
.global fork
fork:
mov x12, #2
b __syscall
.global read
read:
mov x12, #3
b __syscall
.global write
write:
mov x12, #4
b __syscall
.global open
open:
mov x12, #5
b __syscall
.global close
close:
mov x12, #6
b __syscall
.global waitpid
waitpid:
mov x12, #7
b __syscall
.global creat
creat:
mov x12, #8
b __syscall
.global link
link:
mov x12, #9
b __syscall
.global unlink
unlink:
mov x12, #10
b __syscall
.global execve
execve:
mov x12, #11
b __syscall
.global chdir
chdir:
mov x12, #12
b __syscall
.global time
time:
mov x12, #13
b __syscall
.global mknod
mknod:
mov x12, #14
b __syscall
.global chmod
chmod:
mov x12, #15
b __syscall
.global lseek
lseek:
mov x12, #19
b __syscall
.global getpid
getpid:
mov x12, #20
b __syscall
.global mount
mount:
mov x12, #21
b __syscall
.global umount
umount:
mov x12, #22
b __syscall
.global setuid
setuid:
mov x12, #23
b __syscall
.global getuid
getuid:
mov x12, #24
b __syscall
.global access
access:
mov x12, #33
b __syscall
.global sync
sync:
mov x12, #36
b __syscall
.global kill
kill:
mov x12, #37
b __syscall
.global mkdir
mkdir:
mov x12, #39
b __syscall
.global rmdir
rmdir:
mov x12, #40
b __syscall
.global dup
dup:
mov x12, #41
b __syscall
.global pipe
pipe:
mov x12, #42
b __syscall
.global brk
brk:
mov x12, #45
b __syscall
.global setgid
setgid:
mov x12, #46
b __syscall
.global getgid
getgid:
mov x12, #47
b __syscall
.global geteuid
geteuid:
mov x12, #49
b __syscall
.global getegid
getegid:
mov x12, #50
b __syscall
.global ioctl
ioctl:
mov x12, #54
b __syscall
.global fcntl
fcntl:
mov x12, #55
b __syscall
.global dup2
dup2:
mov x12, #63
b __syscall
.global getppid
getppid:
mov x12, #64
b __syscall
.global setsid
setsid:
mov x12, #66
b __syscall
.global sigaction
sigaction:
mov x12, #67
b __syscall
.global gettimeofday
gettimeofday:
mov x12, #78
b __syscall
.global settimeofday
settimeofday:
mov x12, #79
b __syscall
.global mmap
mmap:
mov x12, #192
b __syscall
.global munmap
munmap:
mov x12, #91
b __syscall
.global stat
stat:
mov x12, #106
b __syscall
.global lstat
lstat:
mov x12, #107
b __syscall
.global fstat
fstat:
mov x12, #108
b __syscall
.global sigreturn
sigreturn:
mov x12, #119
b __syscall
.global clone
clone:
mov x12, #120
b __syscall
.global uname
uname:
mov x12, #122
b __syscall
.global fchdir
fchdir:
mov x12, #133
b __syscall
.global getdents
getdents:
mov x12, #141
b __syscall
.global nanosleep
nanosleep:
mov x12, #162
b __syscall
.global poll
poll:
mov x12, #168
b __syscall
.global chown
chown:
mov x12, #182
b __syscall
.global getcwd
getcwd:
mov x12, #183
b __syscall

View File

@ -1,21 +0,0 @@
.global htonl
.global ntohl
ntohl:
htonl:
eor r1, r0, r0, ror #16
bic r1, r1, #0x00ff0000
mov r0, r0, ror #8
eor r0, r0, r1, lsr #8
mov pc, lr
.global htons
.global ntohs
ntohs:
htons:
mov r1, r0, lsr #8
and r0, r0, #255
and r1, r1, #255
mov r0, r0, lsl #8
orr r0, r0, r1
mov pc, lr

View File

@ -1,25 +0,0 @@
.global __memcpylong
__memcpylong:
mov r12, r0 @ Save the base address in r12
memcpylong_loop:
subs r2, r2, #4 @ Decrement the counter (in bytes)
bmi memcpylong_ret @ If the counter is negative, exit
ldr r3, [r1], #4 @ Load 4 bytes from address in r1 into r3 and increment r1
str r3, [r0], #4 @ Store 4 bytes from r3 to address in r0 and increment r0
b memcpylong_loop @ Repeat the loop
memcpylong_ret:
mov r0, r12 @ Restore the original base address
mov pc, lr @ Return from function
.global __memsetlong
__memsetlong:
mov r12, r0 @ Save the base address in r12
memsetlong_loop:
subs r2, r2, #4 @ Decrement the counter (in bytes)
bmi memsetlong_ret @ If the counter is negative, exit
str r1, [r0], #4 @ Store 4 bytes of the value in r1 to address in r0 and increment r0
b memsetlong_loop @ Repeat the loop
memsetlong_ret:
mov r0, r12 @ Restore the original base address
mov pc, lr @ Return from function

View File

@ -1,166 +0,0 @@
.global memcpy
memcpy:
mov r12, r0
memcpy_loop:
subs r2, r2, #1
bmi memcpy_ret
ldrb r3, [r1], #1
strb r3, [r0], #1
b memcpy_loop
memcpy_ret:
mov r0, r12
mov pc, lr
.global memset
memset:
mov r12, r0
memset_loop:
subs r2, r2, #1
bmi memset_ret
strb r1, [r0], #1
b memset_loop
memset_ret:
mov r0, r12
mov pc, lr
.global memmove
memmove:
mov r12, r0
cmp r0, r1
ble memmove_fw
add r3, r1, r2
cmp r0, r3
bgt memmove_fw
@ copying the memory in reverse order
add r0, r0, r2
add r1, r1, r2
memmove_bw:
subs r2, r2, #1
bmi memmove_ret
ldrb r3, [r1, #-1]!
strb r3, [r0, #-1]!
b memmove_bw
memmove_fw:
subs r2, r2, #1
bmi memmove_ret
ldrb r3, [r1], #1
strb r3, [r0], #1
b memmove_fw
memmove_ret:
mov r0, r12
mov pc, lr
.global memchr
memchr:
subs r2, r2, #1
bmi memchr_failed
ldrb r3, [r0], #1
cmp r3, r1
bne memchr
sub r0, r0, #1
b memchr_ret
memchr_failed:
mov r0, #0
memchr_ret:
mov pc, lr
.global memrchr
memrchr:
mov r12, #0
memrchr_loop:
subs r2, r2, #1
bmi memrchr_ret
ldrb r3, [r0], #1
cmp r3, r1
subeq r12, r0, #1
b memrchr_loop
memrchr_ret:
mov r0, r12
mov pc, lr
.global memcmp
memcmp:
subs r2, r2, #1
bmi memcmp_match
ldrb r3, [r0], #1
ldrb r12, [r1], #1
subs r3, r3, r12
movne r0, r3
bne memcmp_ret
b memcmp
memcmp_match:
mov r0, #0
memcmp_ret:
mov pc, lr
.global strlen
strlen:
mov r2, r0
strlen_loop:
ldrb r1, [r0], #1
tst r1, r1
bne strlen_loop
sub r0, r0, r2
sub r0, r0, #1
mov pc, lr
.global strchr
strchr:
ldrb r2, [r0], #1
cmp r1, r2
subeq r0, r0, #1
beq strchr_ret
tst r2, r2
bne strchr
mov r0, #0
strchr_ret:
mov pc, lr
.global strrchr
strrchr:
mov r3, #0
strrchr_loop:
ldrb r2, [r0], #1
cmp r1, r2
subeq r3, r0, #1
tst r2, r2
bne strrchr_loop
strrchr_ret:
mov r0, r3
mov pc, lr
.global strcmp
strcmp:
ldrb r2, [r0], #1
ldrb r3, [r1], #1
cmp r2, r3
beq strcmp
sub r0, r2, r3
mov pc, lr
.global strcpy
strcpy:
mov r3, r0
strcpy_loop:
ldrb r2, [r1], #1
strb r2, [r0], #1
tst r2, r2
bne strcpy_loop
mov r0, r3
mov pc, lr
.global strncmp
strncmp:
mov r12, r2
strncmp_loop:
subs r12, r12, #1
movmi r0, #0
bmi strncmp_ret
ldrb r2, [r0], #1
ldrb r3, [r1], #1
cmp r2, r3
beq strncmp_loop
sub r0, r2, r3
strncmp_ret:
mov pc, lr

View File

@ -1,291 +0,0 @@
__syscall:
stmfd sp!, {r4, r5, r7, lr}
ldr r4, [sp, #16]
ldr r5, [sp, #20]
mov r7, r12
swi #0
cmn r0, #4096
rsbcs r2, r0, #0
ldrcs r3, =errno
mvncs r0, #0
strcs r2, [r3]
ldmfd sp!, {r4, r5, r7, pc}
.extern errno
.global _exit
_exit:
mov r12, #1
b __syscall
.global fork
fork:
mov r12, #2
b __syscall
.global read
read:
mov r12, #3
b __syscall
.global write
write:
mov r12, #4
b __syscall
.global open
open:
mov r12, #5
b __syscall
.global close
close:
mov r12, #6
b __syscall
.global waitpid
waitpid:
mov r12, #7
b __syscall
.global creat
creat:
mov r12, #8
b __syscall
.global link
link:
mov r12, #9
b __syscall
.global unlink
unlink:
mov r12, #10
b __syscall
.global execve
execve:
mov r12, #11
b __syscall
.global chdir
chdir:
mov r12, #12
b __syscall
.global time
time:
mov r12, #13
b __syscall
.global mknod
mknod:
mov r12, #14
b __syscall
.global chmod
chmod:
mov r12, #15
b __syscall
.global lseek
lseek:
mov r12, #19
b __syscall
.global getpid
getpid:
mov r12, #20
b __syscall
.global mount
mount:
mov r12, #21
b __syscall
.global umount
umount:
mov r12, #22
b __syscall
.global setuid
setuid:
mov r12, #23
b __syscall
.global getuid
getuid:
mov r12, #24
b __syscall
.global access
access:
mov r12, #33
b __syscall
.global sync
sync:
mov r12, #36
b __syscall
.global kill
kill:
mov r12, #37
b __syscall
.global mkdir
mkdir:
mov r12, #39
b __syscall
.global rmdir
rmdir:
mov r12, #40
b __syscall
.global dup
dup:
mov r12, #41
b __syscall
.global pipe
pipe:
mov r12, #42
b __syscall
.global brk
brk:
mov r12, #45
b __syscall
.global setgid
setgid:
mov r12, #46
b __syscall
.global getgid
getgid:
mov r12, #47
b __syscall
.global geteuid
geteuid:
mov r12, #49
b __syscall
.global getegid
getegid:
mov r12, #50
b __syscall
.global ioctl
ioctl:
mov r12, #54
b __syscall
.global fcntl
fcntl:
mov r12, #55
b __syscall
.global dup2
dup2:
mov r12, #63
b __syscall
.global getppid
getppid:
mov r12, #64
b __syscall
.global setsid
setsid:
mov r12, #66
b __syscall
.global sigaction
sigaction:
mov r12, #67
b __syscall
.global gettimeofday
gettimeofday:
mov r12, #78
b __syscall
.global settimeofday
settimeofday:
mov r12, #79
b __syscall
.global mmap
mmap:
mov r12, #192
b __syscall
.global munmap
munmap:
mov r12, #91
b __syscall
.global stat
stat:
mov r12, #106
b __syscall
.global lstat
lstat:
mov r12, #107
b __syscall
.global fstat
fstat:
mov r12, #108
b __syscall
.global sigreturn
sigreturn:
mov r12, #119
b __syscall
.global clone
clone:
mov r12, #120
b __syscall
.global uname
uname:
mov r12, #122
b __syscall
.global fchdir
fchdir:
mov r12, #133
b __syscall
.global getdents
getdents:
mov r12, #141
b __syscall
.global nanosleep
nanosleep:
mov r12, #162
b __syscall
.global poll
poll:
mov r12, #168
b __syscall
.global chown
chown:
mov r12, #182
b __syscall
.global getcwd
getcwd:
mov r12, #183
b __syscall