TCC: join two dirs into one

git-svn-id: svn://kolibrios.org@7849 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2020-04-30 09:59:56 +00:00
parent 60c6638d09
commit b364fe71e3
31 changed files with 5 additions and 3379 deletions

View File

@ -170,10 +170,11 @@ extra_files = {
{"kolibrios/develop/oberon07/Lib/KolibriOS/", PROGS .. "/develop/oberon07/Lib/KolibriOS/*"},
{"kolibrios/develop/oberon07/Samples/", PROGS .. "/develop/oberon07/Samples/*"},
{"kolibrios/develop/c--/", PROGS .. "/cmm/c--/*"},
{"kolibrios/develop/tcc/", "common/develop/tcc/*"},
{"kolibrios/develop/tcc/include/", "common/develop/tcc/include/*"},
{"kolibrios/develop/tcc/lib/", "common/develop/tcc/lib/*"},
{"kolibrios/develop/tcc/samples/", "common/develop/tcc/samples/*"},
{"kolibrios/develop/tcc/", PROGS .. "/develop/ktcc/trunk/*"},
{"kolibrios/develop/tcc/", PROGS .. "/develop/ktcc/trunk/bin/*"},
{"kolibrios/develop/tcc/lib/", PROGS .. "/develop/ktcc/trunk/bin/lib/*"},
{"kolibrios/develop/tcc/include/", PROGS .. "/develop/ktcc/trunk/libc/include/*"},
{"kolibrios/develop/tcc/samples/", PROGS .. "/develop/ktcc/trunk/samples/*"},
{"kolibrios/develop/TinyBasic/", "common/develop/TinyBasic/*"},
{"kolibrios/utils/cnc_editor/cnc_editor", PROGS .. "/other/cnc_editor/cnc_editor"},
{"kolibrios/utils/cnc_editor/kolibri.NC", PROGS .. "/other/cnc_editor/kolibri.NC"},

View File

@ -1,19 +0,0 @@
#ifndef __ASSERT_H
#define __ASSERT_H
#ifdef NDEBUG
# define assert(a) (void)0
#else
# define assert(a) ((a) ? (void)0 : __assert_func (__FILE__, __LINE__, #a))
#endif
#ifdef NDEBUG
# define TRACE(s) void(0)
#else
# define TRACE(s) (__trace_func (__FILE__, __LINE__, #s))
#endif
void __assert_func(char*,int,char*);
void __trace_func(char*,int,char*);
#endif

View File

@ -1,203 +0,0 @@
/*
This is adapded thunk for console.obj sys library
.h is equal to svn:\programs\develop\libraries\console\console_en.txt
Adapted for tcc by Siemargl, 2016
*/
#ifndef __conio_h
#define __conio_h
#define cdecl __attribute__ ((cdecl))
#define stdcall __attribute__ ((stdcall))
/*
console.obj exports the following functions
*/
typedef unsigned int dword; /* 32-bit unsigned integer */
typedef unsigned short word; /* 16-bit unsigned integer */
extern void stdcall (*con_init)(dword wnd_width, dword wnd_height,
dword scr_width, dword scr_height, const char* title);
/* Console initialization. Must be called only once.
wnd_width, wnd_height - width and height (in units of characters) of the visible
region;
scr_width, scr_height - width and height (in units of characters) of console;
Any of these four parameters can be set to -1 (=0xFFFFFFFF)
to use the library's default values;
title - console window's caption. */
extern void stdcall (*con_exit)(int bCloseWindow);
/* You should call this funstion at the end of the program.
If bCloseWindow is zero, the string "[Finished]" will be added to the caption of
the window and the console window will remain on the screen until the user
closes it. */
extern void stdcall (*con_set_title)(const char* title);
/* Set new window caption. */
extern void stdcall (*con_write_asciiz)(const char* str);
/* Display ASCIIZ-string to the console at the current position, shifting
the current position. */
extern void stdcall (*con_write_string)(const char* str, dword length);
/* Similar to con_write_asciiz, but length of the string must be given as a
separate parameter */
extern int cdecl (*con_printf)(const char* format, ...);
/* Standard "printf" function from ANSI C. */
extern dword stdcall (*con_get_flags)(void);
/* Get output flags. */
extern dword stdcall (*con_set_flags)(dword new_flags);
/* Set output flags. This function returns previous values. */
/* Flags (bitmask): */
/* text color */
#define CON_COLOR_BLUE 0x01
#define CON_COLOR_GREEN 0x02
#define CON_COLOR_RED 0x04
#define CON_COLOR_BRIGHT 0x08
/* background color */
#define CON_BGR_BLUE 0x10
#define CON_BGR_GREEN 0x20
#define CON_BGR_RED 0x40
#define CON_BGR_BRIGHT 0x80
/* output controls */
#define CON_IGNORE_SPECIALS 0x100
/* if this flag is cleared, function interprets special characters:
10 ('\n') - next line
13 ('\r') - carriage return
8 ('\b') - backspace
9 ('\t') - tab
27 ('\033' = '\x1B') - the beginning of Esc-sequences;
otherwise, these characters will be displayed like ordinary characters. */
/* Supported Esc-sequences:
Esc[<number1>;<number2>;<number3>m - choice of character attributes:
You can specify one, two or three codes in any order;
0 = normal mode (white on black)
1 = bright selection
5 = bright background
7 = inverse mode (black on white)
30 = black characters
31 = red characters
32 = green characters
33 = brown characters
34 = blue characters
35 = purple characters
36 = turqoise characters
37 = white characters
40 = black background
41 = red background
42 = green background
43 = brown background
44 = blue background
45 = purple background
46 = turqoise background
47 = white background
The following sequences appeared in version 5 of library:
Esc[2J - clear screen, move cursor to upper left corner
Esc[<number1>;<number2>H = Esc[<number1>;<number2>f -
move cursor to <number1>,<number2>
Esc[<number>A - move cursor to <number> lines up
Esc[<number>B - move cursor to <number> lines down
Esc[<number>C - move cursor to <number> positions right
Esc[<number>D - move cursor to <number> positions left
*/
/* signal "console closed"; appeared in version 6;
ignored by con_set_flags */
#define CON_WINDOW_CLOSED 0x200
/* The default value for flags = 7. (grey text on black background) */
extern int stdcall (*con_get_font_height)(void);
/* Get the height of the font. */
extern int stdcall (*con_get_cursor_height)(void);
/* Get the height of the cursor. */
extern int stdcall (*con_set_cursor_height)(int new_height);
/* Set the height of the cursor. This function returns previous value.
An attempt to set the value out of the correct interval (from 0 to
font_height-1) is ignored.
Cursor with zero height isn't displayed.
Default value: - 15% from font height. */
extern int stdcall (*con_getch)(void);
/* Get one character from the keyboard.
For normal characters function returns ASCII-code. For extended
characters (eg, Fx, and arrows), first function call returns 0
and second call returns the extended code (similar to the DOS-function
input). Starting from version 7, after closing the console window,
this function returns 0. */
extern word stdcall (*con_getch2)(void);
/* Reads a character from the keyboard. Low byte contains the ASCII-code
(0 for extended characters), high byte - advanced code (like in BIOS
input functions). Starting from version 7, after closing the console
window, this function returns 0. */
extern int stdcall (*con_kbhit)(void);
/* Returns 1 if a key was pressed, 0 otherwise. To read pressed keys use
con_getch and con_getch2. Starting from version 6, after closing
the console window, this function returns 1. */
extern char* stdcall (*con_gets)(char* str, int n);
/* Reads a string from the keyboard. Reading is interrupted when got
"new line" character, or after reading the (n-1) characters (depending on
what comes first). In the first case the newline is also recorded in the
str. The acquired line is complemented by a null character.
Starting from version 6, the function returns a pointer to the entered
line if reading was successful, and NULL if the console window was closed. */
typedef int (stdcall * con_gets2_callback)(int keycode, char** pstr, int* pn,
int* ppos);
extern char* stdcall (*con_gets2)(con_gets2_callback callback, char* str, int n);
/* Con_gets completely analogous, except that when the user
press unrecognized key, it calls the specified callback-procedure
(which may, for example, handle up / down for history and tab to enter
autocompletion). You should pass to the procedure: key code and three pointers
- to the string, to the maximum length and to the current position.
function may change the contents of string and may change the string
itself (for example, to reallocate memory for increase the limit),
maximum length, and position of the line - pointers are passed for it.
Return value: 0 = line wasn't changed 1 = line changed, you should
remove old string and display new, 2 = line changed, it is necessary
to display it; 3 = immediately exit the function.
Starting from version 6, the function returns a pointer to the entered
line with the successful reading, and NULL if the console window was closed. */
extern void stdcall (*con_cls)();
/* Clear screen and set cursor at upper left corner. */
extern void stdcall (*con_get_cursor_pos)(int* px, int* py);
/* Wrote current (x) coordinate of cursor to *px, and (y) to *py. */
extern void stdcall (*con_set_cursor_pos)(int x, int y);
/* Set the cursor position to the specified coordinates. If any of the
parameters beyond the relevant range (from 0 to 1 scr_width-
for x, from 0 to 1 for scr_height-y, scr_width scr_height and were asked if
call con_init), then the corresponding coordinate of the cursor does not change.
*/
extern int __console_initdll_status;
/* == 1 if dll loaded */
extern dword *con_dll_ver;
extern int con_init_console_dll(void);
/* load library and link function symbols. returns 1 if error
called automatic in printf, otherwise, see __console_initdll_status
*/
extern int con_init_console_dll_param(dword wnd_width, dword wnd_height,
dword scr_width, dword scr_height, const char* title);
/* work as con_init_console_dll, but call con_init with params
*/
#endif

View File

@ -1,41 +0,0 @@
#ifndef _CTYPE_H
#define _CTYPE_H
/*
** All character classification functions except isascii().
** Integer argument (c) must be in ASCII range (0-127) for
** dependable answers.
*/
#define __ALNUM 1
#define __ALPHA 2
#define __CNTRL 4
#define __DIGIT 8
#define __GRAPH 16
#define __LOWER 32
#define __PRINT 64
#define __PUNCT 128
#define __BLANK 256
#define __UPPER 512
#define __XDIGIT 1024
extern unsigned short __is[129];
#define isalnum(c)(__is[c+1] & __ALNUM ) /* 'a'-'z', 'A'-'Z', '0'-'9' */
#define isalpha(c)(__is[c+1] & __ALPHA ) /* 'a'-'z', 'A'-'Z' */
#define iscntrl(c)(__is[c+1] & __CNTRL ) /* 0-31, 127 */
#define isdigit(c)(__is[c+1] & __DIGIT ) /* '0'-'9' */
#define isgraph(c)(__is[c+1] & __GRAPH ) /* '!'-'~' */
#define islower(c)(__is[c+1] & __LOWER ) /* 'a'-'z' */
#define isprint(c)(__is[c+1] & __PRINT ) /* ' '-'~' */
#define ispunct(c)(__is[c+1] & __PUNCT ) /* !alnum && !cntrl && !space */
#define isspace(c)(__is[c+1] & __BLANK ) /* HT, LF, VT, FF, CR, ' ' */
#define isupper(c)(__is[c+1] & __UPPER ) /* 'A'-'Z' */
#define isxdigit(c)(__is[c+1] & __XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */
#define isascii(c) (!((c)&(~0x7f)))
#define toascii(c) ((c)&0x7f)
extern unsigned char tolower(unsigned char c);
extern unsigned char toupper(unsigned char c);
#endif

View File

@ -1,6 +0,0 @@
#ifndef _ERRNO_H
#define _ERRNO_H
#include <stdio.h>
#endif

View File

@ -1,65 +0,0 @@
#ifndef _FLOAT_H_
#define _FLOAT_H_
#define FLT_RADIX 2
/* IEEE float */
#define FLT_MANT_DIG 24
#define FLT_DIG 6
#define FLT_ROUNDS 1
#define FLT_EPSILON 1.19209290e-07F
#define FLT_MIN_EXP (-125)
#define FLT_MIN 1.17549435e-38F
#define FLT_MIN_10_EXP (-37)
#define FLT_MAX_EXP 128
#define FLT_MAX 3.40282347e+38F
#define FLT_MAX_10_EXP 38
/* IEEE double */
#define DBL_MANT_DIG 53
#define DBL_DIG 15
#define DBL_EPSILON 2.2204460492503131e-16
#define DBL_MIN_EXP (-1021)
#define DBL_MIN 2.2250738585072014e-308
#define DBL_MIN_10_EXP (-307)
#define DBL_MAX_EXP 1024
#define DBL_MAX 1.7976931348623157e+308
#define DBL_MAX_10_EXP 308
/* horrible intel long double */
#if defined __i386__ || defined __x86_64__
#define LDBL_MANT_DIG 64
#define LDBL_DIG 18
#define LDBL_EPSILON 1.08420217248550443401e-19L
#define LDBL_MIN_EXP (-16381)
#define LDBL_MIN 3.36210314311209350626e-4932L
#define LDBL_MIN_10_EXP (-4931)
#define LDBL_MAX_EXP 16384
#define LDBL_MAX 1.18973149535723176502e+4932L
#define LDBL_MAX_10_EXP 4932
#else
/* same as IEEE double */
#define LDBL_MANT_DIG 53
#define LDBL_DIG 15
#define LDBL_EPSILON 2.2204460492503131e-16
#define LDBL_MIN_EXP (-1021)
#define LDBL_MIN 2.2250738585072014e-308
#define LDBL_MIN_10_EXP (-307)
#define LDBL_MAX_EXP 1024
#define LDBL_MAX 1.7976931348623157e+308
#define LDBL_MAX_10_EXP 308
#endif
#ifndef NAN
# define NAN (__nan__)
#endif
#ifndef INFINITY
# define INFINITY (__inf__)
#endif
#endif /* _FLOAT_H_ */

View File

@ -1,195 +0,0 @@
#ifndef kolibrisys_h
#define kolibrisys_h
/*
#ifdef GNUC
#define stdcall __stdcall
#define cdecl __cdecl
#else
#define stdcall ((__stdcall))
#define cdecl ((__cdecl))
#endif
*/
//#ifdef GNUC
//#define stdcall __stdcall
//#else
#define cdecl __attribute__ ((cdecl))
#define stdcall __attribute__ ((stdcall))
//#endif
typedef unsigned int dword;
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned int fpos_t;
typedef unsigned int size_t;
typedef struct process_table_entry{
int cpu_usage; //+0
int window_pos_info; //+4
short int reserved1; //+8
char name[12]; //+10
int memstart; //+22
int memused; //+26
int pid; //+30
int winx_start; //+34
int winy_start; //+38
int winx_size; //+42
int winy_size; //+46
short int slot_info; //+50
short int reserved2; //+52
int clientx; //+54
int clienty; //+58
int clientwidth; //+62
int clientheight; //+66
unsigned char window_state;//+70
char reserved3[1024-71]; //+71
}__attribute__((packed));
//-----------------------------------------------------------------------------------
//------------------------KolibriOS system acces to files----------------------------
//-----------------------------------------------------------------------------------
extern dword stdcall _ksys_get_filesize(char *filename);
extern dword stdcall _ksys_readfile(char *filename,dword pos,dword blocksize,void *data, int *preadbytes);
extern dword stdcall _ksys_rewritefile(char *filename,dword blocksize,void *data);
extern dword stdcall _ksys_appendtofile(char *filename,dword pos,dword blocksize,void *data);
//-----------------------------------------------------------------------------------
//----------------------Run program---------------------------------------------------
extern void stdcall _ksys_run_program(char* filename,char* parameters);
//------------------------------------------------------------------------------------
//--------------------Debug output---------------------------------------------------
extern void stdcall _ksys_debug_out(int c);
extern void stdcall debug_out_str(char* str);
//-----------------------------------------------------------------------------------
//--------------------------Mouse state----------------------------------------------
extern int stdcall _ksys_GetMouseXY(void);
extern int stdcall _ksys_GetMouseButtonsState(void);
//-----------------------------------------------------------------------------------
//--------------------------get skin height------------------------------------------
extern int stdcall _ksys_get_skin_height(void);
//-----------------------------------------------------------------------------------
//----------------------------background---------------------------------------------
extern void stdcall _ksys_set_background_size(int xsize,int ysize);
extern void stdcall _ksys_write_background_mem(int pos,int color);
extern void stdcall _ksys_draw_background(void);
extern void stdcall _ksys_set_background_draw_type(int type);
extern void stdcall _ksys_background_blockmove(void* src,int bgr_pos, int count);
//-----------------------------------------------------------------------------------
//----------------------------functionf for draw window,lines.bar,etc.---------------
extern void stdcall _ksys_draw_window(int xcoord,int ycoord, int xsize,
int ysize,int workcolor,int type,
int captioncolor,int windowtype,int bordercolor);
extern void stdcall _ksys_window_redraw(int status);
extern int stdcall _ksys_putpixel(int x,int y,int color);
extern void stdcall _ksys_draw_bar(int x, int y, int xsize, int ysize, int color);
extern void stdcall _ksys_line(int x1,int y1,int x2,int y2,int color);
extern void stdcall _ksys_putimage(int x, int y, int xsize, int ysize, void* image);
//-----------------------------------------------------------------------------------
//--------------------------write text(system fonts 6x9)-----------------------------
extern void stdcall _ksys_write_text(int x,int y,int color,char* text,int len);
//-----------------------------------------------------------------------------------
//------------------ get screen size and bytes per pixel---------------------------
extern int stdcall _ksys_get_screen_size(int* x,int* y);
extern void stdcall _ksys_dga_get_resolution(int* xres, int* yres, int* bpp, int* bpscan);
//-----------------------------------------------------------------------------------
//-------------------------------craete thread---------------------------------------
extern void* stdcall _ksys_start_thread(void (* func_ptr)(void),int stack_size,int* pid);
//-----------------------------------------------------------------------------------
//------------------system button(Old function. Better use libGUI functions.)--------
extern void stdcall _ksys_make_button(int x, int y, int xsize, int ysize, int id, int color);
extern int stdcall _ksys_get_button_id(void); //get state of system button
//------------------------------------------------------------------------------------
//----------------------system clock(in 1/100 sec.) and date--------------------------
extern int stdcall _ksys_get_system_clock(void);
extern int stdcall _ksys_get_date(void);
//------------------------------------------------------------------------------------
//-------------------------system delay(in 1/100 sec.)-------------------------------
extern void stdcall _ksys_delay(int m);
//-----------------------------------------------------------------------------------
//------------------------system events----------------------------------------------
extern int stdcall _ksys_wait_for_event_infinite(void);
extern int stdcall _ksys_check_for_event(void);
extern int stdcall _ksys_wait_for_event(int time);
extern void stdcall _ksys_set_wanted_events(int ev);
//-----------------------------------------------------------------------------------
//----------------------------system exit program------------------------------------
extern void stdcall _ksys_exit(void);
//-----------------------------------------------------------------------------------
//-----------------------------system IPC send message-------------------------------
extern void stdcall _ksys_send_message(int pid, void* msg, int size);
//-----------------------------------------------------------------------------------
//---------------------------system work with IRQ from user mode---------------------
extern void stdcall _ksys_define_receive_area(void* area, int size);
extern int stdcall _ksys_get_irq_owner(int irq);
extern int stdcall _ksys_get_data_read_by_irq(int irq, int* size, void* data);
extern int stdcall _ksys_send_data_to_device(int port, unsigned char val);
extern int stdcall _ksys_receive_data_from_device(int port,unsigned char* data);
extern void stdcall _ksys_program_irq(void* intrtable, int irq);
extern void stdcall _ksys_reserve_irq(int irq);
extern void stdcall _ksys_free_irq(int irq);
//----------------------------------------------------------------------------------
//----------------------------system reserve diapason of ports----------------------
extern int stdcall _ksys_reserve_port_area(int start,int end);
extern int stdcall _ksys_free_port_area(int start,int end);
//----------------------------------------------------------------------------------
//-------------functions get key and set keyboard mode------------------------------
extern int stdcall _ksys_get_key(void);
extern void stdcall _ksys_set_keyboard_mode(int mode);
//----------------------------------------------------------------------------------
//--------------simple work with MPU401 sound device---------------------------------
extern void stdcall _ksys_midi_reset(void);
extern void stdcall _ksys_midi_send(int data);
//-----------------------------------------------------------------------------------
//--------------------------acces to PCI BUS from user mode---------------------------
extern int stdcall _ksys_get_pci_version(void);
extern int stdcall _ksys_get_last_pci_bus(void);
extern int stdcall _ksys_get_pci_access_mechanism(void);
extern int stdcall _ksys_pci_read_config_byte(int bus,int dev,int fn,int reg);
extern int stdcall _ksys_pci_read_config_word(int bus,int dev,int fn,int reg);
extern int stdcall _ksys_pci_read_config_dword(int bus,int dev,int fn,int reg);
extern int stdcall _ksys_pci_write_config_byte(int bus,int dev,int fn,int reg,int value);
extern int stdcall _ksys_pci_write_config_word(int bus,int dev,int fn,int reg,int value);
extern int stdcall _ksys_pci_write_config_dword(int bus,int dev,int fn,int reg,int value);
//--------------------------------------------------------------------------------------
//------------------------Process information--------------------------------------
extern int stdcall _ksys_get_process_table(struct process_table_entry *proctab,int pid); //if pid=-1 than get info about him.
//---------------------------------------------------------------------------------
//-----------------Old functions for work with sound(Sound Blaster only).---------
extern void stdcall _ksys_sound_load_block(void* blockptr);
extern void stdcall _ksys_sound_play_block(void);
extern void stdcall _ksys_sound_set_channels(int channels);
extern void stdcall _ksys_sound_set_data_size(int size);
extern void stdcall _ksys_sound_set_frequency(int frequency);
//--------------------------------------------------------------------------------
//------------------------------system speaker(integrated speaker)----------------
extern void stdcall _ksys_sound_speaker_play(void* data);
//--------------------------------------------------------------------------------
//------------------function for work with Dinamic Link Librarys(DLL)--------------
extern dword* stdcall _ksys_cofflib_load(char* name);
extern char* stdcall _ksys_cofflib_getproc(void* exp,char* sz_name);
//---------------------------------------------------------------------------------
#endif

View File

@ -1,800 +0,0 @@
#ifndef __KOS_32_SYS_H__
#define __KOS_32_SYS_H__
// file header taken from newlib
// added many sys functions, compatible with tcc
//#include <newlib.h>
//#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned long long uint64_t;
#ifdef __cplusplus
extern "C" {
#endif
//#ifdef CONFIG_DEBUF
// #define DBG(format,...) printf(format,##__VA_ARGS__)
//#else
// #define DBG(format,...)
//#endif
#define TYPE_3_BORDER_WIDTH 5
#define WIN_STATE_MINIMIZED 0x02
#define WIN_STATE_ROLLED 0x04
#define POS_SCREEN 0
#define POS_WINDOW 1
#define IPC_NOBUFFER 1
#define IPC_LOCKED 2
#define IPC_OVERFLOW 3
#define IPC_NOPID 4
#define SHM_OPEN 0x00
#define SHM_OPEN_ALWAYS 0x04
#define SHM_CREATE 0x08
#define SHM_READ 0x00
#define SHM_WRITE 0x01
typedef unsigned int color_t;
typedef union __attribute__((packed)) pos_t
{
uint32_t val;
struct
{
short x;
short y;
};
} pos_t;
typedef union __attribute__((packed)) oskey_t
{
uint32_t val;
struct
{
uint8_t state;
uint8_t code;
uint16_t ctrl_key;
};
} oskey_t;
typedef struct
{
unsigned handle;
unsigned io_code;
void *input;
int inp_size;
void *output;
int out_size;
}ioctl_t;
typedef union
{
struct
{
void *data;
size_t size;
} x;
unsigned long long raw;
}ufile_t;
struct kolibri_system_colors {
color_t frame_area;
color_t grab_bar;
color_t grab_bar_button;
color_t grab_button_text;
color_t grab_text;
color_t work_area;
color_t work_button;
color_t work_button_text;
color_t work_text;
color_t work_graph;
};
struct blit_call
{
int dstx;
int dsty;
int w;
int h;
int srcx;
int srcy;
int srcw;
int srch;
void *bitmap;
int stride;
};
struct ipc_message
{
uint32_t pid; // PID of sending thread
uint32_t datalen; // data bytes
char data[0]; // data begin
};
struct ipc_buffer
{
uint32_t lock; // nonzero is locked
uint32_t used; // used bytes in buffer
struct ipc_message data[0]; // data begin
};
static inline void begin_draw(void)
{
__asm__ __volatile__(
"int $0x40" ::"a"(12),"b"(1));
};
static inline
void end_draw(void)
{
__asm__ __volatile__(
"int $0x40" ::"a"(12),"b"(2));
};
static inline
void sys_create_window(int x, int y, int w, int h, const char *name,
color_t workcolor, uint32_t style)
{
__asm__ __volatile__(
"int $0x40"
::"a"(0),
"b"((x << 16) | ((w-1) & 0xFFFF)),
"c"((y << 16) | ((h-1) & 0xFFFF)),
"d"((style << 24) | (workcolor & 0xFFFFFF)),
"D"(name),
"S"(0) : "memory");
};
static inline
void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(8),
"b"(x_w),
"c"(y_h),
"d"(id),
"S"(color));
};
static inline
void draw_line(int xs, int ys, int xe, int ye, color_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(38), "d"(color),
"b"((xs << 16) | xe),
"c"((ys << 16) | ye));
}
static inline
void draw_bar(int x, int y, int w, int h, color_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(13), "d"(color),
"b"((x << 16) | w),
"c"((y << 16) | h));
}
static inline
void draw_bitmap(void *bitmap, int x, int y, int w, int h)
{
__asm__ __volatile__(
"int $0x40"
::"a"(7), "b"(bitmap),
"c"((w << 16) | h),
"d"((x << 16) | y));
}
static inline
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(4),"d"(text),
"b"((x << 16) | y),
"S"(len),"c"(color)
:"memory");
}
static inline
uint32_t get_skin_height(void)
{
uint32_t height;
__asm__ __volatile__(
"int $0x40 \n\t"
:"=a"(height)
:"a"(48),"b"(4));
return height;
};
static inline
pos_t get_mouse_pos(int origin)
{
pos_t val;
__asm__ __volatile__(
"int $0x40 \n\t"
"rol $16, %%eax"
:"=a"(val)
:"a"(37),"b"(origin));
return val;
}
static inline
uint32_t get_mouse_buttons(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(37),"b"(2));
return val;
};
static inline
uint32_t get_mouse_wheels(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40 \n\t"
:"=a"(val)
:"a"(37),"b"(7));
return val;
};
static inline uint32_t load_cursor(void *path, uint32_t flags)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(37), "b"(4), "c"(path), "d"(flags));
return val;
}
static inline uint32_t set_cursor(uint32_t cursor)
{
uint32_t old;
__asm__ __volatile__(
"int $0x40"
:"=a"(old)
:"a"(37), "b"(5), "c"(cursor));
return old;
};
static inline int destroy_cursor(uint32_t cursor)
{
int ret;
__asm__ __volatile__(
"int $0x40"
:"=a"(ret)
:"a"(37), "b"(6), "c"(cursor)
:"memory");
return ret;
};
static inline
uint32_t wait_for_event(uint32_t time)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(23), "b"(time));
return val;
};
static inline uint32_t check_os_event()
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(11));
return val;
};
static inline uint32_t get_os_event()
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(10));
return val;
};
static inline
uint32_t get_tick_count(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(26),"b"(9));
return val;
};
static inline
uint64_t get_ns_count(void)
{
uint64_t val;
__asm__ __volatile__(
"int $0x40"
:"=A"(val)
:"a"(26), "b"(10));
return val;
};
static inline
oskey_t get_key(void)
{
oskey_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(2));
return val;
}
static inline
uint32_t get_os_button()
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(17));
return val>>8;
};
static inline uint32_t get_service(char *name)
{
uint32_t retval = 0;
__asm__ __volatile__(
"int $0x40"
:"=a"(retval)
:"a"(68),"b"(16),"c"(name)
:"memory");
return retval;
};
static inline int call_service(ioctl_t *io)
{
int retval;
__asm__ __volatile__(
"int $0x40"
:"=a"(retval)
:"a"(68),"b"(17),"c"(io)
:"memory","cc");
return retval;
};
static inline void yield(void)
{
__asm__ __volatile__(
"int $0x40"
::"a"(68), "b"(1));
};
static inline void delay(uint32_t time)
{
__asm__ __volatile__(
"int $0x40"
::"a"(5), "b"(time)
:"memory");
};
static inline
void *user_alloc(size_t size)
{
void *val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(12),"c"(size));
return val;
}
static inline
int user_free(void *mem)
{
int val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(13),"c"(mem));
return val;
}
static inline
void* user_realloc(void *mem, size_t size)
{
void *val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(20),"c"(size),"d"(mem)
:"memory");
return val;
};
static inline
int *user_unmap(void *base, size_t offset, size_t size)
{
int *val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
return val;
};
static inline ufile_t load_file(const char *path)
{
ufile_t uf;
__asm__ __volatile__ (
"int $0x40"
:"=A"(uf.raw)
:"a" (68), "b"(27),"c"(path));
return uf;
};
static inline int GetScreenSize()
{
int retval;
__asm__ __volatile__(
"int $0x40"
:"=a"(retval)
:"a"(61), "b"(1));
return retval;
}
static inline void get_proc_info(char *info)
{
__asm__ __volatile__(
"int $0x40"
:
:"a"(9), "b"(info), "c"(-1)
:"memory");
};
static inline void Blit(void *bitmap, int dst_x, int dst_y,
int src_x, int src_y, int w, int h,
int src_w, int src_h, int stride)
{
volatile struct blit_call bc;
bc.dstx = dst_x;
bc.dsty = dst_y;
bc.w = w;
bc.h = h;
bc.srcx = src_x;
bc.srcy = src_y;
bc.srcw = src_w;
bc.srch = src_h;
bc.stride = stride;
bc.bitmap = bitmap;
__asm__ __volatile__(
"int $0x40"
::"a"(73),"b"(0),"c"(&bc.dstx));
};
// newlib exclusive
#ifndef __TINYC__
int create_thread(int (*proc)(void *param), void *param, int stack_size);
void* load_library(const char *name);
void* get_proc_address(void *handle, const char *proc_name);
void enumerate_libraries(int (*callback)(void *handle, const char* name,
uint32_t base, uint32_t size, void *user_data),
void *user_data);
#endif
// May be next section need to be added in newlibc
enum KOLIBRI_GUI_EVENTS {
KOLIBRI_EVENT_NONE = 0, /* Event queue is empty */
KOLIBRI_EVENT_REDRAW = 1, /* Window and window elements should be redrawn */
KOLIBRI_EVENT_KEY = 2, /* A key on the keyboard was pressed */
KOLIBRI_EVENT_BUTTON = 3, /* A button was clicked with the mouse */
KOLIBRI_EVENT_DESKTOP = 5, /* Desktop redraw finished */
KOLIBRI_EVENT_MOUSE = 6, /* Mouse activity (movement, button press) was detected */
KOLIBRI_EVENT_IPC = 7, /* Interprocess communication notify */
KOLIBRI_EVENT_NETWORK = 8, /* Network event */
KOLIBRI_EVENT_DEBUG = 9, /* Debug subsystem event */
KOLIBRI_EVENT_IRQBEGIN = 16 /* 16..31 IRQ0..IRQ15 interrupt =IRQBEGIN+IRQn */
};
// copied from /programs/system/shell/system/kolibri.c
// fn's returned -1 as syserror, 1 as error, 0 as OK
static inline
int kol_clip_num()
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(0));
return val;
}
static inline
char* kol_clip_get(int n)
// returned buffer must be freed by user_free()
{
register char* val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(1), "c"(n));
return val;
}
static inline
int kol_clip_set(int n, char buffer[])
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(2), "c"(n), "d"(buffer));
return val;
}
static inline
int kol_clip_pop()
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(3));
return val;
}
static inline
int kol_clip_unlock()
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(4));
return val;
}
static inline void get_system_colors(struct kolibri_system_colors *color_table)
{
__asm__ volatile ("int $0x40"
:
:"a"(48),"b"(3),"c"(color_table),"d"(40)
);
/* color_table should point to the system color table */
}
static inline void debug_board_write_byte(const char ch){
__asm__ __volatile__(
"int $0x40"
:
:"a"(63), "b"(1), "c"(ch));
}
static inline void draw_number_sys(int32_t number, int x, int y, int len, color_t color){
register uint32_t fmt;
fmt = len << 16 | 0x80000000; // no leading zeros + width
// fmt = len << 16 | 0x00000000; // leading zeros + width
__asm__ __volatile__(
"int $0x40"
:
:"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color));
}
static inline
uint32_t get_mouse_eventstate(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(37),"b"(3));
return val;
};
static inline
uint32_t set_event_mask(uint32_t mask)
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(40), "b"(mask));
return val;
}
typedef void (*thread_proc)(void*);
static inline
int start_thread(thread_proc proc, char* stack_top)
{
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(51), "b"(1), "c"(proc), "d"(stack_top));
return val;
}
static inline
void kos_exit()
{
asm volatile ("int $0x40"::"a"(-1));
}
static inline void focus_window(int slot){
asm volatile ("int $0x40"::"a"(18), "b"(3), "c"(slot));
}
static inline int get_thread_slot(int tid){
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(18), "b"(21), "c"(tid));
return val;
}
static inline void set_current_folder(char* dir){
asm volatile ("int $0x40"::"a"(30), "b"(1), "c"(dir));
}
static inline int get_current_folder(char* buf, int bufsize){
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize));
return val;
}
static inline
void ipc_set_area(void* buf, int bufsize){
asm volatile ("int $0x40"::"a"(60), "b"(1), "c"(buf), "d"(bufsize));
}
static inline
int ipc_send_message(int pid_reciever, void *data, int datalen) {
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(60), "b"(2), "c"(pid_reciever), "d"(data), "S"(datalen));
return val;
}
static inline
void* shm_open(char *shm_name, int msize, int flags, int *retsz){
register int val, cod;
asm volatile ("int $0x40":"=a"(val),"=d"(cod):"a"(68), "b"(22), "c"(shm_name), "d"(msize), "S"(flags));
if(retsz) *retsz = cod; // errcode if NULL or memsize when open
return (void*)val;
}
static inline
void shm_close(char *shm_name){
asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(shm_name));
}
static inline
int start_app(char *app_name, char *args){
struct file_op_t
{
uint32_t fn;
uint32_t flags;
char* args;
uint32_t res1, res2;
char zero;
char* app_name __attribute__((packed));
} file_op;
memset(&file_op, 0, sizeof(file_op));
file_op.fn = 7;
file_op.args = args;
file_op.app_name = app_name;
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(70), "b"(&file_op));
return val;
}
/*
static inline char *getcwd(char *buf, size_t size)
{
int rc = get_current_folder(buf, size);
if (rc > size)
{
errno = ERANGE;
return 0;
}
else
return buf;
}
*/
// end section
//added nonstatic inline because incomfortabre stepping in in debugger
void __attribute__ ((noinline)) debug_board_write_str(const char* str);
void __attribute__ ((noinline)) debug_board_printf(const char *format,...);
/* copy body to only one project file
void __attribute__ ((noinline)) debug_board_write_str(const char* str){
while(*str)
debug_board_write_byte(*str++);
}
void __attribute__ ((noinline)) debug_board_printf(const char *format,...)
{
va_list ap;
char log_board[300];
va_start (ap, format);
vsnprintf(log_board, sizeof log_board, format, ap);
va_end(ap);
debug_board_write_str(log_board);
}
*/
// TinyC don't support aliasing of static inline funcs
#ifndef __TINYC__
static inline void BeginDraw(void) __attribute__ ((alias ("begin_draw")));
static inline void EndDraw(void) __attribute__ ((alias ("end_draw")));
static inline void DrawWindow(int x, int y, int w, int h, const char *name,
color_t workcolor, uint32_t style)
__attribute__ ((alias ("sys_create_window")));
static inline void DefineButton(void) __attribute__ ((alias ("define_button")));
static inline void DrawLine(int xs, int ys, int xe, int ye, color_t color)
__attribute__ ((alias ("draw_line")));
static inline void DrawBar(int x, int y, int w, int h, color_t color)
__attribute__ ((alias ("draw_bar")));
static inline void DrawBitmap(void *bitmap, int x, int y, int w, int h)
__attribute__ ((alias ("draw_bitmap")));
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height")));
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos")));
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons")));
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels")));
static inline uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor")));
static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor")));
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor")));
static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event")));
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc")));
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free")));
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc")));
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap")));
static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file")));
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,994 +0,0 @@
#ifndef __KOS_32_SYS_H__
#define __KOS_32_SYS_H__
// file header taken from newlib
// added many sys functions, compatible with tcc
// with gcc USE gcc -mno-ms-bitfields!!!
//#include <newlib.h>
//#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
typedef unsigned int uint32_t;
typedef int int32_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned long long uint64_t;
#ifdef __cplusplus
extern "C" {
#endif
//#ifdef CONFIG_DEBUF
// #define DBG(format,...) printf(format,##__VA_ARGS__)
//#else
// #define DBG(format,...)
//#endif
#define TYPE_3_BORDER_WIDTH 5
#define WIN_STATE_MINIMIZED 0x02
#define WIN_STATE_ROLLED 0x04
#define POS_SCREEN 0
#define POS_WINDOW 1
#define IPC_NOBUFFER 1
#define IPC_LOCKED 2
#define IPC_OVERFLOW 3
#define IPC_NOPID 4
#define SHM_OPEN 0x00
#define SHM_OPEN_ALWAYS 0x04
#define SHM_CREATE 0x08
#define SHM_READ 0x00
#define SHM_WRITE 0x01
typedef unsigned int color_t;
typedef union __attribute__((packed)) pos_t
{
uint32_t val;
struct
{
short x;
short y;
};
} pos_t;
typedef union __attribute__((packed)) oskey_t
{
uint32_t val;
struct
{
uint8_t state;
uint8_t code;
uint16_t ctrl_key;
};
} oskey_t;
typedef struct
{
unsigned handle;
unsigned io_code;
void *input;
int inp_size;
void *output;
int out_size;
}ioctl_t;
typedef union
{
struct
{
void *data;
size_t size;
} x;
unsigned long long raw;
}ufile_t;
struct kolibri_system_colors {
color_t frame_area;
color_t grab_bar;
color_t grab_bar_button;
color_t grab_button_text;
color_t grab_text;
color_t work_area;
color_t work_button;
color_t work_button_text;
color_t work_text;
color_t work_graph;
};
struct blit_call
{
int dstx;
int dsty;
int w;
int h;
int srcx;
int srcy;
int srcw;
int srch;
void *bitmap;
int stride;
};
struct ipc_message
{
uint32_t pid; // PID of sending thread
uint32_t datalen; // data bytes
char data[0]; // data begin
};
struct ipc_buffer
{
uint32_t lock; // nonzero is locked
uint32_t used; // used bytes in buffer
struct ipc_message data[0]; // data begin
};
typedef struct __attribute__((packed)) file_op_t
{
uint32_t fn;
uint32_t flags;
char* args;
uint32_t res1, res2;
char zero;
char* app_name
#ifdef __TINYC__
__attribute__((packed))
#endif
;
} file_op_t;
static inline void begin_draw(void)
{
__asm__ __volatile__(
"int $0x40" ::"a"(12),"b"(1));
};
static inline
void end_draw(void)
{
__asm__ __volatile__(
"int $0x40" ::"a"(12),"b"(2));
};
static inline
void sys_create_window(int x, int y, int w, int h, const char *name,
color_t workcolor, uint32_t style)
{
__asm__ __volatile__(
"int $0x40"
::"a"(0),
"b"((x << 16) | ((w-1) & 0xFFFF)),
"c"((y << 16) | ((h-1) & 0xFFFF)),
"d"((style << 24) | (workcolor & 0xFFFFFF)),
"D"(name),
"S"(0) : "memory");
};
static inline
void define_button(uint32_t x_w, uint32_t y_h, uint32_t id, uint32_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(8),
"b"(x_w),
"c"(y_h),
"d"(id),
"S"(color));
};
static inline
void draw_line(int xs, int ys, int xe, int ye, color_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(38), "d"(color),
"b"((xs << 16) | xe),
"c"((ys << 16) | ye));
}
static inline
void draw_bar(int x, int y, int w, int h, color_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(13), "d"(color),
"b"((x << 16) | w),
"c"((y << 16) | h));
}
static inline
void draw_bitmap(void *bitmap, int x, int y, int w, int h)
{
__asm__ __volatile__(
"int $0x40"
::"a"(7), "b"(bitmap),
"c"((w << 16) | h),
"d"((x << 16) | y));
}
static inline
void draw_text_sys(const char *text, int x, int y, int len, color_t color)
{
__asm__ __volatile__(
"int $0x40"
::"a"(4),"d"(text),
"b"((x << 16) | y),
"S"(len),"c"(color)
:"memory");
}
static inline
uint32_t get_skin_height(void)
{
uint32_t height;
__asm__ __volatile__(
"int $0x40 \n\t"
:"=a"(height)
:"a"(48),"b"(4));
return height;
};
static inline
pos_t get_mouse_pos(int origin)
{
pos_t val;
__asm__ __volatile__(
"int $0x40 \n\t"
"rol $16, %%eax"
:"=a"(val)
:"a"(37),"b"(origin));
return val;
}
static inline
uint32_t get_mouse_buttons(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(37),"b"(2));
return val;
};
static inline
uint32_t get_mouse_wheels(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40 \n\t"
:"=a"(val)
:"a"(37),"b"(7));
return val;
};
static inline uint32_t load_cursor(void *path, uint32_t flags)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(37), "b"(4), "c"(path), "d"(flags));
return val;
}
static inline uint32_t set_cursor(uint32_t cursor)
{
uint32_t old;
__asm__ __volatile__(
"int $0x40"
:"=a"(old)
:"a"(37), "b"(5), "c"(cursor));
return old;
};
static inline int destroy_cursor(uint32_t cursor)
{
int ret;
__asm__ __volatile__(
"int $0x40"
:"=a"(ret)
:"a"(37), "b"(6), "c"(cursor)
:"memory");
return ret;
};
static inline
uint32_t wait_for_event(uint32_t time)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(23), "b"(time));
return val;
};
static inline uint32_t check_os_event()
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(11));
return val;
};
static inline uint32_t get_os_event()
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(10));
return val;
};
static inline
uint32_t get_tick_count(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(26),"b"(9));
return val;
};
static inline
uint64_t get_ns_count(void)
{
uint64_t val;
__asm__ __volatile__(
"int $0x40"
:"=A"(val)
:"a"(26), "b"(10));
return val;
};
static inline
oskey_t get_key(void)
{
oskey_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(2));
return val;
}
static inline
uint32_t get_os_button()
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(17));
return val>>8;
};
static inline uint32_t get_service(char *name)
{
uint32_t retval = 0;
__asm__ __volatile__(
"int $0x40"
:"=a"(retval)
:"a"(68),"b"(16),"c"(name)
:"memory");
return retval;
};
static inline int call_service(ioctl_t *io)
{
int retval;
__asm__ __volatile__(
"int $0x40"
:"=a"(retval)
:"a"(68),"b"(17),"c"(io)
:"memory","cc");
return retval;
};
static inline void yield(void)
{
__asm__ __volatile__(
"int $0x40"
::"a"(68), "b"(1));
};
static inline void delay(uint32_t time)
{
__asm__ __volatile__(
"int $0x40"
::"a"(5), "b"(time)
:"memory");
};
static inline
void *user_alloc(size_t size)
{
void *val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(12),"c"(size));
return val;
}
static inline
int user_free(void *mem)
{
int val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(13),"c"(mem));
return val;
}
static inline
void* user_realloc(void *mem, size_t size)
{
void *val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(20),"c"(size),"d"(mem)
:"memory");
return val;
};
static inline
int *user_unmap(void *base, size_t offset, size_t size)
{
int *val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(68),"b"(26),"c"(base),"d"(offset),"S"(size));
return val;
};
static inline ufile_t load_file(const char *path)
{
ufile_t uf;
__asm__ __volatile__ (
"int $0x40"
:"=A"(uf.raw)
:"a" (68), "b"(27),"c"(path));
return uf;
};
static inline int GetScreenSize()
{
int retval;
__asm__ __volatile__(
"int $0x40"
:"=a"(retval)
:"a"(61), "b"(1));
return retval;
}
static inline void get_proc_info(char *info)
{
__asm__ __volatile__(
"int $0x40"
:
:"a"(9), "b"(info), "c"(-1)
:"memory");
};
static inline void Blit(void *bitmap, int dst_x, int dst_y,
int src_x, int src_y, int w, int h,
int src_w, int src_h, int stride)
{
volatile struct blit_call bc;
bc.dstx = dst_x;
bc.dsty = dst_y;
bc.w = w;
bc.h = h;
bc.srcx = src_x;
bc.srcy = src_y;
bc.srcw = src_w;
bc.srch = src_h;
bc.stride = stride;
bc.bitmap = bitmap;
__asm__ __volatile__(
"int $0x40"
::"a"(73),"b"(0),"c"(&bc.dstx));
};
// newlib exclusive
#ifndef __TINYC__
int create_thread(int (*proc)(void *param), void *param, int stack_size);
void* load_library(const char *name);
void* get_proc_address(void *handle, const char *proc_name);
void enumerate_libraries(int (*callback)(void *handle, const char* name,
uint32_t base, uint32_t size, void *user_data),
void *user_data);
#endif
///////////////////////////////////////////////////////////////////////////////
/// May be next section need to be added in newlibc
// Siemargl addenium
#define X_Y(x,y) (((x)<<16)|(y))
enum KOLIBRI_GUI_EVENTS {
KOLIBRI_EVENT_NONE = 0, /* Event queue is empty */
KOLIBRI_EVENT_REDRAW = 1, /* Window and window elements should be redrawn */
KOLIBRI_EVENT_KEY = 2, /* A key on the keyboard was pressed */
KOLIBRI_EVENT_BUTTON = 3, /* A button was clicked with the mouse */
KOLIBRI_EVENT_DESKTOP = 5, /* Desktop redraw finished */
KOLIBRI_EVENT_MOUSE = 6, /* Mouse activity (movement, button press) was detected */
KOLIBRI_EVENT_IPC = 7, /* Interprocess communication notify */
KOLIBRI_EVENT_NETWORK = 8, /* Network event */
KOLIBRI_EVENT_DEBUG = 9, /* Debug subsystem event */
KOLIBRI_EVENT_IRQBEGIN = 16 /* 16..31 IRQ0..IRQ15 interrupt =IRQBEGIN+IRQn */
};
enum control_keys {
KM_SHIFT = 0x00010000,
KM_CTRL = 0x00020000,
KM_ALT = 0x00040000,
KM_NUMLOCK = 0x00080000
};
struct __attribute__ ((__packed__)) fs_dirinfo {
uint32_t subfn; // 1 read dir
uint32_t start;
uint32_t flags;
uint32_t size;
uint32_t retval;
union {
struct __attribute__ ((__packed__)) {
uint8_t zero; // 0
char* ppath;
};
char path[5]; // up to 4096
} ;
};
static inline
uint32_t sf_file(int subfn, struct fs_dirinfo* dinfo)
/// SysFn70 call with subfunction
/// retval 0 if ok
{
uint32_t retval;
dinfo->subfn = subfn;
__asm__ __volatile__(
"int $0x40 "
:"=a"(retval)
:"a"(70),"b"(dinfo)
:);
return retval;
};
struct fs_dirheader {
uint32_t version; // 1
uint32_t curn_blocks; // number of read dir items (BDFE)
uint32_t totl_blocks; // directory full size
char other[20]; // reserved 0
};
enum filetype
{
FS_RONLY = 1,
FS_HIDDEN = 2,
FS_SYSTEM = 4,
FS_VOLID = 8,
FS_SUBDIR = 16,
FS_FOLDER = 16,
FS_ARCHIV = 32
};
struct __attribute__ ((__packed__)) fs_filetime {
uint8_t sec;
uint8_t mm;
uint8_t hour;
uint8_t zero;
};
struct __attribute__ ((__packed__)) fs_filedate {
uint8_t day;
uint8_t month;
uint16_t year;
};
/// directory entry cp866
struct fsBDFE {
uint32_t filetype;
uint32_t encoding; // 0 - cp866, 1 - utf16le
struct fs_filetime tm_created;
struct fs_filedate dt_created;
struct fs_filetime tm_accessed;
struct fs_filedate dt_accessed;
struct fs_filetime tm_modified;
struct fs_filedate dt_modified;
uint64_t size;
char fname[264];
}; // must be sized 304
/// directory entry UTF16LE
struct fsBDFE_16 {
uint32_t filetype;
uint32_t encoding; // 0 - cp866, 1 - utf16le
struct fs_filetime tm_created;
struct fs_filedate dt_created;
struct fs_filetime tm_accessed;
struct fs_filedate dt_accessed;
struct fs_filetime tm_modified;
struct fs_filedate dt_modified;
uint64_t size;
wchar_t fname[260];
}; // must be sized 560
// copied from /programs/system/shell/system/kolibri.c
// fn's returned -1 as syserror, 1 as error, 0 as OK
static inline
int kol_clip_num()
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(0));
return val;
}
static inline
char* kol_clip_get(int n)
// returned buffer must be freed by user_free()
{
register char* val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(1), "c"(n));
return val;
}
static inline
int kol_clip_set(int n, char buffer[])
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(2), "c"(n), "d"(buffer));
return val;
}
static inline
int kol_clip_pop()
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(3));
return val;
}
static inline
int kol_clip_unlock()
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(54), "b"(4));
return val;
}
static inline void get_system_colors(struct kolibri_system_colors *color_table)
{
__asm__ volatile ("int $0x40"
:
:"a"(48),"b"(3),"c"(color_table),"d"(40)
);
/* color_table should point to the system color table */
}
static inline void debug_board_write_byte(const char ch){
__asm__ __volatile__(
"int $0x40"
:
:"a"(63), "b"(1), "c"(ch));
}
static inline void draw_number_sys(int32_t number, int x, int y, int len, color_t color){
register uint32_t fmt;
fmt = len << 16 | 0x80000000; // no leading zeros + width
// fmt = len << 16 | 0x00000000; // leading zeros + width
__asm__ __volatile__(
"int $0x40"
:
:"a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color));
}
static inline
uint32_t get_mouse_eventstate(void)
{
uint32_t val;
__asm__ __volatile__(
"int $0x40"
:"=a"(val)
:"a"(37),"b"(3));
return val;
};
static inline
uint32_t set_event_mask(uint32_t mask)
{
register uint32_t val;
asm volatile ("int $0x40":"=a"(val):"a"(40), "b"(mask));
return val;
}
typedef void (*thread_proc)(void*);
static inline
int start_thread(thread_proc proc, char* stack_top)
{
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(51), "b"(1), "c"(proc), "d"(stack_top));
return val;
}
static inline
void kos_exit()
{
asm volatile ("int $0x40"::"a"(-1));
}
static inline void focus_window(int slot){
asm volatile ("int $0x40"::"a"(18), "b"(3), "c"(slot));
}
static inline int get_thread_slot(int tid){
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(18), "b"(21), "c"(tid));
return val;
}
static inline void set_current_folder(char* dir){
asm volatile ("int $0x40"::"a"(30), "b"(1), "c"(dir));
}
static inline int get_current_folder(char* buf, int bufsize){
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize));
return val;
}
static inline
void ipc_set_area(void* buf, int bufsize){
asm volatile ("int $0x40"::"a"(60), "b"(1), "c"(buf), "d"(bufsize));
}
static inline
int ipc_send_message(int pid_reciever, void *data, int datalen) {
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(60), "b"(2), "c"(pid_reciever), "d"(data), "S"(datalen));
return val;
}
static inline
void* shm_open(char *shm_name, int msize, int flags, int *retsz){
register int val, cod;
asm volatile ("int $0x40":"=a"(val),"=d"(cod):"a"(68), "b"(22), "c"(shm_name), "d"(msize), "S"(flags));
if(retsz) *retsz = cod; // errcode if NULL or memsize when open
return (void*)val;
}
static inline
void shm_close(char *shm_name){
asm volatile ("int $0x40"::"a"(68), "b"(23), "c"(shm_name));
}
static inline
int start_app(char *app_name, char *args){
file_op_t file_op;
memset(&file_op, 0, sizeof(file_op));
file_op.fn = 7;
file_op.args = args;
file_op.app_name = app_name;
register int val;
asm volatile ("int $0x40":"=a"(val):"a"(70), "b"(&file_op));
return val;
}
static inline
uint32_t get_control_keys(void)
{
uint32_t ctrl;
__asm__ __volatile__(
"int $0x40 \n\t"
:"=a"(ctrl)
:"a"(66),"b"(3));
return ctrl;
};
static inline
int get_keyboard_layout(int opt, char* buf)
/// 128 byte buffer
/// opt: 1 - normal, 2 - shifted, 3 - alted, or 9 - return language
{
uint32_t lang;
__asm__ __volatile__(
"int $0x40 \n\t"
:"=a"(lang)
:"a"(26),"b"(2), "c"(opt), "d"(buf));
return lang;
};
static inline
int font_size(int color)
/// decode font size in pixels from color as SysFn4
/// returns (width, hight)
{
int font = color >> 24;
int font_multipl = (font & 7) + 1;
int width_sym, hight_sym;
if (font & 0x10) // 8x16
{
width_sym = 8 * font_multipl;
hight_sym = 16 * font_multipl;
} else // 6x9
{
width_sym = 6 * font_multipl;
hight_sym = 9 * font_multipl;
}
return hight_sym + (width_sym << 16);
}
/*
static inline char *getcwd(char *buf, size_t size)
{
int rc = get_current_folder(buf, size);
if (rc > size)
{
errno = ERANGE;
return 0;
}
else
return buf;
}
*/
/* not finished
void staticnum_draw(staticnum *st)
{
register uint32_t fmt;
if (st->width < 0)
fmt = (-st->width << 16); // leading zeros, decimal
else
fmt = (st->width << 16) | 0x80000000; // no leading zeros, decimal
__asm__ __volatile__(
"int $0x40"
::"a"(47),
"b"(fmt),
"c"(st->number),
"d"(st->start_xy),
"S"(st->color_flags),
"D"(st->bg_color)
:);
}
*/
//////////// end section
//added nonstatic inline because incomfortabre stepping in in debugger
void __attribute__ ((noinline)) debug_board_write_str(const char* str);
void __attribute__ ((noinline)) debug_board_printf(const char *format,...);
/* copy body to only one project file
void __attribute__ ((noinline)) debug_board_write_str(const char* str){
while(*str)
debug_board_write_byte(*str++);
}
void __attribute__ ((noinline)) debug_board_printf(const char *format,...)
{
va_list ap;
char log_board[300];
va_start (ap, format);
vsnprintf(log_board, sizeof log_board, format, ap);
va_end(ap);
debug_board_write_str(log_board);
}
__attribute__ ((noinline)) void trap(int n)
{
// nothing todo, just see n in debugger. use "bp trap" command
__asm__ __volatile__(
"nop"
:
:"a"(n));
}
*/
// TinyC don't support aliasing of static inline funcs
#ifndef __TINYC__
static inline void BeginDraw(void) __attribute__ ((alias ("begin_draw")));
static inline void EndDraw(void) __attribute__ ((alias ("end_draw")));
static inline void DrawWindow(int x, int y, int w, int h, const char *name,
color_t workcolor, uint32_t style)
__attribute__ ((alias ("sys_create_window")));
static inline void DefineButton(void) __attribute__ ((alias ("define_button")));
static inline void DrawLine(int xs, int ys, int xe, int ye, color_t color)
__attribute__ ((alias ("draw_line")));
static inline void DrawBar(int x, int y, int w, int h, color_t color)
__attribute__ ((alias ("draw_bar")));
static inline void DrawBitmap(void *bitmap, int x, int y, int w, int h)
__attribute__ ((alias ("draw_bitmap")));
static inline uint32_t GetSkinHeight(void) __attribute__ ((alias ("get_skin_height")));
static inline pos_t GetMousePos(int origin) __attribute__ ((alias ("get_mouse_pos")));
static inline uint32_t GetMouseButtons(void) __attribute__ ((alias ("get_mouse_buttons")));
static inline uint32_t GetMouseWheels(void) __attribute__ ((alias ("get_mouse_wheels")));
static inline uint32_t LoadCursor(void *path, uint32_t flags) __attribute__ ((alias ("load_cursor")));
static inline uint32_t SetCursor(uint32_t cursor) __attribute__ ((alias ("set_cursor")));
static inline int DestroyCursor(uint32_t cursor) __attribute__ ((alias ("destroy_cursor")));
static inline uint32_t GetOsEvent(void) __attribute__ ((alias ("get_os_event")));
static inline void *UserAlloc(size_t size) __attribute__ ((alias ("user_alloc")));
static inline int UserFree(void *mem) __attribute__ ((alias ("user_free")));
static inline void* UserRealloc(void *mem, size_t size) __attribute__ ((alias ("user_realloc")));
static inline int *UserUnmap(void *base, size_t offset, size_t size) __attribute__ ((alias ("user_unmap")));
static inline ufile_t LoadFile(const char *path) __attribute__ ((alias ("load_file")));
static inline void GetProcInfo(char *info) __attribute__ ((alias ("get_proc_info")));
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,194 +0,0 @@
/* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#ifndef _MATH_H
#define _MATH_H
//extern int stdcall integer(float number);
extern double acos(double _x);
extern double asin(double _x);
extern double atan(double _x);
extern double atan2(double _y, double _x);
extern double ceil(double _x);
extern double cos(double _x);
extern double cosh(double _x);
extern double exp(double _x);
extern double fabs(double _x);
extern double floor(double _x);
extern double fmod(double _x, double _y);
extern double frexp(double _x, int *_pexp);
extern double ldexp(double _x, int _exp);
extern double log(double _y);
extern double log10(double _x);
extern double modf(double _x, double *_pint);
extern double pow(double _x, double _y);
extern double sin(double _x);
extern double sinh(double _x);
extern double sqrt(double _x);
extern double tan(double _x);
extern double tanh(double _x);
//#ifndef __STRICT_ANSI__
//#ifndef _POSIX_SOURCE
#define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074
#define M_LOG10E 0.43429448190325182765
#define M_LN2 0.69314718055994530942
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.78539816339744830962
#define M_1_PI 0.31830988618379067154
#define M_2_PI 0.63661977236758134308
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.70710678118654752440
#define PI M_PI
#define PI2 M_PI_2
extern double acosh(double);
extern double asinh(double);
extern double atanh(double);
extern double cbrt(double);
extern double exp10(double _x);
extern double exp2(double _x);
extern double expm1(double);
extern double hypot(double, double);
extern double log1p(double);
extern double log2(double _x);
extern long double modfl(long double _x, long double *_pint);
extern double pow10(double _x);
extern double pow2(double _x);
extern double powi(double, int);
extern void sincos(double *, double *, double);
/* These are in libm.a (Cygnus). You must link -lm to get these */
/* See libm/math.h for comments */
/*
#ifndef __cplusplus
struct exception {
int type;
const char *name;
double arg1;
double arg2;
double retval;
int err;
};
#endif
*/
extern double erf(double);
extern double erfc(double);
extern double gamma(double);
extern int isinf(double);
extern int isnan(double);
extern int finite(double);
extern double j0(double);
extern double j1(double);
extern double jn(int, double);
extern double lgamma(double);
extern double nan(void);
extern double y0(double);
extern double y1(double);
extern double yn(int, double);
extern double logb(double);
extern double nextafter(double, double);
extern double remainder(double, double);
extern double scalb(double, double);
//#ifndef __cplusplus
//extern int matherr(struct exception *);
//#endif
extern double significand(double);
extern double copysign(double, double);
extern int ilogb(double);
extern double rint(double);
extern double scalbn(double, int);
extern double drem(double, double);
extern double gamma_r(double, int *);
extern double lgamma_r(double, int *);
extern float acosf(float);
extern float asinf(float);
extern float atanf(float);
extern float atan2f(float, float);
extern float cosf(float);
extern float sinf(float);
extern float tanf(float);
extern float coshf(float);
extern float sinhf(float);
extern float tanhf(float);
extern float expf(float);
extern float frexpf(float, int *);
extern float ldexpf(float, int);
extern float logf(float);
extern float log10f(float);
extern float modff(float, float *);
extern float powf(float, float);
extern float sqrtf(float);
extern float ceilf(float);
extern float fabsf(float);
extern float floorf(float);
extern float fmodf(float, float);
extern float erff(float);
extern float erfcf(float);
extern float gammaf(float);
extern float hypotf(float, float);
extern int isinff(float);
extern int isnanf(float);
extern int finitef(float);
extern float j0f(float);
extern float j1f(float);
extern float jnf(int, float);
extern float lgammaf(float);
extern float nanf(void);
extern float y0f(float);
extern float y1f(float);
extern float ynf(int, float);
extern float acoshf(float);
extern float asinhf(float);
extern float atanhf(float);
extern float cbrtf(float);
extern float logbf(float);
extern float nextafterf(float, float);
extern float remainderf(float, float);
extern float scalbf(float, float);
extern float significandf(float);
extern float copysignf(float, float);
extern int ilogbf(float);
extern float rintf(float);
extern float scalbnf(float, int);
extern float dremf(float, float);
extern float expm1f(float);
extern float log1pf(float);
extern float gammaf_r(float, int *);
extern float lgammaf_r(float, int *);
double round (double x);
long double roundl (long double x);
#ifndef NAN
# define NAN (__nan__)
#endif
#ifndef INFINITY
# define INFINITY (__inf__)
#endif
//#endif /* !_POSIX_SOURCE */
//#endif /* !__STRICT_ANSI__ */
//#endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
//#ifndef __dj_ENFORCE_FUNCTION_CALLS
//#endif /* !__dj_ENFORCE_FUNCTION_CALLS */
//#ifdef __cplusplus
//}
//#endif
//#endif /* _USE_LIBM_MATH_H */
//#endif /* !__dj_include_math_h_ */
#endif

View File

@ -1,75 +0,0 @@
#ifndef _STDARG_H
#define _STDARG_H
#ifdef __x86_64__
#ifndef _WIN64
//This should be in sync with the declaration on our lib/libtcc1.c
/* GCC compatible definition of va_list. */
typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
union {
unsigned int overflow_offset;
char *overflow_arg_area;
};
char *reg_save_area;
} __va_list_struct;
typedef __va_list_struct va_list[1];
void __va_start(__va_list_struct *ap, void *fp);
void *__va_arg(__va_list_struct *ap, int arg_type, int size, int align);
#define va_start(ap, last) __va_start(ap, __builtin_frame_address(0))
#define va_arg(ap, type) \
(*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type))))
#define va_copy(dest, src) (*(dest) = *(src))
#define va_end(ap)
#else /* _WIN64 */
typedef char *va_list;
#define va_start(ap,last) __builtin_va_start(ap,last)
#define va_arg(ap,type) (ap += 8, sizeof(type)<=8 ? *(type*)ap : **(type**)ap)
#define va_copy(dest, src) ((dest) = (src))
#define va_end(ap)
#endif
#elif __arm__
typedef char *va_list;
#define _tcc_alignof(type) ((int)&((struct {char c;type x;} *)0)->x)
#define _tcc_align(addr,type) (((unsigned)addr + _tcc_alignof(type) - 1) \
& ~(_tcc_alignof(type) - 1))
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
#define va_arg(ap,type) (ap = (void *) ((_tcc_align(ap,type)+sizeof(type)+3) \
&~3), *(type *)(ap - ((sizeof(type)+3)&~3)))
#define va_copy(dest, src) (dest) = (src)
#define va_end(ap)
#elif defined(__aarch64__)
typedef struct {
void *__stack;
void *__gr_top;
void *__vr_top;
int __gr_offs;
int __vr_offs;
} va_list;
#define va_start(ap, last) __va_start(ap, last)
#define va_arg(ap, type) __va_arg(ap, type)
#define va_end(ap)
#define va_copy(dest, src) ((dest) = (src))
#else /* __i386__ */
typedef char *va_list;
/* only correct for i386 */
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
#define va_copy(dest, src) (dest) = (src)
#define va_end(ap)
#endif
/* fix a buggy dependency on GCC in libio.h */
typedef va_list __gnuc_va_list;
#define _VA_LIST_DEFINED
#endif /* _STDARG_H */

View File

@ -1,11 +0,0 @@
#ifndef _STDBOOL_H
#define _STDBOOL_H
/* ISOC99 boolean */
#define bool _Bool
#define true 1
#define false 0
#define __bool_true_false_are_defined 1
#endif /* _STDBOOL_H */

View File

@ -1,46 +0,0 @@
#ifndef _STDDEF_H
#define _STDDEF_H
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ssize_t;
typedef __WCHAR_TYPE__ wchar_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __PTRDIFF_TYPE__ intptr_t;
typedef __SIZE_TYPE__ uintptr_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
typedef signed long long int int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
#endif
#ifndef NULL
#define NULL ((void*)0)
#endif
#define offsetof(type, field) ((size_t)&((type *)0)->field)
void *alloca(size_t size);
#endif
/* Older glibc require a wint_t from <stddef.h> (when requested
by __need_wint_t, as otherwise stddef.h isn't allowed to
define this type). Note that this must be outside the normal
_STDDEF_H guard, so that it works even when we've included the file
already (without requiring wint_t). Some other libs define _WINT_T
if they've already provided that type, so we can use that as guard.
TCC defines __WINT_TYPE__ for us. */
#if defined (__need_wint_t)
#ifndef _WINT_T
#define _WINT_T
typedef __WINT_TYPE__ wint_t;
#endif
#undef __need_wint_t
#endif

View File

@ -1 +0,0 @@
#include <stddef.h>

View File

@ -1,128 +0,0 @@
#ifndef stdio_h
#define stdio_h
#include "kolibrisys.h"
#include <stdarg.h>
/* use stdarg.h
typedef char *va_list;
#define _roundsize(n) ( (sizeof(n) + 3) & ~3 )
#define va_start(ap,v) (ap = (va_list)&v+_roundsize(v))
#define va_arg(ap,t) ( *(t *)((ap += _roundsize(t)) - _roundsize(t)) )
#define va_end(ap) (ap = (va_list)0)
*/
#ifndef NULL
# define NULL ((void*)0)
#endif
typedef unsigned int fpos_t; // 32bit is not enough! 4Gb limit
typedef unsigned int size_t;
int format_print(char *dest, size_t maxlen,const char *fmt0, va_list argp);
typedef struct {
char* buffer;
dword buffersize;
dword filesize; // too small
int filepos; // too small, may be -1
char* filename;
int mode;
int ungetc_buf;
dword buffer_start; // 1st byte position
dword buffer_end; // points after last buffered data
} FILE;
#define stderr ((FILE*)3) /* works only for fprintf!!! */
#define FILE_OPEN_READ 0
#define FILE_OPEN_WRITE 1
#define FILE_OPEN_APPEND 2
#define FILE_OPEN_TEXT 4
#define FILE_OPEN_PLUS 8
#define EOF (-1)
#define BUFSIZ (4096)
#define FILENAME_MAX (0x400)
extern FILE* fopen(const char* filename, const char *mode);
extern int fclose(FILE* file);
extern int feof(FILE* file);
extern int fflush(FILE* file);
extern int fgetc(FILE* file);
extern int fgetpos(FILE* file,fpos_t* pos);
extern int fsetpos(FILE* file,const fpos_t* pos);
extern int fputc(int c,FILE* file);
extern int fread(void* buffer,int size,int count,FILE* file);
extern int fwrite(void *buffer,int size,int count,FILE* file);
extern long ftell(FILE* file);
#define SEEK_CUR 0
#define SEEK_END 1
#define SEEK_SET 2
extern int fseek(FILE* file,long offset,int origin);
extern void rewind(FILE* file);
extern int cdecl fprintf(FILE* file, const char* format,...);
extern int fscanf(FILE* file,const char* format,...);
extern int ungetc(int c,FILE* file);
extern int cdecl printf(const char *format,...);
extern int vsnprintf(char *dest, size_t size,const char *format,va_list ap);
extern int cdecl snprintf(char *dest, size_t size, const char *format,...);
extern int cdecl sprintf(char *dest,const char *format,...);
#define getc(a) fgetc(a)
#define putc(a, b) fputc(a, b)
char * fgets (char * str, int num, FILE * stream);
int putchar (int ch);
int getchar (void);
int puts (const char * str);
char * gets (char * str);
typedef int (*virtual_getc)(void *sp, const void *obj);
typedef void (*virtual_ungetc)(void *sp, int c, const void *obj);
int format_scan(const void *src, const char *fmt, va_list argp, virtual_getc vgetc, virtual_ungetc vungetc);
int vscanf ( const char * format, va_list arg );
int scanf ( const char * format, ...);
int vsscanf ( const char * s, const char * format, va_list arg );
int sscanf ( const char * s, const char * format, ...);
int vfscanf ( FILE * stream, const char * format, va_list arg );
int fputs ( const char * str, FILE * file );
void clearerr ( FILE * stream );
int ferror ( FILE * stream );
void perror ( const char * str );
int vprintf ( const char * format, va_list arg );
int vsprintf (char * s, const char * format, va_list arg );
int vfprintf ( FILE * stream, const char * format, va_list arg );
int tiny_sprintf (char * s, const char * format, ... );
int tiny_snprintf (char * s, size_t n, const char * format, ... );
int tiny_vsnprintf (char * s, size_t n, const char * format, va_list args );
// support %c, %s, %d, %x, %u, %% for 32-bit values only. no width specs, left align
// always zero-ended
extern int errno;
/* errors codes from KOS, but minus */
#ifndef E_SUCCESS
# define E_SUCCESS (0)
# define E_UNSUPPORTED (-2)
# define E_UNKNOWNFS (-3)
# define E_NOTFOUND (-5)
# define E_EOF (-6)
# define E_INVALIDPTR (-7)
# define E_DISKFULL (-8)
# define E_FSYSERROR (-9)
# define E_ACCESS (-10)
# define E_HARDWARE (-11)
# define E_NOMEM (-12)
/* conversion errors */
# define ERANGE (-20)
# define EINVAL (-21)
/* program run and pipe errors */
# define E_NOMEM2 (-30)
# define E_FILEFMT (-31)
# define E_TOOMANY (-32)
# define E_PARAM (-33)
#endif
#endif

View File

@ -1,77 +0,0 @@
#ifndef stdlib_h
#define stdlib_h
#include "kolibrisys.h"
#define RAND_MAX 65535
#ifndef NULL
# define NULL ((void*)0)
#endif
#define abs(i) (((i)<0)?(-(i)):(i))
#define labs(li) abs(li)
#define min(a, b) ((a)<(b) ? (a) : (b))
#define max(a, b) ((a)>(b) ? (a) : (b))
extern int atoib(char *s,int b);
extern int atoi(char *s);
extern char *itoab(unsigned int n,char* s,int b);
extern char *__itoa(int n,char* s);
// function using KOS syscalls
extern void* stdcall sysmalloc(dword size);
extern void stdcall sysfree(void *pointer);
extern void* stdcall sysrealloc(void* pointer,dword size);
extern void* syscalloc (size_t num, size_t size);
// suballocator functions
extern void* wtmalloc(size_t size);
extern void wtfree(void *pointer);
extern void* wtrealloc(void* pointer, size_t size);
extern void* wtcalloc (size_t num, size_t size);
extern int wtmalloc_freelist_check();
extern int wtmalloc_poiner_check(void *ptr);
extern void wtmalloc_freelist_print();
#ifdef USESYSALLOC
#define malloc(x) sysmalloc(x)
#define free(x) sysfree(x)
#define realloc(x,y) sysrealloc(x,y)
#define calloc(x,y) syscalloc(x,y)
#else
#define malloc(x) wtmalloc(x)
#define free(x) wtfree(x)
#define realloc(x,y) wtrealloc(x,y)
#define calloc(x,y) wtcalloc(x,y)
#endif
extern int rand (void);
extern void srand (unsigned int seed);
double strtod (const char* str, char** endptr);
long double strtold (const char* str, char** endptr);
float strtof (const char* str, char** endptr);
long int strtol (const char* str, char** endptr, int base);
#define strtoul(s, ep, b) ((unsigned long int)strtol(s, ep, b))
void exit (int status); /* close console if was initialized, also stay window [finished] when status is error < 0 */
#define abort() exit(-1)
typedef struct {
int quot;
int rem;
} div_t;
typedef div_t ldiv_t;
div_t div (int numer, int denom);
#define ldiv(a, b) div(a, b)
#define atol(a) atoi(a)
#define atof(a) strtod(a, NULL)
#endif

View File

@ -1,35 +0,0 @@
#ifndef string_h
#define string_h
typedef unsigned int size_t;
extern void* memchr(const void*,int,size_t);
extern int memcmp(const void*,const void*,size_t);
extern void* memcpy(void*,const void*,size_t);
extern void* memmove(void*,const void*,size_t);
extern void* memset(void*,int,size_t);
extern char* strcat(char*,const char*);
extern char* strchr(const char*,int);
extern int strcmp(const char*,const char*);
extern int strcoll(const char*,const char*);
extern char* strcpy(char*,const char*);
extern size_t strcspn(const char*,const char*);
extern int strlen(const char*);
extern char* strncat(char*,const char*,size_t);
extern int strncmp(const char*,const char*,size_t);
extern char* strncpy(char*,const char*,size_t);
extern char* strpbrk(const char*,const char*);
extern char* strrchr(const char*,int);
extern size_t strspn(const char*,const char*);
extern char* strstr(const char*,const char*);
extern char* strtok(char*,const char*);
extern int strxfrm(char*,const char*,int);
extern char* strdup(const char*);
extern char* strrev(char *p);
char * strerror ( int errnum );
#ifndef NULL
# define NULL ((void*)0)
#endif
#endif

View File

@ -1,29 +0,0 @@
#ifndef _TIME_H
#define _TIME_H
typedef unsigned long int clock_t;
typedef unsigned long int time_t;
#define clock() get_tick_count()
#define CLOCKS_PER_SEC 100
struct tm {
int tm_sec; /* seconds after the minute 0-61*/
int tm_min; /* minutes after the hour 0-59 */
int tm_hour; /* hours since midnight 0-23 */
int tm_mday; /* day of the month 1-31 */
int tm_mon; /* months since January 0-11 */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday 0-6 */
int tm_yday; /* days since January 1 0-365 */
int tm_isdst; /* Daylight Saving Time flag */
};
time_t mktime (struct tm * timeptr);
time_t time (time_t* timer);
struct tm * localtime (const time_t * timer); /* non-standard! ignore parameter and return just time now, not generate tm_isdst, tm_yday, tm_wday == -1 */
double difftime (time_t end, time_t beginning);
extern struct tm __buffertime;
#endif

View File

@ -1,12 +0,0 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#ifndef _VARARGS_H
#define _VARARGS_H
#error "TinyCC no longer implements <varargs.h>."
#error "Revise your code to use <stdarg.h>."
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,126 +0,0 @@
see
source/readme.*
source/changelog
source/tcc-doc.info or .texi
building Kolibri version
>make -f Makefile.kos32
========= for compiler developers =========
read .\source\readme_kos32.txt
------ TODO -------
-minimal memory allocator
-more libc stardard functions. see report below
-more Kolibly SysFn wrappers. see \libc\KOSfuncs_inc_status.txt
-add stdin, stderr, stdout emulation íå õâàòàåò stdin, stdout - ìîæíî ñäåëàòü êàê stderr!, íî íàäî âîçèòüñÿ çàîäíî ñ ferror & feof
-getchar, gets if returs errorcode (0, null) - you must exit program, because of closed console window
-ïðè íîðìàëüíîì âûõîäå çàêðûâàòü êîíñîëü
------ errors ------
-not working: default search path are ./include ./lib from executable (under KOS need to use -Bpath_to_ktcc)
--start.o not found using -B (kos) - put near your.c file
-åñëè ïðîåêò ìíîãîôàéëîâûé - .dbg ãåíåðèò äóáëèðóþùèåñÿ ìåòêè äàííûõ, òèïà L.78 ìîæåò óêàçûâàòü íà äðóãîé ñåãìåíò (
-.dbg sometimes generated improperly for source code labels
----- fixed errors ------
-if static var sized more than 14096+ -> crash compiled .exe (kos)
(^ default stack size set at compile time tccmeos:177 is below 4k)
FIX - use -stack=1280000 option
-con_set_title is NULL. fixed 180128
========= libc ===========
-no "finished" in title of console program after exit console - use con_exit()
-used system memory allocator (4096 bytes minimum)
libc not complete. overall status:
no files:
limits.h
locale.h
setjmp.h
signal.h
wchar.h
wctype.h
functions absent list:
stdio.h:
remove
rename
tmpfile
tmpnam
freopen
setbuf
setvbuf
stdlib.h:
atexit
getenv
system
bsearch
qsort
mblen
mbtowc
wctomb
mbstowcs
wcstombs
string.h:
strxfrm
time.h: - needs include kos32sys1.h
asctime
ctime
gmtime
localtime - non standard
strftime
Status or libc tests
---FAILED---
strtoul incorrect work with big unsigned > MAX_LONG
---NOT TESTED---
no library fns realized
qsort
time
---HANG---
sscanf
>TEST_F(0x1234p56) - no %a formats
---STACK IS SMALL---
use new -stack=1280000 option to pass test
tstring
strtodlong
--other--
fscanf
-?scanf ignores width specs, '*' and [chars], cant read %a float
-%n counts as parameter
snprintf
-some format misturbances
-may incorrect prints unsigned > 2147483647L
ungetc
-ungetc fails if filepos == 0 - by design
all file ops limited to 2Gb

View File

@ -1,23 +0,0 @@
// demonstration conio use, color text
// more info in conio.h
#include <conio.h>
int main()
{
int i;
if (con_init_console_dll()) return 1; // init fail
// con_write_asciiz("\033[0;31;42m test \n"); // red on green bk
for(i = 30; i < 48; i++)
{
con_printf("\033[%dmColor 0x%02X: ", i, i);
con_write_asciiz("Text sample.");
con_printf(" printf %s test %d\n", "small", i);
}
con_exit(0);
}

View File

@ -1,43 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int i;
char c;
FILE *f;
FILE *fin;
FILE *fout;
//write to file
f=fopen("testfile.txt","w");
for(i=0;i<50;i++)
{
fputc('1',f);
}
fclose(f);
//append to file
f=fopen("testfile.txt","a");
for(i=0;i<50;i++)
{
fputc('2',f);
}
fclose(f);
//copy from testfile.txt to copyfile.txt
fin=fopen("testfile.txt","r");
fout=fopen("copyfile.txt","w");
while((c=fgetc(fin))!=EOF)
{
fputc(c,fout);
}
fclose(fin);
fclose(fout);
}

View File

@ -1,61 +0,0 @@
// simple sample by Ghost
#include <stdio.h>
#include <string.h>
#include <kolibrisys.h>
#define FONT0 0
#define FONT1 0x10000000
#define BT_NORMAL 0
#define BT_DEL 0x80000000
#define BT_HIDE 0x40000000
#define BT_NOFRAME 0x20000000
char header[]={" -= C demo programm. Compiled whith KTCC halyavin and andrew_programmer port =- "};
void rotate_str(char *str){
char tmp;
int i;
tmp = str[0];
for(i = 1; str[i]; i++)str[i - 1] = str[i];
str[i - 1] = tmp;
}
void draw_window(){
static int offs = 0;
static int fcolor = 0;
static int col = 0;
_ksys_window_redraw(1);
_ksys_draw_window(100, 100, 300, 120, 0xaabbcc, 2, 0x5080d0, 0, 0x5080d0);
_ksys_write_text(6 - offs, 8, fcolor | FONT0, header, strlen(header));
_ksys_draw_bar(1, 6, 5, 13, 0x05080d0);
_ksys_draw_bar(274, 6, 26, 13, 0x05080d0);
_ksys_make_button(300 - 19, 5, 12, 12, 1 | BT_NORMAL, 0x6688dd);
_ksys_window_redraw(2);
offs = (offs + 1) % 6;
if(!offs)rotate_str(header);
fcolor += (col)?-0x80808:0x80808;
if(fcolor > 0xf80000 || fcolor == 0)col = !col;
}
int main(int argc, char **argv){
while(!0){
switch(_ksys_wait_for_event(10)){
case 2:return 0;
case 3:
if(_ksys_get_button_id() == 1)return 0;
break;
default:
draw_window();
break;
}
}
}

View File

@ -1,148 +0,0 @@
/*
newlib-style window example
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "kos32sys1.h"
struct kolibri_system_colors sys_color_table;
char statusbar[255];
char proc_info[1024];
char text_line[255];
enum BUTTONS
{
BTN_QUIT = 1,
BTN_POP = 10,
BTN_UNLOCK = 11
};
#define FONT_W 8
#define FONT_H 14
#define LINES 10
void draw_window()
{
int win_hight, win_width, i, pos_y = get_skin_height() + 36; // 60 == 24+36
// start redraw
begin_draw();
// define&draw window
sys_create_window(10, 40, 600, 400, "My window", /*sys_color_table.work_area*/0xFFFFFF, 0x13);
get_proc_info(proc_info);
win_width = *(int*)(proc_info + 0x3E); // client, 2A windows
win_hight = *(int*)(proc_info + 0x42); // client, 2E windows
define_button((10 << 16) + 80, (30 << 16) + 20, BTN_POP, sys_color_table.work_button);
draw_text_sys("BUTTON1", 15, 34, 0, 0x90000000 | sys_color_table.work_button_text); //0x80000000 asciiz
define_button((100 << 16) + 100, (30 << 16) + 20, BTN_UNLOCK, sys_color_table.work_button);
draw_text_sys("BUTTTON2", 110, 34, 0, 0x90000000 | sys_color_table.work_button_text);
// display statusbar
draw_bar(6, win_hight - 17, win_width - 11, 12, 0x80000000 | sys_color_table.work_area); //0x80000000 gradient
draw_text_sys(statusbar, 10, win_hight - 15, 0, 0x80000000 | sys_color_table.work_text);
// display strings
for (i = LINES; i > 0; i--)
{
tiny_snprintf (text_line, sizeof text_line, "Line[%d]<<Just a text>>", i);
text_line[(win_width - 10 - 5) / FONT_W + 1] = '\0'; // clip text size, seems to big lines crashing OS, and form len by window size
// draw_number_sys(nbytes, 5, pos_y, 6, 0x10000000); 8x12 font
draw_text_sys(text_line, 5, pos_y, 0, 0x90000000 /*| sys_color_table.work_text*/);
pos_y += FONT_H;
if(pos_y + 29 > win_hight) break; // 12 font + 12 statusbar + 5 border
}
// end redraw
end_draw();
}
int main()
{
int gui_event;
uint32_t pressed_button = 0, mouse_button;
pos_t mouse_pos;
strcpy(statusbar, "Program running...Double click on TEXT for details");
get_system_colors(&sys_color_table);
set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside
do /* Start of main activity loop */
{
// gui_event = wait_for_event(10); // 100 = 1 sec, case you have background work
gui_event = get_os_event();
switch(gui_event)
{
case KOLIBRI_EVENT_NONE:
// background work
break;
case KOLIBRI_EVENT_REDRAW:
draw_window();
break;
case KOLIBRI_EVENT_KEY:
// scroll
break;
case KOLIBRI_EVENT_BUTTON:
pressed_button = get_os_button();
switch (pressed_button)
{
case BTN_POP:
strcpy(statusbar, "POP pressed....");
draw_window();
break;
case BTN_UNLOCK:
strcpy(statusbar, "UNLOCK pressed....");
draw_window();
break;
case BTN_QUIT:
return 0;
break;
}
break;
case KOLIBRI_EVENT_MOUSE:
mouse_pos = get_mouse_pos(POS_WINDOW); // window relative
mouse_button = get_mouse_eventstate();
debug_board_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button);
if (mouse_button & (1<<24)) // double click
{
int n = (mouse_pos.y - 60) / FONT_H;
if (n < 0 || n >= LINES) break;
debug_board_printf("click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
tiny_sprintf(statusbar, "click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
draw_window();
}
// ignore
break;
}
} while(1) ; /* End of main activity loop */
return 0;
}
void __attribute__ ((noinline)) debug_board_write_str(const char* str){
while(*str)
debug_board_write_byte(*str++);
}
void __attribute__ ((noinline)) debug_board_printf(const char *format,...)
{
va_list ap;
char log_board[300];
va_start (ap, format);
tiny_vsnprintf(log_board, sizeof log_board, format, ap);
va_end(ap);
debug_board_write_str(log_board);
}

View File

@ -1,43 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int i;
char c;
FILE *f;
FILE *fin;
FILE *fout;
//write to file
f=fopen("testfile.txt","w");
for(i=0;i<50;i++)
{
fputc('1',f);
}
fclose(f);
//append to file
f=fopen("testfile.txt","a");
for(i=0;i<50;i++)
{
fputc('2',f);
}
fclose(f);
//copy from testfile.txt to copyfile.txt
fin=fopen("testfile.txt","r");
fout=fopen("copyfile.txt","w");
while((c=fgetc(fin))!=EOF)
{
fputc(c,fout);
}
fclose(fin);
fclose(fout);
}