- Duplicate functionality files removed;
- Refactoring of file handling functions;
- Removed broken impliments.
Gears (C + TinyGL):
- Removed because it duplicates an existing example on Fasm and uses unsupported wrappers on the KOS API.
KosJS:
- Removed. The MuJS port is too old and not used anywhere. Support is not profitable.
Backy:
- Removed useless GCC version. Support is not profitable.
DGen-SDL and SQLite3
- Fix after removing broken "dirent.h".
Fridge:
- Moving the KOS API wrapper to avoid compilation errors.
Udis86, uARM and 8086tiny:
- Fix after removing redundant "kos_LoadConsole.h".


git-svn-id: svn://kolibrios.org@9952 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat
2024-01-04 22:20:35 +00:00
parent c6d4aab9c5
commit 9562f01892
112 changed files with 344 additions and 22302 deletions

View File

@@ -0,0 +1,11 @@
/*
* Copyright (C) KolibriOS team 2004-2024. All rights reserved.
* Distributed under terms of the GNU General Public License
*/
#include <sys/ksys.h>
int chdir(char* dir){
_ksys_setcwd(dir);
return 0;
}

View File

@@ -15,7 +15,7 @@
#include <errno.h>
#include <stdlib.h>
#include <sys/unistd.h>
#include <sys/kos_io.h>
#include <sys/ksys.h>
#include "glue.h"
#include "io.h"

View File

@@ -1,3 +1,8 @@
/*
* Copyright (C) KolibriOS team 2004-2024. All rights reserved.
* Distributed under terms of the GNU General Public License
*/
#include <_ansi.h>
#include <stdio.h>
#include <sys/unistd.h>
@@ -16,28 +21,8 @@ static int console_read(const char *path, void *buff,
size_t offset, size_t count, size_t *done)
{
char *p = buff;
/*int cnt = 0;
short c;
char ch;*/
con_gets(p, count+1);
*done = strlen(p);
// __asm__ volatile("int3");
/*
do
{
c = con_getch2();
printf("%d\n",(char)c);
ch = (char)c;
if(ch != 0)
{
p[cnt] = ch != 0x0D ? ch : 0x0A;
con_write_string(p+cnt, 1);
cnt++;
}
}while(ch != 0x0D);
*done = cnt;
*/
return 0;
}
@@ -48,7 +33,7 @@ static int console_write(const char *path, const void *buff,
*writes = count;
return 0;
};
}
void __init_conio()
{

View File

@@ -1,25 +0,0 @@
#include <sys/types.h>
#include <sys/kos_io.h>
int create_file(const char *path)
{
int retval;
__asm__ __volatile__ (
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %1, 1(%%esp) \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $2 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"r" (path)
:"ebx");
return retval;
};

View File

@@ -1,48 +0,0 @@
#include <sys/types.h>
#include <sys/kos_io.h>
int get_fileinfo(const char *path, fileinfo_t *info)
{
int retval;
__asm__ __volatile__ (
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %1, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $5 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"r" (path), "b" (info));
return retval;
};
int set_fileinfo(const char *path, fileinfo_t *info)
{
int retval;
__asm__ __volatile__ (
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %1, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $6 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"r" (path), "b" (info));
return retval;
};

View File

@@ -1,26 +0,0 @@
#include <sys/types.h>
#include <sys/kos_io.h>
int set_file_size(const char *path, unsigned size)
{
int retval;
__asm__ __volatile__(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl $0 \n\t"
"pushl %%ebx \n\t"
"push $4 \n\t"
"movl %%esp, %%ebx \n\t"
"movl $70, %%eax \n\t"
"int $0x40 \n\t"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"a" (path), "b" (size));
return retval;
};

View File

@@ -15,7 +15,7 @@
#include <errno.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/kos_io.h>
#include <sys/ksys.h>
#include <sys/stat.h>
#include "glue.h"
#include "io.h"
@@ -25,7 +25,7 @@ _DEFUN (fstat, (fd, buf),
int fd _AND
struct stat *buf)
{
fileinfo_t info;
ksys_file_info_t info;
struct tm time;
__io_handle *ioh;
@@ -33,8 +33,8 @@ _DEFUN (fstat, (fd, buf),
if( (fd < 0) || (fd >=64) )
{
errno = EBADF;
return (-1);
};
return -1;
}
memset (buf, 0, sizeof (* buf));
@@ -47,7 +47,7 @@ _DEFUN (fstat, (fd, buf),
{
ioh = &__io_tab[fd];
get_fileinfo(ioh->name, &info);
_ksys_file_info(ioh->name, &info);
if (info.attr & 0x10)
buf->st_mode = S_IFDIR;

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) KolibriOS team 2004-2024. All rights reserved.
* Distributed under terms of the GNU General Public License
*/
#include <stdlib.h>
#include <sys/ksys.h>
char *getcwd(char *buf, unsigned size){
if(!buf){
if((buf = malloc(size))==NULL){
return NULL;
}
}
_ksys_getcwd(buf, size);
return(buf);
}

View File

@@ -1,31 +1,15 @@
/*
* Copyright (C) KolibriOS team 2004-2024. All rights reserved.
* Distributed under terms of the GNU General Public License
*/
#include <sys/types.h>
#include <sys/kos_io.h>
#include <sys/ksys.h>
int read_file(const char *path, void *buff,
size_t offset, size_t count, size_t *reads)
{
int retval;
int d0;
__asm__ __volatile__(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl %%edx \n\t"
"pushl $0 \n\t"
"pushl %%ecx \n\t"
"pushl $0 \n\t"
"movl %%esp, %%ebx \n\t"
"mov $70, %%eax \n\t"
"int $0x40 \n\t"
"testl %%esi, %%esi \n\t"
"jz 1f \n\t"
"movl %%ebx, (%%esi) \n\t"
"1:"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(reads));
return retval == 6 ? 0 : retval;
};
ksys_file_status_t st = _ksys_file_read(path, offset, count, buff);
*reads = st.rw_bytes;
return st.status == KSYS_FS_ERR_EOF ? 0 : st.status;
}

View File

@@ -1,33 +1,20 @@
/*
* Copyright (C) KolibriOS team 2004-2024. All rights reserved.
* Distributed under terms of the GNU General Public License
*/
#include <sys/types.h>
#include <errno.h>
#include <sys/kos_io.h>
#include <sys/ksys.h>
int write_file(const char *path,const void *buff,
int write_file(const char *path, const void *buff,
size_t offset, size_t count, size_t *writes)
{
int retval;
__asm__ __volatile__(
"pushl $0 \n\t"
"pushl $0 \n\t"
"movl %%eax, 1(%%esp) \n\t"
"pushl %%ebx \n\t"
"pushl %%edx \n\t"
"pushl $0 \n\t"
"pushl %%ecx \n\t"
"pushl $3 \n\t"
"movl %%esp, %%ebx \n\t"
"mov $70, %%eax \n\t"
"int $0x40 \n\t"
"testl %%esi, %%esi \n\t"
"jz 1f \n\t"
"movl %%ebx, (%%esi) \n\t"
"1:"
"addl $28, %%esp \n\t"
:"=a" (retval)
:"a"(path),"b"(buff),"c"(offset),"d"(count),"S"(writes));
if(retval == 0)
ksys_file_status_t st = _ksys_file_write(path, offset, count, buff);
*writes = st.rw_bytes;
if(!st.status)
return 0;
else if (retval == 8)
else if (st.status == KSYS_FS_ERR_8)
return ENOSPC;
return -1;
};
}

View File

@@ -1,28 +1,30 @@
/*
* Copyright (C) KolibriOS team 2004-2024. All rights reserved.
* Distributed under terms of the GNU General Public License
*/
#include <errno.h>
#include <stdlib.h>
#include <sys/unistd.h>
#include <sys/kos_io.h>
#include <sys/ksys.h>
#include "glue.h"
#include "io.h"
_off_t
_DEFUN (lseek, (fd, pos, whence),
int fd _AND
_off_t pos _AND
int whence)
{
fileinfo_t info;
ksys_file_info_t info;
__io_handle *ioh;
_off_t ret;
if( (fd < 0) || (fd >=64) )
if ((fd < 0) || (fd >=64))
{
errno = EBADF;
return (-1);
};
}
ioh = &__io_tab[fd];
@@ -36,16 +38,16 @@ _DEFUN (lseek, (fd, pos, whence),
break;
case SEEK_END:
{
get_fileinfo(ioh->name, &info);
_ksys_file_info(ioh->name, &info);
ret = pos + info.size;
break;
}
default:
errno = EINVAL;
return (-1);
};
return -1;
}
ioh->offset = ret;
return( ret );
};
return ret;
}

View File

@@ -15,13 +15,20 @@
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/kos_io.h>
#include <sys/ksys.h>
#include "glue.h"
#include "io.h"
#undef erro
#undef errno
extern int errno;
extern int write_file(const char *path,const void *buff,
size_t offset, size_t count, size_t *writes);
extern int read_file(const char *path, void *buff,
size_t offset, size_t count, size_t *reads);
static inline int is_slash(char c)
{
return c=='/' || c=='\\';
@@ -49,7 +56,7 @@ void fix_slashes(char * in,char * out)
}
}
*out='\0';
};
}
void buildpath(char *buf, const char* file)
@@ -89,26 +96,14 @@ __do_until_slash:
*ptr++ = *file++;
}
*ptr = 0;
};
static char *getccwd(char *buf, size_t size)
{
int bsize;
__asm__ __volatile__(
"int $0x40"
:"=a"(bsize)
:"a"(30),"b"(2),"c"(buf), "d"(size)
:"memory");
return buf;
};
}
int open (const char * filename, int flags, ...)
{
char buf[1024];
__io_handle *ioh;
fileinfo_t info;
ksys_file_info_t info;
int iomode, rwmode, offset;
int hid;
int err;
@@ -127,28 +122,28 @@ int open (const char * filename, int flags, ...)
}
else
{
getccwd(buf, 1024);
_ksys_getcwd(buf, 1024);
buildpath(buf, filename);
}
err = get_fileinfo(buf, &info);
err = _ksys_file_info(buf, &info);
if( flags & O_EXCL &&
if (flags & O_EXCL &&
flags & O_CREAT )
{
if( !err )
if (!err)
{
errno = EEXIST;
__io_free(hid);
return (-1);
};
}
}
if( err )
if (err)
{
if(flags & O_CREAT)
err=create_file(buf);
if( err )
err = _ksys_file_create(buf).status;
if(err)
{
errno = EACCES;
__io_free(hid);
@@ -156,8 +151,8 @@ int open (const char * filename, int flags, ...)
};
};
if( flags & O_TRUNC )
set_file_size(buf, 0);
if (flags & O_TRUNC)
_ksys_file_set_size(buf, 0);
ioh = &__io_tab[hid];
@@ -166,25 +161,28 @@ int open (const char * filename, int flags, ...)
iomode = 0;
offset = 0;
if( rwmode == O_RDWR )
if (rwmode == O_RDWR)
iomode |= _READ | _WRITE;
else if( rwmode == O_RDONLY)
else if (rwmode == O_RDONLY)
iomode |= _READ;
else if( rwmode == O_WRONLY)
else if (rwmode == O_WRONLY)
iomode |= _WRITE;
if( flags & O_APPEND )
if (flags & O_APPEND)
{
iomode |= _APPEND;
offset = info.size;
};
}
if( flags & (O_BINARY|O_TEXT) )
if (flags & (O_BINARY|O_TEXT))
{
if( flags & O_BINARY )
if (flags & O_BINARY)
iomode |= _BINARY;
} else
}
else
{
iomode |= _BINARY;
}
ioh->name = strdup(buf);
ioh->offset = offset;
@@ -193,6 +191,4 @@ int open (const char * filename, int flags, ...)
ioh->write = write_file;
return hid;
};
}

View File

@@ -29,7 +29,7 @@ ssize_t read(int fd, void *buf, size_t cnt)
char *buffer = buf;
int rc;
int h;
unsigned amount_read;
size_t amount_read;
int err;
__io_handle *ioh;

View File

@@ -13,7 +13,7 @@
* they apply.
*/
#include <sys/stat.h>
#include <sys/kos_io.h>
#include <sys/ksys.h>
#include <errno.h>
#include <time.h>
#include <string.h>
@@ -28,16 +28,16 @@ _DEFUN (stat, (path, buf),
struct stat *buf)
{
fileinfo_t info;
ksys_file_info_t info;
struct tm time;
if( get_fileinfo(path, &info))
if (_ksys_file_info(path, &info))
{
errno = ENOENT;
return (-1);
};
}
memset (buf, 0, sizeof (* buf));
memset(buf, 0, sizeof (*buf));
buf->st_size = info.size;
@@ -91,4 +91,3 @@ _DEFUN (lstat, (path, buf),
{
return stat(path, buf);
}

View File

@@ -15,7 +15,6 @@
#include <errno.h>
#include <unistd.h>
#include <alloca.h>
#include <sys/kos_io.h>
#include "io.h"
#undef erro