linking native Kolibri executable

git-svn-id: svn://kolibrios.org@704 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-01-28 13:49:43 +00:00
parent 97918755c2
commit 7ad5e56087
24 changed files with 2080 additions and 1600 deletions

View File

@ -6,8 +6,8 @@ VpeMain
WRect WRect
0 0
370 370
10240 10304
9870 9950
2 2
MProject MProject
3 3
@ -42,8 +42,8 @@ WRect
WFileName WFileName
10 10
clib_r.tgt clib_r.tgt
10 0
42 0
11 11
VComponent VComponent
12 12
@ -59,5 +59,5 @@ WFileName
7 7
crt.tgt crt.tgt
0 0
17 20
8 8

View File

@ -0,0 +1,3 @@
include mdef.inc
alias_function strdup, __clib_strdup
end

View File

@ -0,0 +1,3 @@
include mdef.inc
alias_function strcmpi, stricmp
end

View File

@ -0,0 +1,3 @@
include mdef.inc
alias_function _strdup, __clib_strdup
end

View File

@ -0,0 +1,3 @@
include mdef.inc
alias_function _stricmp, stricmp
end

View File

@ -49,45 +49,31 @@ _DATA segment dword public 'DATA'
assume DS:DGROUP assume DS:DGROUP
extrn ___cmdline : near
extrn ___pgmname : near
_LpCmdLine dd offset ___cmdline ; pointer to raw command line
_LpPgmName dd offset ___pgmname ; pointer to program name (for argv[0])
ifndef __NETWARE__ ifndef __NETWARE__
_dynend dd 0 ; top of dynamic data area _dynend dd 0 ; top of dynamic data area
_curbrk dd 0 ; top of usable memory _curbrk dd 0 ; top of usable memory
endif endif
ifndef __QNX__
ifndef __LINUX__ _STACKLOW dd 0 ; lowest address in stack
ifndef _NETWARE_LIBC _STACKTOP dd 0 ; highest address in stack
_LpCmdLine dd 0 ; pointer to raw command line
_LpPgmName dd 0 ; pointer to program name (for argv[0])
endif
ifdef __NT__
_LpDllName dd 0 ; pointer to dll name (for OS/2,WIN32)
_LpwCmdLine dd 0 ; pointer to widechar raw command line
_LpwPgmName dd 0 ; pointer to widechar program name (for argv[0])
_LpwDllName dd 0 ; pointer to widechar dll name (for OS/2,WIN32)
endif
ifdef __OS2__
_LpDllName dd 0 ; pointer to dll name (for OS/2,WIN32)
_LpwCmdLine dd 0 ; pointer to widechar raw command line
_LpwPgmName dd 0 ; pointer to widechar program name (for argv[0])
_LpwDllName dd 0 ; pointer to widechar dll name (for OS/2,WIN32)
endif
ifdef __DOS__
_psp dw 0,0 ; segment addr of program segment prefix
__x386_stacklow label dword
endif
endif
endif
_STACKLOW dd 0 ; lowest address in stack
_STACKTOP dd 0 ; highest address in stack
__EFG_printf dd 0 __EFG_printf dd 0
__EFG_scanf dd 0 __EFG_scanf dd 0
__ASTACKSIZ dd 0 ; alternate stack size __ASTACKSIZ dd 0 ; alternate stack size
__ASTACKPTR dd 0 ; alternate stack pointer __ASTACKPTR dd 0 ; alternate stack pointer
ifndef __NETWARE__ ifndef __NETWARE__
_cbyte dd 0 ; used by getch, getche _cbyte dd 0 ; used by getch, getche
_cbyte2 dd 0 ; used by getch, getche _cbyte2 dd 0 ; used by getch, getche
_child dd 0 ; non-zero => a spawned process is running _child dd 0 ; non-zero => a spawned process is running
endif endif
__no87 dw 0 ; non-zero => "NO87" environment var present __no87 dw 0 ; non-zero => "NO87" environment var present
ifndef __NETWARE__ ifndef __NETWARE__
ifdef __DOS__ ifdef __DOS__
@ -141,10 +127,6 @@ ifndef _NETWARE_LIBC
public "C",_LpPgmName public "C",_LpPgmName
endif endif
ifdef __NT__ ifdef __NT__
public "C",_LpDllName
public "C",_LpwCmdLine
public "C",_LpwPgmName
public "C",_LpwDllName
public "C",_LpCmdLine public "C",_LpCmdLine
public "C",_LpPgmName public "C",_LpPgmName
endif endif

View File

@ -37,12 +37,11 @@
.386p .386p
assume nothing assume nothing
extrn __NTMain : near extrn __NTMain : near
extrn ___begtext : near extrn ___begtext : near
extrn __LpCmdLine : near
extrn __LpPgmName : near
extrn __STACKLOW : near extrn __STACKLOW : near
extrn __STACKTOP : near extrn __STACKTOP : near
extrn ___stack_low : near
_TEXT segment use32 word public 'CODE' _TEXT segment use32 word public 'CODE'
@ -55,13 +54,7 @@ _cstart_ proc near
mainCRTStartup: mainCRTStartup:
mov dword ptr [__STACKTOP], esp mov dword ptr [__STACKTOP], esp
lea eax, [esp-40000h] mov dword ptr[__STACKLOW], offset ___stack_low
mov dword ptr[__STACKLOW], eax
mov eax, dword ptr [ds:0x1c]
mov dword ptr [__LpCmdLine], eax
mov eax, dword ptr [ds:0x20]
mov dword ptr [__LpPgmName], eax
jmp __NTMain jmp __NTMain
dd ___begtext ; reference module with segment definitions dd ___begtext ; reference module with segment definitions

View File

@ -36,12 +36,13 @@
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <windows.h> #include <windows.h>
//#include "ntex.h"
#include "kolibri.h"
//#include "sigtab.h" //#include "sigtab.h"
#include "initfini.h" #include "initfini.h"
#include "initarg.h" #include "initarg.h"
void _stdcall InitHeap(int heap_size);
int __appcwdlen; int __appcwdlen;
char* __appcwd; char* __appcwd;
extern char *LpCmdLine; extern char *LpCmdLine;
@ -74,7 +75,7 @@ void __F_NAME(__NTMain,__wNTMain)( void )
/***************************************/ /***************************************/
{ {
InitHeap(0); init_heap();
__process_fini = &__FiniRtns; __process_fini = &__FiniRtns;
__InitRtns( 255 ); __InitRtns( 255 );
@ -106,6 +107,8 @@ void __F_NAME(__NTMain,__wNTMain)( void )
#endif #endif
#endif #endif
#pragma aux __exit aborts;
_WCRTLINK void __exit( unsigned ret_code ) _WCRTLINK void __exit( unsigned ret_code )
{ {
__FiniRtns( 0, FINI_PRIORITY_EXIT-1 ); __FiniRtns( 0, FINI_PRIORITY_EXIT-1 );

View File

@ -40,16 +40,12 @@ include langenv.inc
assume nothing assume nothing
extrn _cstart_ : near
extrn __STACKLOW : near
extrn __STACKTOP : near
if COMP_CFG_COFF
DGROUP group _NULL,_AFTERNULL,CONST,_DATA,DATA,_BSS,STACK DGROUP group _NULL,_AFTERNULL,CONST,_DATA,DATA,TIB,TI,TIE,XIB,XI,XIE,YIB,YI,YIE,_IEND,_BSS,STACK,MEMSIZE
else
ifdef __LINUX__
DGROUP group _NULL,_AFTERNULL,CONST,_DATA,DATA,TIB,TI,TIE,XIB,XI,XIE,YIB,YI,YIE,_BSS
else
DGROUP group _NULL,_AFTERNULL,CONST,_DATA,DATA,_BSS,STACK,TIB,TI,TIE,XIB,XI,XIE,YIB,YI,YIE
endif
endif
; this guarantees that no function pointer will equal NULL ; this guarantees that no function pointer will equal NULL
; (WLINK will keep segment 'BEGTEXT' in front) ; (WLINK will keep segment 'BEGTEXT' in front)
@ -59,6 +55,16 @@ endif
BEGTEXT segment use32 word public 'CODE' BEGTEXT segment use32 word public 'CODE'
assume cs:BEGTEXT assume cs:BEGTEXT
forever label near forever label near
db 'MENUET01'
dd 0x0001
dd offset _cstart_
dd offset ___iend
dd offset MEMSIZE
dd offset MEMSIZE
dd offset ___cmdline
dd offset ___pgmname
int 3h int 3h
jmp short forever jmp short forever
; NOTE that __begtext needs to be at offset 3 ; NOTE that __begtext needs to be at offset 3
@ -123,16 +129,30 @@ _DATA ends
DATA segment word public 'DATA' DATA segment word public 'DATA'
DATA ends DATA ends
_IEND segment word public 'IEND'
___iend label byte
_IEND ends
_BSS segment word public 'BSS' _BSS segment word public 'BSS'
public ___cmdline
public ___pgmname
___cmdline db 256 dup(?) ; pointer to raw command line
___pgmname db 1024 dup (?) ; pointer to program name (for argv[0])
_BSS ends _BSS ends
ifndef __LINUX__
STACK_SIZE equ 4096h
STACK segment para stack 'STACK' STACK segment para stack 'STACK'
db (STACK_SIZE) dup(?)
___stack_low label byte
public ___stack_low
STACK ends STACK ends
endif
MEMSIZE segment para stack 'STACK'
MEMSIZE ends
_TEXT segment use32 word public 'CODE' _TEXT segment use32 word public 'CODE'
_TEXT ends _TEXT ends

View File

@ -51,15 +51,10 @@ include mdef.inc
_TEXT SEGMENT PARA PUBLIC USE32 'CODE' _TEXT SEGMENT PARA PUBLIC USE32 'CODE'
_TEXT ENDS _TEXT ENDS
CONST SEGMENT DWORD PUBLIC USE32 'DATA'
CONST ENDS
CONST2 SEGMENT DWORD PUBLIC USE32 'DATA' _DATA SEGMENT DWORD PUBLIC USE32 'DATA'
CONST2 ENDS
DATA32 SEGMENT DWORD PUBLIC USE32 'DATA'
Y EQU 0 Y EQU 0
@ -145,19 +140,19 @@ atan_k_by_16 dd 000000000H, 000000000H, 000000000H, 000000000H
dd 0AC526641H, 0C0CE85B8H, 000003FFEH, 000000000H dd 0AC526641H, 0C0CE85B8H, 000003FFEH, 000000000H
dd 02168C235H, 0C90FDAA2H, 000003FFEH, 000000000H dd 02168C235H, 0C90FDAA2H, 000003FFEH, 000000000H
DATA32 ENDS _DATA ENDS
BSS32 SEGMENT DWORD PUBLIC USE32 'BSS' _BSS SEGMENT DWORD PUBLIC USE32 'BSS'
BSS32 ENDS _BSS ENDS
EXTRN __fdiv_fpr:NEAR EXTRN __fdiv_fpr:NEAR
DGROUP GROUP CONST,CONST2,DATA32,BSS32 DGROUP GROUP _DATA,_BSS
_TEXT SEGMENT PARA PUBLIC USE32 'CODE' _TEXT SEGMENT PARA PUBLIC USE32 'CODE'
ASSUME CS:_TEXT,DS:DGROUP,ES:DGROUP, SS:nothing ASSUME CS:_TEXT,DS:DGROUP,ES:DGROUP, SS:DGROUP
public __fpatan_chk public __fpatan_chk
defpe __fpatan_chk defpe __fpatan_chk
@ -394,4 +389,4 @@ hw_fpatan:
__fpatan_chk ENDP __fpatan_chk ENDP
_TEXT ENDS _TEXT ENDS
END END

View File

@ -167,19 +167,19 @@ ENDM
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' _TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
_TEXT ENDS _TEXT ENDS
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' _DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
DATA32 ENDS _DATA ENDS
CONST32 SEGMENT DWORD USE32 PUBLIC 'CONST' CONST SEGMENT DWORD USE32 PUBLIC 'DATA'
CONST32 ENDS CONST ENDS
BSS32 SEGMENT DWORD USE32 PUBLIC 'BSS' _BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
BSS32 ENDS _BSS ENDS
DGROUP GROUP CONST32, BSS32, DATA32 DGROUP GROUP CONST,_DATA,_BSS
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' _DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
fdiv_risc_table DB 0, 1, 0, 0, 4, 0, 0, 7, 0, 0, 10, 0, 0, 13, 0, 0 fdiv_risc_table DB 0, 1, 0, 0, 4, 0, 0, 7, 0, 0, 10, 0, 0, 13, 0, 0
fdiv_scale_1 DD 03f700000h ;0.9375 fdiv_scale_1 DD 03f700000h ;0.9375
@ -252,7 +252,7 @@ dispatch_table DD offset label0
DD offset label62 DD offset label62
DD offset label63 DD offset label63
DATA32 ENDS _DATA ENDS
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' _TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'

View File

@ -63,7 +63,7 @@ endif
ENDM ENDM
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA' _DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
; ;
; Stack variables for remainder routines. ; Stack variables for remainder routines.
@ -123,25 +123,17 @@ FPU_STATE ENDS
ENV_SIZE EQU 28 ENV_SIZE EQU 28
DATA32 ENDS _DATA ENDS
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE' _TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
_TEXT ENDS _TEXT ENDS
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA'
DATA32 ENDS
CONST32 SEGMENT DWORD USE32 PUBLIC 'CONST' DGROUP GROUP _DATA
CONST32 ENDS
BSS32 SEGMENT DWORD USE32 PUBLIC 'BSS'
BSS32 ENDS
DGROUP GROUP CONST32, BSS32, DATA32
CODE32 SEGMENT DWORD USE32 PUBLIC 'CODE' _TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
assume cs:_TEXT, ds:DGROUP, es:DGROUP, ss:nothing assume cs:_TEXT, ds:DGROUP, es:DGROUP, ss:nothing
@ -847,5 +839,5 @@ fpinit PROC NEAR
fpinit ENDP fpinit ENDP
endif endif
CODE32 ENDS _TEXT ENDS
END END

View File

@ -23,6 +23,7 @@ extern "C"
#define FILE_NOT_FOUND 5 #define FILE_NOT_FOUND 5
#define FILE_EOF 6 #define FILE_EOF 6
#if 0
typedef unsigned int DWORD; typedef unsigned int DWORD;
typedef unsigned short int WORD; typedef unsigned short int WORD;
@ -62,10 +63,6 @@ typedef struct
DWORD size_high; DWORD size_high;
} FILEINFO; } FILEINFO;
void _stdcall InitHeap(int heap_size);
void* _stdcall UserAlloc(int size);
int _stdcall UserFree(void* p);
void _stdcall GetNotify(void *event); void _stdcall GetNotify(void *event);
void _stdcall CreateThread(void *fn, char *p_stack); void _stdcall CreateThread(void *fn, char *p_stack);
@ -85,7 +82,8 @@ int _stdcall remap_key(int key);
int _cdecl get_button_id(); int _cdecl get_button_id();
void delay(int val); //void delay(int val);
int wait_for_event(int time); int wait_for_event(int time);
int wait_for_event_infinite(); int wait_for_event_infinite();
void BeginDraw(void); void BeginDraw(void);
@ -99,6 +97,37 @@ void _stdcall make_button(int x, int y, int xsize, int ysize, int id, int color)
void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color); void _stdcall draw_bar(int x, int y, int xsize, int ysize, int color);
void _stdcall write_text(int x,int y,int color,char* text,int len); void _stdcall write_text(int x,int y,int color,char* text,int len);
#endif
unsigned init_heap(void);
#pragma aux init_heap = \
"mov EAX, 68" \
"mov EBX, 11" \
"int 0x40" \
value [EAX] \
modify [ EBX ];
void *user_alloc(unsigned size);
void *user_alloc(unsigned size);
#pragma aux user_alloc = \
"mov EAX, 68" \
"mov EBX, 12" \
"int 0x40" \
parm [ ECX ] value [EAX] \
modify [ EBX ];
unsigned user_free(void *);
#pragma aux user_free = \
"mov EAX, 68" \
"mov EBX, 13" \
"int 0x40" \
parm [ ECX ] value [EAX] \
modify [ EBX ];
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
} }

View File

@ -0,0 +1,37 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
/* locales.h */
#define C_LOCALE 0
#define NATIVE_LOCALE 1
#define INVALID_LOCALE 2

View File

@ -0,0 +1,36 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
extern char _LocaleSetting[];
#define _INITLOCALESETTING
#define _LOCALESETTING _LocaleSetting

View File

@ -291,3 +291,6 @@
#endif #endif
#endif #endif
#undef _WCRTLINKD
#define _WCRTLINKD

View File

@ -0,0 +1,66 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Platform independent implementation of creat().
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "seterrno.h"
/* file attributes */
#define _A_RDONLY 0x01
_WCRTLINK int __F_NAME(creat,_wcreat)( const CHAR_TYPE *name, mode_t pmode )
{
#ifndef __NETWARE__
return( __F_NAME(open,_wopen)( name, O_RDWR | O_CREAT | O_TRUNC, pmode ) );
#else
int acc;
acc = O_CREAT | O_TRUNC;
if( (pmode & S_IWRITE) && (pmode & S_IREAD) ) {
acc |= O_RDWR;
} else if( pmode & S_IWRITE ) {
acc |= O_WRONLY;
} else if( pmode & S_IREAD ) {
acc |= O_RDONLY;
} else if( !pmode ) {
acc |= O_RDWR;
}
return( __F_NAME(open,_wopen)( name, acc, pmode ) );
#endif
}

View File

@ -0,0 +1,56 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include "rtcheck.h"
extern long filelength(int);
extern long tell(int);
_WCRTLINK int eof( int handle ) /* determine if at EOF */
{
long current_posn, file_len;
__handle_check( handle, -1 );
file_len = filelength( handle );
if( file_len == -1L )
return( -1 );
current_posn = tell( handle );
if( current_posn == -1L )
return( -1 );
if( current_posn == file_len )
return( 1 );
return( 0 );
}

View File

@ -29,7 +29,6 @@
****************************************************************************/ ****************************************************************************/
//#include "dll.h" // needs to be first
#include "variety.h" #include "variety.h"
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
@ -45,9 +44,7 @@
// #include "tinyio.h" // #include "tinyio.h"
#endif #endif
#if defined(__WINDOWS_286__) || defined(__NT__) #if defined(__WINDOWS_286__) || defined(__NT__)
void* _stdcall UserAlloc(int size); #include "kolibri.h"
// #include "windows.h"
#endif #endif
#if defined(__OS2__) #if defined(__OS2__)
// #include <wos2.h> // #include <wos2.h>
@ -404,7 +401,7 @@ static int __CreateNewNHeap( unsigned amount )
#elif defined(__NT__) #elif defined(__NT__)
// brk_value = (unsigned) VirtualAlloc( NULL, amount, MEM_COMMIT, // brk_value = (unsigned) VirtualAlloc( NULL, amount, MEM_COMMIT,
// PAGE_EXECUTE_READWRITE ); // PAGE_EXECUTE_READWRITE );
brk_value = (unsigned) UserAlloc (amount ); brk_value = (unsigned) user_alloc(amount );
//brk_value = (unsigned) LocalAlloc( LMEM_FIXED, amount ); //brk_value = (unsigned) LocalAlloc( LMEM_FIXED, amount );
if( brk_value == 0 ) { if( brk_value == 0 ) {

View File

@ -29,7 +29,6 @@
****************************************************************************/ ****************************************************************************/
//#include "dll.h" // needs to be first
#include "variety.h" #include "variety.h"
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
@ -40,8 +39,7 @@
// #include "extender.h" // #include "extender.h"
#endif #endif
#if defined(__WINDOWS_286__) || defined(__NT__) #if defined(__WINDOWS_286__) || defined(__NT__)
int _stdcall UserFree(void* p); #include "kolibri.h"
// #include "windows.h"
#endif #endif
#if defined(__OS2__) #if defined(__OS2__)
// #include <wos2.h> // #include <wos2.h>
@ -77,41 +75,6 @@ _WCRTLINK int _nheapmin( void )
defined(__WINDOWS_386__) || \ defined(__WINDOWS_386__) || \
defined(__NT__) || \ defined(__NT__) || \
defined(__CALL21__) defined(__CALL21__)
static int __ReturnMemToSystem( mheapptr mhp )
{
mheapptr pnext;
pnext = mhp->next;
#if defined(__WARP__)
if( DosFreeMem( (PBYTE)mhp ) ) return( -1 );
#elif defined(__NT__)
//if( LocalFree( (HLOCAL)mhp ) != NULL ) return( -1 );
// if (!VirtualFree(mhp, 0, MEM_RELEASE))
// return -1;
if(!UserFree(mhp))
return -1;
#elif defined(__WINDOWS_386__)
if( DPMIFree( (unsigned long)mhp ) != 0 ) return( -1 );
#elif defined(__WINDOWS_286__)
if( LocalFree( (HLOCAL)mhp ) != NULL ) return( -1 );
#elif defined(__CALL21__)
// No way to free storage under OSI
if( mhp ) return( -1 );
#endif
if( __MiniHeapRover == mhp ) { // Update rovers
if( pnext ) {
__MiniHeapRover = pnext;
} else {
__MiniHeapRover = __nheapbeg;
__LargestSizeB4MiniHeapRover = 0;
}
}
if( __MiniHeapFreeRover == mhp ) {
__MiniHeapFreeRover = 0;
}
return( 0 ); // success
}
static void __ReleaseMiniHeap( mheapptr mhp ) static void __ReleaseMiniHeap( mheapptr mhp )
{ {
@ -120,7 +83,7 @@ static void __ReleaseMiniHeap( mheapptr mhp )
pprev = mhp->prev; pprev = mhp->prev;
pnext = mhp->next; pnext = mhp->next;
if( __ReturnMemToSystem( mhp ) == 0 ) { if( user_free( mhp ) == 1 ) {
if( pprev == NULL ) { if( pprev == NULL ) {
__nheapbeg = pnext; __nheapbeg = pnext;
} else { } else {

View File

@ -35,10 +35,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <dos.h> #include <dos.h>
//#include <windows.h> #include "kolibri.h"
void* _stdcall UserAlloc(int size);
void* user_alloc(unsigned size);
extern unsigned _curbrk; extern unsigned _curbrk;
extern unsigned _STACKTOP; extern unsigned _STACKTOP;
@ -52,7 +51,7 @@ _WCRTLINK void _WCNEAR *sbrk( int increment )
increment = ( increment + 0x0fff ) & ~0x0fff; increment = ( increment + 0x0fff ) & ~0x0fff;
//p = LocalAlloc( LMEM_FIXED, increment ); //p = LocalAlloc( LMEM_FIXED, increment );
//p = VirtualAlloc(NULL, increment, MEM_COMMIT,PAGE_EXECUTE_READWRITE); //p = VirtualAlloc(NULL, increment, MEM_COMMIT,PAGE_EXECUTE_READWRITE);
p = UserAlloc(increment); p = user_alloc(increment);
if( p != NULL ) return( p ); if( p != NULL ) return( p );
errno = ENOMEM; errno = ENOMEM;
} }

View File

@ -0,0 +1,46 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include "locales.h"
char _LocaleSetting[] = {
/* QNX */
C_LOCALE, /* LC_TYPE */
C_LOCALE, /* LC_NUMERIC */
C_LOCALE, /* LC_TIME */
C_LOCALE, /* LC_COLLATE */
C_LOCALE, /* LC_MONETARY */
C_LOCALE, /* LC_MESSAGES */
C_LOCALE /* LC_ALL */
};

View File

@ -0,0 +1,89 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <string.h>
#include <locale.h>
#include "locales.h"
#include "localset.h"
#ifdef __WIDECHAR__
static wchar_t *ValidLocales[] = {
L"C", /* C_LOCALE */
L"", /* NATIVE_LOCALE */
NULL /* INVALID_LOCALE */
};
#else
static char *ValidLocales[] = {
"C", /* C_LOCALE */
"", /* NATIVE_LOCALE */
NULL /* INVALID_LOCALE */
};
#endif
_WCRTLINK CHAR_TYPE *__F_NAME(setlocale,_wsetlocale)( int category, CHAR_TYPE const *locale )
{
register int i;
_INITLOCALESETTING
if( category < LC_CTYPE || category > LC_ALL ) {
return( NULL );
}
if( locale == NULL ) {
i = _LOCALESETTING[category];
} else {
i = C_LOCALE;
if( *locale != __F_NAME('\0',L'\0') ) {
for( ; ValidLocales[i]; ++i ) {
if( __F_NAME(strcmp,wcscmp)( locale, ValidLocales[i] ) == 0 ) break;
}
}
if( i != INVALID_LOCALE ) {
_LOCALESETTING[category] = i;
if( category == LC_ALL ) {
_LOCALESETTING[LC_COLLATE] = i;
_LOCALESETTING[LC_CTYPE] = i;
_LOCALESETTING[LC_NUMERIC] = i;
_LOCALESETTING[LC_TIME] = i;
_LOCALESETTING[LC_MONETARY] = i;
#if defined( __UNIX__ )
_LOCALESETTING[LC_MESSAGES] = i;
#endif
}
}
}
return( ValidLocales[ i ] );
}

File diff suppressed because it is too large Load Diff