Libs/newlib: Fix sys/ksys.h warnings #93

Open
Egor00f wants to merge 2 commits from Egor00f/kolibrios:Libs-newlib-Fix-sys-ksys.h-warnings into main
2 changed files with 46 additions and 33 deletions

3
.gitignore vendored
View File

@ -7,3 +7,6 @@ ehthumbs_vista.db
### macOS ### ### macOS ###
.DS_Store .DS_Store
._* ._*
# vscode folder
.vscode/

View File

@ -24,6 +24,10 @@
#include <stdbool.h> #include <stdbool.h>
#ifdef __cplusplus #ifdef __cplusplus
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
extern "C" { extern "C" {
#endif #endif
@ -516,7 +520,7 @@ KOSAPI void _ksys_define_button(uint32_t x, uint32_t y, uint32_t w, uint32_t h,
KOSAPI void _ksys_delete_button(uint32_t id) KOSAPI void _ksys_delete_button(uint32_t id)
{ {
asm_inline("int $0x40" ::"a"(8), "d"(id & 0x00FFFFFF | 0x80000000)); asm_inline("int $0x40" ::"a"(8), "d"((id & 0x00FFFFFF) | 0x80000000));
} }
/*============ Function 9 - information on execution thread. ===========*/ /*============ Function 9 - information on execution thread. ===========*/
@ -1075,17 +1079,21 @@ KOSAPI void _ksys_draw_line(int xs, int ys, int xe, int ye, ksys_color_t color)
KOSAPI void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color) KOSAPI void _ksys_draw_number(int number, int x, int y, int len, ksys_color_t color)
{ {
unsigned fmt; unsigned fmt;
fmt = len << 16 | 0x80000000; // no leading zeros + width fmt = (((unsigned int) len) << 16) | 0x80000000; // no leading zeros + width
asm_inline( asm_inline(
"int $0x40" "int $0x40"
: :
: "a"(47), "b"(fmt), "c"(number), "d"((x << 16) | y), "S"(color)); : "a"(47),
"b"(fmt),
"c"(number),
"d"((x << 16) | y),
"S"(color));
} }
KOSAPI void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg) KOSAPI void _ksys_draw_number_bg(unsigned number, int x, int y, int len, ksys_color_t color, ksys_color_t bg)
{ {
unsigned fmt; unsigned fmt;
fmt = len << 16 | 0x80000000; // no leading zeros + width fmt = (((unsigned int) len) << 16) | 0x80000000; // no leading zeros + width
asm_inline( asm_inline(
"int $0x40" "int $0x40"
: :
@ -1141,7 +1149,7 @@ enum KSYS_CLIP_TYPES {
KOSAPI int _ksys_clip_num(void) KOSAPI int _ksys_clip_num(void)
{ {
unsigned val; int val;
asm_inline( asm_inline(
"int $0x40" "int $0x40"
: "=a"(val) : "=a"(val)
@ -1167,7 +1175,7 @@ KOSAPI char* _ksys_clip_get(int n) // returned buffer must be freed by _ksys_fre
KOSAPI int _ksys_clip_set(int n, char* buffer) KOSAPI int _ksys_clip_set(int n, char* buffer)
{ {
unsigned val; int val;
asm_inline( asm_inline(
"int $0x40" "int $0x40"
: "=a"(val) : "=a"(val)
@ -1181,7 +1189,7 @@ KOSAPI int _ksys_clip_set(int n, char* buffer)
KOSAPI int _ksys_clip_pop() KOSAPI int _ksys_clip_pop()
{ {
unsigned val; int val;
asm_inline( asm_inline(
"int $0x40" "int $0x40"
: "=a"(val) : "=a"(val)
@ -1194,7 +1202,7 @@ KOSAPI int _ksys_clip_pop()
KOSAPI int _ksys_clip_unlock() KOSAPI int _ksys_clip_unlock()
{ {
unsigned val; int val;
asm_inline( asm_inline(
"int $0x40" "int $0x40"
: "=a"(val) : "=a"(val)
@ -1223,12 +1231,13 @@ KOSAPI void _ksys_debug_puts(const char* s)
KOSAPI void ksys_draw_bitmap_palette(void* bitmap, int x, int y, int w, int h, int bpp, void* palette, int offset) KOSAPI void ksys_draw_bitmap_palette(void* bitmap, int x, int y, int w, int h, int bpp, void* palette, int offset)
{ {
asm_inline( asm_inline(
"pushl %%ebp\n\t" // save EBP register "pushl %%ebp\n\t" // save EBP register
"movl 0x24(%%ebp), %%ebp\n\t" // 0x24 - "offset" param "movl %0, %%ebp\n\t" // mov offset to EBP register
"int $0x40\n\t" "int $0x40\n\t" // system call
"popl %%ebp" // restore EBP register "popl %%ebp" // restore EBP register
: ::
: "a"(65), "X"(offset),
"a"(65),
"b"(bitmap), "b"(bitmap),
"c"((w << 16) + h), "c"((w << 16) + h),
"d"((x << 16) + y), "d"((x << 16) + y),
@ -1553,7 +1562,7 @@ KOSAPI ksys_file_status_t _ksys_file_read(const char* name, uint64_t offset, uin
f.data_size = size; f.data_size = size;
f.data = buf; f.data = buf;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)name; f.path_ptr = (char*) name;
return _ksys_file(&f); return _ksys_file(&f);
} }
@ -1567,7 +1576,7 @@ KOSAPI ksys_file_status_t _ksys_file_read_dir(const char* name, uint32_t offset,
f.data_size = blocks; f.data_size = blocks;
f.data = buff; f.data = buff;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)name; f.path_ptr = (char*) name;
return _ksys_file(&f); return _ksys_file(&f);
} }
@ -1582,7 +1591,7 @@ KOSAPI ksys_file_status_t _ksys_file_create(const char* name)
f.data_size = 0; f.data_size = 0;
f.data = NULL; f.data = NULL;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)name; f.path_ptr = (char*) name;
return _ksys_file(&f); return _ksys_file(&f);
} }
@ -1595,9 +1604,9 @@ KOSAPI ksys_file_status_t _ksys_file_write(const char* name, uint64_t offset, ui
f.func_num = KSYS_FILE_WRITE; f.func_num = KSYS_FILE_WRITE;
f.offset64 = offset; f.offset64 = offset;
f.data_size = size; f.data_size = size;
f.data = (void*)buf; f.data = (void*) buf;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)name; f.path_ptr = (char*) name;
return _ksys_file(&f); return _ksys_file(&f);
} }
@ -1611,8 +1620,8 @@ KOSAPI int _ksys_file_set_size(const char* name, uint64_t size)
f.data_size = 0; f.data_size = 0;
f.data = NULL; f.data = NULL;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)name; f.path_ptr = (char*) name;
return _ksys_file(&f).status; return (int) _ksys_file(&f).status;
} }
/*========== Function 70, subfunction 5 - get information on file/folder. =====*/ /*========== Function 70, subfunction 5 - get information on file/folder. =====*/
@ -1632,10 +1641,10 @@ KOSAPI int _ksys_file_info(const char* name, ksys_file_info_t* info)
f.func_num = KSYS_FILE_GET_INFO; f.func_num = KSYS_FILE_GET_INFO;
f.offset64 = 0; f.offset64 = 0;
f.data_size = 0; f.data_size = 0;
f.data = (void*)info; f.data = (void*) info;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)name; f.path_ptr = (char*) name;
return _ksys_file(&f).status; return (int) _ksys_file(&f).status;
} }
#define _ksys_dir_info _ksys_file_info #define _ksys_dir_info _ksys_file_info
@ -1658,8 +1667,8 @@ KOSAPI int _ksys_exec(const char* path, char* args, bool debug)
f.debug = debug; f.debug = debug;
f.args = args; f.args = args;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)path; f.path_ptr = (char*) path;
return _ksys_file(&f).status; return (int) _ksys_file(&f).status;
} }
/*========== Function 70, subfunction 8 - delete file/folder. ==========*/ /*========== Function 70, subfunction 8 - delete file/folder. ==========*/
@ -1672,8 +1681,8 @@ KOSAPI int _ksys_file_delete(const char* path)
f.data_size = 0; f.data_size = 0;
f.data = NULL; f.data = NULL;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)path; f.path_ptr = (char*) path;
return _ksys_file(&f).status; return (int) _ksys_file(&f).status;
} }
#define _ksys_rmdir(x) _ksys_file_delete(x) #define _ksys_rmdir(x) _ksys_file_delete(x)
@ -1688,8 +1697,8 @@ KOSAPI int _ksys_mkdir(const char* path)
f.data_size = 0; f.data_size = 0;
f.data = NULL; f.data = NULL;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)path; f.path_ptr = (char*) path;
return _ksys_file(&f).status; return (int) _ksys_file(&f).status;
} }
/*============= Function 70, subfunction 10 - rename/move. =============*/ /*============= Function 70, subfunction 10 - rename/move. =============*/
@ -1698,11 +1707,11 @@ KOSAPI int _ksys_file_rename(const char* name, const char* new_name)
{ {
ksys_file_t f; ksys_file_t f;
f.func_num = KSYS_FILE_REMOVE; f.func_num = KSYS_FILE_REMOVE;
f.data = (void*)new_name; f.data = (void*) new_name;
f.data_size = 0; f.data_size = 0;
f.zero = 0; f.zero = 0;
f.path_ptr = (char*)name; f.path_ptr = (char*) name;
return _ksys_file(&f).status; return (int) _ksys_file(&f).status;
} }
#define _ksys_dir_rename _ksys_file_rename #define _ksys_dir_rename _ksys_file_rename
@ -1810,6 +1819,7 @@ KOSAPI int _ksys_posix_pipe2(int pipefd[2], int flags)
#ifdef __cplusplus #ifdef __cplusplus
} }
#pragma GCC diagnostic pop
#endif #endif
#endif // _KSYS_H_ #endif // _KSYS_H_