fix libck

git-svn-id: svn://kolibrios.org@7172 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
siemargl
2018-03-05 17:53:31 +00:00
parent df2b9b2d5a
commit b7fe2ec210
18 changed files with 782 additions and 185 deletions

View File

@@ -1,4 +1,5 @@
#ifndef __ASSERT_H
#define __ASSERT_H
#ifdef NDEBUG
# define assert(a) (void)0

View File

@@ -1,3 +1,5 @@
#ifndef _CTYPE_H
#define _CTYPE_H
/*
** All character classification functions except isascii().
** Integer argument (c) must be in ASCII range (0-127) for
@@ -35,3 +37,5 @@ extern unsigned short __is[128];
extern unsigned char tolower(unsigned char c);
extern unsigned char toupper(unsigned char c);
#endif

View File

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

View File

@@ -3,6 +3,8 @@
// 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>
@@ -42,7 +44,6 @@ extern "C" {
#define SHM_WRITE 0x01
typedef unsigned int color_t;
@@ -132,6 +133,22 @@ struct ipc_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__(
@@ -524,7 +541,11 @@ void enumerate_libraries(int (*callback)(void *handle, const char* name,
void *user_data);
#endif
// May be next section need to be added in newlibc
///////////////////////////////////////////////////////////////////////////////
/// 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 */
@@ -539,6 +560,107 @@ enum KOLIBRI_GUI_EVENTS {
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
@@ -695,15 +817,7 @@ void shm_close(char *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;
file_op_t file_op;
memset(&file_op, 0, sizeof(file_op));
file_op.fn = 7;
file_op.args = args;
@@ -715,6 +829,55 @@ int start_app(char *app_name, char *args){
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)
@@ -729,7 +892,28 @@ static inline char *getcwd(char *buf, size_t size)
return buf;
}
*/
// end section
/* 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
@@ -753,6 +937,16 @@ void __attribute__ ((noinline)) debug_board_printf(const char *format,...)
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));
}
*/

View File

@@ -1,6 +1,8 @@
/* 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);
@@ -189,3 +191,4 @@ long double roundl (long double x);
//#endif /* _USE_LIBM_MATH_H */
//#endif /* !__dj_include_math_h_ */
#endif

View File

@@ -28,7 +28,7 @@ typedef struct {
int mode;
} FILE;
#define stderr ((FILE*)3) /* works inly for fprintf!!! */
#define stderr ((FILE*)3) /* works only for fprintf!!! */
#define FILE_OPEN_READ 0

View File

@@ -30,7 +30,7 @@ long int strtol (const char* str, char** endptr, int base);
void* calloc (size_t num, size_t size);
#define exit(a) _ksys_exit()
void exit (int status); /* close console if was initialized, also stay window [finished] when status is error < 0 */
#define abort() exit(-1)
typedef struct {

View File

@@ -0,0 +1,29 @@
#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