forked from KolibriOS/kolibrios
libc.obj: add copyright & delete _exit.h & fix tabs in crt0.asm
This commit is contained in:
@@ -55,7 +55,7 @@ start:
|
||||
mov dl, cl ; parameter starts
|
||||
cmp al, '"'
|
||||
jz @f ; quotes loaded
|
||||
mov dh, ch ; parameter without quotes
|
||||
mov dh, ch ; parameter without quotes
|
||||
dec esi
|
||||
call push_param
|
||||
inc esi
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ksys.h>
|
||||
#include "_exit.h"
|
||||
|
||||
void _exit(int status)
|
||||
{
|
||||
@@ -14,9 +13,7 @@ void __libc_exit(int status, void (*before_exit)(int status))
|
||||
if (status && status != 128) {
|
||||
fprintf(stderr, "\nexit code: %d\n", status);
|
||||
}
|
||||
|
||||
WRITE_EXIT_CODE(status);
|
||||
|
||||
|
||||
if (before_exit) {
|
||||
before_exit(status);
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#ifndef __STDLIB_EXIT_H__
|
||||
#define __STDLIB_EXIT_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/dir.h>
|
||||
#include <sys/ksys.h>
|
||||
|
||||
#define __PATH_TO_STATUS_FILE "/tmp0/1/.libc"
|
||||
#define __STATUS_FILE_EXTENSION ".status"
|
||||
#define __STATUS_FILE_FORMAT "%d"
|
||||
#define __FULL_STATUS_FILE_NAME __PATH_TO_STATUS_FILE "/%d" __STATUS_FILE_EXTENSION
|
||||
#define __FULL_STATUS_FILE_NAME_SIZE (sizeof(__PATH_TO_STATUS_FILE) + 32 + sizeof(__STATUS_FILE_EXTENSION))
|
||||
|
||||
void __libc_exit(int status, void (*before_exit)(int status));
|
||||
|
||||
// Save exit code
|
||||
inline void WRITE_EXIT_CODE(int status)
|
||||
{
|
||||
mkdir(__PATH_TO_STATUS_FILE);
|
||||
|
||||
char buff[__FULL_STATUS_FILE_NAME_SIZE];
|
||||
ksys_thread_t t;
|
||||
|
||||
_ksys_thread_info(&t, -1);
|
||||
snprintf(buff, sizeof(buff), __FULL_STATUS_FILE_NAME, t.pid);
|
||||
|
||||
FILE* f = fopen(buff, "w");
|
||||
|
||||
if (f) {
|
||||
snprintf(buff, sizeof(buff), __STATUS_FILE_FORMAT, status);
|
||||
fputs(buff, f);
|
||||
fflush(f);
|
||||
fclose(f);
|
||||
} else {
|
||||
_ksys_debug_puts("error while write status\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Read exit code
|
||||
inline int READ_EXIT_CODE(int pid, ksys_thread_t* t)
|
||||
{
|
||||
char buff[__FULL_STATUS_FILE_NAME_SIZE];
|
||||
int status = 0;
|
||||
bool free_t = false;
|
||||
|
||||
if (!t) {
|
||||
t = malloc(sizeof(ksys_thread_t));
|
||||
_ksys_thread_info(t, -1);
|
||||
free_t = true;
|
||||
}
|
||||
snprintf(buff, sizeof(buff), __FULL_STATUS_FILE_NAME, t->pid);
|
||||
|
||||
FILE* f = fopen(buff, "r");
|
||||
if (f) {
|
||||
fscanf(f, __STATUS_FILE_FORMAT, &status);
|
||||
fclose(f);
|
||||
} else if (t && t->slot_state == 4) // it was stopped before it created status file
|
||||
{
|
||||
status = -1;
|
||||
}
|
||||
|
||||
if (free_t) {
|
||||
free(t);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif // __STDLIB_EXIT_H__
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
* Copyright (C) 2026 KolibriOS team
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ksys.h>
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
* Copyright (C) 2026 KolibriOS team
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
struct atexit_n {
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/* Copyright (C) 2021 Logaev Maxim (turbocat2001), GPLv2 */
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-only
|
||||
* Copyright (C) 2021 Logaev Maxim
|
||||
* Copyright (C) 2026 KolibriOS team
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/ksys.h>
|
||||
#include "_exit.h"
|
||||
|
||||
/*
|
||||
TODO
|
||||
static void __close_all()
|
||||
{
|
||||
}
|
||||
@@ -11,6 +17,7 @@ static void __close_all()
|
||||
static void __free_all_mem()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
void __normal_exit(int status)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user