libc.obj:

- Added inttypes header;
 - Fixed warnings in mouse api wrappers;
 - Preparation for build only via tcc+fasm.


git-svn-id: svn://kolibrios.org@9774 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat
2022-04-20 19:07:54 +00:00
parent eeb3d0e5b9
commit 82646d764b
12 changed files with 275 additions and 93 deletions

View File

@@ -1,8 +1,18 @@
if tup.getconfig("NO_FASM") ~= "" then return end
if tup.getconfig("NO_GCC") ~= "" then return end
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../../../../" or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_gcc.lua")
CFLAGS = " -c -nostdinc -DGNUC -D_BUILD_LIBC -Os -fno-common -fno-builtin -fno-leading-underscore -fno-pie"
CFLAGS = " -c -nostdinc -DGNUC -D_BUILD_LIBC -Os -fno-common -fno-builtin -fno-leading-underscore -fno-pie"
INCLUDES = " -I../include"
tup.rule("libc.c", "kos32-gcc" .. CFLAGS .. INCLUDES .. " -o %o %f " .. tup.getconfig("KPACK_CMD"), "libc.obj")
OBJS = {"math/tan.obj", "math/sqrt.obj"}
for _, OBJ in pairs(OBJS) do
tup.rule(string.gsub(OBJ, ".obj", ".asm"), "fasm %f %o ", OBJ)
end
tup.rule("libc.c", "kos32-gcc" .. CFLAGS .. INCLUDES .. " -o %o %f ", "libc_tmp.obj")
table.insert(OBJS, "libc_tmp.obj");
tup.rule(OBJS, "clink -o %o %f" .. " && kos32-strip %o --strip-unneeded " .. tup.getconfig("KPACK_CMD"), "libc.obj");

View File

@@ -139,9 +139,7 @@ __asm__(
".include \"math/pow2.s\"\n\t"
".include \"math/pow10.s\"\n\t"
".include \"math/round.s\"\n\t"
".include \"math/sqrt.s\"\n\t"
".include \"math/sin.s\"\n\t"
".include \"math/tan.s\"\n\t");
".include \"math/sin.s\"\n\t");
__asm__(
".include \"string/memmove.s\"\n\t"

View File

@@ -1,11 +1,10 @@
KTCC=kos32-tcc
FASM=fasm
OBJ= memcpy.o memmove.o memset.o libtcc1.o
all: $(OBJ)
ar -crs ../../../bin/lib/libtcc.a $(OBJ)
ar -crs ../../../bin/lib/libtcc1.a $(OBJ)
rm -f *.o
%.o : %.c
@@ -13,4 +12,4 @@ all: $(OBJ)
%.o : %.asm
$(FASM) $< $@

View File

@@ -6,19 +6,18 @@ include '../../../../../../proc32.inc'
public memcpy
proc memcpy c, to:dword,from:dword,count:dword
push esi
push edi
mov ecx,[count]
test ecx,ecx
jz no_copy_block
mov esi,[from]
mov edi,[to]
cld
rep movsb
no_copy_block:
pop edi
pop esi
mov eax, [to]
ret
endp
push esi
push edi
mov ecx, [count]
test ecx, ecx
jz .no_copy_block
mov esi, [from]
mov edi, [to]
cld
rep movsb
.no_copy_block:
pop edi
pop esi
mov eax, [to]
ret
endp

View File

@@ -6,29 +6,27 @@ include '../../../../../../proc32.inc'
public memmove
proc memmove c, to:dword,from:dword,count:dword
push esi
push edi
mov ecx,[count]
test ecx,ecx
jz no_copy_block_
mov esi,[from]
mov edi,[to]
cmp esi, edi
je no_copy_block_
jg copy_
add esi, ecx
add edi, ecx
dec esi
dec edi
std
copy_:
rep movsb
cld
no_copy_block_:
pop edi
pop esi
mov eax,[to]
ret
push esi
push edi
mov ecx,[count]
test ecx,ecx
jz .no_copy_block
mov esi,[from]
mov edi,[to]
cmp esi, edi
je .no_copy_block
jg .copy
add esi, ecx
add edi, ecx
dec esi
dec edi
std
.copy:
rep movsb
cld
.no_copy_block:
pop edi
pop esi
mov eax,[to]
ret
endp

View File

@@ -3,14 +3,14 @@ section '.text' executable
public memset
memset:
push edi
mov edi,[esp+8]
mov eax,[esp+12]
mov ecx,[esp+16]
jecxz .no_set
cld
rep stosb
push edi
mov edi, [esp+8]
mov eax, [esp+12]
mov ecx, [esp+16]
jecxz .no_set
cld
rep stosb
.no_set:
mov eax, [esp+8]
pop edi
ret
mov eax, [esp+8]
pop edi
ret

View File

@@ -0,0 +1,9 @@
format COFF
section '.text'
public _sqrt as "sqrt"
_sqrt:
fld qword[esp+4]
fsqrt
ret

View File

@@ -1,8 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
.global sqrt;
sqrt:
fldl 4(%esp)
fsqrt
ret

View File

@@ -1,16 +0,0 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
tan.L0:
.quad 0xffffffffffffffff
tan:
fldl 4(%esp)
fptan
fstsw
fstp %st(0)
sahf
jnp tan.L1
/* fstp %st(0) - if exception, there is nothing on the stack */
fldl tan.L0
tan.L1:
ret