Clib create_file, read_file, write_file: watcom-specific implementation

git-svn-id: svn://kolibrios.org@711 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-02-05 06:08:42 +00:00
parent 039660a246
commit 54786d007d
10 changed files with 1184 additions and 1011 deletions

View File

@ -42,8 +42,8 @@ WRect
WFileName WFileName
10 10
clib_r.tgt clib_r.tgt
0 21
0 50
11 11
VComponent VComponent
12 12
@ -59,5 +59,5 @@ WFileName
7 7
crt.tgt crt.tgt
0 0
32 12
8 8

View File

@ -99,7 +99,28 @@ void _stdcall write_text(int x,int y,int color,char* text,int len);
#endif #endif
typedef struct
{ unsigned attr;
unsigned flags;
unsigned cr_time;
unsigned cr_date;
unsigned acc_time;
unsigned acc_date;
unsigned mod_time;
unsigned mod_date;
unsigned size;
unsigned size_high;
} FILEINFO;
unsigned init_heap(void); unsigned init_heap(void);
void *user_alloc(unsigned size);
unsigned user_free(void *);
int create_file(const char *name);
int get_fileinfo(const char *name,FILEINFO* pinfo);
int read_file (const char *name,void *buff, unsigned offset, unsigned count,unsigned *reads);
int write_file(const char *name,const void *buff,unsigned offset,unsigned count,unsigned *writes);
#pragma aux init_heap = \ #pragma aux init_heap = \
"mov EAX, 68" \ "mov EAX, 68" \
@ -108,10 +129,6 @@ unsigned init_heap(void);
value [EAX] \ value [EAX] \
modify [ EBX ]; modify [ EBX ];
void *user_alloc(unsigned size);
void *user_alloc(unsigned size);
#pragma aux user_alloc = \ #pragma aux user_alloc = \
"mov EAX, 68" \ "mov EAX, 68" \
"mov EBX, 12" \ "mov EBX, 12" \
@ -119,8 +136,6 @@ void *user_alloc(unsigned size);
parm [ ECX ] value [EAX] \ parm [ ECX ] value [EAX] \
modify [ EBX ]; modify [ EBX ];
unsigned user_free(void *);
#pragma aux user_free = \ #pragma aux user_free = \
"mov EAX, 68" \ "mov EAX, 68" \
"mov EBX, 13" \ "mov EBX, 13" \
@ -128,6 +143,78 @@ unsigned user_free(void *);
parm [ ECX ] value [EAX] \ parm [ ECX ] value [EAX] \
modify [ EBX ]; modify [ EBX ];
#pragma aux create_file = \
"push 0" \
"push 0" \
"mov [esp+1], eax" \
"push 0" \
"push 0" \
"push 0" \
"push 0" \
"push 2" \
"mov ebx, esp" \
"mov eax, 70" \
"int 0x40" \
"add esp, 28" \
parm [EAX] value [EAX] \
modify [ EBX ];
#pragma aux get_fileinfo = \
"push 0" \
"push 0" \
"mov [esp+1], eax" \
"push ebx" \
"push 0" \
"push 0" \
"push 0" \
"push 5" \
"mov ebx, esp" \
"mov eax, 70" \
"int 0x40" \
"add esp, 28" \
parm [EAX] [ebx] value [EAX] \
modify [ EBX ];
#pragma aux read_file = \
"push 0" \
"push 0" \
"mov [esp+1], eax" \
"push ebx" \
"push edx" \
"push 0" \
"push ecx" \
"push 0" \
"mov ebx, esp" \
"mov eax, 70" \
"int 0x40" \
"test esi, esi" \
"jz skip" \
"mov [esi], ebx" \
"skip:" \
"add esp, 28" \
parm [EAX] [EBX] [ECX] [EDX] [ESI] value [EAX] \
modify [ EBX ];
#pragma aux write_file = \
"push 0" \
"push 0" \
"mov [esp+1], eax" \
"push ebx" \
"push edx" \
"push 0" \
"push ecx" \
"push 3" \
"mov ebx, esp" \
"mov eax, 70" \
"int 0x40" \
"test esi, esi" \
"jz skip" \
"mov [esi], ebx" \
"skip:" \
"add esp, 28" \
parm [EAX] [EBX] [ECX] [EDX] [ESI] value [EAX] \
modify [ EBX ];
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
} }

View File

@ -36,15 +36,7 @@
#include "seterrno.h" #include "seterrno.h"
#include "lseek.h" #include "lseek.h"
#include "handleio.h" #include "handleio.h"
#include "kolibri.h"
/*
DWORD SetFilePointer(
HANDLE hFile, // handle to file
LONG lDistanceToMove, // bytes to move pointer
PLONG lpDistanceToMoveHigh, // bytes to move pointer
DWORD dwMoveMethod // starting point
);
*/
#ifndef INVALID_SET_FILE_POINTER #ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF #define INVALID_SET_FILE_POINTER 0xFFFFFFFF
@ -56,21 +48,6 @@ typedef struct
unsigned int offset; unsigned int offset;
}__file_handle; }__file_handle;
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
_WCRTLINK long __lseek( int hid, long offset, int origin ) _WCRTLINK long __lseek( int hid, long offset, int origin )
{ {
__file_handle *fh; __file_handle *fh;

View File

@ -46,6 +46,7 @@
#include "openmode.h" #include "openmode.h"
#include "rtdata.h" #include "rtdata.h"
#include "seterrno.h" #include "seterrno.h"
#include "kolibri.h"
extern unsigned __NFiles; extern unsigned __NFiles;
extern char *__appcwd; extern char *__appcwd;
@ -53,23 +54,6 @@ extern int __appcwdlen;
#if (defined(__WINDOWS__) || defined(__NT__)) #if (defined(__WINDOWS__) || defined(__NT__))
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall create_file(const char *name);
typedef struct typedef struct
{ {
char *name; char *name;

View File

@ -36,6 +36,7 @@
#include "seterrno.h" #include "seterrno.h"
#include "qread.h" #include "qread.h"
#include <stdio.h> #include <stdio.h>
#include "kolibri.h"
typedef struct typedef struct
{ {
@ -43,9 +44,6 @@ typedef struct
unsigned int offset; unsigned int offset;
}__file_handle; }__file_handle;
int _stdcall read_file (const char *name,char *buff,unsigned offset, unsigned count,unsigned *reads);
int __qread( int handle, void *buffer, unsigned len ) int __qread( int handle, void *buffer, unsigned len )
{ {
__file_handle *fh; __file_handle *fh;

View File

@ -41,7 +41,7 @@
#include "seterrno.h" #include "seterrno.h"
#include "qwrite.h" #include "qwrite.h"
#include "liballoc.h" #include "liballoc.h"
#include "kolibri.h"
/* /*
Use caution when setting the file pointer in a multithreaded Use caution when setting the file pointer in a multithreaded
@ -51,27 +51,12 @@
using a critical section object or a mutex object. using a critical section object or a mutex object.
*/ */
typedef struct
{ DWORD attr;
DWORD flags;
DWORD cr_time;
DWORD cr_date;
DWORD acc_time;
DWORD acc_date;
DWORD mod_time;
DWORD mod_date;
DWORD size;
DWORD size_high;
} FILEINFO;
typedef struct typedef struct
{ {
char *name; char *name;
unsigned int offset; unsigned int offset;
}__file_handle; }__file_handle;
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall write_file(const char *name,const void *buff,unsigned offset,unsigned count,unsigned *writes);
char* getfullpath(const char* path); char* getfullpath(const char* path);
int __qwrite( int handle, const void *buffer, unsigned len ) int __qwrite( int handle, const void *buffer, unsigned len )
@ -79,7 +64,6 @@ int __qwrite( int handle, const void *buffer, unsigned len )
int atomic; int atomic;
__file_handle *fh; __file_handle *fh;
unsigned len_written; unsigned len_written;
__handle_check( handle, -1 ); __handle_check( handle, -1 );

View File

@ -0,0 +1,29 @@
include mdef.inc
modstart cosf
xdefp _cosf
_cosf proc
fcos
fnstsw ax
test eax, 0x400
jnz L1
ret
L1: fldpi
fadd st,st
fxch st(1)
L2:
fprem1
fnstsw ax
test eax,0x400
jnz L2
fstp st(1)
fcos
ret
_cosf endp
endmod
end

View File

@ -0,0 +1,29 @@
include mdef.inc
modstart sinf
xdefp _sinf
_sinf proc
fsin
fnstsw ax
test eax, 0x400
jnz L1
ret
L1: fldpi
fadd st,st
fxch st(1)
L2:
fprem1
fnstsw ax
test eax,0x400
jnz L2
fstp st(1)
fsin
ret
_sinf endp
endmod
end

View File

@ -0,0 +1,31 @@
include mdef.inc
modstart tanf
xdefp _tanf
_tanf proc
fptan
fnstsw ax
test eax, 0x400
jnz L1
fstp st(0)
ret
L1: fldpi
fadd st,st
fxch st(1)
L2:
fprem1
fnstsw ax
test eax,0x400
jnz L2
fstp st(1)
fptan
fstp st(0)
ret
_tanf endp
endmod
end

File diff suppressed because it is too large Load Diff