libc.obj: add new and update functions
#311
2 Participants
Notifications
Due Date
No due date set.
Blocks
#3 obj версия для 5.3
Lua/Lua
#4 obj версия для 5.4
Lua/Lua
#5 obj версия для 5.2
Lua/Lua
#6 obj версия для 5.1
Lua/Lua
Reference: KolibriOS/kolibrios#311
Reference in New Issue
Block a user
Delete Branch "Egor00f/kolibrios:update-libc.obj"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Changes
functions changes
malloc/free/reallocexitfrees all memory allocated through malloc.New functions:
abortatexitsystemstrtok_rOther additions
EXIT_SUCCESSandEXIT_FAILUREexitaftermainmainexit code in/tmp0/1/.libc/pid.statusstrpbrkto EXPORTSvoid abort(),int atexit( void (*func)(void) ), EXIT_ SUCCESS/FAILUREmalloc/calloc/realloc/free&& update build scripts 9a559fdae4exitaftermain&& add build forctr0.o&& usereturninsteadexitin samplesWIP: update `libc.obj`to WIP: `libc.obj`: update allocator and `exit`WIP: `libc.obj`: update allocator and `exit`to `libc.obj`: update allocator and `exit``libc.obj`: update allocator and `exit`to WIP: `libc.obj`: update allocator and `exit`systemWIP: `libc.obj`: update allocator and `exit`to `libc.obj`: update allocator and `exit`@@ -43,0 +60,4 @@tup.rule(CRT0_ASM_SRC, "fasm %f %o", "%B.obj")tup.rule(CRT_C_SRC, CC .. " -c -nostdinc -nostdlib" .. " -I../include" .. " %f -o %o", "%B.o")tup.rule({ "crt0.obj", "crt_exit.o" }, "ld -r %f -o %o -m elf_i386", "crt0.o")Why did you decide to use GNU LD instead of tcc?
@@ -14,6 +14,7 @@ public startpublic start as '_start'If you decide to change the file encoding, I also suggest translating it into English. Otherwise, return it as it was.
@@ -89,6 +89,8 @@#include "stdlib/atol.c"#include "stdlib/atoll.c"#include "stdlib/calloc.c"#include "stdlib/atexit.c" // должно быть до exit.cPlease comments in English
@@ -0,0 +43,4 @@char* cmd;char* args;int ret = _ksys_exec(cmd, args);C99:
If string is a null pointer, the system function determines whether the host environment has a command processor. If string is not a null pointer, the system function passes the string pointed to by string to that command processor to be executed in a manner which the implementation shall document; this might then cause the program calling system to behave in a non-conforming manner or to terminate.
If the argument is a null pointer, the system function returns nonzero only if a command processor is available. If the argument is not a null pointer, and the system function does return, it returns an implementation-defined value.
system()implies execution through the command processor and not directly. In the case of GNU Linux this is/bin/sh. In the case of KolibriOS this isSHELL. In fact, I don’t think that this is of any benefit for native applications. It's just cluttering the code. Don't forgetlibc.objis on the floppy diskI want to add Lua assembly using TCC. It uses
libc.obj. I think it would be better to add it to libc and make it a built-insystemin Lua.If in about
os.execute()then there isshell-commandas an argument. In any case, this is not a native application and you can insert this code into the Lua itself if you need it.You also have the option to implement this according to the C99 standard via the SHELL call.
Yes i can. Would i'll do it? Maybe...
Ok i think i too stupid for this
If you implemented the allocator yourself, I respect you. If you took it from somewhere, it’s better to keep the copyrights. In any case, it would be nice to add at least basic tests for malloc.
@@ -91,2 +90,2 @@int 0x40dd -1push eaxcall crt_exitTry
call [exit]SHELLinsystem&& direct callexitincrt0.asm169b4642efcrt0.asm@@ -0,0 +4,4 @@int system(const char* command){if (command == NULL || *command == '\0')You did it almost right. You only need to check if
/sys/shellis present when the argument isNULL. If/sys/shellexists on thesystem(NULL), return 1.@@ -2,2 +3,3 @@endCFLAGS = " -r -nostdinc -nostdlib -DGNUC -D_BUILD_LIBC "function AddPrefix(prefix, t)What is this for?
@@ -0,0 +6,4 @@{ksys_thread_t t;_ksys_thread_info(&t, -1);printf("\nAbort in %d\n", t.pid);Better:
fprintf(stderr, ...`libc.obj`: update allocator and `exit`to WIP: `libc.obj`: update allocator and `exit`strtok_ssystemeacda328beshellhave page fault onmkdir, becausestrtokis wrong.fixed
strtok&& update change path to exit codeWIP: `libc.obj`: update allocator and `exit`to WIP: `libc.obj`: add new and update functionsWIP: `libc.obj`: add new and update functionsto `libc.obj`: add new and update functions@Egor00f Please stop randomly adding features to your PR that you want to do! I can't review that much code. Otherwise I will close it and you will be forced to divide it into smaller parts.
@@ -0,0 +1,296 @@#include <stdlib.h>English please for messages and comments
@@ -0,0 +10,4 @@if (func()) { \printf("[SUCCESS]\tTest %s is ok.\n\n", #func); \} else { \printf("[FAIL]\tTest %s failed.\n\n", #func); \Please use
fprintf(stderr ...)for errors@@ -0,0 +136,4 @@unsigned char *byte_ptr = (unsigned char *)ptr;for (size_t i = 0; i < size; ++i) {if (byte_ptr[i] != pattern) {fprintf(stderr, "Ошибка: Байт %zu не соответствует паттерну. Ожидалось %02X, получено %02X\n",English please
@@ -0,0 +157,4 @@int *new_ptr = (int *)realloc(ptr, new_size * sizeof(int));if (new_ptr == NULL) {free(ptr); // Оригинальный блок все еще действителенEnglish please
@@ -0,0 +161,4 @@return false;}// Проверяем, что старые данные сохранилисьEnglish please
@@ -0,0 +167,4 @@return false;}// Проверяем, что новый участок доступен для записиEnglish please
@@ -0,0 +220,4 @@return false;}// Проверяем, что данные сохранилисьEnglish please
@@ -0,0 +36,4 @@// wait of end of shellksys_thread_t t;while (_ksys_thread_info(&t, pid) != -1 && t.slot_state != 3 && t.slot_state != 4 && t.slot_state != 9) {It was enough for you to check the existence of the binary file. Why are you using these redundant checks?
Pull request closed