mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-29 01:39:41 +03:00
Fix gcc version of backy and add to autobuild
git-svn-id: svn://kolibrios.org@8467 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b7804a951e
commit
e3201d94c3
@ -1,104 +0,0 @@
|
||||
|
||||
/*
|
||||
* Backy_lib.h
|
||||
* Author: JohnXenox aka Aleksandr Igorevich.
|
||||
*/
|
||||
|
||||
#ifndef __jxl_Date_get_h__
|
||||
#define __jxl_Date_get_h__
|
||||
|
||||
#ifdef ___TINY_C___
|
||||
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef char int8_t;
|
||||
typedef short int int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long long int64_t;
|
||||
|
||||
static inline int32_t saveFile(uint32_t nbytes, uint8_t *data, uint32_t enc, uint8_t *path)
|
||||
{
|
||||
int32_t val;
|
||||
|
||||
uint8_t dt[28]; // basic information structure.
|
||||
|
||||
(uint32_t) dt[0] = 2; // subfunction number.
|
||||
(uint32_t) dt[4] = 0; // reserved.
|
||||
(uint32_t) dt[8] = 0; // reserved.
|
||||
(uint32_t) dt[12] = nbytes; // number of bytes to write.
|
||||
(uint8_t *) dt[16] = data; // pointer to data.
|
||||
(uint32_t) dt[20] = enc; // string encoding (0 = default, 1 = cp866, 2 = UTF-16LE, 3 = UTF-8).
|
||||
(uint8_t *) dt[24] = path; // pointer to path.
|
||||
|
||||
__asm__ __volatile__("int $0x40":"=a"(val):"a"(80), "b"(&dt));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline int32_t saveFile(uint32_t nbytes, uint8_t *data, uint32_t enc, uint8_t *path)
|
||||
{
|
||||
int32_t val;
|
||||
|
||||
struct file_op_t
|
||||
{
|
||||
uint32_t fn;
|
||||
uint32_t reserved0;
|
||||
uint32_t reserved1;
|
||||
uint32_t number_of_bytes_to_write;
|
||||
void * pointer_to_data;
|
||||
char path[1];
|
||||
} *file_op = calloc(sizeof(*file_op) + strlen(path) + 2, 1); // FIXME: Not works on UTF16LE enc
|
||||
|
||||
file_op->fn = 2;
|
||||
file_op->number_of_bytes_to_write = nbytes;
|
||||
file_op->pointer_to_data = data;
|
||||
if (enc != 0)
|
||||
{
|
||||
file_op->path[0] = enc;
|
||||
strcpy(file_op->path + 1, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(file_op->path, path);
|
||||
}
|
||||
|
||||
asm volatile ("int $0x40":"=a"(val):"a"(80), "b"(file_op));
|
||||
return val;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static inline uint32_t getDate(void)
|
||||
{
|
||||
uint32_t date;
|
||||
__asm__ __volatile__("int $0x40":"=a"(date):"a"(29));
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline uint32_t getTime(void)
|
||||
{
|
||||
uint32_t time;
|
||||
__asm__ __volatile__("int $0x40":"=a"(time):"a"(3));
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static inline void *openFile(uint32_t *length, const uint8_t *path)
|
||||
{
|
||||
uint8_t *fd;
|
||||
|
||||
__asm__ __volatile__ ("int $0x40":"=a"(fd), "=d"(*length):"a" (68), "b"(27),"c"(path));
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
#endif
|
@ -9,38 +9,6 @@
|
||||
* Works from command line, only!
|
||||
*/
|
||||
|
||||
|
||||
// Copied from TCC
|
||||
char* strrev(char *p)
|
||||
{
|
||||
char *q = p, *res = p, z;
|
||||
while(q && *q) ++q; /* find eos */
|
||||
for(--q; p < q; ++p, --q)
|
||||
{
|
||||
z = *p;
|
||||
*p = *q;
|
||||
*q = z;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
char* itoab(unsigned int n, char* s, int b)
|
||||
{
|
||||
char *ptr;
|
||||
int lowbit;
|
||||
ptr = s;
|
||||
b >>= 1;
|
||||
do {
|
||||
lowbit = n & 1;
|
||||
n = (n >> 1) & 0x7FFFFFFF;
|
||||
*ptr = ((n % b) << 1) + lowbit;
|
||||
if(*ptr < 10) *ptr += '0'; else *ptr += 55;
|
||||
++ptr;
|
||||
} while(n /= b);
|
||||
*ptr = 0;
|
||||
return strrev(s);
|
||||
}
|
||||
|
||||
|
||||
#define CREATION_DATE "2020.05.27"
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -48,7 +16,6 @@ char* itoab(unsigned int n, char* s, int b)
|
||||
#include <string.h>
|
||||
#include "console_obj.h"
|
||||
|
||||
#include "Backy_lang.h"
|
||||
#include "Backy_lib.h"
|
||||
|
||||
int date = 0;
|
||||
@ -421,6 +388,7 @@ int main(int argc, char** argv)
|
||||
return 13;
|
||||
}
|
||||
|
||||
return checkStateOnSave(saveFile(length, data, 0, path_out));
|
||||
|
||||
saveFile(length, data, 0, path_out);//return checkStateOnSave(saveFile(length, data, 0, path_out));
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,37 @@
|
||||
|
||||
#ifndef __Backy_lib_h__
|
||||
#define __Backy_lib_h__
|
||||
|
||||
// Copied from TCC
|
||||
char* strrev(char *p)
|
||||
{
|
||||
char *q = p, *res = p, z;
|
||||
while(q && *q) ++q; /* find eos */
|
||||
for(--q; p < q; ++p, --q)
|
||||
{
|
||||
z = *p;
|
||||
*p = *q;
|
||||
*q = z;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
char* itoab(unsigned int n, char* s, int b)
|
||||
{
|
||||
char *ptr;
|
||||
int lowbit;
|
||||
ptr = s;
|
||||
b >>= 1;
|
||||
do {
|
||||
lowbit = n & 1;
|
||||
n = (n >> 1) & 0x7FFFFFFF;
|
||||
*ptr = ((n % b) << 1) + lowbit;
|
||||
if(*ptr < 10) *ptr += '0'; else *ptr += 55;
|
||||
++ptr;
|
||||
} while(n /= b);
|
||||
*ptr = 0;
|
||||
return strrev(s);
|
||||
}
|
||||
|
||||
/*
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
@ -43,37 +74,34 @@ static inline void *openFile(uint32_t *length, const uint8_t *path)
|
||||
return fd;
|
||||
}
|
||||
|
||||
// FILE SAVING NOT WORKING
|
||||
/*
|
||||
struct saveFile__
|
||||
struct saveFileStruct
|
||||
{
|
||||
int num;
|
||||
int res_;
|
||||
int res;
|
||||
int nbyte;
|
||||
int p1;
|
||||
int p2;
|
||||
int p3;
|
||||
int p4;
|
||||
|
||||
char* data_;
|
||||
int enc_;
|
||||
char* path_;
|
||||
char* p5;
|
||||
int p6;
|
||||
char* p7;
|
||||
};
|
||||
*/
|
||||
|
||||
static inline int32_t saveFile(uint32_t nbytes, uint8_t *data, uint32_t enc, uint8_t *path)
|
||||
{
|
||||
int32_t val;
|
||||
/*
|
||||
struct saveFile__ dt;
|
||||
//uint8_t dt[28]; // basic information structure.
|
||||
|
||||
dt.num = 2; // subfunction number.
|
||||
dt.res_= 0; // reserved.
|
||||
dt.res = 0; // reserved.
|
||||
dt.nbyte = nbytes; // number of bytes to write.
|
||||
dt.data_ = data; // pointer to data.
|
||||
dt.enc_ = enc; // string encoding (0 = default, 1 = cp866, 2 = UTF-16LE, 3 = UTF-8).
|
||||
dt.path_ = path; // pointer to path.
|
||||
|
||||
__asm__ __volatile__("int $0x40":"=a"(val):"a"(80), "b"(&dt));
|
||||
*/
|
||||
struct saveFileStruct dt; // basic information structure.
|
||||
|
||||
dt.p1 = 2; // subfunction number.
|
||||
dt.p2= 0; // reserved.
|
||||
dt.p3 = 0; // reserved.
|
||||
dt.p4 = nbytes; // number of bytes to write.
|
||||
dt.p5 = data; // pointer to data.
|
||||
dt.p6 = enc; // string encoding (0 = default, 1 = cp866, 2 = UTF-16LE, 3 = UTF-8).
|
||||
dt.p7 = path; // pointer to path.
|
||||
|
||||
__asm__ __volatile__("int $0x40":"=a"(val):"a"(80), "b"(&dt):"memory");
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -9,19 +9,17 @@ CFLAGS = -c -fno-ident -O2 -fomit-frame-pointer -fno-ident -U__WIN32__ -U_Win32
|
||||
INCLUDES = -I $(SDK_DIR)/sources/newlib/libc/include
|
||||
LIBPATH = -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib
|
||||
|
||||
ifndef LANG_backy
|
||||
LANG_backy = lang_en
|
||||
ifndef LANG_
|
||||
LANG_ = lang_en
|
||||
endif
|
||||
|
||||
default: backy
|
||||
|
||||
backy: $(OBJECTS) Makefile
|
||||
echo "#define $(LANG_backy)" > Backy_lang.h
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -o Backy.o Backy.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -D$(LANG_) -o Backy.o Backy.c
|
||||
$(LD) $(LDFLAGS) $(LIBPATH) --subsystem console -o Backy Backy.o -lgcc -lc.dll
|
||||
kos32-strip -s Backy -o Backy
|
||||
objcopy Backy -O binary
|
||||
rm Backy.o
|
||||
rm Backy_lang.h
|
||||
clean:
|
||||
rm Backy
|
||||
|
12
programs/develop/backy/gcc_version/Tupfile.lua
Executable file
12
programs/develop/backy/gcc_version/Tupfile.lua
Executable file
@ -0,0 +1,12 @@
|
||||
if tup.getconfig("NO_GCC") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_gcc.lua")
|
||||
tup.include(HELPERDIR .. "/use_newlib.lua")
|
||||
|
||||
if tup.getconfig("LANG") == "ru"
|
||||
then CFLAGS = CFLAGS .. " -Dlang_ru"
|
||||
else CFLAGS = CFLAGS .. " -Dlang_en"
|
||||
end
|
||||
|
||||
compile_gcc{"backy.c"}
|
||||
link_gcc("backy")
|
@ -1,7 +1,6 @@
|
||||
Port backy to gcc
|
||||
Files not working yet
|
||||
Languages:
|
||||
Eng:
|
||||
make
|
||||
Rus:
|
||||
env LANG_backy=lang_ru make
|
||||
env LANG_=lang_ru make
|
||||
|
Loading…
Reference in New Issue
Block a user