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
0
370
10240
9870
10304
9950
2
MProject
3
@ -42,8 +42,8 @@ WRect
WFileName
10
clib_r.tgt
10
42
0
0
11
VComponent
12
@ -59,5 +59,5 @@ WFileName
7
crt.tgt
0
17
20
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

@ -48,46 +48,32 @@ _TEXT ends
_DATA segment dword public 'DATA'
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__
_dynend dd 0 ; top of dynamic data area
_curbrk dd 0 ; top of usable memory
endif
ifndef __QNX__
ifndef __LINUX__
ifndef _NETWARE_LIBC
_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
_STACKLOW dd 0 ; lowest address in stack
_STACKTOP dd 0 ; highest address in stack
__EFG_printf dd 0
__EFG_scanf dd 0
__ASTACKSIZ dd 0 ; alternate stack size
__ASTACKPTR dd 0 ; alternate stack pointer
__ASTACKSIZ dd 0 ; alternate stack size
__ASTACKPTR dd 0 ; alternate stack pointer
ifndef __NETWARE__
_cbyte dd 0 ; used by getch, getche
_cbyte2 dd 0 ; used by getch, getche
_child dd 0 ; non-zero => a spawned process is running
endif
__no87 dw 0 ; non-zero => "NO87" environment var present
ifndef __NETWARE__
ifdef __DOS__
@ -141,10 +127,6 @@ ifndef _NETWARE_LIBC
public "C",_LpPgmName
endif
ifdef __NT__
public "C",_LpDllName
public "C",_LpwCmdLine
public "C",_LpwPgmName
public "C",_LpwDllName
public "C",_LpCmdLine
public "C",_LpPgmName
endif

View File

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

View File

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

View File

@ -1,140 +1,160 @@
;*****************************************************************************
;*
;* 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!
;*
;*****************************************************************************
;
; segment definitions for WATCOM C/C++32
;
include langenv.inc
name segdefns
.386p
assume nothing
if COMP_CFG_COFF
DGROUP group _NULL,_AFTERNULL,CONST,_DATA,DATA,_BSS,STACK
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
; (WLINK will keep segment 'BEGTEXT' in front)
; This segment must be at least 4 bytes in size to avoid confusing the
; signal function.
BEGTEXT segment use32 word public 'CODE'
assume cs:BEGTEXT
forever label near
int 3h
jmp short forever
; NOTE that __begtext needs to be at offset 3
; don't move it. i.e. don't change any code before here.
___begtext label byte
nop
nop
nop
nop
public ___begtext
assume cs:nothing
BEGTEXT ends
assume ds:DGROUP
_NULL segment para public 'BEGDATA'
__nullarea label word
db 01h,01h,01h,00h
public __nullarea
_NULL ends
_AFTERNULL segment word public 'BEGDATA'
_AFTERNULL ends
CONST segment word public 'DATA'
CONST ends
if COMP_CFG_COFF eq 0
TIB segment byte public 'DATA'
TIB ends
TI segment byte public 'DATA'
TI ends
TIE segment byte public 'DATA'
TIE ends
XIB segment word public 'DATA'
_Start_XI label byte
public "C",_Start_XI
XIB ends
XI segment word public 'DATA'
XI ends
XIE segment word public 'DATA'
_End_XI label byte
public "C",_End_XI
XIE ends
YIB segment word public 'DATA'
_Start_YI label byte
public "C",_Start_YI
YIB ends
YI segment word public 'DATA'
YI ends
YIE segment word public 'DATA'
_End_YI label byte
public "C",_End_YI
YIE ends
endif
_DATA segment word public 'DATA'
_DATA ends
DATA segment word public 'DATA'
DATA ends
_BSS segment word public 'BSS'
_BSS ends
ifndef __LINUX__
STACK_SIZE equ 4096h
STACK segment para stack 'STACK'
db (STACK_SIZE) dup(?)
STACK ends
endif
_TEXT segment use32 word public 'CODE'
_TEXT ends
end
;*****************************************************************************
;*
;* 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!
;*
;*****************************************************************************
;
; segment definitions for WATCOM C/C++32
;
include langenv.inc
name segdefns
.386p
assume nothing
extrn _cstart_ : near
extrn __STACKLOW : near
extrn __STACKTOP : near
DGROUP group _NULL,_AFTERNULL,CONST,_DATA,DATA,TIB,TI,TIE,XIB,XI,XIE,YIB,YI,YIE,_IEND,_BSS,STACK,MEMSIZE
; this guarantees that no function pointer will equal NULL
; (WLINK will keep segment 'BEGTEXT' in front)
; This segment must be at least 4 bytes in size to avoid confusing the
; signal function.
BEGTEXT segment use32 word public 'CODE'
assume cs:BEGTEXT
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
jmp short forever
; NOTE that __begtext needs to be at offset 3
; don't move it. i.e. don't change any code before here.
___begtext label byte
nop
nop
nop
nop
public ___begtext
assume cs:nothing
BEGTEXT ends
assume ds:DGROUP
_NULL segment para public 'BEGDATA'
__nullarea label word
db 01h,01h,01h,00h
public __nullarea
_NULL ends
_AFTERNULL segment word public 'BEGDATA'
_AFTERNULL ends
CONST segment word public 'DATA'
CONST ends
if COMP_CFG_COFF eq 0
TIB segment byte public 'DATA'
TIB ends
TI segment byte public 'DATA'
TI ends
TIE segment byte public 'DATA'
TIE ends
XIB segment word public 'DATA'
_Start_XI label byte
public "C",_Start_XI
XIB ends
XI segment word public 'DATA'
XI ends
XIE segment word public 'DATA'
_End_XI label byte
public "C",_End_XI
XIE ends
YIB segment word public 'DATA'
_Start_YI label byte
public "C",_Start_YI
YIB ends
YI segment word public 'DATA'
YI ends
YIE segment word public 'DATA'
_End_YI label byte
public "C",_End_YI
YIE ends
endif
_DATA segment word public 'DATA'
_DATA ends
DATA segment word public 'DATA'
DATA ends
_IEND segment word public 'IEND'
___iend label byte
_IEND ends
_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
STACK segment para stack 'STACK'
___stack_low label byte
public ___stack_low
STACK ends
MEMSIZE segment para stack 'STACK'
MEMSIZE ends
_TEXT segment use32 word public 'CODE'
_TEXT ends
end

View File

@ -51,15 +51,10 @@ include mdef.inc
_TEXT SEGMENT PARA PUBLIC USE32 'CODE'
_TEXT ENDS
_TEXT ENDS
CONST SEGMENT DWORD PUBLIC USE32 'DATA'
CONST ENDS
CONST2 SEGMENT DWORD PUBLIC USE32 'DATA'
CONST2 ENDS
DATA32 SEGMENT DWORD PUBLIC USE32 'DATA'
_DATA SEGMENT DWORD PUBLIC USE32 'DATA'
Y EQU 0
@ -145,19 +140,19 @@ atan_k_by_16 dd 000000000H, 000000000H, 000000000H, 000000000H
dd 0AC526641H, 0C0CE85B8H, 000003FFEH, 000000000H
dd 02168C235H, 0C90FDAA2H, 000003FFEH, 000000000H
DATA32 ENDS
_DATA ENDS
BSS32 SEGMENT DWORD PUBLIC USE32 'BSS'
BSS32 ENDS
_BSS SEGMENT DWORD PUBLIC USE32 'BSS'
_BSS ENDS
EXTRN __fdiv_fpr:NEAR
DGROUP GROUP CONST,CONST2,DATA32,BSS32
DGROUP GROUP _DATA,_BSS
_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
defpe __fpatan_chk
@ -394,4 +389,4 @@ hw_fpatan:
__fpatan_chk ENDP
_TEXT ENDS
END
END

View File

@ -167,19 +167,19 @@ ENDM
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'
_TEXT ENDS
DATA32 SEGMENT DWORD USE32 PUBLIC 'DATA'
DATA32 ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST32 SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST32 ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'DATA'
CONST ENDS
BSS32 SEGMENT DWORD USE32 PUBLIC 'BSS'
BSS32 ENDS
_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
_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_scale_1 DD 03f700000h ;0.9375
@ -252,7 +252,7 @@ dispatch_table DD offset label0
DD offset label62
DD offset label63
DATA32 ENDS
_DATA ENDS
_TEXT SEGMENT DWORD USE32 PUBLIC 'CODE'

View File

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

View File

@ -23,6 +23,7 @@ extern "C"
#define FILE_NOT_FOUND 5
#define FILE_EOF 6
#if 0
typedef unsigned int DWORD;
typedef unsigned short int WORD;
@ -62,10 +63,6 @@ typedef struct
DWORD size_high;
} FILEINFO;
void _stdcall InitHeap(int heap_size);
void* _stdcall UserAlloc(int size);
int _stdcall UserFree(void* p);
void _stdcall GetNotify(void *event);
void _stdcall CreateThread(void *fn, char *p_stack);
@ -85,7 +82,8 @@ int _stdcall remap_key(int key);
int _cdecl get_button_id();
void delay(int val);
//void delay(int val);
int wait_for_event(int time);
int wait_for_event_infinite();
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 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
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

@ -1,293 +1,296 @@
/****************************************************************************
*
* 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: Configuration for clib builds.
*
****************************************************************************/
#ifndef _VARIETY_H_INCLUDED
#define _VARIETY_H_INCLUDED
//
// Note: for the DLL versions of the runtime libraries, this file must be
// included before any of the runtime header files.
//
#ifndef _COMDEF_H_INCLUDED
#include <_comdef.h>
#endif
// specialized data reference macro
#define _HUGEDATA _WCDATA
// memory model macros
#if defined(__SMALL__)
#define __SMALL_DATA__
#define __SMALL_CODE__
#elif defined(__FLAT__)
#define __SMALL_DATA__
#define __SMALL_CODE__
#elif defined(__MEDIUM__)
#define __SMALL_DATA__
#define __BIG_CODE__
#elif defined(__COMPACT__)
#define __BIG_DATA__
#define __SMALL_CODE__
#elif defined(__LARGE__)
#define __BIG_DATA__
#define __BIG_CODE__
#elif defined(__HUGE__)
#define __BIG_DATA__
#define __BIG_CODE__
#elif defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
// these effectively use near data references
#define __SMALL_DATA__
#define __SMALL_CODE__
#else
#error unable to configure memory model
#endif
// operating system and processor macros
#if defined(__GENERIC__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __GENERIC_386__
#elif defined(M_I86)
#define __REAL_MODE__
#define __GENERIC_086__
#else
#error unrecognized processor for GENERIC
#endif
#elif defined(__OS2__)
#if defined(M_I86)
#define __REAL_MODE__
#define __OS2_286__
#elif defined(__386__)
#define __PROTECT_MODE__
#define __OS2_386__
#define __WARP__
#elif defined(__PPC__)
#define __PROTECT_MODE__
#define __OS2_PPC__
#define __WARP__
#else
#error unrecognized processor for OS2
#endif
#elif defined(__NT__)
#if !defined(WIN32_LEAN_AND_MEAN) && !defined(WIN32_NICE_AND_FAT)
#define WIN32_LEAN_AND_MEAN
#endif
#define __PROTECT_MODE__
#if defined(__386__)
#define __NT_386__
#elif defined(__AXP__)
#define __NT_AXP__
#elif defined(__PPC__)
#define __NT_PPC__
#else
#error unrecognized processor for NT
#endif
#elif defined(__WINDOWS__) || defined(__WINDOWS_386__)
#define __PROTECT_MODE__
#if defined(__386__)
#define __WINDOWS__
#elif defined(M_I86)
#define __WINDOWS_286__
#else
#error unrecognized processor for WINDOWS
#endif
#elif defined(__DOS__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __DOS_386__
#elif defined(M_I86)
#define __REAL_MODE__
#define __DOS_086__
#else
#error unrecognized processor for DOS
#endif
#elif defined(__OSI__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __OSI_386__
#else
#error unrecognized processor for OSI
#endif
#elif defined(__QNX__)
#define __PROTECT_MODE__
#define __UNIX__
#if defined(__386__)
#define __QNX_386__
#elif defined(M_I86)
#define __QNX_286__
#else
#error unrecognized processor for QNX
#endif
#elif defined(__LINUX__)
#define __PROTECT_MODE__
#define __UNIX__
#if defined(__386__)
#define __LINUX_386__
#elif defined(__PPC__)
#define __LINUX_PPC__
#elif defined(__MIPS__)
#define __LINUX_MIPS__
#else
#error unrecognized processor for Linux
#endif
#elif defined(__NETWARE__)
#define __PROTECT_MODE__
#if defined(__386__)
#define __NETWARE_386__
#else
#error unrecognized processor for NETWARE
#endif
#else
#error unable to configure operating system and processor
#endif
// handle building dll's with appropriate linkage
#if !defined(__SW_BR) && (defined(__WARP__) || defined(__NT__))
#if defined(__MAKE_DLL_CLIB)
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllexport) _WRTLCALL
#define _WCIRTLINK __declspec(dllexport) _WRTLCALL
#define _WCRTLINKD __declspec(dllexport)
#define _WMRTLINK __declspec(dllimport) _WRTLCALL
#define _WMIRTLINK __declspec(dllimport) _WRTLCALL
#define _WMRTLINKD __declspec(dllimport)
#define _WPRTLINK __declspec(dllimport) _WRTLCALL
#define _WPIRTLINK __declspec(dllimport) _WRTLCALL
#define _WPRTLINKD __declspec(dllimport)
#elif defined(__WARP__)
#define _WCRTLINK __declspec(dllexport) _WRTLCALL
#define _WCIRTLINK __declspec(dllexport) _WRTLCALL
#define _WCRTLINKD __declspec(dllexport)
#define _WMRTLINK _WRTLCALL
#define _WMIRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK _WRTLCALL
#define _WPIRTLINK _WRTLCALL
#define _WPRTLINKD
#endif
#elif defined(__MAKE_DLL_MATHLIB)
#define _RTDLL
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllimport) _WRTLCALL
#define _WCIRTLINK __declspec(dllimport) _WRTLCALL
#define _WCRTLINKD __declspec(dllimport)
#define _WMRTLINK __declspec(dllexport) _WRTLCALL
#define _WMIRTLINK __declspec(dllexport) _WRTLCALL
#define _WMRTLINKD __declspec(dllexport)
#define _WPRTLINK __declspec(dllimport) _WRTLCALL
#define _WPIRTLINK __declspec(dllimport) _WRTLCALL
#define _WPRTLINKD __declspec(dllimport)
#elif defined(__WARP__)
#define _WCRTLINK _WRTLCALL
#define _WCIRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK __declspec(dllexport) _WRTLCALL
#define _WMIRTLINK __declspec(dllexport) _WRTLCALL
#define _WMRTLINKD __declspec(dllexport)
#define _WPRTLINK _WRTLCALL
#define _WPIRTLINK _WRTLCALL
#define _WPRTLINKD
#endif
#elif defined(__MAKE_DLL_CPPLIB)
#define _RTDLL
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllimport) _WRTLCALL
#define _WCIRTLINK __declspec(dllimport) _WRTLCALL
#define _WCRTLINKD __declspec(dllimport)
#define _WMRTLINK __declspec(dllimport) _WRTLCALL
#define _WMIRTLINK __declspec(dllimport) _WRTLCALL
#define _WMRTLINKD __declspec(dllimport)
#define _WPRTLINK __declspec(dllexport) _WRTLCALL
#define _WPIRTLINK __declspec(dllexport) _WRTLCALL
#define _WPRTLINKD __declspec(dllexport)
#elif defined(__WARP__)
#define _WCRTLINK _WRTLCALL
#define _WCIRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK _WRTLCALL
#define _WMIRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK __declspec(dllexport) _WRTLCALL
#define _WPIRTLINK __declspec(dllexport) _WRTLCALL
#define _WPRTLINKD __declspec(dllexport)
#endif
#endif
#endif
#define __ptr_check( p, a )
#define __null_check( p, a )
#define __stream_check( s, a )
#define __ROUND_UP_SIZE( __x, __amt ) (((__x)+((__amt)-1))&(~((__amt)-1)))
///
/// This doesn't work for far pointer's
///
///#define __ROUND_UP_PTR( __x, __amt ) ((void *)__ROUND_UP_SIZE((unsigned)(__x),__amt))
#if defined(M_I86)
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 2 )
// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 2 )
#elif defined(__386__)
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 4 )
/// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 4 )
#else
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 8 )
// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 8 )
#endif
#endif
/****************************************************************************
*
* 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: Configuration for clib builds.
*
****************************************************************************/
#ifndef _VARIETY_H_INCLUDED
#define _VARIETY_H_INCLUDED
//
// Note: for the DLL versions of the runtime libraries, this file must be
// included before any of the runtime header files.
//
#ifndef _COMDEF_H_INCLUDED
#include <_comdef.h>
#endif
// specialized data reference macro
#define _HUGEDATA _WCDATA
// memory model macros
#if defined(__SMALL__)
#define __SMALL_DATA__
#define __SMALL_CODE__
#elif defined(__FLAT__)
#define __SMALL_DATA__
#define __SMALL_CODE__
#elif defined(__MEDIUM__)
#define __SMALL_DATA__
#define __BIG_CODE__
#elif defined(__COMPACT__)
#define __BIG_DATA__
#define __SMALL_CODE__
#elif defined(__LARGE__)
#define __BIG_DATA__
#define __BIG_CODE__
#elif defined(__HUGE__)
#define __BIG_DATA__
#define __BIG_CODE__
#elif defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
// these effectively use near data references
#define __SMALL_DATA__
#define __SMALL_CODE__
#else
#error unable to configure memory model
#endif
// operating system and processor macros
#if defined(__GENERIC__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __GENERIC_386__
#elif defined(M_I86)
#define __REAL_MODE__
#define __GENERIC_086__
#else
#error unrecognized processor for GENERIC
#endif
#elif defined(__OS2__)
#if defined(M_I86)
#define __REAL_MODE__
#define __OS2_286__
#elif defined(__386__)
#define __PROTECT_MODE__
#define __OS2_386__
#define __WARP__
#elif defined(__PPC__)
#define __PROTECT_MODE__
#define __OS2_PPC__
#define __WARP__
#else
#error unrecognized processor for OS2
#endif
#elif defined(__NT__)
#if !defined(WIN32_LEAN_AND_MEAN) && !defined(WIN32_NICE_AND_FAT)
#define WIN32_LEAN_AND_MEAN
#endif
#define __PROTECT_MODE__
#if defined(__386__)
#define __NT_386__
#elif defined(__AXP__)
#define __NT_AXP__
#elif defined(__PPC__)
#define __NT_PPC__
#else
#error unrecognized processor for NT
#endif
#elif defined(__WINDOWS__) || defined(__WINDOWS_386__)
#define __PROTECT_MODE__
#if defined(__386__)
#define __WINDOWS__
#elif defined(M_I86)
#define __WINDOWS_286__
#else
#error unrecognized processor for WINDOWS
#endif
#elif defined(__DOS__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __DOS_386__
#elif defined(M_I86)
#define __REAL_MODE__
#define __DOS_086__
#else
#error unrecognized processor for DOS
#endif
#elif defined(__OSI__)
#if defined(__386__)
#define __PROTECT_MODE__
#define __OSI_386__
#else
#error unrecognized processor for OSI
#endif
#elif defined(__QNX__)
#define __PROTECT_MODE__
#define __UNIX__
#if defined(__386__)
#define __QNX_386__
#elif defined(M_I86)
#define __QNX_286__
#else
#error unrecognized processor for QNX
#endif
#elif defined(__LINUX__)
#define __PROTECT_MODE__
#define __UNIX__
#if defined(__386__)
#define __LINUX_386__
#elif defined(__PPC__)
#define __LINUX_PPC__
#elif defined(__MIPS__)
#define __LINUX_MIPS__
#else
#error unrecognized processor for Linux
#endif
#elif defined(__NETWARE__)
#define __PROTECT_MODE__
#if defined(__386__)
#define __NETWARE_386__
#else
#error unrecognized processor for NETWARE
#endif
#else
#error unable to configure operating system and processor
#endif
// handle building dll's with appropriate linkage
#if !defined(__SW_BR) && (defined(__WARP__) || defined(__NT__))
#if defined(__MAKE_DLL_CLIB)
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllexport) _WRTLCALL
#define _WCIRTLINK __declspec(dllexport) _WRTLCALL
#define _WCRTLINKD __declspec(dllexport)
#define _WMRTLINK __declspec(dllimport) _WRTLCALL
#define _WMIRTLINK __declspec(dllimport) _WRTLCALL
#define _WMRTLINKD __declspec(dllimport)
#define _WPRTLINK __declspec(dllimport) _WRTLCALL
#define _WPIRTLINK __declspec(dllimport) _WRTLCALL
#define _WPRTLINKD __declspec(dllimport)
#elif defined(__WARP__)
#define _WCRTLINK __declspec(dllexport) _WRTLCALL
#define _WCIRTLINK __declspec(dllexport) _WRTLCALL
#define _WCRTLINKD __declspec(dllexport)
#define _WMRTLINK _WRTLCALL
#define _WMIRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK _WRTLCALL
#define _WPIRTLINK _WRTLCALL
#define _WPRTLINKD
#endif
#elif defined(__MAKE_DLL_MATHLIB)
#define _RTDLL
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllimport) _WRTLCALL
#define _WCIRTLINK __declspec(dllimport) _WRTLCALL
#define _WCRTLINKD __declspec(dllimport)
#define _WMRTLINK __declspec(dllexport) _WRTLCALL
#define _WMIRTLINK __declspec(dllexport) _WRTLCALL
#define _WMRTLINKD __declspec(dllexport)
#define _WPRTLINK __declspec(dllimport) _WRTLCALL
#define _WPIRTLINK __declspec(dllimport) _WRTLCALL
#define _WPRTLINKD __declspec(dllimport)
#elif defined(__WARP__)
#define _WCRTLINK _WRTLCALL
#define _WCIRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK __declspec(dllexport) _WRTLCALL
#define _WMIRTLINK __declspec(dllexport) _WRTLCALL
#define _WMRTLINKD __declspec(dllexport)
#define _WPRTLINK _WRTLCALL
#define _WPIRTLINK _WRTLCALL
#define _WPRTLINKD
#endif
#elif defined(__MAKE_DLL_CPPLIB)
#define _RTDLL
#undef _WCRTLINK
#undef _WCIRTLINK
#undef _WCRTLINKD
#undef _WMRTLINK
#undef _WMIRTLINK
#undef _WMRTLINKD
#undef _WPRTLINK
#undef _WPIRTLINK
#undef _WPRTLINKD
#if defined(__NT__)
#define _WCRTLINK __declspec(dllimport) _WRTLCALL
#define _WCIRTLINK __declspec(dllimport) _WRTLCALL
#define _WCRTLINKD __declspec(dllimport)
#define _WMRTLINK __declspec(dllimport) _WRTLCALL
#define _WMIRTLINK __declspec(dllimport) _WRTLCALL
#define _WMRTLINKD __declspec(dllimport)
#define _WPRTLINK __declspec(dllexport) _WRTLCALL
#define _WPIRTLINK __declspec(dllexport) _WRTLCALL
#define _WPRTLINKD __declspec(dllexport)
#elif defined(__WARP__)
#define _WCRTLINK _WRTLCALL
#define _WCIRTLINK _WRTLCALL
#define _WCRTLINKD
#define _WMRTLINK _WRTLCALL
#define _WMIRTLINK _WRTLCALL
#define _WMRTLINKD
#define _WPRTLINK __declspec(dllexport) _WRTLCALL
#define _WPIRTLINK __declspec(dllexport) _WRTLCALL
#define _WPRTLINKD __declspec(dllexport)
#endif
#endif
#endif
#define __ptr_check( p, a )
#define __null_check( p, a )
#define __stream_check( s, a )
#define __ROUND_UP_SIZE( __x, __amt ) (((__x)+((__amt)-1))&(~((__amt)-1)))
///
/// This doesn't work for far pointer's
///
///#define __ROUND_UP_PTR( __x, __amt ) ((void *)__ROUND_UP_SIZE((unsigned)(__x),__amt))
#if defined(M_I86)
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 2 )
// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 2 )
#elif defined(__386__)
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 4 )
/// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 4 )
#else
#define __ALIGN_SIZE( __x ) __ROUND_UP_SIZE( __x, 8 )
// #define __ALIGN_PTR( __x ) __ROUND_UP_PTR( __x, 8 )
#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 <stddef.h>
#include <stdlib.h>
@ -45,9 +44,7 @@
// #include "tinyio.h"
#endif
#if defined(__WINDOWS_286__) || defined(__NT__)
void* _stdcall UserAlloc(int size);
// #include "windows.h"
#include "kolibri.h"
#endif
#if defined(__OS2__)
// #include <wos2.h>
@ -404,7 +401,7 @@ static int __CreateNewNHeap( unsigned amount )
#elif defined(__NT__)
// brk_value = (unsigned) VirtualAlloc( NULL, amount, MEM_COMMIT,
// PAGE_EXECUTE_READWRITE );
brk_value = (unsigned) UserAlloc (amount );
brk_value = (unsigned) user_alloc(amount );
//brk_value = (unsigned) LocalAlloc( LMEM_FIXED, amount );
if( brk_value == 0 ) {

View File

@ -29,7 +29,6 @@
****************************************************************************/
//#include "dll.h" // needs to be first
#include "variety.h"
#include <stddef.h>
#include <stdlib.h>
@ -40,8 +39,7 @@
// #include "extender.h"
#endif
#if defined(__WINDOWS_286__) || defined(__NT__)
int _stdcall UserFree(void* p);
// #include "windows.h"
#include "kolibri.h"
#endif
#if defined(__OS2__)
// #include <wos2.h>
@ -77,41 +75,6 @@ _WCRTLINK int _nheapmin( void )
defined(__WINDOWS_386__) || \
defined(__NT__) || \
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 )
{
@ -120,7 +83,7 @@ static void __ReleaseMiniHeap( mheapptr mhp )
pprev = mhp->prev;
pnext = mhp->next;
if( __ReturnMemToSystem( mhp ) == 0 ) {
if( user_free( mhp ) == 1 ) {
if( pprev == NULL ) {
__nheapbeg = pnext;
} else {

View File

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