forked from KolibriOS/kolibrios
newlib: update
git-svn-id: svn://kolibrios.org@1906 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
|
||||
#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 %0, 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;
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/kos_io.h>
|
||||
|
||||
int delete_file(const char *path)
|
||||
{
|
||||
int retval;
|
||||
__asm__ __volatile__ (
|
||||
"pushl $0 \n\t"
|
||||
"pushl $0 \n\t"
|
||||
"movl %0, 1(%%esp) \n\t"
|
||||
"pushl $0 \n\t"
|
||||
"pushl $0 \n\t"
|
||||
"pushl $0 \n\t"
|
||||
"pushl $0 \n\t"
|
||||
"pushl $8 \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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/kos_io.h>
|
||||
|
||||
void *load_file(const char *path, size_t *len)
|
||||
{
|
||||
fileinfo_t info;
|
||||
size_t bytes;
|
||||
void *file = NULL;
|
||||
|
||||
if( len) *len = 0;
|
||||
|
||||
|
||||
if( !get_fileinfo(path, &info) )
|
||||
{
|
||||
|
||||
file = user_alloc( info.size );
|
||||
read_file(path, file, 0, info.size, &bytes );
|
||||
if( bytes == info.size )
|
||||
{
|
||||
if ( *(uint32_t*)file == 0x4B43504B )
|
||||
{
|
||||
void *tmp = NULL;
|
||||
info.size = ((size_t*)file)[1];
|
||||
tmp = user_alloc(info.size);
|
||||
unpack(file, tmp);
|
||||
user_free(file);
|
||||
file = tmp;
|
||||
}
|
||||
if(len) *len = info.size;
|
||||
};
|
||||
};
|
||||
return file;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/kos_io.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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/kos_io.h>
|
||||
|
||||
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));
|
||||
return retval;
|
||||
};
|
||||
Reference in New Issue
Block a user