Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9136 → Rev 9137

/programs/develop/ktcc/trunk/libc.obj/include/stdlib.h
43,4 → 43,6
extern void _FUNC(__assert_fail)(const char *expr, const char *file, int line, const char *func);
extern void _FUNC(qsort)(void *base0, size_t n, size_t size, int (*compar)(const void *, const void *));
 
extern double _FUNC(atof)(const char *ascii);
 
#endif
/programs/develop/ktcc/trunk/libc.obj/include/sys/ksys.h
11,11 → 11,11
* All wrappers must start with the "_ksys_" prefix.
* I consider it mandatory to place the wrappers in the correct order in the official documentation.
* Enjoy writing your code :)
 
* Warning! The end of the file is the old definitions of function/structure names.
* They are for compatibility... Better not to use them.
*/
 
// Warning! The end of the file is the old definitions of function/structure names.
// They are for compatibility... Better not to use them. */
#ifndef _KSYS_H_
#define _KSYS_H_
 
686,6 → 686,8
);
}
 
/*===================== Function 18, subfunction 21 ====================*/
/*=====Get the slot number of the process / thread by identifier.. =====*/
 
static inline
int _ksys_get_thread_slot(int PID){
962,12 → 964,13
/*==================== Function 51 - create thread. ====================*/
 
static inline
int _ksys_start_thread(void* thread_entry, void* stack_top){
int _ksys_create_thread(void* thread_entry, void* stack_top){
int val;
asm_inline(
"int $0x40"
:"=a"(val)
:"a"(51), "b"(1), "c"(thread_entry), "d"(stack_top)
:"memory"
);
return val;
}
/programs/develop/ktcc/trunk/libc.obj/samples/Makefile
21,6 → 21,7
clayer/dialog.kex \
clayer/msgbox.kex \
clayer/boxlib.kex \
thread_work.kex
 
LIBS= -ltcc -ldialog -lrasterworks -limg -lbox -lmsgbox -lnetwork -lc.obj
 
/programs/develop/ktcc/trunk/libc.obj/samples/thread_work.c
0,0 → 1,69
/*
* An example of using threads to create a copy of a window.
* Built on top of the /programs/develop/examples/thread/trunk/thread.asm example.
*
* Created by turbocat (Maxim Logaev) 2021.
*/
 
#include <sys/ksys.h>
#include <stdio.h>
#include <stdlib.h>
 
#define TH_STACK_SIZE 1024
 
enum BUTTONS{
BTN_QUIT = 1,
BTN_CREATE_TH = 2,
};
 
ksys_colors_table_t sys_colors;
 
extern int main();
 
void redraw_window(void){
ksys_pos_t mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS);
_ksys_start_draw();
_ksys_create_window(mouse_pos.x, mouse_pos.y, 140, 60, "Threads", sys_colors.work_area, 0x14);
_ksys_define_button(10, 30, 120, 20, BTN_CREATE_TH, sys_colors.work_button);
_ksys_draw_text("Create thread!", 15, 34, 0, 0x90000000 | sys_colors.work_button_text);
_ksys_end_draw();
}
 
void create_thread(void){
unsigned tid; // New thread ID
void *th_stack = malloc(TH_STACK_SIZE); // Allocate memory for thread stack
if(!th_stack){
_ksys_debug_puts("Memory allocation error for thread!");
return;
}
tid = _ksys_create_thread(main, th_stack+TH_STACK_SIZE); // Create new thread with entry "main"
if(tid==-1){
_ksys_debug_puts("Unable to create a new thread!");
return;
}
debug_printf("New thread created (TID=%u)\n", tid);
}
 
int main(){
_ksys_get_system_colors(&sys_colors);
int gui_event;
redraw_window();
while(1){
gui_event = _ksys_get_event();
switch(gui_event){
case KSYS_EVENT_REDRAW:
redraw_window();
break;
case KSYS_EVENT_BUTTON:
switch (_ksys_get_button()){
case BTN_CREATE_TH:
create_thread();
break;
case BTN_QUIT:
_ksys_exit();
}
break;
}
}
}
/programs/develop/ktcc/trunk/libc.obj/source/libc.c
100,6 → 100,7
#include "stdlib/rand.c"
#include "stdlib/qsort.c"
#include "stdlib/assert.c"
#include "stdlib/atof.c"
 
#include "math/acosh.c"
#include "math/asinh.c"
/programs/develop/ktcc/trunk/libc.obj/source/stdlib/atof.c
0,0 → 1,8
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <stdlib.h>
 
double
atof(const char *ascii)
{
return strtod(ascii, 0);
}
/programs/develop/ktcc/trunk/libc.obj/source/symbols.txt
46,6 → 46,7
atoi
atol
atoll
atof
calloc
div
exit