fopen fread fseek lseek ftell

git-svn-id: svn://kolibrios.org@548 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2007-06-21 22:10:44 +00:00
parent 251b27b263
commit f6fbed07ac
145 changed files with 12044 additions and 3101 deletions

View File

@ -0,0 +1,45 @@
/****************************************************************************
*
* 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: Default 80x87 control word.
*
****************************************************************************/
#include <float.h>
/* This is the default value loaded into the 80x87 control word.
If you want higher precision, then change PC_53 to PC_64. The
reason we have the default set to PC_53 is generate reproducible
floating-point results regardless of the level of optimization
chosen for the compiler.
This value is loaded when the 80x87 is initialized by the startup
code, and also when _fpreset is called.
*/
#pragma aux __8087cw "*";
/* 0x1000 | 0x0000 | 0x0200 | 0x007F */
unsigned short __8087cw = IC_AFFINE | RC_NEAR | PC_53 | 0x007F;

View File

@ -0,0 +1,45 @@
/****************************************************************************
*
* 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: prototype for 8087 save/restore state functions and data
*
****************************************************************************/
#if defined(_M_IX86)
typedef struct _87state { /* 80x87 save area */
#if defined( __386__ )
char data[108]; /* 32-bit save area size */
#else
char data[94]; /* 16-bit save area size */
#endif
} _87state;
extern void (*__Save8087)(_87state *);
extern void (*__Rest8087)(_87state *);
#endif

View File

@ -0,0 +1,52 @@
;*****************************************************************************
;*
;* 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 mdef.inc
modstart _8087
xref "C",__chk8087
datasegment
public __8087
public __real87
extrn __no87 :word
__8087 db 0 ; 0 => no 8087 and no EMU, otherwise 8087 or EMU present
__real87 db 0 ; 0 => no real 8087 is used, otherwise real 8087 is used
enddata
include xinit.inc
xinit __chk8087,INIT_PRIORITY_FPU + 3
endmod
end

View File

@ -0,0 +1,35 @@
/****************************************************************************
*
* 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: 80x87 related globals for OSI.
*
****************************************************************************/
#include "variety.h"
unsigned char _8087;
unsigned char _real87;

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: Argument vector and count.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include "initarg.h"
_WCRTLINKD int __F_NAME(___Argc,___wArgc); /* argument count */
_WCRTLINKD CHAR_TYPE** __F_NAME(___Argv,___wArgv); /* argument vector */

View File

@ -0,0 +1,41 @@
/****************************************************************************
*
* 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: Implementation _Exit().
*
****************************************************************************/
#include <stdlib.h>
/* POSIX says _exit() and _Exit() "shall be functionally equivalent" */
_WCRTLINK void _Exit( int status )
/********************************/
{
_exit( status );
}

View File

@ -0,0 +1,54 @@
/****************************************************************************
*
* 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 abort() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <stdlib.h>
#include "rtdata.h"
#include "exitwmsg.h"
#include <signal.h>
#include <unistd.h>
void (*_RWD_abort)( void ) = __terminate;
_WCRTLINK void abort( void )
{
if( _RWD_abort != __terminate ) {
(*_RWD_abort)();
}
__terminate(); /* 23-may-90 */
}
void __terminate( void )
{
__fatal_runtime_error( "ABNORMAL TERMINATION\r\n", EXIT_FAILURE );
}

View File

@ -0,0 +1,49 @@
/****************************************************************************
*
* 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: Argument vector definition and startup.
*
****************************************************************************/
#include "variety.h"
#include "rtinit.h"
#include "widechar.h"
#include <stdlib.h>
#include "initarg.h"
int __F_NAME(_argc,_wargc);
CHAR_TYPE** __F_NAME(_argv,_wargv);
int __F_NAME(__argc,__wargc);
CHAR_TYPE** __F_NAME(__argv,__wargv);
#if defined(__386__) || defined(__AXP__) || defined(__PPC__)
AXI( __F_NAME(__Init_Argv,__wInit_Argv), INIT_PRIORITY_RUNTIME )
AYI( __F_NAME(__Fini_Argv,__wFini_Argv), INIT_PRIORITY_LIBRARY )
#else
AXI( __F_NAME(__Init_Argv,__wInit_Argv), 1 )
AYI( __F_NAME(__Fini_Argv,__wFini_Argv), 1 )
#endif

View File

@ -0,0 +1,43 @@
/****************************************************************************
*
* 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: Special object file to force binary mode when linked in.
*
****************************************************************************/
#include "variety.h"
#include <fcntl.h>
#include <stdlib.h>
#include "rtdata.h"
#include "rtinit.h"
static void do_it( void )
{
_RWD_fmode = O_BINARY;
}
AXI( do_it, INIT_PRIORITY_LIBRARY )

View File

@ -0,0 +1,58 @@
;*****************************************************************************
;*
;* 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 mdef.inc
include struct.inc
xref __STK
modstart chk
xdefp __CHK
xdefp __GRO
defp __CHK
xchg eax,4[esp]
call __STK
mov eax,4[esp]
ret 4
endproc __CHK
defp __GRO
ret 4
endproc __GRO
endmod
end

View File

@ -0,0 +1,344 @@
/****************************************************************************
*
* 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: __chk8087 and other FPU related functions.
*
****************************************************************************/
#include "variety.h"
#include <stdlib.h>
#include <float.h>
#if defined( __OS2__ )
#endif
#if defined( __WINDOWS__ )
#include <i86.h>
#endif
#include "rtdata.h"
#include "exitwmsg.h"
#include "87state.h"
extern void __GrabFP87( void );
extern unsigned short __8087cw;
#pragma aux __8087cw "*";
#if defined( __DOS_086__ )
extern unsigned char __dos87real;
#pragma aux __dos87real "*";
extern unsigned short __dos87emucall;
#pragma aux __dos87emucall "*";
#endif
extern void __init_80x87( void );
#if defined( __DOS_086__ )
#pragma aux __init_80x87 "*" = \
".8087" \
"cmp __dos87real,0" \
"jz l1" \
"finit" \
"fldcw __8087cw" \
"l1: cmp __dos87emucall,0" \
"jz l2" \
"mov ax,1" \
"call __dos87emucall" \
"l2:" ;
#else
#pragma aux __init_80x87 "*" = \
".8087" \
"finit" \
"fldcw __8087cw" ;
#endif
/* 0 => no 8087; 2 => 8087,287; 3=>387 */
extern unsigned char _WCI86NEAR __x87id( void );
#pragma aux __x87id "*";
#if !defined( __UNIX__ ) && !defined( __OS2_386__ )
extern void __fsave( _87state * );
extern void __frstor( _87state * );
#if defined( __386__ )
#pragma aux __fsave = \
0x9b 0xdd 0x30 /* fsave [eax] ; save the 8087 state */ \
0x9b /* wait */ \
parm routine [eax];
#pragma aux __frstor = \
0xdd 0x20 /* frstor [eax] ; restore the 8087 */ \
0x9b /* wait ; wait */ \
parm routine [eax];
#else /* __286__ */
#if defined( __BIG_DATA__ )
#pragma aux __fsave = \
0x53 /* push bx */ \
0x1e /* push ds */ \
0x8e 0xda /* mov ds,dx */ \
0x8b 0xd8 /* mov bx,ax */ \
0x9b 0xdd 0x37 /* fsave [bx] */ \
0x90 0x9b /* fwait */ \
0x1f /* pop ds */ \
0x5b /* pop bx */ \
parm routine [dx ax];
#else
#pragma aux __fsave = \
0x53 /* push bx */ \
0x8b 0xd8 /* mov bx,ax */ \
0x9b 0xdd 0x37 /* fsave [bx] */ \
0x90 0x9b /* fwait */ \
0x5b /* pop bx */ \
parm routine [ax];
#endif
#if defined( __BIG_DATA__ )
#pragma aux __frstor = \
0x53 /* push bx */ \
0x1e /* push ds */ \
0x8e 0xda /* mov ds,dx */ \
0x8b 0xd8 /* mov bx,ax */ \
0x9b 0xdd 0x27 /* frstor [bx] */ \
0x90 0x9b /* fwait */ \
0x1f /* pop ds */ \
0x5b /* pop bx */ \
parm routine [dx ax];
#else
#pragma aux __frstor = \
0x53 /* push bx */ \
0x8b 0xd8 /* mov bx,ax */ \
0x9b 0xdd 0x27 /* frstor [bx] */ \
0x90 0x9b /* fwait */ \
0x5b /* pop bx */ \
parm routine [ax];
#endif
#endif
static void __save_8087( _87state * __fs )
{
__fsave( __fs );
}
static void __rest_8087( _87state * __fs )
{
__frstor( __fs );
}
#endif /* !__UNIX__ && && !__OS2__ */
_WCRTLINK void _fpreset( void )
{
if( _RWD_8087 != 0 ) {
__init_80x87();
}
}
void __init_8087( void )
{
#if !defined( __UNIX__ ) && !defined( __OS2_386__ )
if( _RWD_real87 != 0 )
{ /* if our emulator, don't worry */
_RWD_Save8087 = __save_8087; /* point to real save 8087 routine */
_RWD_Rest8087 = __rest_8087; /* point to real restore 8087 routine */
}
#endif
_fpreset();
}
#if defined( __DOS__ ) || defined( __OS2_286__ )
void _WCI86FAR __default_sigfpe_handler( int fpe_sig )
{
__fatal_runtime_error( "Floating point exception\r\n", EXIT_FAILURE );
}
#endif
#if defined( __OS2__ )
void __chk8087( void )
/********************/
{
char devinfo;
#if defined( __386__ )
DosDevConfig( &devinfo, DEVINFO_COPROCESSOR );
if( devinfo == 0 ) {
_RWD_real87 = 0;
} else {
_RWD_real87 = __x87id();
}
_RWD_8087 = _RWD_real87;
#else
if( _RWD_8087 == 0 ) {
DosDevConfig( &devinfo, 3, 0 );
if( devinfo == 0 ) {
_RWD_real87 = 0;
} else {
_RWD_real87 = __x87id();
}
_RWD_8087 = _RWD_real87;
}
if( _RWD_real87 ) {
__GrabFP87();
}
if( _RWD_8087 ) {
_RWD_FPE_handler = __default_sigfpe_handler;
}
#endif
_fpreset();
}
#elif defined( __QNX__ )
void __chk8087( void )
/********************/
{
extern char __87;
extern char __r87;
_RWD_real87 = __r87;
_RWD_8087 = __87;
_fpreset();
}
#elif defined( __LINUX__ )
void __chk8087( void )
/********************/
{
// TODO: We really need to call Linux and determine if the machine
// has a real FPU or not, so we can properly work with an FPU
// emulator.
_RWD_real87 = __x87id();
_RWD_8087 = _RWD_real87;
_fpreset();
}
#elif defined( __NETWARE__ )
extern short __87present( void );
#pragma aux __87present = \
"smsw ax ", \
"test ax, 4 ", \
"jne no_emu ", \
"xor ax, ax ", \
"no_emu: ", \
"mov ax, 1 " \
value [ ax ];
extern void __chk8087( void )
/*****************************/
{
if( _RWD_8087 == 0 ) {
if( __87present() ) {
_RWD_8087 = 3; /* 387 */
_RWD_real87 = 3;
}
__init_80x87();
}
}
#elif defined( __NT__ )
void __chk8087( void )
/********************/
{
_RWD_real87 = 3; //387+ ; //__x87id();
_RWD_8087 = _RWD_real87;
__init_8087();
}
#elif defined( __DOS__ )
void __chk8087( void )
/********************/
{
if( _RWD_8087 != 0 ) { /* if we already know we have an 80x87 */
#if !defined( __386__ )
if( __dos87real )
__GrabFP87();
#endif
_RWD_FPE_handler = __default_sigfpe_handler;
return; /* this prevents real87 from being set */
} /* when we have an emulator */
_RWD_real87 = __x87id(); /* if a coprocessor is present then we */
_RWD_8087 = _RWD_real87; /* initialize even when NO87 is defined */
#if !defined( __386__ )
__dos87real = _RWD_real87;
#endif
__init_8087(); /* this handles the fpi87 and NO87 case */
if( _RWD_no87 != 0 ) { /* if NO87 environment var is defined */
_RWD_8087 = 0; /* then we want to pretend that the */
_RWD_real87 = 0; /* coprocessor doesn't exist */
}
if( _RWD_real87 ) {
__GrabFP87();
}
if( _RWD_8087 ) {
_RWD_FPE_handler = __default_sigfpe_handler;
}
}
#elif defined( __WINDOWS__ )
void __chk8087( void )
/********************/
{
if( _RWD_8087 != 0 ) /* if we already know we have an 80x87 */
return; /* this prevents real87 from being set */
/* when we have an emulator */
if( GetWinFlags() & WF_80x87 ) { /* if a coprocessor is present then we */
#if defined( __386__ )
extern void pascal _FloatingPoint( void );
_FloatingPoint();
#endif
_RWD_real87 = __x87id(); /* initialize even when NO87 is defined */
_RWD_8087 = _RWD_real87; /* this handles the fpi87 and NO87 case */
__init_8087();
} else {
#if defined( __386__ )
// check to see if emulator is loaded
union REGS regs;
regs.w.ax = 0xfa00;
int86( 0x2f, &regs, &regs );
if( regs.w.ax == 0x0666 ) { /* check for emulator present */
_RWD_real87 = __x87id(); /* initialize even when NO87 is defined */
_RWD_8087 = _RWD_real87; /* this handles the fpi87 and NO87 case */
__init_8087();
}
#endif
}
if( _RWD_no87 != 0 ) { /* if NO87 environment var is defined */
_RWD_8087 = 0; /* then we want to pretend that the */
_RWD_real87 = 0; /* coprocessor doesn't exist */
}
}
#endif

View File

@ -0,0 +1,65 @@
/****************************************************************************
*
* 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: Common clib initialization code.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#if defined(__DOS_386__) && !defined(__OSI__)
#elif defined(__OS2__)
#elif defined(__WINDOWS_386__) || defined(__NT__)
#endif
#if defined(__OS2__)
#endif
#if defined(__DOS_386__) && !defined(__OSI__)
#endif
void __CommonInit( void )
/**************************/
{
#if !defined(__NETWARE__) && !defined(__NT__)
_amblksiz = 32 * 1024; /* set minimum memory block allocation */
#endif
#if defined(__DOS_386__) && !defined(__OSI__)
/*
* If we are running under DOS/4G then we need to page lock interrupt
* handlers (since we could be running under VMM).
*/
if (!_IsPharLap() && (__DPMI_hosted() == 1))
{
DPMILockLinearRegion((long)&__GETDSStart_,
((long)&__GETDSEnd_ - (long)&__GETDSStart_));
}
#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: set commit mode initialization function
*
****************************************************************************/
#include "variety.h"
#include "rtdata.h"
#include "rtinit.h"
#include "commode.h"
/*
* __set_commode function is actually a _WCRTLINK function. It's prototyped
* incorrectly so that this module will work correctly with both dynamic
* and static versions of the C library.
*
* The pragma is there so that this module will work with both stack and
* register calling conventions, eliminating the need to have a separate
* object file for each.
*
* Similarly, __set_commode is declared _WCI86FAR so that the same object
* file will work in any 16-bit memory model.
*/
static void do_it( void )
{
__set_commode();
}
AXI( do_it, INIT_PRIORITY_LIBRARY )

View File

@ -0,0 +1,34 @@
/****************************************************************************
*
* 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: declaration for set commit mode function
*
****************************************************************************/
/* see note in commode.c */
_WCRTLINK extern void _WCI86FAR __set_commode( void );
#pragma aux __set_commode "*_";

View File

@ -0,0 +1,179 @@
;*****************************************************************************
;*
;* 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: C runtime read/write data (386 version).
;*
;*****************************************************************************
name crwdata
.387
.386p
assume nothing
DGROUP group _DATA
_TEXT segment byte public 'CODE'
assume cs:_TEXT
__null_FPE_rtn proc near
ret
__null_FPE_rtn endp
_TEXT ends
_DATA segment dword public 'DATA'
assume DS:DGROUP
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
__EFG_printf dd 0
__EFG_scanf dd 0
__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__
_Extender db 0 ; see clib\h\extender.inc for values
_ExtenderSubtype db 0 ; non-zero -> variant of extender
__X32VM db 0 ; non-zero => X-32VM DOS Extender
endif
_Envptr dd 0 ; offset part of environment pointer
_Envseg dw 0 ; segment containing environment strings
ifndef __QNX__
ifndef __LINUX__
_osmajor db 0 ; major DOS version number
_osminor db 0 ; minor DOS version number
ifdef __NT__
_osbuild dw 0 ; operating system build number
_osver dd 0 ; operating system build number
_winmajor dd 0 ; operating system major version number
_winminor dd 0 ; operating system minor version number
_winver dd 0 ; operating system version number
endif
endif
endif
endif
__FPE_handler dd __null_FPE_rtn ; FPE handler
ifndef __QNX__
ifndef __LINUX__
ifndef __NETWARE__
public "C",_osmajor
public "C",_osminor
ifdef __NT__
public "C",_osbuild
public "C",_osver
public "C",_winmajor
public "C",_winminor
public "C",_winver
public "C",__EFG_printf
public "C",__EFG_scanf
endif
endif
ifdef __DOS__
public "C",_psp
public "C",_Extender
public "C",_ExtenderSubtype
public __X32VM
public __x386_stacklow
endif
ifndef _NETWARE_LIBC
public "C",_LpCmdLine
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
ifdef __OS2__
public "C",_LpDllName
public "C",_LpwCmdLine
public "C",_LpwPgmName
public "C",_LpwDllName
endif
endif
endif
ifndef __NETWARE__
public "C",_dynend
public "C",_curbrk
endif
public "C",_STACKLOW
public "C",_STACKTOP
public __ASTACKSIZ
public __ASTACKPTR
ifndef __NETWARE__
public "C",_cbyte
public "C",_cbyte2
public "C",_child
public "C",_Envptr
public "C",_Envseg
endif
public __no87
public "C",__FPE_handler
_DATA ends
end

View File

@ -0,0 +1,70 @@
name cstrklbri
.386p
assume nothing
extrn __KolibriMain : near
extrn ___begtext : near
extrn __STACKTOP : near
extrn __STACKLOW : near
extrn __FiniRtns : near
extrn _LpCmdLine : near
extrn _LpPgmName : near
_TEXT segment use32 dword public 'CODE'
public _cstart_
public mainCRTStartup
public __exit_
assume cs:_TEXT
_cstart_ proc near
mainCRTStartup:
mov edx, 0x400
mov eax, 0xff
out dx, al
mov eax, esp
sub eax, 8192
mov dword ptr [__STACKTOP],esp ; set stack top
mov dword ptr [__STACKLOW],eax
mov eax, dword ptr [ds:0x001c]
mov ebx, dword ptr [ds:0x0020]
mov dword ptr [_LpCmdLine], eax
mov dword ptr [_LpPgmName], ebx
jmp __KolibriMain
dd ___begtext ; reference module with segment definitions
;
; copyright message
;
db "Open Watcom C/C++32 Run-Time system. "
db "Portions Copyright (c) Sybase, Inc. 1988-2002."
_cstart_ endp
__exit_ proc near
mov eax,00h ; run finalizers
mov edx,0fh ; less than exit
call __FiniRtns ; call finalizer routines
mov eax, -1
int 0x40
ret
__exit_ endp
public _scalbn
_scalbn proc
fild dword ptr [esp+12]
fld qword ptr [esp+4]
fscale
fstp st[1]
ret
_scalbn endp
_TEXT ends
end _cstart_ ;programm entry point

View File

@ -0,0 +1,77 @@
;*****************************************************************************
;*
;* 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: C/C++ Windows NT 32-bit console startup code.
;*
;*****************************************************************************
; This must be assembled using one of the following commands:
; wasm cstrtwnt -bt=NT -ms -3r
; wasm cstrtwnt -bt=NT -ms -3s
;
name cstrtwnt
.386p
assume nothing
extrn __NTMain : near
extrn ___begtext : near
extrn __LpCmdLine : near
extrn __LpPgmName : near
extrn __STACKLOW : near
extrn __STACKTOP : near
_TEXT segment use32 word public 'CODE'
public _cstart_
public mainCRTStartup
assume cs:_TEXT
_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
jmp __NTMain
dd ___begtext ; reference module with segment definitions
;
; copyright message
;
db "Open Watcom C/C++32 Run-Time system. "
db "Portions Copyright (c) Sybase, Inc. 1988-2002."
_cstart_ endp
_TEXT ends
end _cstart_

View File

@ -0,0 +1,50 @@
/****************************************************************************
*
* 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: __CVTBuffer() implementation.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdlib.h>
//#include "liballoc.h"
#include "rtdata.h"
#include "exitwmsg.h"
#include "xfloat.h"
#if defined(__SW_BM)
#include "thread.h"
#endif
#if !defined(__SW_BM)
static MAX_CHAR_TYPE cvt_buffer[ __FPCVT_BUFFERLEN + 1 ];
#endif
_WCRTLINK CHAR_TYPE *__CVTBuffer( void )
{
return( (CHAR_TYPE *)_RWD_cvtbuf );
}

View File

@ -0,0 +1,84 @@
/****************************************************************************
*
* 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: errno related functions.
*
****************************************************************************/
#include "variety.h"
#include "rtdata.h"
#if defined(__QNX__)
#include <sys/magic.h>
#include <errno.h>
_WCRTLINK int *__get_errno_ptr( void )
{
#if defined(__386__)
void *err_ptr;
__getmagicvar( &err_ptr, _m_errno_ptr );
return( err_ptr );
#else
return( (int *)&__MAGIC.Errno );
#endif
}
#elif defined(__LINUX__)
#include "errorno.h"
#if !defined( __SW_BM )
_WCRTLINKD int errno;
#endif
_WCRTLINK int *__get_errno_ptr( void )
{
return( &_RWD_errno );
}
#else
#include "errorno.h"
#if !defined( __SW_BM )
_WCRTLINKD int errno;
_WCRTLINKD int _doserrno;
#endif
_WCRTLINK int *__get_errno_ptr( void )
{
return( &_RWD_errno );
}
_WCRTLINK int *__get_doserrno_ptr( void )
{
return( &_RWD_doserrno );
}
#endif

View File

@ -0,0 +1,39 @@
/****************************************************************************
*
* 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: Module to initialize errno access.
*
****************************************************************************/
#include "variety.h"
#include "rtinit.h"
extern void __initerrno( void );
_WCRTLINKD unsigned errno;
AXI( __initerrno, INIT_PRIORITY_LIBRARY )

View File

@ -0,0 +1,60 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
#if defined(__OS2__) || defined(__NT__)
#if defined(__SW_BM)
#include "thread.h"
#define _ERRNO (__THREADDATAPTR->__errnoP)
#define _DOSERRNO (__THREADDATAPTR->__doserrnoP)
#else
#define _ERRNO errno
#define _DOSERRNO _doserrno
#endif
#else
// QNX errno is magically multithread aware
// What does NETWARE do?
#if !defined (_NETWARE_LIBC)
#define _ERRNO errno
#else
extern int * ___errno(void);
#define _ERRNO *___errno() /* get LibC errno */
#endif
#ifndef __NETWARE__
#define _DOSERRNO _doserrno
#endif
#endif

View File

@ -0,0 +1,84 @@
/****************************************************************************
*
* 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: Implementation of exit() and associated functions.
*
****************************************************************************/
#include "variety.h"
#include "rtdata.h"
#include "exitwmsg.h"
#include "initfini.h"
#include "rtinit.h"
#include <stdio.h>
#include <stdlib.h>
//#include "defwin.h"
#include "widechar.h"
#include "initarg.h"
/*
__int23_exit is used by OS/2 as a general termination routine which unhooks
exception handlers. A better name for this variable is __sig_exit.
__sig_exit should be the system dependent signal termination routine and
should replace the calls to __int23_exit and __FPE_handler_exit.
Each OS should define its own __sig_exit and do the appropriate thing (for
example, DOS version would call __int23_exit and __FPE_handler_exit)
*/
#if defined(__NT__) || defined(__WARP__)
_WCRTLINK extern void (*__process_fini)( unsigned, unsigned );
#endif
#if !defined(__UNIX__) && !defined(__WINDOWS_386__)
static void _null_exit_rtn() {}
void (*__FPE_handler_exit)() = _null_exit_rtn;
#endif
_WCRTLINK void exit( int status )
{
#if defined(__UNIX__)
#elif defined(__WINDOWS_386__)
#elif defined(__NT__) || defined(__WARP__)
__FiniRtns( FINI_PRIORITY_EXIT, 255 );
#else
__FiniRtns( FINI_PRIORITY_EXIT, 255 );
#endif
_exit( status );
}
#ifndef __NETWARE__
_WCRTLINK void _exit( int status )
{
__exit( status );
}
#endif

View File

@ -0,0 +1,85 @@
/****************************************************************************
*
* 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: Fatal runtime error handlers.
*
****************************************************************************/
#ifndef _EXITWMSG_H_INCLUDED
#define _EXITWMSG_H_INCLUDED
#include "variety.h"
#ifdef __cplusplus
extern "C" {
#endif
#undef _EWM_PARM1
#undef _EWM_PARM2
#if defined(__386__)
#define _EWM_PARM1 eax
#define _EWM_PARM2 edx
#elif defined(M_I86)
#define _EWM_PARM1 ax dx
#define _EWM_PARM2 bx
#else
#define _EWM_PARM1
#define _EWM_PARM2
#endif
// C interface
// - tracks normal calling convention
// - this is the funtion that is called from ASM and from C, C++
// - note there is no #pragma aborts so that debugger can trace out
_WCRTLINK extern void __exit_with_msg( char _WCI86FAR *, unsigned );
_WCRTLINK extern void __fatal_runtime_error( char _WCI86FAR *, unsigned );
// ASM interface
// - always uses register calling convention
// - this function is only called from the C implementation
// of __exit_with_msg
extern void __do_exit_with_msg( char _WCI86FAR *, unsigned );
#ifdef _M_IX86
#pragma aux __do_exit_with_msg "*__" \
parm caller [_EWM_PARM1] [_EWM_PARM2];
#endif
#undef _EWM_PARM1
#undef _EWM_PARM2
_WCRTLINKD extern char volatile __WD_Present;
// WVIDEO interface
// this function should be called before __exit_with_msg()
// to allow Watcom Debugger (nee WVIDEO) to trap runtime errors.
// this really needs to be far!!!
_WCRTLINK extern int __EnterWVIDEO( char _WCFAR *string );
#ifdef __cplusplus
};
#endif
#endif

View File

@ -0,0 +1,53 @@
;*****************************************************************************
;*
;* 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!
;*
;*****************************************************************************
ifdef __WASM__
ifdef __386__
extrn "C",__fatal_runtime_error : near
else
ifdef __SMALL__
extrn "C",__fatal_runtime_error : near
endif
ifdef __COMPACT__
extrn "C",__fatal_runtime_error : near
endif
ifdef __MEDIUM__
extrn "C",__fatal_runtime_error : far
endif
ifdef __LARGE__
extrn "C",__fatal_runtime_error : far
endif
ifdef __HUGE__
extrn "C",__fatal_runtime_error : far
endif
endif
endif

View File

@ -0,0 +1,74 @@
/****************************************************************************
*
* 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: Far pointer support typedefs.
*
****************************************************************************/
#ifndef _FARSUPP_H_INCLUDED
#define _FARSUPP_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#ifdef __LONG_LONG_SUPPORT__
#include "clibi64.h"
#endif
/* Only support near/far pointers on 16-bit targets, extended DOS
* and Win386. Ideally we might want to test for non-flat memory model.
*/
#if defined( _M_I86 ) || defined( __DOS__ ) || defined( __WINDOWS__ )
#define __FAR_SUPPORT__
typedef CHAR_TYPE _WCFAR *FAR_STRING;
typedef char _WCFAR *FAR_ASCII_STRING;
typedef wchar_t _WCFAR *FAR_UNI_STRING;
typedef int _WCFAR *FAR_INT;
typedef signed char _WCFAR *FAR_CHAR;
typedef short _WCFAR *FAR_SHORT;
typedef long _WCFAR *FAR_LONG;
typedef float _WCFAR *FAR_FLOAT;
typedef double _WCFAR *FAR_DOUBLE;
#ifdef __LONG_LONG_SUPPORT__
typedef UINT64_TYPE _WCFAR *FAR_INT64;
#endif
#else
#undef __FAR_SUPPORT__
typedef CHAR_TYPE *FAR_STRING;
typedef char *FAR_ASCII_STRING;
typedef wchar_t *FAR_UNI_STRING;
typedef int *FAR_INT;
typedef signed char *FAR_CHAR;
typedef short *FAR_SHORT;
typedef long *FAR_LONG;
typedef float *FAR_FLOAT;
typedef double *FAR_DOUBLE;
#ifdef __LONG_LONG_SUPPORT__
typedef UINT64_TYPE *FAR_INT64;
#endif
#endif
#endif

View File

@ -0,0 +1,47 @@
/****************************************************************************
*
* 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: Module to invoke floating-point support initialiation.
*
****************************************************************************/
#include "variety.h"
#include "rtinit.h"
#if defined(__AXP__) || defined(__386__) || defined(__PPC__)
unsigned _fltused_ = 0;
#else
unsigned _fltused_ = 1;
#endif
#if defined(_M_IX86)
#pragma aux _fltused_ "*";
#endif
extern void __setEFGfmt( void );
AXI( __setEFGfmt, INIT_PRIORITY_LIBRARY )

View File

@ -0,0 +1,52 @@
/****************************************************************************
*
* 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: Floating-point exception handler wrapper.
*
****************************************************************************/
#include "variety.h"
#include "rtdata.h"
/*
__FPE_exception is called from machine language with parm in EAX/AX
(see "fstatus" module in CGSUPP)
*/
#if defined(__386__)
#define parmreg eax
#else
#define parmreg ax
#endif
void __FPE_exception( int fpe_type );
#pragma aux __FPE_exception "*_" parm caller [parmreg];
void __FPE_exception( int fpe_type )
{
_RWD_FPE_handler( fpe_type );
}

View File

@ -0,0 +1,45 @@
/****************************************************************************
*
* 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: Prototypes for floating-point formatting routines.
*
****************************************************************************/
#ifndef _FTOS_H_INCLUDED
#define _FTOS_H_INCLUDED
#include "variety.h"
#include "farsupp.h"
_WCRTLINK extern FAR_STRING (*__EFG_printf)();
_WCRTLINK extern void (*__EFG_scanf)();
extern FAR_STRING _EFG_Format();
extern void __cnvs2d();
_WMRTLINK extern FAR_STRING (*__get_EFG_Format())();
_WMRTLINK extern void (*__get__cnvs2d())();
#endif

View File

@ -0,0 +1,58 @@
/****************************************************************************
*
* 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: prototypes for arguments processing variables
*
****************************************************************************/
#ifndef _INITARG_H_INCLUDED
#define _INITARG_H_INCLUDED
extern int __F_NAME(_argc,_wargc); /* argument count */
extern CHAR_TYPE **__F_NAME(_argv,_wargv); /* argument vector */
extern void __F_NAME(__Init_Argv,__wInit_Argv)( void );
extern void __F_NAME(__Fini_Argv,__wFini_Argv)( void );
_WCRTLINKD extern int __F_NAME(___Argc,___wArgc); /* argument count */
_WCRTLINKD extern CHAR_TYPE**__F_NAME(___Argv,___wArgv); /* argument vector */
_WCRTLINKD extern char *_LpCmdLine; /* pointer to command line */
_WCRTLINKD extern char *_LpPgmName; /* pointer to program name */
extern char *_LpDllName; /* pointer to dll name */
_WCRTLINKD extern wchar_t *_LpwCmdLine; /* pointer to wide command line */
_WCRTLINKD extern wchar_t *_LpwPgmName; /* pointer to wide program name */
extern wchar_t *_LpwDllName; /* pointer to wide dll name */
#if defined(__WINDOWS_386__)
extern char __Is_DLL;
#else
extern int __Is_DLL;
#endif
#endif

View File

@ -0,0 +1,222 @@
/****************************************************************************
*
* 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: Functions to set up argc and argv parameters of main(), etc.
*
****************************************************************************/
#define __NETWARE__
#ifdef __NETWARE__
void __Init_Argv( void ) { }
void __Fini_Argv( void ) { }
#else
//#include "dll.h" // needs to be first
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <io.h>
//#include "liballoc.h"
#include "initarg.h"
extern int __historical_splitparms;
extern void _Not_Enough_Memory( void ); /* 25-jul-89 */
static unsigned _SplitParms(int, CHAR_TYPE *, CHAR_TYPE **, CHAR_TYPE ** );
_WCRTLINKD static CHAR_TYPE *__F_NAME(__CmdLine,__wCmdLine); /* cmdline buffer */
_WCRTLINK void *__F_NAME( _getargv, _wgetargv )(
int historical, CHAR_TYPE *exe, CHAR_TYPE *cmd,
int *pargc, CHAR_TYPE ***pargv );
void __F_NAME(__Init_Argv,__wInit_Argv)( void )
{
__F_NAME( __CmdLine, __wCmdLine ) = __F_NAME( _getargv, _wgetargv )(
__historical_splitparms,
__F_NAME( _LpPgmName, _LpwPgmName ), __F_NAME( _LpCmdLine, _LpwCmdLine ),
&__F_NAME( _argc, _wargc ), &__F_NAME( _argv, _wargv ) );
__F_NAME( __argc, __wargc ) = __F_NAME( _argc, _wargc );
__F_NAME( ___Argc, ___wArgc ) = __F_NAME( _argc, _wargc );
__F_NAME( __argv, __wargv ) = __F_NAME( _argv, _wargv );
__F_NAME( ___Argv, ___wArgv ) = __F_NAME( _argv, _wargv );
}
_WCRTLINK void *__F_NAME( _getargv, _wgetargv )(
int historical, CHAR_TYPE *exe, CHAR_TYPE *cmd,
int *pargc, CHAR_TYPE ***pargv )
{
unsigned argc; /* argument count */
CHAR_TYPE **argv; /* Actual arguments */
CHAR_TYPE *endptr; /* ptr to end of command line */
unsigned len; /* length of command line */
CHAR_TYPE *cmdline; /* copy of command line */
unsigned size; /* amount to allocate */
unsigned argv_offset; /* offset of argv in storage */
argc = _SplitParms( historical, cmd, NULL, &endptr ) + 1;
len = (unsigned) ( endptr - cmd ) + 1;
argv_offset = __ALIGN_SIZE(len * sizeof(CHAR_TYPE));
size = argv_offset + (argc+1) * sizeof(CHAR_TYPE *);
// round up size for alignment of argv pointer
size = __ALIGN_SIZE( size );
#if defined(__REAL_MODE__) && defined(__BIG_DATA__)
#if defined(__OS2_286__)
if( _osmode == DOS_MODE ) {
cmdline = lib_nmalloc( size );
if( (void _WCI86NEAR *) cmdline == NULL ) {
cmdline = lib_malloc( size );
}
} else {
cmdline = lib_malloc( size );
}
#else
cmdline = lib_nmalloc( size );
if( (void _WCI86NEAR *) cmdline == NULL ) {
cmdline = lib_malloc( size );
}
#endif
#else
cmdline = lib_malloc( size );
#endif
argv = NULL;
argc = 0;
if( cmdline ) {
memcpy( cmdline, cmd, len * sizeof(CHAR_TYPE) );
argv = (void *) ( ( ( char*) cmdline ) + argv_offset );
argv[0] = exe;
argc = _SplitParms( historical, cmdline, argv + 1, &endptr ) + 1;
argv[argc] = NULL;
}
*pargc = argc;
*pargv = argv;
return( cmdline );
}
static unsigned _SplitParms( int historical, CHAR_TYPE *p, CHAR_TYPE **argv, CHAR_TYPE **endptr )
{
register unsigned argc;
register CHAR_TYPE *start;
register CHAR_TYPE *new;
enum QUOTE_STATE {
QUOTE_NONE, /* no " active in current parm */
QUOTE_DELIMITER, /* " was first char and must be last */
QUOTE_STARTED /* " was seen, look for a match */
};
register enum QUOTE_STATE state;
argc = 0;
for(;;) {
while( *p == ' ' || *p == '\t' ) {
++p; /* skip over blanks or tabs */
}
if( *p == '\0' ) break;
/* we are at the start of a parm */
state = QUOTE_NONE;
if( *p == '\"' ) {
p++;
state = QUOTE_DELIMITER;
}
new = start = p;
for(;;) {
if( *p == '\"' ) {
if( !historical ) {
p++;
if( state == QUOTE_NONE ) {
state = QUOTE_STARTED;
} else {
state = QUOTE_NONE;
}
continue;
} else {
if( state == QUOTE_DELIMITER ) {
break;
}
}
}
if( *p == ' ' || *p == '\t' ) {
if( state == QUOTE_NONE ) {
break;
}
}
if( *p == '\0' ) break;
if( *p == '\\' ) {
if( !historical ) {
if( p[1] == '\"' ) {
++p;
if( p[-2] == '\\' ) {
continue;
}
}
} else {
if( p[1] == '\"' || p[1] == '\\' && state == QUOTE_DELIMITER ) {
++p;
}
}
}
if( argv ) {
*(new++) = *p;
}
++p;
}
if( argv ) {
argv[ argc ] = start;
++argc;
/*
The *new = '\0' is req'd in case there was a \" to "
translation. It must be after the *p check against
'\0' because new and p could point to the same char
in which case the scan would be terminated too soon.
*/
if( *p == '\0' ) {
*new = '\0';
break;
}
*new = '\0';
++p;
} else {
++argc;
if( *p == '\0' ) {
break;
}
++p;
}
}
*endptr = p;
return( argc );
}
void __F_NAME(__Fini_Argv,__wFini_Argv)( void )
{
if( __F_NAME(__CmdLine,__wCmdLine) != NULL ) {
lib_free( __F_NAME(__CmdLine,__wCmdLine) );
}
}
#endif

View File

@ -0,0 +1,86 @@
/****************************************************************************
*
* 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: Init/Fini routines delcarations.
*
****************************************************************************/
#ifndef _INITFINI_H_INCLUDED
#define _INITFINI_H_INCLUDED
#include "variety.h"
#include "rtinit.h"
#if defined(__386__)
#define __PARMREG1 eax
#define __PARMREG2 edx
#elif defined(M_I86)
#define __PARMREG1 ax
#define __PARMREG2 dx
#else
#define __PARMREG1
#define __PARMREG2
#endif
extern void __InitRtns( unsigned );
// - takes priority limit parm in __PARMREG1
// code will run init routines whose
// priority is <= __PARMREG1 (really [0-255])
// __PARMREG1==255 -> run all init routines
// __PARMREG1==15 -> run init routines whose priority is <= 15
#if defined(_M_IX86)
#pragma aux __InitRtns "*" parm [__PARMREG1]
#if !defined(__386__)
extern void _WCI86FAR __FInitRtns(unsigned);
#pragma aux __FInitRtns "*" parm [__PARMREG1]
#endif
#endif
extern void __FiniRtns(unsigned,unsigned);
// - takes priority limit range in __PARMREG1, __PARMREG2
// code will run fini routines whose
// priority is >= __PARMREG1 (really [0-255]) and
// <= __PARMREG2 (really [0-255])
// __PARMREG1==0 ,__PARMREG2==255 -> run all fini routines
// __PARMREG1==16,__PARMREG2==255 -> run fini routines in range 16...255
// __PARMREG1==16,__PARMREG2==40 -> run fini routines in range 16...40
#if defined(_M_IX86)
#pragma aux __FiniRtns "*" parm [__PARMREG1] [__PARMREG2]
#if !defined(__386__)
extern void _WCI86FAR __FFiniRtns( unsigned, unsigned );
#pragma aux __FFiniRtns "*" parm [__PARMREG1] [__PARMREG2]
#endif
#endif
#if defined(__OS2__) && defined(__386__)
#define EXIT_PRIORITY_CLIB 0x00009F00
#endif
#undef __PARMREG1
#undef __PARMREG2
#endif

View File

@ -0,0 +1,293 @@
/****************************************************************************
*
* 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: Initialization and termination of clib.
*
****************************************************************************/
#include "variety.h"
#include "initfini.h"
#include "rtinit.h"
#define PNEAR ((__type_rtp)0)
#define PFAR ((__type_rtp)1)
#define PDONE ((__type_rtp)2)
#if ( COMP_CFG_COFF == 1 ) || defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
// following is an attempt to drop the need for an assembler
// segment definitions file
// unfortunately, the use of XIB,XIE,YIB,YIE doesn't get the
// right sort of segments by default
#pragma data_seg( ".rtl$xib", "DATA" );
YIXI( TS_SEG_XIB, _Start_XI, 0, 0 )
#pragma data_seg( ".rtl$xie", "DATA" );
YIXI( TS_SEG_XIE, _End_XI, 0, 0 )
#pragma data_seg( ".rtl$yib", "DATA" );
YIXI( TS_SEG_YIB, _Start_YI, 0, 0 )
#pragma data_seg( ".rtl$yie", "DATA" );
YIXI( TS_SEG_YIE, _End_YI, 0, 0 )
#pragma data_seg( ".data", "DATA" );
#elif defined(_M_IX86)
extern struct rt_init _Start_XI;
extern struct rt_init _End_XI;
extern struct rt_init _Start_YI;
extern struct rt_init _End_YI;
#else
#error unsupported platform
#endif
typedef void (*pfn)(void);
typedef void (_WCI86FAR * _WCI86FAR fpfn)(void);
typedef void (_WCI86NEAR * _WCI86NEAR npfn)(void);
#if defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
#define __GETDS()
#define save_ds()
#define restore_ds()
#define save_es()
#define restore_es()
#define setup_es()
#elif defined(__WINDOWS_386__)
#define __GETDS()
#define save_ds()
#define restore_ds()
#define save_es()
#define restore_es()
#define setup_es()
#elif defined(__386__)
#define __GETDS()
#define save_ds()
#define restore_ds()
#if defined(__FLAT__)
#define save_es()
#define restore_es()
#define setup_es()
#else
extern void save_es( void );
#pragma aux save_es = modify exact [es];
extern void restore_es( void );
#pragma aux restore_es = modify exact [es];
extern void setup_es( void );
#pragma aux setup_es = \
"push ds" \
"pop es" \
modify exact [es];
#endif
#elif defined(M_I86)
extern void save_dx( void );
#pragma aux save_dx = modify exact [dx];
extern void _WCI86NEAR __GETDS( void );
#pragma aux __GETDS "__GETDS";
extern void save_ds( void );
#pragma aux save_ds = "push ds" modify exact [sp];
extern void restore_ds( void );
#pragma aux restore_ds = "pop ds" modify exact [sp];
#define save_es()
#define restore_es()
#else
#error unsupported platform
#endif
#if defined(M_I86)
static void callit_near( npfn *f ) {
// don't call a null pointer
if( *f ) {
save_dx();
save_ds();
// call function
(void)(**f)();
restore_ds();
}
}
static void callit_far( fpfn _WCI86NEAR *f ) {
// don't call a null pointer
if( *f ) {
save_ds();
// call function
(void)(**f)();
restore_ds();
}
}
#else
static void callit( pfn *f ) {
// don't call a null pointer
if( *f ) {
// QNX needs es==ds
setup_es();
// call function
(void)(**f)();
}
}
#endif
/*
; - takes priority limit parm in eax, code will run init routines whose
; priority is < eax (really al [0-255])
; eax==255 -> run all init routines
; eax==15 -> run init routines whose priority is <= 15
;
*/
void __InitRtns( unsigned limit ) {
__type_rtp local_limit;
struct rt_init _WCI86NEAR *pnext;
save_ds();
save_es();
__GETDS();
local_limit = (__type_rtp)limit;
for(;;) {
{
__type_rtp working_limit;
struct rt_init _WCI86NEAR *pcur;
pcur = (struct rt_init _WCI86NEAR*)&_Start_XI;
#if defined(COMP_CFG_COFF)
pcur++;
#endif
pnext = (struct rt_init _WCI86NEAR*)&_End_XI;
working_limit = local_limit;
// walk list of routines
while( pcur < (struct rt_init _WCI86NEAR*)&_End_XI )
{
// if this one hasn't been called
if( pcur->rtn_type != PDONE ) {
// if the priority is better than best so far
if( pcur->priority <= working_limit )
{
// remember this one
pnext = pcur;
working_limit = pcur->priority;
}
}
// advance to next entry
pcur++;
}
// check to see if all done, if we didn't find any
// candidates then we can return
if( pnext == (struct rt_init _WCI86NEAR*)&_End_XI ) {
break;
}
}
#if defined(M_I86)
if( pnext->rtn_type == PNEAR ) {
callit_near( (npfn *)&pnext->rtn );
} else {
callit_far( (fpfn _WCI86NEAR *)&pnext->rtn );
}
#else
callit( &pnext->rtn );
#endif
// mark entry as invoked
pnext->rtn_type = PDONE;
}
restore_es();
restore_ds();
}
/*
; - takes priority range parms in eax, edx, code will run fini routines whose
; priority is >= eax (really al [0-255]) and <= edx (really dl [0-255])
; eax==0, edx=255 -> run all fini routines
; eax==16, edx=255 -> run fini routines in range 16..255
; eax==16, edx=40 -> run fini routines in range 16..40
*/
#if defined(M_I86)
void _WCI86FAR __FFiniRtns( unsigned min_limit, unsigned max_limit ) {
__FiniRtns( min_limit, max_limit );
}
#endif
void __FiniRtns( unsigned min_limit, unsigned max_limit )
{
__type_rtp local_min_limit;
__type_rtp local_max_limit;
struct rt_init _WCI86NEAR *pnext;
save_ds();
save_es();
__GETDS();
local_min_limit = (__type_rtp)min_limit;
local_max_limit = (__type_rtp)max_limit;
for(;;) {
{
__type_rtp working_limit;
struct rt_init _WCI86NEAR *pcur;
pcur = (struct rt_init _WCI86NEAR*)&_Start_YI;
#if defined(COMP_CFG_COFF)
pcur++;
#endif
pnext = (struct rt_init _WCI86NEAR*)&_End_YI;
working_limit = local_min_limit;
// walk list of routines
while( pcur < (struct rt_init _WCI86NEAR*)&_End_YI )
{
// if this one hasn't been called
if( pcur->rtn_type != PDONE ) {
// if the priority is better than best so far
if( pcur->priority >= working_limit )
{
// remember this one
pnext = pcur;
working_limit = pcur->priority;
}
}
// advance to next entry
pcur++;
}
// check to see if all done, if we didn't find any
// candidates then we can return
if( pnext == (struct rt_init _WCI86NEAR*)&_End_YI ) {
break;
}
}
if( pnext->priority <= local_max_limit ) {
#if defined(M_I86)
if( pnext->rtn_type == PNEAR ) {
callit_near( (npfn *)&pnext->rtn );
} else {
callit_far( (fpfn _WCI86NEAR *)&pnext->rtn );
}
#else
callit( &pnext->rtn );
#endif
}
// mark entry as invoked even if we don't call it
// if we didn't call it, it is because we don't want to
// call finirtns with priority > max_limit, in that case
// marking the function as called, won't hurt anything
pnext->rtn_type = PDONE;
}
restore_es();
restore_ds();
}

View File

@ -0,0 +1,33 @@
#include "variety.h"
#include "initfini.h"
_WCRTLINKD extern char *LpCmdLine; /* pointer to command line */
_WCRTLINKD extern char *LpPgmName; /* pointer to program name */
_WCRTLINKD int ___Argc; /* argument count */
_WCRTLINKD char * ___Argv[2]; /* argument vector */
_WCRTLINK void exit( int status );
_WCRTLINK extern void (*__process_fini)( unsigned, unsigned );
extern int main( int, char ** );
#pragma aux __KolibriMain "*";
void __KolibriMain(void )
/***************************************/
{ ___Argc = 2;
___Argv[0] = LpPgmName;
___Argv[1] = LpCmdLine;
// __process_fini = &__FiniRtns;
__InitRtns( 255 );
// __CommonInit();
exit( main( ___Argc, ___Argv ) );
}

View File

@ -0,0 +1,113 @@
/****************************************************************************
*
* 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: Establish common stuff for a target environment for
* language-related processors.
*
****************************************************************************/
#ifndef __LANGENV_H__
#define __LANGENV_H__
// This file uses __TGT_SYS to figure out the required target.
//
// langenvd.h contains the possible values.
//
// __TGT_SYS_X86 is the default
//
#include "langenvd.h"
#ifndef __TGT_SYS
#define __TGT_SYS __TGT_SYS_X86
#endif
#if __TGT_SYS == __TGT_SYS_X86
#define TS_SEG_CODE "_TEXT"
#define TS_SEG_CONST "CONST"
#define TS_SEG_CONST2 "CONST2"
#define TS_SEG_DATA "_DATA"
#define TS_SEG_TIB "TIB"
#define TS_SEG_TI "TI"
#define TS_SEG_TIE "TIE"
#define TS_SEG_XIB "XIB"
#define TS_SEG_XI "XI"
#define TS_SEG_XIE "XIE"
#define TS_SEG_YIB "YIB"
#define TS_SEG_YI "YI"
#define TS_SEG_YIE "YIE"
#define TS_SEG_YC "YC"
#define TS_SEG_BSS "_BSS"
#define TS_SEG_STACK "STACK"
#define TS_SEG_DEPENDS "not used"
#define TS_SEG_TLSB ".tls"
#define TS_SEG_TLS ".tls$"
#define TS_SEG_TLSE ".tls$ZZZ"
#define TS_SEG_TLS_CLASS "TLS"
#define TS_MAX_OBJNAME 256
#define TS_DATA_MANGLE "_*"
#define TS_CODE_MANGLE "*_"
#elif __TGT_SYS == __TGT_SYS_AXP_NT || __TGT_SYS == __TGT_SYS_PPC_NT || __TGT_SYS == __TGT_SYS_MIPS
#define TS_SEG_CODE ".text"
#define TS_SEG_CONST ".const"
#define TS_SEG_CONST2 ".const2"
#define TS_SEG_DATA ".data"
#define TS_SEG_TIB ".rtl$tib"
#define TS_SEG_TI ".rtl$tid"
#define TS_SEG_TIE ".rtl$tie"
#define TS_SEG_XIB ".rtl$xib"
#define TS_SEG_XI ".rtl$xid"
#define TS_SEG_XIE ".rtl$xie"
#define TS_SEG_YIB ".rtl$yib"
#define TS_SEG_YI ".rtl$yid"
#define TS_SEG_YIE ".rtl$yie"
#define TS_SEG_YC ".rtl$yc"
#define TS_SEG_BSS ".bss"
#define TS_SEG_STACK ".stack"
#define TS_SEG_DEPENDS ".depend"
#define TS_SEG_TLSB ".tls"
#define TS_SEG_TLS ".tls$"
#define TS_SEG_TLSE ".tls$ZZZ"
#define TS_SEG_TLS_CLASS NULL
#define TS_MAX_OBJNAME 1024
#define TS_DATA_MANGLE "*"
#define TS_CODE_MANGLE "*"
#else
#error Invalid target system
#endif
#undef __TGT_SYS
#endif

View File

@ -0,0 +1,33 @@
;*****************************************************************************
;*
;* 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!
;*
;*****************************************************************************
COMP_CFG_COFF equ 0

View File

@ -0,0 +1,40 @@
/****************************************************************************
*
* 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: Define values for language targets.
*
****************************************************************************/
#ifndef __LANGENVD_H__
#define __LANGENVD_H__
#define __TGT_SYS_X86 0 // All x86 systems to date
#define __TGT_SYS_AXP_NT 1 // Win32 on DEC Alpha AXP
#define __TGT_SYS_PPC_NT 2 // Win32 on IBM/Motorola PowerPC
#define __TGT_SYS_MIPS 3 // MIPS RISC Architecture
#endif

View File

@ -0,0 +1,105 @@
/****************************************************************************
*
* 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: Implementation of __NTMain().
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <windows.h>
//#include "ntex.h"
//#include "sigtab.h"
#include "initfini.h"
#include "initarg.h"
void _cdecl mf_init();
void _stdcall InitHeap(int heap_size);
int __appcwdlen;
char* __appcwd;
_WCRTLINK void (*__process_fini)(unsigned,unsigned) = 0;
extern void __CommonInit( void );
extern int wmain( int, wchar_t ** );
extern int main( int, char ** );
extern char *LpCmdLine;
extern char *LpPgmName;
void __F_NAME(__NTMain,__wNTMain)( void )
/***************************************/
{
InitHeap(32*1024*1024);
//mf_init();
__process_fini = &__FiniRtns;
__InitRtns( 255 );
__CommonInit();
__appcwdlen = strrchr(_LpPgmName, '/') - _LpPgmName + 1;
__appcwdlen = __appcwdlen > 512 ? 512 : __appcwdlen;
__appcwd= (char*)malloc(__appcwdlen);
strncpy(__appcwd, _LpPgmName, __appcwdlen);
__appcwd[__appcwdlen] = 0;
___Argc = 2;
___Argv[0] = _LpPgmName;
___Argv[1] = _LpCmdLine;
#ifdef __WIDECHAR__
exit( wmain( ___wArgc, ___wArgv ) );
#else
exit( main( ___Argc, ___Argv ) );
#endif
}
#ifdef __WIDECHAR__
#if defined(_M_IX86)
#pragma aux __wNTMain "*"
#endif
#else
#if defined(_M_IX86)
#pragma aux __NTMain "*"
#endif
#endif
_WCRTLINK void __exit( unsigned ret_code )
{
__FiniRtns( 0, FINI_PRIORITY_EXIT-1 );
_asm
{
mov eax, -1
int 0x40
}
}

View File

@ -0,0 +1,358 @@
;*****************************************************************************
;*
;* 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: Memory model setup for interfacing with C code.
;*
;*****************************************************************************
_SMALL_CODE = 00h
_BIG_CODE = 01h
_SMALL_DATA = 00h
_BIG_DATA = 02h
_HUGE_DATA = 04h
_LONG_INTS = 08h
_USE_32_SEGS = 10h
_386 = 10h ; from old clib
_DS_PEGGED = 20h ; from old clib (used for Windows)
_TINY = 40h ; from old clib (formerly 10h)
_FLAT = ( _SMALL_CODE or _SMALL_DATA or _USE_32_SEGS )
_SMALL = ( _SMALL_CODE or _SMALL_DATA )
_COMPACT = ( _SMALL_CODE or _BIG_DATA )
_MEDIUM = ( _BIG_CODE or _SMALL_DATA )
_LARGE = ( _BIG_CODE or _BIG_DATA )
_HUGE = ( _BIG_CODE or _HUGE_DATA )
_EMULATION = 00h
_8087 = 01h
ifdef __WASM__
ifdef __FLAT__
_MODEL = _FLAT
endif
ifdef __SMALL__
_MODEL = _SMALL
endif
ifdef __COMPACT__
_MODEL = _COMPACT
endif
ifdef __MEDIUM__
_MODEL = _MEDIUM
endif
ifdef __LARGE__
_MODEL = _LARGE
endif
ifdef __HUGE__
_MODEL = _HUGE
endif
ifdef __386__
_MODEL = ( _MODEL or _USE_32_SEGS )
endif
ifdef __WINDOWS__
if _MODEL and (_BIG_DATA or _HUGE_DATA)
_MODEL = ( _MODEL or _DS_PEGGED )
endif
endif
ifdef __FPC__
_MATH = _EMULATION
endif
ifdef __FPI__
_MATH = _8087
endif
ifdef __FPI87__
_MATH = _8087
endif
else
include .\model.inc ; defines _MODEL, _MATH symbols
endif
if _MODEL and _BIG_CODE
modstart macro modname,alignment
ifdef NDEBUG
name modname
endif
ifb <alignment>
_TEXT segment word public 'CODE'
else
_TEXT segment alignment public 'CODE'
endif
assume cs:_TEXT
endm
calli macro regname
call dword ptr [regname]
endm
codeptr macro p1,p2
ifb <p2>
extrn p1 : dword
else
extrn "&p1",p2 : dword
endif
endm
docall macro dest
call far ptr dest
endm
dojmp macro dest
jmp far ptr dest
endm
defp macro dsym,exp
dsym proc far exp
endm
defpe macro dsym
ifdef _EXPORT
dsym proc far export
else
dsym proc far
endif
endm
defn macro dsym
dsym proc near
endm
endproc macro dsym
dsym endp
endm
epilog macro
if _MODEL and _USE_32_SEGS
pop EBP
dec EBP
mov ESP,EBP
else
pop BP
dec BP
endif
endm
prolog macro
if _MODEL and _USE_32_SEGS
inc EBP
push EBP
mov EBP,ESP
else
inc BP
push BP
mov BP,SP
endif
endm
xdefp macro p1,p2
ifb <p2>
public p1
else
public "&p1",p2
endif
endm
xref macro p1,p2
ifb <p2>
extrn `p1` : far
else
extrn "&p1",`p2` : far
endif
endm
lcall macro dest
push cs
call near ptr dest
endm
else
modstart macro modname,alignment
ifdef NDEBUG
name modname
endif
if _MODEL and _USE_32_SEGS
_TEXT segment use32 alignment public 'CODE'
else
_TEXT segment alignment public 'CODE'
endif
assume cs:_TEXT
endm
calli macro regname
call regname
endm
codeptr macro p1,p2
if _MODEL and _USE_32_SEGS
ifb <p2>
extrn p1 : dword
else
extrn "&p1",p2 : dword
endif
else
ifb <p2>
extrn p1 : word
else
extrn "&p1",p2 : word
endif
endif
endm
defn macro dsym
dsym proc near
endm
defp macro dsym,exp
dsym proc near exp
endm
defpe macro dsym
ifdef _EXPORT
dsym proc near export
else
dsym proc near
endif
endm
docall macro dest
call dest
endm
dojmp macro dest
jmp dest
endm
endproc macro dsym
dsym endp
endm
epilog macro
if _MODEL and _USE_32_SEGS
pop EBP
else
pop BP
endif
endm
prolog macro
if _MODEL and _USE_32_SEGS
push EBP
mov EBP,ESP
else
push BP
mov BP,SP
endif
endm
xdefp macro p1,p2
ifb <p2>
public p1
else
public "&p1",p2
endif
endm
xref macro p1,p2
ifb <p2>
extrn `p1` : near
else
extrn "&p1",`p2` : near
endif
endm
lcall macro dest
call dest
endm
endif
endmod macro
_TEXT ends
endm
dataseg macro
DGROUP group _DATA
assume ds:DGROUP,ss:DGROUP
if _MODEL and _USE_32_SEGS
_DATA segment use32 dword public 'DATA'
else
_DATA segment word public 'DATA'
endif
endm
datasegment macro
dataseg ; should be phased out
endm
enddata macro
_DATA ends
endm
bss_segment macro
if _MODEL and _USE_32_SEGS
_BSS segment use32 dword public 'BSS'
else
_BSS segment word public 'BSS'
endif
DGROUP group _BSS
assume ds:DGROUP
endm
endbss macro
_BSS ends
endm
alias_function macro alias, function
ifb <function>
xref "C",_&alias
else
xref "C",function
endif
.code
public "C",`alias`
ifdef _EXPORT
`alias` proc export
else
`alias` proc
endif
ifb <function>
jmp _&alias
else
jmp `function`
endif
`alias` endp
endm
xred macro p1,p2,p3
ifb <p3>
extrn p1 : p2
else
extrn "&p1",p2 : p3
endif
endm

View File

@ -0,0 +1,211 @@
/****************************************************************************
*
* 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: Internal CLIB structures and variables.
*
****************************************************************************/
#ifndef _RTDATA_H_INCLUDED
#define _RTDATA_H_INCLUDED
#include "variety.h"
#include <stdio.h>
#include "errorno.h"
/* DOS based platforms have stdaux/stdprn in addition to stdin/out/err */
#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OSI__)
#define NUM_STD_STREAMS 5
#else
#define NUM_STD_STREAMS 3
#endif
#if defined(__NT__) || defined(__OS2__)
struct __pipe_info {
int isPipe; /* non-zero if it's a pipe */
int pid; /* PID of spawned process */
};
#endif
typedef struct __stream_link {
struct __stream_link * next;
struct __iobuf * stream;
unsigned char * _base; /* location of buffer */
int _orientation; /* wide/byte/not oriented */
int _extflags; /* extended flags */
unsigned char _tmpfchar; /* tmpfile number */
unsigned char _filler[sizeof(int)-1];/* explicit padding */
#if defined(__NT__) || defined(__OS2__)
struct __pipe_info pipeInfo; /* pipe-related fields */
#endif
} __stream_link;
typedef void _WCI86FAR FPEhandler( int );
#define _FP_BASE(__fp) ((__fp)->_link->_base)
#ifndef __NETWARE__
#define _FP_ORIENTATION(__fp) ((__fp)->_link->_orientation)
#define _FP_EXTFLAGS(__fp) ((__fp)->_link->_extflags)
#endif
#define _FP_TMPFCHAR(__fp) ((__fp)->_link->_tmpfchar)
#ifndef __NETWARE__
#define _FP_PIPEDATA(__fp) ((__fp)->_link->pipeInfo)
#endif
extern __stream_link *__OpenStreams;
extern __stream_link *__ClosedStreams;
extern char * _WCNEAR __env_mask; /* ptr to char array of flags */
extern FPEhandler *__FPE_handler;
extern void (*__FPE_handler_exit)( void );
#if !defined(__NETWARE__)
extern int _cbyte;
extern int _cbyte2;
extern int _child;
extern int __umaskval;
extern unsigned _curbrk;
extern int _commode;
#endif
#if !defined (_NETWARE_LIBC)
extern unsigned _STACKTOP;
#endif
#if !defined(__QNX__) && !defined(__LINUX__)
extern void (*__Save8087)();/* Ptr to FP state save rtn (spawn) */
extern void (*__Rest8087)();/* Ptr to FP state restore rtn (spawn) */
#endif
extern unsigned short _8087cw; /* control word initializer */
extern unsigned char _no87; /* NO87 environment var defined */
extern unsigned char _8087; /* type of 8087/emulator present */
extern unsigned char _real87; /* 8087 coprocessor hardware present */
#if defined(_M_IX86)
#pragma aux _8087cw "_*";
#pragma aux _no87 "_*";
#pragma aux _8087 "_*";
#pragma aux _real87 "_*";
#endif
#if !defined(__SW_BM)
extern unsigned _STACKLOW;
#endif
#define _RWD_ostream __OpenStreams
#define _RWD_cstream __ClosedStreams
#define _RWD_iob __iob
#if !defined(__NETWARE__)
#define _RWD_threadid _threadid
#endif
#define _RWD_environ environ
#define _RWD_wenviron _wenviron
#define _RWD_env_mask __env_mask
#define _RWD_abort __abort
#define _RWD_sigtab __SIGNALTABLE
#define _RWD_FPE_handler_exit __FPE_handler_exit
#define _RWD_FPE_handler __FPE_handler
#define _RWD_fmode _fmode
#if !defined(__NETWARE__)
#define _RWD_umaskval __umaskval
#define _RWD_cbyte _cbyte
#define _RWD_cbyte2 _cbyte2
#define _RWD_child _child
#define _RWD_amblksiz _amblksiz
#define _RWD_curbrk _curbrk
#define _RWD_dynend _dynend
#define _RWD_psp _psp
#endif
#if !defined (_NETWARE_LIBC)
#define _RWD_stacktop _STACKTOP
#endif
#if !defined(__QNX__) && !defined(__LINUX__)
#define _RWD_Save8087 __Save8087
#define _RWD_Rest8087 __Rest8087
#endif
#define _RWD_8087cw _8087cw
#define _RWD_no87 _no87
#define _RWD_8087 _8087
#define _RWD_real87 _real87
#if !defined(__NETWARE__)
#define _RWD_HShift _HShift
#define _RWD_osmajor _osmajor
#define _RWD_osminor _osminor
#define _RWD_osmode _osmode
#if defined(__NT__)
#define _RWD_osbuild _osbuild
#define _RWD_osver _osver
#define _RWD_winmajor _winmajor
#define _RWD_winminor _winminor
#define _RWD_winver _winver
#endif
#define _RWD_doserrno _DOSERRNO
#endif
#define _RWD_tmpfnext __tmpfnext
#if !defined(_RWD_errno)
#define _RWD_errno _ERRNO
#endif
#define _RWD_nexttok _NEXTTOK
#define _RWD_nextftok _NEXTFTOK
#define _RWD_nextmbtok _NEXTMBTOK
#define _RWD_nextmbftok _NEXTMBFTOK
#define _RWD_nextwtok _NEXTWTOK
#define _RWD_tzname tzname
#define _RWD_timezone timezone
#define _RWD_daylight daylight
#define _RWD_dst_adjust __dst_adjust
#define _RWD_start_dst __start_dst
#define _RWD_end_dst __end_dst
#define _RWD_asctime _RESULT
#ifdef __SW_BM
#define _RWD_cvtbuf __THREADDATAPTR->__cvt_buffer
#else
#define _RWD_cvtbuf cvt_buffer
#endif
#if defined(__NETWARE__)
#define _RWD_ioexit __ioexit
#define _RWD_tmpnambuf (__THREADDATAPTR->__tmpnambuf)
#define _RWD_randnextinit (__THREADDATAPTR->__randnextinit)
#else
#define _RWD_tmpnambuf _tmpname
#define _RWD_randnextinit THREAD_PTR.__randnextinit
#endif
#define _RWD_stacklow _STACKLOW
#define _RWD_randnext _RANDNEXT
#define _RWD_ThreadData _ThreadData
#define _RWD_StaticInitSema _StaticInitSema
#define _RWD_PureErrorFlag _PureErrorFlag
#define _RWD_UndefVfunFlag _UndefVfunFlag
#define _RWD_ModuleInit _ModuleInit
/*
For the sake of efficiency, tell the compiler
that the __exit... routines never return.
*/
_WCRTLINK extern void __exit( unsigned );
#if defined(_M_IX86)
#pragma aux __exit aborts;
#endif
extern void (*__abort)( void ); // Defined in abort.c
extern void __terminate( void ); // Defined in abort.c
#endif // _RTDATA_H_INCLUDED

View File

@ -0,0 +1,131 @@
/****************************************************************************
*
* 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: Structures for run-time initialization/finalization.
*
****************************************************************************/
#ifndef __RTINIT_H__
#define __RTINIT_H__
#include "langenvd.h"
#if defined( __PPC__ )
#define __TGT_SYS __TGT_SYS_AXP_PPC
typedef unsigned __type_rtp;
typedef unsigned __type_pad;
typedef void( *__type_rtn ) ( void );
#elif defined( __AXP__ )
#define __TGT_SYS __TGT_SYS_AXP_NT
typedef unsigned __type_rtp;
typedef unsigned __type_pad;
typedef void( *__type_rtn ) ( void );
#elif defined( __MIPS__ )
#define __TGT_SYS __TGT_SYS_MIPS
typedef unsigned __type_rtp;
typedef unsigned __type_pad;
typedef void( *__type_rtn ) ( void );
#else
#define __TGT_SYS __TGT_SYS_X86
typedef unsigned char __type_rtp;
typedef unsigned short __type_pad;
#if defined( __386__ )
typedef void __near( *__type_rtn ) ( void );
#else
typedef void( *__type_rtn ) ( void );
#endif
#endif
#include "langenv.h"
#if defined( __MEDIUM__ ) || defined( __LARGE__ ) || defined( __HUGE__ )
#define __LARGE_CODE__
#endif
// initialization progresses from highest priority to lowest
// finalization progresses from lowest to highest
#pragma pack( 1 )
struct rt_init // structure placed in XI/YI segment
{
__type_rtp rtn_type; // - near=0/far=1 routine indication
// also used when walking table to flag
// completed entries
__type_rtp priority; // - priority (0-highest 255-lowest)
__type_rtn rtn; // - routine
#if !( defined( __LARGE_CODE__ ) || defined( __386__ ) ) || defined( COMP_CFG_COFF )
__type_pad padding; // - padding, when small code ptr
// or when risc cpu
#endif
};
#pragma pack()
#if defined( M_I86 )
#if defined( __LARGE_CODE__ ) /* segmented large code models */
#define YIXI( seg, label, routine, priority ) \
struct rt_init __based( __segname( seg ) ) label = \
{ 1, priority, routine };
#else /* other segmented models */
#define YIXI( seg, label, routine, priority ) \
struct rt_init __based( __segname( seg ) ) label = \
{ 0, priority, routine, 0 };
#endif
#else /* non-segmented architectures */
#define YIXI( seg, label, routine, priority ) \
struct rt_init __based( __segname( seg ) ) label = \
{ 0, priority, routine };
#endif
/*
Use these when you want a global label for the XI/YI structure
*/
#define XI( label, routine, priority ) YIXI( TS_SEG_XI, label, routine, priority )
#define YI( label, routine, priority ) YIXI( TS_SEG_YI, label, routine, priority )
/*
Use these when you don't care about the label on the XI/YI structure
*/
#define __ANON( x ) __anon ## x
#define ANON( x ) __ANON( x )
#define AXI( routine, priority ) static XI( ANON( __LINE__ ), routine, priority )
#define AYI( routine, priority ) static YI( ANON( __LINE__ ), routine, priority )
enum {
INIT_PRIORITY_THREAD = 1, // priority for thread data init
INIT_PRIORITY_FPU = 2, // priority for FPU/EMU init
INIT_PRIORITY_RUNTIME = 10, // priority for run/time initialization
INIT_PRIORITY_IOSTREAM = 20, // priority for IOSTREAM
INIT_PRIORITY_LIBRARY = 32, // default library-initialization priority
INIT_PRIORITY_PROGRAM = 64, // default program-initialization priority
FINI_PRIORITY_DTOR = 40, // priority for module DTOR
DTOR_PRIORITY = 40, // priority for module DTOR
FINI_PRIORITY_EXIT = 16 // when exit() is called, functions between
// 255 and this are called, the rest of the
// fini routines are called from __exit().
};
/* have to turn off, or we get unref'd warnings for AXI & AYI stuff */
#pragma off( unreferenced )
#endif

View File

@ -0,0 +1,40 @@
/****************************************************************************
*
* 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 "87state.h"
#include "rtdata.h"
static void _do_nothing( _87state *st ) {}
void (*_RWD_Save8087)(_87state *) = _do_nothing;
void (*_RWD_Rest8087)(_87state *) = _do_nothing;

View File

@ -0,0 +1,140 @@
;*****************************************************************************
;*
;* 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

View File

@ -0,0 +1,48 @@
/****************************************************************************
*
* 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: Routine to bring in real floating-point formatting code.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "ftos.h"
#include "farsupp.h"
/* This routine will be called by cstart if "_fltused" is referenced. */
void __setEFGfmt( void )
{
#ifdef __SW_BR
__EFG_printf = __get_EFG_Format();
__EFG_scanf = __get__cnvs2d(); /* 27-mar-90 */
#else
__EFG_printf = _EFG_Format;
__EFG_scanf = __cnvs2d; /* 27-mar-90 */
#endif
}

View File

@ -0,0 +1,59 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
#ifndef _STACKLOW_H_INCLUDED
#define _STACKLOW_H_INCLUDED
#define __Align4K( x ) (((x)+0xfffL) & ~0xfffL )
#if defined(_M_IX86)
extern unsigned _SP();
#if defined(__386__)
#pragma aux _SP = "mov eax,esp" value [eax];
#else
#pragma aux _SP = "mov ax,sp" value [ax];
#endif
#endif
#if defined(__NT__)
void __init_stack_limits( unsigned *stacklow, unsigned *stacktop );
#endif
#if defined(__SW_BM)
#include "thread.h"
#define _STACKLOW (__THREADDATAPTR->__stklowP)
#else
extern unsigned _STACKLOW;
#endif
#endif

View File

@ -0,0 +1,68 @@
/****************************************************************************
*
* 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: Dummy stack check routines for non-x86 Win32 platforms.
*
****************************************************************************/
#include "variety.h"
#include "rtdata.h"
#include "stacklow.h"
#include "exitwmsg.h"
#if defined(__AXP__) || defined(__PPC__)
void _init_stk( void )
{
}
_WCRTLINK unsigned __CHK( unsigned i )
{
return( i );
}
_WCRTLINK void __GRO( unsigned i )
{
i = i;
}
_WCRTLINK void __STKOVERFLOW( void )
{
__fatal_runtime_error( "stack overflow", -1 );
}
#endif
_WCRTLINK unsigned stackavail()
{
#if defined(__AXP__) || defined(__PPC__)
unsigned _SP;
_SP = (unsigned)&_SP;
return( _SP - _RWD_stacklow );
#else
return( _SP() - _RWD_stacklow );
#endif
}

View File

@ -0,0 +1,120 @@
;*****************************************************************************
;*
;* 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 mdef.inc
include struct.inc
include xinit.inc
include exitwmsg.inc
modstart stk
datasegment
extrn "C",_STACKLOW : dword
msg db "Stack Overflow!", 0dh, 0ah, 0
enddata
xinit _init_stk,DEF_PRIORITY
assume ds:DGROUP
defp _init_stk
ret ; return
endproc _init_stk
xdefp __CHK
defpe __CHK ; new style stack check
xchg eax,4[esp] ; get parm in eax
call __STK ; call stack checker
mov eax,4[esp] ; restore eax
ret 4
endproc __CHK
xdefp __STK
defpe __STK
push eax ; save parm for __GRO routine
_guess ; guess: no overflow
cmp eax,esp ; - quit if user asking for too much
_quif ae ; - ...
sub eax,esp ; - calculate new low point
neg eax ; - calc what new SP would be
cmp eax,_STACKLOW ; - quit if too much
_quif be ; - ...
call __GRO ; - return
ret
_endguess ; endguess
__STKOVERFLOW:
xdefp "C",__STKOVERFLOW
pop eax ; pop the stack
ifdef __STACK__
push 1 ; ...
push offset msg ; print the error message
else
mov eax,offset msg ; print the error message
mov edx,1 ; ...
endif
call __fatal_runtime_error ; ...
endproc __STK
xdefp __GRO
defpe __GRO ; dummy function to resolve symbol
push eax ; save regs
push ebx ; ...
mov eax,12[esp] ; get size to grow by
mov ebx,-4 ; initialiaze index
lup: ; do {
mov [esp+ebx],ebx ; - touch that stack page
sub ebx,1000H ; - decrement by 4k
sub eax,1000H ; - decrement by 4k
jg lup ; } while stack left to go
pop ebx ; restore regs
pop eax ; ...
ret 4 ; return to caller
endproc __GRO
xdefp __alloca_probe
; on entry eax is size of stack to grow
; on exit esp has been advanced to new size
defpe __alloca_probe ; ms compatible function
push eax ; size parm to __GRO
call __GRO
push eax ; save size
lea eax,8[esp] ; get esp value to adjust
sub eax,[esp] ; carve off piece of stack
xchg eax,esp ; set new esp
mov eax,4[eax] ; snag return address
jmp eax ; return to caller
endproc __alloca_probe
endmod
end

View File

@ -0,0 +1,220 @@
;*****************************************************************************
;*
;* 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: Structured macros for MASM/WASM.
;*
;*****************************************************************************
__label = 0
__depth = 0
__inner_loop = 0
_guess macro name
__depth = __depth + 1
__label = __label + 1
_set __astk,%__depth,__label,<>
__label = __label + 1
_set __estk,%__depth,__label,<>
ifnb <name>
name = __label
endif
endm
_quif macro cc,name
ifnb <name>
_set __elbl,,name,<>
_j cc,_l,%__elbl
else
_set __albl,,__astk,%__depth
_j cc,_l,%__albl
endif
endm
_quit macro name
_quif ,name
endm
_admit macro
_set __albl,,__astk,%__depth
__label = __label + 1
_set __astk,%__depth,__label,<>
_set __elbl,,__estk,%__depth
_j ,_l,%__elbl
_label _l,%__albl
endm
_endguess macro
_set __albl,,__astk,%__depth
_label _l,%__albl
_set __elbl,,__estk,%__depth
_label _l,%__elbl
__depth = __depth - 1
endm
_loop macro name
_guess name
_set __albl,,__astk,%__depth
_label _m,%__albl
_set __elbl,,__estk,%__depth
_label _m,%__elbl
_set __llbl,%__depth,%__inner_loop,<>
_set __inner_loop,,%__depth,<>
endm
_loopif macro cc,name
ifnb <name>
_set __elbl,,name,<>
_j cc,_m,%__elbl
else
_set __albl,,__astk,%__inner_loop
_j cc,_m,%__albl
endif
endm
_until macro cc
_set __albl,,__astk,%__depth
_jn cc,_m,%__albl
_set __inner_loop,,__llbl,%__depth
_endguess
endm
_endloop macro
_set __albl,,__astk,%__depth
_j ,_m,%__albl
_set __inner_loop,,__llbl,%__depth
_endguess
endm
_if macro cc
_guess
_set __albl,,__astk,%__depth
_jn cc,_l,%__albl
endm
_else macro
_admit
endm
_endif macro
_endguess
endm
_set macro base1,ext1,base2,ext2
base1&ext1 = base2&ext2
endm
_label macro base,ext
base&ext:
endm
_j macro cc,base,ext
j&cc base&ext
endm
_jn macro cc,base,ext
jn&cc base&ext
endm
jnna macro label
ja label
endm
jnnae macro label
jae label
endm
jnnb macro label
jb label
endm
jnnbe macro label
jbe label
endm
jnnc macro label
jc label
endm
jnne macro label
je label
endm
jnng macro label
jg label
endm
jnnge macro label
jge label
endm
jnnl macro label
jl label
endm
jnnle macro label
jle label
endm
jnno macro label
jo label
endm
jnnp macro label
jp label
endm
jnns macro label
js label
endm
jnnz macro label
jz label
endm
jnpe macro label
jpo label
endm
jnpo macro label
jpe label
endm
j macro label
jmp label
endm
jn macro label
nop
endm
_shl macro reg,count
add reg,reg
endm
_rcl macro reg,count
adc reg,reg
endm

View File

@ -0,0 +1,293 @@
/****************************************************************************
*
* 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

View File

@ -0,0 +1,74 @@
/****************************************************************************
*
* 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: Macros for single source wide/narrow character code.
*
****************************************************************************/
#ifndef _WIDECHAR_H_INCLUDED
#define _WIDECHAR_H_INCLUDED
#include "variety.h"
#include <stdlib.h> /* for wchar_t and _atouni */
/*** Define some handy macros ***/
#ifdef __WIDECHAR__
#define DIR_TYPE struct _wdirent
#define CHAR_TYPE wchar_t
#define UCHAR_TYPE wchar_t
#define INTCHAR_TYPE wint_t
#define INT_WC_TYPE wchar_t
#define VOID_WC_TYPE wchar_t
#define NULLCHAR 0
#define STRING(a) L##a
#define _AToUni(p1,p2) _atouni(p1,p2)
#define IS_ASCII(c) ( (c & 0xff00) == 0 )
#define TO_ASCII(c) ( c )
#define __F_NAME(n1,n2) n2
#define UNICODE
#define _UNICODE
#define __UNICODE__
#else
#define DIR_TYPE struct dirent
#define CHAR_TYPE char
#define UCHAR_TYPE unsigned char
#define INTCHAR_TYPE int
#define INT_WC_TYPE int
#define VOID_WC_TYPE void
#define NULLCHAR '\0'
#define STRING(a) a
#define _AToUni(p1,p2) (p2)
#define IS_ASCII(c) ( 1 )
#define TO_ASCII(c) ( (unsigned char)c )
#define __F_NAME(n1,n2) n1
#endif
#define CHARSIZE (sizeof( CHAR_TYPE ))
/* must be the larger of char and wchar_t */
#define MAX_CHAR_TYPE wchar_t
#endif

View File

@ -0,0 +1,479 @@
/****************************************************************************
*
* 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: C/C++ run-time library floating-point definitions.
*
****************************************************************************/
#ifndef _XFLOAT_H_INCLUDED
#define _XFLOAT_H_INCLUDED
#include <stddef.h> // for wchar_t
#include <float.h> // for LDBL_DIG
#ifdef __cplusplus
extern "C" {
#endif
#if (defined(__386__) || defined(M_I86)) && defined(__WATCOMC__)
#define _LONG_DOUBLE_
#endif
typedef struct { // This layout matches Intel 8087
#ifdef _LONG_DOUBLE_
unsigned long low_word; // - low word of fraction
unsigned long high_word; // - high word of fraction
unsigned short exponent; // - exponent and sign
#else // use this for all other 32-bit RISC
union {
double value; // - double value
unsigned long word[2];// - so we can access bits
};
#endif
} long_double;
typedef struct { // Layout of IEEE 754 double (FD)
union {
double value; // - double value
unsigned long word[2];// - so we can access bits
};
} float_double;
typedef struct { // Layout of IEEE 754 single (FS)
union {
float value; // - double value
unsigned long word; // - so we can access bits
};
} float_single;
/* NB: The following values *must* match FP_ macros in math.h! */
enum ld_classification {
__ZERO = 0,
__DENORMAL = 1,
__NONZERO = 2,
__NAN = 3,
__INFINITY = 4
};
enum ldcvt_flags {
E_FMT = 0x0001, // 'E' format
F_FMT = 0x0002, // 'F' format
G_FMT = 0x0004, // 'G' format
F_CVT = 0x0008, // __cvt routine format rules
F_DOT = 0x0010, // always put '.' in result
LONG_DOUBLE = 0x0020, // number is true long double
NO_TRUNC = 0x0040, // always provide ndigits in buffer
IN_CAPS = 0x0080, // 'inf'/'nan' is uppercased
};
typedef struct cvt_info {
int ndigits; // INPUT: number of digits
int scale; // INPUT: FORTRAN scale factor
int flags; // INPUT: flags (see ldcvt_flags)
int expchar; // INPUT: exponent character to use
int expwidth; // INPUT/OUTPUT: number of exponent digits
int sign; // OUTPUT: 0 => +ve; otherwise -ve
int decimal_place; // OUTPUT: position of '.'
int n1; // OUTPUT: number of leading characters
int nz1; // OUTPUT: followed by this many '0's
int n2; // OUTPUT: followed by these characters
int nz2; // OUTPUT: followed by this many '0's
} CVT_INFO;
_WMRTLINK extern void __LDcvt(
long_double *pld, // pointer to long_double
CVT_INFO *cvt, // conversion info
char *buf ); // buffer
#if defined( __WATCOMC__ )
_WMRTLINK extern int __Strtold(
const char *bufptr,
long_double *pld,
char **endptr );
#endif
extern int __LDClass( long_double * );
extern void __ZBuf2LD(char _WCNEAR *, long_double _WCNEAR *);
extern void _LDScale10x(long_double _WCNEAR *,int);
_WMRTLINK extern void __cnvd2ld( double _WCNEAR *src, long_double _WCNEAR *dst );
_WMRTLINK extern void __cnvs2d( char *buf, double *value );
_WMRTLINK extern int __cnvd2f( double *src, float *tgt );
#ifdef _LONG_DOUBLE_
extern void __iLDFD(long_double _WCNEAR *, double _WCNEAR *);
extern void __iLDFS(long_double _WCNEAR *, float _WCNEAR *);
extern void __iFDLD(double _WCNEAR *,long_double _WCNEAR *);
extern void __iFSLD(float _WCNEAR *,long_double _WCNEAR *);
extern long __LDI4(long_double _WCNEAR *);
extern void __I4LD(long,long_double _WCNEAR *);
extern void __U4LD(unsigned long,long_double _WCNEAR *);
extern void __FLDA(long_double _WCNEAR *,long_double _WCNEAR *,long_double _WCNEAR *);
extern void __FLDS(long_double _WCNEAR *,long_double _WCNEAR *,long_double _WCNEAR *);
extern void __FLDM(long_double _WCNEAR *,long_double _WCNEAR *,long_double _WCNEAR *);
extern void __FLDD(long_double _WCNEAR *,long_double _WCNEAR *,long_double _WCNEAR *);
extern int __FLDC(long_double _WCNEAR *,long_double _WCNEAR *);
#endif
#ifdef __WATCOMC__
#if defined(__386__)
#pragma aux __ZBuf2LD "*" parm caller [eax] [edx];
#if defined(__FPI__)
extern unsigned __Get87CW(void);
extern void __Set87CW(unsigned short);
#pragma aux __Get87CW = \
"push 0"\
float "fstcw [esp]"\
float "fwait"\
"pop eax"\
value [eax];
#pragma aux __Set87CW = \
"push eax"\
float "fldcw [esp]"\
"pop eax"\
parm caller [eax];
#pragma aux __FLDA = \
float "fld tbyte ptr [eax]"\
float "fld tbyte ptr [edx]"\
float "fadd"\
float "fstp tbyte ptr [ebx]"\
parm caller [eax] [edx] [ebx];
#pragma aux __FLDS = \
float "fld tbyte ptr [eax]"\
float "fld tbyte ptr [edx]"\
float "fsub"\
float "fstp tbyte ptr [ebx]"\
parm caller [eax] [edx] [ebx];
#pragma aux __FLDM = \
float "fld tbyte ptr [eax]"\
float "fld tbyte ptr [edx]"\
float "fmul"\
float "fstp tbyte ptr [ebx]"\
parm caller [eax] [edx] [ebx];
#pragma aux __FLDD = \
float "fld tbyte ptr [eax]"\
float "fld tbyte ptr [edx]"\
float "fdiv"\
float "fstp tbyte ptr [ebx]"\
parm caller [eax] [edx] [ebx];
#pragma aux __FLDC = \
/* ST(1) */\
float "fld tbyte ptr [edx]"\
/* ST(0) */\
float "fld tbyte ptr [eax]"\
/* compare ST(0) with ST(1) */\
float "fcompp"\
float "fstsw ax"\
"sahf"\
"sbb edx,edx"\
"shl edx,1"\
"shl ah,2"\
"cmc"\
"adc edx,0"\
/* edx will be -1,0,+1 if [eax] <, ==, > [edx] */\
parm caller [eax] [edx] value [edx];
#pragma aux __LDI4 = \
float "fld tbyte ptr [eax]"\
"push eax"\
"push eax"\
float "fstcw [esp]"\
float "fwait"\
"pop eax"\
"push eax"\
"or ah,0x0c"\
"push eax"\
float "fldcw [esp]"\
"pop eax"\
float "fistp dword ptr 4[esp]"\
float "fldcw [esp]"\
"pop eax"\
"pop eax"\
parm caller [eax] value [eax];
#pragma aux __I4LD = \
"push eax"\
float "fild dword ptr [esp]"\
"pop eax"\
float "fstp tbyte ptr [edx]"\
parm caller [eax] [edx];
#pragma aux __U4LD = \
"push 0"\
"push eax"\
float "fild qword ptr [esp]"\
"pop eax"\
"pop eax"\
float "fstp tbyte ptr [edx]"\
parm caller [eax] [edx];
#pragma aux __iFDLD = \
float "fld qword ptr [eax]"\
float "fstp tbyte ptr [edx]"\
parm caller [eax] [edx];
#pragma aux __iFSLD = \
float "fld dword ptr [eax]"\
float "fstp tbyte ptr [edx]"\
parm caller [eax] [edx];
#pragma aux __iLDFD = \
float "fld tbyte ptr [eax]"\
float "fstp qword ptr [edx]"\
parm caller [eax] [edx];
#pragma aux __iLDFS = \
float "fld tbyte ptr [eax]"\
float "fstp dword ptr [edx]"\
parm caller [eax] [edx];
#else // floating-point calls
#pragma aux __FLDA "*" parm caller [eax] [edx] [ebx];
#pragma aux __FLDS "*" parm caller [eax] [edx] [ebx];
#pragma aux __FLDM "*" parm caller [eax] [edx] [ebx];
#pragma aux __FLDD "*" parm caller [eax] [edx] [ebx];
#pragma aux __LDI4 "*" parm caller [eax] value [eax];
#pragma aux __I4LD "*" parm caller [eax] [edx];
#pragma aux __U4LD "*" parm caller [eax] [edx];
#pragma aux __iFDLD "*" parm caller [eax] [edx];
#pragma aux __iFSLD "*" parm caller [eax] [edx];
#pragma aux __iLDFD "*" parm caller [eax] [edx];
#pragma aux __iLDFS "*" parm caller [eax] [edx];
#pragma aux __FLDC "*" parm caller [eax] [edx] value [eax];
#endif
#elif defined(M_I86) // 16-bit pragmas
#pragma aux __ZBuf2LD "*" parm caller [ax] [dx];
#if defined(__FPI__)
extern unsigned __Get87CW(void);
extern void __Set87CW(unsigned short);
#pragma aux __Get87CW = \
"push ax"\
"push bp"\
"mov bp,sp"\
float "fstcw 2[bp]"\
float "fwait"\
"pop bp"\
"pop ax"\
value [ax];
#pragma aux __Set87CW = \
"push ax"\
"push bp"\
"mov bp,sp"\
float "fldcw 2[bp]"\
"pop bp"\
"pop ax"\
parm caller [ax];
#pragma aux __FLDA = \
"push bp"\
"mov bp,ax"\
float "fld tbyte ptr [bp]"\
"mov bp,dx"\
float "fld tbyte ptr [bp]"\
float "fadd"\
"mov bp,bx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [ax] [dx] [bx];
#pragma aux __FLDS = \
"push bp"\
"mov bp,ax"\
float "fld tbyte ptr [bp]"\
"mov bp,dx"\
float "fld tbyte ptr [bp]"\
float "fsub"\
"mov bp,bx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [ax] [dx] [bx];
#pragma aux __FLDM = \
"push bp"\
"mov bp,ax"\
float "fld tbyte ptr [bp]"\
"mov bp,dx"\
float "fld tbyte ptr [bp]"\
float "fmul"\
"mov bp,bx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [ax] [dx] [bx];
#pragma aux __FLDD = \
"push bp"\
"mov bp,ax"\
float "fld tbyte ptr [bp]"\
"mov bp,dx"\
float "fld tbyte ptr [bp]"\
float "fdiv"\
"mov bp,bx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [ax] [dx] [bx];
#pragma aux __FLDC = \
"push bp"\
"mov bp,dx"\
/* ST(1) */\
float "fld tbyte ptr [bp]"\
"mov bp,ax"\
/* ST(0) */\
float "fld tbyte ptr [bp]"\
/* compare ST(0) with ST(1) */\
float "fcompp"\
"push ax"\
"mov bp,sp"\
float "fstsw 0[bp]"\
float "fwait"\
"pop ax"\
"sahf"\
"sbb dx,dx"\
"shl dx,1"\
"shl ah,1"\
"shl ah,1"\
"cmc"\
"adc dx,0"\
"pop bp"\
parm caller [ax] [dx] value [dx];
#pragma aux __LDI4 = \
"push bp"\
"mov bp,ax"\
float "fld tbyte ptr [bp]"\
"push dx"\
"push ax"\
"push ax"\
"mov bp,sp"\
float "fstcw [bp]"\
float "fwait"\
"pop ax"\
"push ax"\
"or ah,0x0c"\
"mov 2[bp],ax"\
float "fldcw 2[bp]"\
float "fistp dword ptr 2[bp]"\
float "fldcw [bp]"\
"pop ax"\
"pop ax"\
"pop dx"\
"pop bp"\
parm caller [ax] value [dx ax];
#pragma aux __I4LD = \
"push bp"\
"push dx"\
"push ax"\
"mov bp,sp"\
float "fild dword ptr [bp]"\
"pop ax"\
"pop dx"\
"mov bp,bx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [dx ax] [bx];
#pragma aux __U4LD = \
"push bp"\
"push ax"\
"push ax"\
"push dx"\
"push ax"\
"mov bp,sp"\
"sub ax,ax"\
"mov 4[bp],ax"\
"mov 6[bp],ax"\
float "fild qword ptr 2[bp]"\
"pop ax"\
"pop dx"\
"pop ax"\
"pop ax"\
"mov bp,bx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [dx ax] [bx];
#pragma aux __iFDLD = \
"push bp"\
"mov bp,ax"\
float "fld qword ptr [bp]"\
"mov bp,dx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [ax] [dx];
#pragma aux __iFSLD = \
"push bp"\
"mov bp,ax"\
float "fld dword ptr [bp]"\
"mov bp,dx"\
float "fstp tbyte ptr [bp]"\
"pop bp"\
parm caller [ax] [dx];
#pragma aux __iLDFD = \
"push bp"\
"mov bp,ax"\
float "fld tbyte ptr [bp]"\
"mov bp,dx"\
float "fstp qword ptr [bp]"\
"pop bp"\
parm caller [ax] [dx];
#pragma aux __iLDFS = \
"push bp"\
"mov bp,ax"\
float "fld tbyte ptr [bp]"\
"mov bp,dx"\
float "fstp dword ptr [bp]"\
"pop bp"\
parm caller [ax] [dx];
#else // floating-point calls
#pragma aux __FLDA "*" parm caller [ax] [dx] [bx];
#pragma aux __FLDS "*" parm caller [ax] [dx] [bx];
#pragma aux __FLDM "*" parm caller [ax] [dx] [bx];
#pragma aux __FLDD "*" parm caller [ax] [dx] [bx];
#pragma aux __LDI4 "*" parm caller [ax] value [dx ax];
#pragma aux __I4LD "*" parm caller [dx ax] [bx];
#pragma aux __U4LD "*" parm caller [dx ax] [bx];
#pragma aux __iFDLD "*" parm caller [ax] [dx];
#pragma aux __iFSLD "*" parm caller [ax] [dx];
#pragma aux __iLDFD "*" parm caller [ax] [dx];
#pragma aux __iLDFS "*" parm caller [ax] [dx];
#pragma aux __FLDC "*" parm caller [ax] [dx] value [ax];
#endif
#endif
#endif
#ifdef _LONG_DOUBLE_
// macros to allow old source code names to still work
#define __FDLD __iFDLD
#define __FSLD __iFSLD
#define __LDFD __iLDFD
#define __LDFS __iLDFS
#endif
// define number of significant digits for long double numbers (80-bit)
// it will be defined in float.h as soon as OW support long double
// used in mathlib/c/ldcvt.c
#ifdef _LONG_DOUBLE_
#if LDBL_DIG == 15
#undef LDBL_DIG
#define LDBL_DIG 19
#else
#error LDBL_DIG has changed from 15
#endif
#endif
// floating point conversion buffer length definition
// used by various floating point conversion routines
// used in clib/startup/c/cvtbuf.c and lib_misc/h/thread.h
// it must be equal maximum FP precision ( LDBL_DIG )
#define __FPCVT_BUFFERLEN 19
#ifdef __cplusplus
};
#endif
#endif

View File

@ -0,0 +1,109 @@
;*****************************************************************************
;*
;* 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 langenv.inc
PNEAR equ 0
PFAR equ 1
xinit macro rtn,priority
XI segment word public 'DATA'
if _MODEL and _BIG_CODE
db PFAR
db priority
dd rtn
else
if _MODEL and _USE_32_SEGS
db PNEAR
db priority
dd rtn
if COMP_CFG_COFF EQ 1
dw 0
endif
else
db PNEAR
db priority
dw rtn
dw 0
endif
endif
XI ends
endm
xfini macro rtn,priority
YI segment word public 'DATA'
if _MODEL and _BIG_CODE
db PFAR
db priority
dd rtn
else
if _MODEL and _USE_32_SEGS
db PNEAR
db priority
dd rtn
if COMP_CFG_COFF EQ 1
dw 0
endif
else
db PNEAR
db priority
dw rtn
dw 0
endif
endif
YI ends
endm
INIT_PRIORITY_THREAD equ 1 ; priority for thread data init
INIT_PRIORITY_FPU equ 2 ; priority for FPU/EMU init
INIT_PRIORITY_RUNTIME equ 10 ; priority for run-time initialization
INIT_PRIORITY_IOSTREAM equ 20 ; priority for IOSTREAM
INIT_PRIORITY_LIBRARY equ 32 ; default library-initialization priority
DEF_PRIORITY equ 32 ; ...
INIT_PRIORITY_PROGRAM equ 64 ; default program-initialization priority
DTOR_PRIORITY equ 40 ; priority for module DTOR
DGROUP group XIB,XI,XIE,YIB,YI,YIE
XIB segment word public 'DATA'
XIB ends
XI segment word public 'DATA'
XI ends
XIE segment word public 'DATA'
XIE ends
YIB segment word public 'DATA'
YIB ends
YI segment word public 'DATA'
YI ends
YIE segment word public 'DATA'
YIE ends

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: Fatal runtime error handler for Win32.
*
****************************************************************************/
#include "variety.h"
#include "rtdata.h"
#include "exitwmsg.h"
void debug_out_str(const char* str);
_WCRTLINK void __exit_with_msg( char *msg, unsigned retcode )
{
unsigned len;
char *end;
end = msg;
for( len = 0; *end++ != '\0'; len++ )
;
debug_out_str(msg);
__exit( retcode );
}
_WCRTLINK void __fatal_runtime_error( char *msg, unsigned retcode )
{
__exit_with_msg( msg, retcode );
}

View File

@ -0,0 +1,68 @@
/****************************************************************************
*
* 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: Prototypes for direct 'calls' to inline functions.
*
****************************************************************************/
#ifndef _XSTRING_H_INCLUDED
#include "variety.h"
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __INLINE_FUNCTIONS__
void *_inline_memchr( const void *__s, int __c, size_t __n );
int _inline_memcmp( const void *__s1, const void *__s2, size_t __n );
void *_inline_memcpy( void *__s1, const void *__s2, size_t __n );
void *_inline_memmove( void *__s1, const void *__s2, size_t __n );
void *_inline_memset( void *__s, int __c, size_t __n );
char *_inline_strcat( char *__s1, const char *__s2 );
char *_inline_strchr( const char *__s, int __c );
int _inline_strcmp( const char *__s1, const char *__s2 );
char *_inline_strcpy( char *__s1, const char *__s2 );
size_t _inline_strlen( const char *__s );
void _WCFAR *_inline__fmemchr( const void _WCFAR *__s, int __c, size_t __n );
void _WCFAR *_inline__fmemcpy( void _WCFAR *__s1, const void _WCFAR *__s2, size_t __n );
void _WCFAR *_inline__fmemset( void _WCFAR *__s, int __c, size_t __n );
int _inline__fmemcmp( const void _WCFAR *__s1, const void _WCFAR *__s2, size_t __n );
char _WCFAR *_inline__fstrcat( char _WCFAR *__s1, const char _WCFAR *__s2 );
char _WCFAR *_inline__fstrchr( const char _WCFAR *__s, int __c );
int _inline__fstrcmp( const char _WCFAR *__s1, const char _WCFAR *__s2 );
char _WCFAR *_inline__fstrcpy( char _WCFAR *__s1, const char _WCFAR *__s2 );
size_t _inline__fstrlen( const char _WCFAR *__s );
void _inline_movedata( unsigned __srcseg, unsigned __srcoff,
unsigned __tgtseg, unsigned __tgtoff, unsigned __len );
#endif /* __INLINE_FUNCTIONS__ */
#define _XSTRING_H_INCLUDED
#ifdef __cplusplus
};
#endif
#endif

View File

@ -0,0 +1,92 @@
/****************************************************************************
*
* 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 __allocfp() implementation.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "liballoc.h"
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "streamio.h"
#define KEEP_FLAGS (_READ | _WRITE | _DYNAMIC)
FILE *__allocfp( int handle )
{
FILE *end;
FILE *fp;
__stream_link *link;
unsigned flags;
handle = handle;
_AccessIOB();
/* Try and take one off the recently closed list */
link = _RWD_cstream;
if( link != NULL ) {
_RWD_cstream = link->next;
fp = link->stream;
flags = (fp->_flag & KEEP_FLAGS) | (_READ | _WRITE);
goto got_one;
}
/* See if there is a static FILE structure available. */
end = &_RWD_iob[_NFILES];
for( fp = _RWD_iob; fp < end; ++fp ) {
if( (fp->_flag & (_READ | _WRITE)) == 0 ) {
link = lib_malloc( sizeof( __stream_link ) );
if( link == NULL )
goto no_mem;
flags = _READ | _WRITE;
goto got_one;
}
}
/* Allocate a new dynamic structure */
flags = _DYNAMIC | _READ | _WRITE;
link = lib_malloc( sizeof( __stream_link ) + sizeof( FILE ) );
if( link == NULL )
goto no_mem;
fp = (FILE *)(link + 1);
got_one:
memset( fp, 0, sizeof( *fp ) );
fp->_flag = flags;
link->stream = fp;
link->stream->_link = link; /* point back to link structure */
link->next = _RWD_ostream;
_RWD_ostream = link;
_ReleaseIOB();
return( fp );
no_mem:
__set_errno( ENOMEM );
_ReleaseIOB();
return( NULL ); /* no free slots */
}

View File

@ -0,0 +1,61 @@
/****************************************************************************
*
* 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: Prototypes and pragmas for handling __int64 values.
*
****************************************************************************/
#ifndef _I64_H_INCLUDED
#define _I64_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#include "watcom.h"
#define INT64_TYPE __int64
#define UINT64_TYPE unsigned __int64
#define _clib_I64Negative( a ) (((__int64)a) < 0)
#define _clib_I64Positive( a ) (((__int64)a) > 0)
#define _clib_I32ToI64( a, b ) b = (__int64)a
#define _clib_U32ToU64( a, b ) b = (unsigned __int64)(unsigned_32)a
#define _clib_I64ToInt( a, b ) b = (signed)a
#define _clib_U64ToUInt( a, b ) b = (unsigned)a
#define _clib_I64ToLong( a, b ) b = (signed long)a
#define _clib_U64ToULong( a, b ) b = (unsigned long)a
#define _clib_I64Neg( a, b ) b = -a
#define _clib_U64Neg( a, b ) _clib_I64Neg( a, b )
#define _clib_U64Zero( a ) (a == 0)
#define _clib_U64Cmp( a, b ) (a > b ? +1 : a < b ? -1 : 0)
#define _clib_U64Mul( a, b, c ) c = a * b
#define _clib_U64Div( a, b, c, d ) (d = a % b, c = a / b)
#define _clib_U64Add( a, b, c ) c = a + b
// conversion functions - use standard ulltoa()/atoll()
#endif

View File

@ -0,0 +1,32 @@
/****************************************************************************
*
* 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: prototype for __close clib internal function
*
****************************************************************************/
extern int __close( int handle );

View File

@ -0,0 +1,34 @@
/****************************************************************************
*
* 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: declaration for set commit mode function
*
****************************************************************************/
/* see note in commode.c */
_WCRTLINK extern void _WCI86FAR __set_commode( void );
#pragma aux __set_commode "*_";

View File

@ -0,0 +1,47 @@
/****************************************************************************
*
* 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: Commit mode state variable and accessor.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "commode.h"
int _commode = 0;
/*
* Before changing any of this, check startup/c/commode.c!
*/
_WCRTLINK void _WCI86FAR __set_commode( void )
{
_commode = _COMMIT;
}

View File

@ -0,0 +1,35 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
#define _ERRNO errno

View File

@ -0,0 +1,85 @@
/****************************************************************************
*
* 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: Fatal runtime error handlers.
*
****************************************************************************/
#ifndef _EXITWMSG_H_INCLUDED
#define _EXITWMSG_H_INCLUDED
#include "variety.h"
#ifdef __cplusplus
extern "C" {
#endif
#undef _EWM_PARM1
#undef _EWM_PARM2
#if defined(__386__)
#define _EWM_PARM1 eax
#define _EWM_PARM2 edx
#elif defined(M_I86)
#define _EWM_PARM1 ax dx
#define _EWM_PARM2 bx
#else
#define _EWM_PARM1
#define _EWM_PARM2
#endif
// C interface
// - tracks normal calling convention
// - this is the funtion that is called from ASM and from C, C++
// - note there is no #pragma aborts so that debugger can trace out
_WCRTLINK extern void __exit_with_msg( char _WCI86FAR *, unsigned );
_WCRTLINK extern void __fatal_runtime_error( char _WCI86FAR *, unsigned );
// ASM interface
// - always uses register calling convention
// - this function is only called from the C implementation
// of __exit_with_msg
extern void __do_exit_with_msg( char _WCI86FAR *, unsigned );
#ifdef _M_IX86
#pragma aux __do_exit_with_msg "*__" \
parm caller [_EWM_PARM1] [_EWM_PARM2];
#endif
#undef _EWM_PARM1
#undef _EWM_PARM2
_WCRTLINKD extern char volatile __WD_Present;
// WVIDEO interface
// this function should be called before __exit_with_msg()
// to allow Watcom Debugger (nee WVIDEO) to trap runtime errors.
// this really needs to be far!!!
_WCRTLINK extern int __EnterWVIDEO( char _WCFAR *string );
#ifdef __cplusplus
};
#endif
#endif

View File

@ -0,0 +1,53 @@
;*****************************************************************************
;*
;* 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!
;*
;*****************************************************************************
ifdef __WASM__
ifdef __386__
extrn "C",__fatal_runtime_error : near
else
ifdef __SMALL__
extrn "C",__fatal_runtime_error : near
endif
ifdef __COMPACT__
extrn "C",__fatal_runtime_error : near
endif
ifdef __MEDIUM__
extrn "C",__fatal_runtime_error : far
endif
ifdef __LARGE__
extrn "C",__fatal_runtime_error : far
endif
ifdef __HUGE__
extrn "C",__fatal_runtime_error : far
endif
endif
endif

View File

@ -0,0 +1,106 @@
/****************************************************************************
*
* 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: Special interface for calls to non-Watcom routines from
* inside clib (x86 specific).
*
****************************************************************************/
#ifndef EXTFUNC_H_INCLUDED
#define EXTFUNC_H_INCLUDED
#include "variety.h"
#if defined(_M_IX86)
#if !defined(__WINDOWS__)
#if defined(__BIG_DATA__)
#define __DS ds
#endif
#endif
#if !defined(__FLAT__)
#define __ES es
#endif
#if defined(__386__)
#if defined(__WINDOWS__) || !defined(__FLAT__)
#define __FS fs
#endif
#define __GS gs
#if defined(__SW_3S)
#define __AX eax
#define __BX ebx
#define __CX ecx
#define __DX edx
#endif
#endif
#ifndef __AX
#define __AX
#endif
#ifndef __BX
#define __BX
#endif
#ifndef __CX
#define __CX
#endif
#ifndef __DX
#define __DX
#endif
#ifndef __DS
#define __DS
#endif
#ifndef __ES
#define __ES
#endif
#ifndef __FS
#define __FS
#endif
#ifndef __GS
#define __GS
#endif
#pragma aux __outside_CLIB modify [__AX __BX __CX __DX __DS __ES __FS __GS];
/*
use as follows:
typedef void vfv( void );
#pragma aux (__outside_CLIB) __vfv;
*/
#undef __AX
#undef __BX
#undef __CX
#undef __DX
#undef __DS
#undef __ES
#undef __FS
#undef __GS
#endif
#endif

View File

@ -0,0 +1,43 @@
/****************************************************************************
*
* 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: Macros for switching between far and near function version
*
****************************************************************************/
#ifndef _FARFUNC_H_INCLUDED
#define _FARFUNC_H_INCLUDED
#ifdef __FARFUNC__
#define _FFAR _WCFAR
#define _NEARFAR(n1,n2) n2
#else
#define _FFAR
#define _NEARFAR(n1,n2) n1
#endif
#endif

View File

@ -0,0 +1,74 @@
/****************************************************************************
*
* 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: Far pointer support typedefs.
*
****************************************************************************/
#ifndef _FARSUPP_H_INCLUDED
#define _FARSUPP_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#ifdef __LONG_LONG_SUPPORT__
#include "clibi64.h"
#endif
/* Only support near/far pointers on 16-bit targets, extended DOS
* and Win386. Ideally we might want to test for non-flat memory model.
*/
#if defined( _M_I86 ) || defined( __DOS__ ) || defined( __WINDOWS__ )
#define __FAR_SUPPORT__
typedef CHAR_TYPE _WCFAR *FAR_STRING;
typedef char _WCFAR *FAR_ASCII_STRING;
typedef wchar_t _WCFAR *FAR_UNI_STRING;
typedef int _WCFAR *FAR_INT;
typedef signed char _WCFAR *FAR_CHAR;
typedef short _WCFAR *FAR_SHORT;
typedef long _WCFAR *FAR_LONG;
typedef float _WCFAR *FAR_FLOAT;
typedef double _WCFAR *FAR_DOUBLE;
#ifdef __LONG_LONG_SUPPORT__
typedef UINT64_TYPE _WCFAR *FAR_INT64;
#endif
#else
#undef __FAR_SUPPORT__
typedef CHAR_TYPE *FAR_STRING;
typedef char *FAR_ASCII_STRING;
typedef wchar_t *FAR_UNI_STRING;
typedef int *FAR_INT;
typedef signed char *FAR_CHAR;
typedef short *FAR_SHORT;
typedef long *FAR_LONG;
typedef float *FAR_FLOAT;
typedef double *FAR_DOUBLE;
#ifdef __LONG_LONG_SUPPORT__
typedef UINT64_TYPE *FAR_INT64;
#endif
#endif
#endif

View File

@ -0,0 +1,227 @@
/****************************************************************************
*
* 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 fgetc() implementation.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <unistd.h>
#ifndef __UNIX__
#include <conio.h>
#endif
#include "fileacc.h"
#include <errno.h>
#include "rtdata.h"
#include "seterrno.h"
#ifdef __WIDECHAR__
#include <mbstring.h>
#include <wchar.h>
#endif
#include "qread.h"
#include "orient.h"
#include "flush.h"
#include "streamio.h"
#define DOS_EOF_CHAR 0x1a
#ifdef __WIDECHAR__
#define CHARMASK 0xffff
#else
#define CHARMASK 0xff
#endif
int __F_NAME(__fill_buffer,__wfill_buffer)( FILE *fp )
{
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp );
}
if( fp->_flag & _ISTTY ) { /* 20-aug-90 */
if( fp->_flag & (_IONBF | _IOLBF) ) {
__flushall( _ISTTY ); /* flush all TTY output */
}
}
fp->_flag &= ~_UNGET; /* 10-mar-90 */
fp->_ptr = _FP_BASE(fp);
#ifdef __UNIX__
fp->_cnt = __qread( fileno( fp ), fp->_ptr,
(fp->_flag & _IONBF) ? CHARSIZE : fp->_bufsize );
#else
if(( fp->_flag & (_IONBF | _ISTTY)) == (_IONBF | _ISTTY) &&
( fileno( fp ) == STDIN_FILENO ))
{
int c; /* JBS 31-may-91 */
fp->_cnt = 0;
// c = getche();
if( c != EOF ) {
*(CHAR_TYPE *)fp->_ptr = c;
fp->_cnt = CHARSIZE;
}
} else {
fp->_cnt = __qread( fileno( fp ), fp->_ptr,
(fp->_flag & _IONBF) ? CHARSIZE : fp->_bufsize );
}
#endif
if( fp->_cnt <= 0 ) {
if( fp->_cnt == 0 ) {
fp->_flag |= _EOF;
} else {
fp->_flag |= _SFERR;
fp->_cnt = 0;
}
}
return( fp->_cnt );
}
int __F_NAME(__filbuf,__wfilbuf)( FILE *fp )
{
if( __F_NAME(__fill_buffer,__wfill_buffer)( fp ) == 0 ) {
return( EOF );
}
else {
fp->_cnt -= CHARSIZE;
fp->_ptr += CHARSIZE;
return( *(CHAR_TYPE *)(fp->_ptr - CHARSIZE) & CHARMASK );
}
}
#ifndef __WIDECHAR__
_WCRTLINK int fgetc( FILE *fp )
{
int c;
_ValidFile( fp, EOF );
_AccessFile( fp );
/*** Deal with stream orientation ***/
ORIENT_STREAM(fp,EOF);
if( (fp->_flag & _READ) == 0 ) {
__set_errno( EBADF );
fp->_flag |= _SFERR;
c = EOF;
} else {
fp->_cnt--;
// it is important that this remain a relative comparison
// to ensure that the getc() macro works properly
if( fp->_cnt < 0 ) {
c = __F_NAME(__filbuf,__wfilbuf)( fp );
} else {
c = *(char *)fp->_ptr;
fp->_ptr++;
}
}
#ifndef __UNIX__
if( !(fp->_flag & _BINARY) ) {
if( c == '\r' ) {
fp->_cnt--;
// it is important that this remain a relative comparison
// to ensure that the getc() macro works properly
if( fp->_cnt < 0 ) {
c = __F_NAME(__filbuf,__wfilbuf)( fp );
} else {
c = *(CHAR_TYPE*)fp->_ptr & CHARMASK;
fp->_ptr += CHARSIZE;
}
}
if( c == DOS_EOF_CHAR ) {
fp->_flag |= _EOF;
c = EOF;
}
}
#endif
_ReleaseFile( fp );
return( c );
}
#else
static int __read_wide_char( FILE *fp, wchar_t *wc )
/**************************************************/
{
if( fp->_flag & _BINARY ) {
/*** Read a wide character ***/
return( fread( wc, sizeof( wchar_t ), 1, fp ) );
} else {
char mbc[MB_CUR_MAX];
wchar_t wcTemp;
int rc;
/*** Read the multibyte character ***/
if( !fread( &mbc[0], 1, 1, fp ) )
return( 0 );
if( _ismbblead( mbc[0] ) ) {
if( !fread( &mbc[1], 1, 1, fp ) )
return( 0 );
}
/*** Convert it to wide form ***/
rc = mbtowc( &wcTemp, mbc, MB_CUR_MAX );
if( rc >= 0 ) {
*wc = wcTemp;
return( 1 );
} else {
__set_errno( EILSEQ );
return( 0 );
}
}
}
_WCRTLINK wint_t fgetwc( FILE *fp )
{
wchar_t c;
_ValidFile( fp, WEOF );
_AccessFile( fp );
/*** Deal with stream orientation ***/
ORIENT_STREAM(fp,WEOF);
/*** Read the character ***/
if( !__read_wide_char( fp, &c ) ) {
_ReleaseFile( fp );
return( WEOF );
}
if( !(fp->_flag & _BINARY) && (c == L'\r') ) {
if( !__read_wide_char( fp, &c ) ) {
_ReleaseFile( fp );
return( WEOF );
}
}
_ReleaseFile( fp );
return( (wint_t)c );
}
#endif

View File

@ -0,0 +1,81 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
#define _ValidFile( fp, retval ) /* make sure fp is a valid pointer */
#define SetupTGCSandNCS( x ) /* initialization for Netware/386 */
#if defined(__SW_BM)
#define _AccessFile( fp ) _AccessFileH( (fp)->_handle )
#define _ReleaseFile( fp ) _ReleaseFileH( (fp)->_handle )
#if defined(__386__) || defined(__AXP__) || defined(__PPC__)
extern void (*_AccessFileH)( int );
extern void (*_ReleaseFileH)( int );
extern void (*_AccessIOB)( void );
extern void (*_ReleaseIOB)( void );
#else
// 16bit OS/2 multi-thread is different
extern void __AccessFileH( int );
extern void __ReleaseFileH( int );
extern void __AccessIOB( void );
extern void __ReleaseIOB( void );
// define macros to call the access routines directly for OS/2 1.x
#define _AccessFileH( hdl ) __AccessFileH( hdl )
#define _ReleaseFileH( hdl ) __ReleaseFileH( hdl )
#define _AccessIOB() __AccessIOB()
#define _ReleaseIOB() __ReleaseIOB()
#endif
#if defined(__NT__)
extern void (*_AccessFList)( void );
extern void (*_ReleaseFList)( void );
#endif
#else
/* these are for multi thread support */
/* they are not required if not building multi-thread library */
/* note: 32 bit NETWARE, OS/2, NT, QNX libraries are always multi-thread */
#define _AccessFile( fp ) /* gain access to the FILE* pointer */
#define _ReleaseFile( fp ) /* release access */
#define _AccessFileH( hdl ) /* gain access to the file handle */
#define _ReleaseFileH( hdl ) /* release access */
#define _AccessIOB() /* gain access to array of __iob's */
#define _ReleaseIOB() /* release access */
#if defined(__NT__)
#define _AccessFList()
#define _ReleaseFList()
#endif
#endif

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: Fixed-point data type.
*
****************************************************************************/
typedef union t32 {
unsigned long uWhole;
signed long sWhole;
struct { unsigned short int lo, hi; } wd;
struct { unsigned char b1, b2, b3, b4; } bite;
} T32;

View File

@ -0,0 +1,34 @@
/****************************************************************************
*
* 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: Prototype for __flush and __flushall internal routines.
*
****************************************************************************/
/* __flush is used by C++ run-time library */
_WCRTLINK extern int __flush( FILE * );
extern int __flushall( int );

View File

@ -0,0 +1,65 @@
/****************************************************************************
*
* 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: Implementation of flushall() - flush all streams.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "rtdata.h"
#include "fileacc.h"
#include "flush.h"
/* __fill_buffer calls this routine with _ISTTY mask */
int __flushall( int mask )
{
__stream_link *link;
FILE *fp;
int number_of_open_files;
_AccessIOB();
number_of_open_files = 0;
for( link = _RWD_ostream; link != NULL; link = link->next ) {
fp = link->stream;
if( fp->_flag & mask ) { /* if file is a candidate */
++number_of_open_files;
if( fp->_flag & _DIRTY ) {
__flush( fp );
}
}
}
_ReleaseIOB();
return( number_of_open_files );
}
_WCRTLINK int flushall( void )
{
return( __flushall( ~0 ) );
}

View File

@ -0,0 +1,33 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
/* define _fmode to be _fmode */

View File

@ -0,0 +1,359 @@
/****************************************************************************
*
* 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 fopen() implementation.
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <ctype.h>
#ifdef __WIDECHAR__
#include <wctype.h>
#endif
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "fileacc.h"
#include "fmode.h"
#include "openmode.h"
#include "rtdata.h"
#include "seterrno.h"
//#include "defwin.h"
#include "streamio.h"
#ifdef __UNIX__
#define PMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#else
#define PMODE (S_IREAD | S_IWRITE)
#endif
int __F_NAME(__open_flags,__wopen_flags)( const CHAR_TYPE *modestr, int *extflags )
{
int flags;
int alive = 1;
int gotplus = 0;
int gottextbin = 0;
#ifndef __NETWARE__
int gotcommit = 0;
#endif
flags = 0;
if( extflags != NULL ) {
#ifdef __NETWARE__
*extflags = 0;
#else
if( _commode == _COMMIT ) {
*extflags = _COMMIT;
} else {
*extflags = 0;
}
#endif
}
/*
* The first character in modestr must be 'r', 'w', or 'a'.
*/
switch( *modestr ) {
case 'r':
flags |= _READ;
break;
case 'w':
flags |= _WRITE;
break;
case 'a':
flags |= _WRITE | _APPEND;
break;
default:
__set_errno( EINVAL );
return( 0 );
}
modestr++;
/*
* Next we might have, in any order, some additional mode modifier
* characters:
* 1. A '+' character.
* 2. Either a 't' or a 'b'.
* 3. Either a 'c' or a 'n'. (Not available for Netware.)
* For MS compatability, scanning stops when any of the three groups
* is encountered twice; e.g., "wct+b$&!" is valid and will result in
* a text, not binary, stream. Also for MS compatability, scanning
* stops at any unrecognized character, without causing failure.
*/
while( (*modestr != NULLCHAR) && alive ) {
switch( *modestr ) {
case '+':
if( gotplus ) {
alive = 0;
} else {
flags |= _READ | _WRITE;
gotplus = 1;
}
break;
case 't':
if( gottextbin ) {
alive = 0;
} else {
gottextbin = 1;
}
break;
case 'b':
if( gottextbin ) {
alive = 0;
} else {
#ifndef __UNIX__
flags |= _BINARY;
#endif
gottextbin = 1;
}
break;
#ifndef __NETWARE__
case 'c':
if( gotcommit ) {
alive = 0;
} else {
*extflags |= _COMMIT;
gotcommit = 1;
}
break;
case 'n':
if( gotcommit ) {
alive = 0;
} else {
*extflags &= ~_COMMIT;
gotcommit = 1;
}
break;
#endif
default:
break;
}
modestr++;
}
/*
* Handle defaults for any unspecified options.
*/
#ifndef __UNIX__
if( !gottextbin ) {
if( _RWD_fmode == O_BINARY ) flags |= _BINARY;
}
#endif
return( flags );
}
static FILE *__F_NAME(__doopen,__wdoopen)( const CHAR_TYPE *name,
CHAR_TYPE mode,
int file_flags,
int extflags,
int shflag, /* sharing flag */
FILE * fp )
{
int open_mode;
int p_mode;
SetupTGCSandNCS( RETURN_ARG( FILE *, 0 ) ); /* for NW386 */
fp->_flag &= ~(_READ | _WRITE);
fp->_flag |= file_flags;
/* we need the mode character to indicate if the original */
/* intention is to open for read or for write */
mode = __F_NAME(tolower,towlower)( mode );
if( mode == 'r' ) {
open_mode = O_RDONLY;
if( file_flags & _WRITE ) { /* if "r+" mode */
open_mode = O_RDWR;
}
#if defined( __NETWARE__ )
open_mode |= O_BINARY;
#elif defined( __UNIX__ )
#else
if( file_flags & _BINARY ) {
open_mode |= O_BINARY;
} else {
open_mode |= O_TEXT;
}
#endif
p_mode = 0;
} else { /* mode == 'w' || mode == 'a' */
if( file_flags & _READ ) { /* if "a+" or "w+" mode */
open_mode = O_RDWR | O_CREAT;
} else {
open_mode = O_WRONLY | O_CREAT;
}
if( file_flags & _APPEND ) {
open_mode |= O_APPEND;
} else { /* mode == 'w' */
open_mode |= O_TRUNC;
}
#if defined( __NETWARE__ )
open_mode |= O_BINARY;
#elif defined( __UNIX__ )
#else
if( file_flags & _BINARY ) {
open_mode |= O_BINARY;
} else {
open_mode |= O_TEXT;
}
#endif
p_mode = PMODE;
}
fp->_handle = __F_NAME(sopen,_wsopen)( name, open_mode, shflag, p_mode );
if( fp->_handle == -1 ) {
// since we couldn't open the file, release the FILE struct
__freefp( fp );
return( NULL );
}
fp->_cnt = 0;
fp->_bufsize = 0; /* was BUFSIZ JBS 31-may-91 */
#ifndef __NETWARE__
_FP_ORIENTATION(fp) = _NOT_ORIENTED; /* initial orientation */
_FP_EXTFLAGS(fp) = extflags;
#endif
#if defined( __NT__ ) || defined( __OS2__ )
_FP_PIPEDATA(fp).isPipe = 0; /* not a pipe */
#endif
_FP_BASE(fp) = NULL;
if( file_flags & _APPEND ) {
fseek( fp, 0L, SEEK_END );
}
__chktty( fp ); /* JBS 28-aug-90 */
return( fp );
}
_WCRTLINK FILE *__F_NAME(_fsopen,_wfsopen)( const CHAR_TYPE *name,
const CHAR_TYPE *access_mode, int shflag )
{
FILE * fp;
int file_flags;
int extflags;
/* validate access_mode */
file_flags = __F_NAME(__open_flags,__wopen_flags)( access_mode, &extflags );
if( file_flags == 0 ) {
return( NULL );
}
/* specify dummy handle 0 */
fp = __allocfp( 0 ); /* JBS 30-aug-91 */
if( fp != NULL ) {
fp = __F_NAME(__doopen,__wdoopen)( name, *access_mode,
file_flags, extflags,
shflag, fp );
}
return( fp );
}
_WCRTLINK FILE *__F_NAME(fopen,_wfopen)( const CHAR_TYPE *name, const CHAR_TYPE *access_mode )
{
return( __F_NAME(_fsopen,_wfsopen)( name, access_mode, OPENMODE_DENY_COMPAT ) );
}
static FILE *close_file( FILE *fp )
{
__stream_link * link;
__stream_link **owner;
_AccessIOB();
/* See if the file pointer is a currently open file. */
link = _RWD_ostream;
for( ;; ) {
if( link == NULL ) break;
if( link->stream == fp ) {
if( fp->_flag & (_READ|_WRITE) ) {
__doclose( fp, 1 );
}
_ReleaseIOB();
return( fp );
}
link = link->next;
}
/*
It's not on the list of open files, so check the list of
recently closed ones.
*/
owner = &_RWD_cstream;
for( ;; ) {
link = *owner;
if( link == NULL ) break;
if( link->stream == fp ) {
/* remove from closed list and put on open */
*owner = link->next;
link->next = _RWD_ostream;
_RWD_ostream = link;
_ReleaseIOB();
return( fp );
}
owner = &link->next;
}
/* We ain't seen that file pointer ever. Leave things be. */
__set_errno( EBADF );
_ReleaseIOB();
return( NULL );
}
_WCRTLINK FILE *__F_NAME(freopen,_wfreopen)( const CHAR_TYPE *name,
const CHAR_TYPE *access_mode, FILE *fp )
{
int hdl;
int file_flags;
int extflags;
_ValidFile( fp, 0 );
/* validate access_mode */
file_flags = __F_NAME(__open_flags,__wopen_flags)( access_mode, &extflags );
if( file_flags == 0 ) {
return( NULL );
}
hdl = fileno( fp );
_AccessFileH( hdl );
#ifdef DEFAULT_WINDOWING
if( _WindowsRemoveWindowedHandle != 0 ) {
_WindowsRemoveWindowedHandle( hdl );
}
#endif
fp = close_file( fp );
if( fp != NULL ) {
fp->_flag &= _DYNAMIC; /* 24-jul-92 */
fp = __F_NAME(__doopen,__wdoopen)( name, *access_mode,
file_flags, extflags,
0, fp );
}
_ReleaseFileH( hdl );
return( fp );
}

View File

@ -0,0 +1,32 @@
/****************************************************************************
*
* 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: Prototype for __fprtf() internal routine.
*
****************************************************************************/
extern int __F_NAME(__fprtf,__fwprtf)( FILE *fp, const CHAR_TYPE *format, va_list arg );

View File

@ -0,0 +1,165 @@
/****************************************************************************
*
* 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: Implementation of fread() - read data from stream.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include "fileacc.h"
#include <string.h>
#include <errno.h>
#include "rtdata.h"
#include "seterrno.h"
#include "qread.h"
#include "streamio.h"
#define DOS_EOF_CHAR 0x1a
extern int __fill_buffer( FILE * ); /* located in fgetc */
_WCRTLINK size_t fread( void *_buf, size_t size, size_t n, FILE *fp )
{
char *buf = _buf;
size_t len_read;
_ValidFile( fp, 0 );
_AccessFile( fp );
if( (fp->_flag & _READ) == 0 ) {
__set_errno( EBADF );
fp->_flag |= _SFERR;
_ReleaseFile( fp );
return( 0 );
}
#if 0
/*** If the buffer is _DIRTY, resync it before reading ***/
if( fp->_flag & (_WRITE | _UNGET) ) {
if( fp->_flag & _DIRTY ) {
fseek( fp, 0, SEEK_CUR );
}
}
#endif
n *= size;
if( n == 0 ) {
_ReleaseFile( fp );
return( n );
}
if( _FP_BASE(fp) == NULL ) {
__ioalloc( fp ); /* allocate buffer */
}
len_read = 0;
#if !defined( __UNIX__ )
if( fp->_flag & _BINARY )
#endif
{
size_t bytes_left = n, bytes;
for( ;; ) {
if( fp->_cnt != 0 ) {
bytes = fp->_cnt;
if( bytes > bytes_left ) {
bytes = bytes_left;
}
memcpy( buf, fp->_ptr, bytes );
fp->_ptr += bytes;
buf += bytes;
fp->_cnt -= bytes;
bytes_left -= bytes;
len_read += bytes;
}
if( bytes_left == 0 ) break;
/* if user's buffer is larger than our buffer, OR
_IONBF is set, then read directly into user's buffer. */
if( (bytes_left >= fp->_bufsize) || (fp->_flag & _IONBF) ) {
bytes = bytes_left;
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
if( !(fp->_flag & _IONBF) ) {
/* if more than a sector, set to multiple of sector size*/
if( bytes > 512 ) {
bytes &= -512;
}
}
n = __qread( fileno(fp), buf, bytes );
if( n == -1 ) {
fp->_flag |= _SFERR;
break;
} else if( n == 0 ) {
fp->_flag |= _EOF;
break;
}
buf += n;
bytes_left -= n;
len_read += n;
} else {
if( __fill_buffer( fp ) == 0 ) break;
}
} /* end for */
#if !defined(__UNIX__)
} else {
for( ;; ) {
int c;
// ensure non-empty buffer
if( fp->_cnt == 0 ) {
if( __fill_buffer( fp ) == 0 ) break;
}
// get character
--fp->_cnt;
c = *fp->_ptr++ & 0xff;
// perform new-line translation
if( c == '\r' ) {
// ensure non-empty buffer
if( fp->_cnt == 0 ) {
if( __fill_buffer( fp ) == 0 ) break;
}
// get character
--fp->_cnt;
c = *fp->_ptr++ & 0xff;
}
// check for DOS end of file marker
if( c == DOS_EOF_CHAR ) {
fp->_flag |= _EOF;
break;
}
// store chracter
buf[len_read] = (char)c;
++len_read;
if( len_read == n ) break;
}
#endif
}
_ReleaseFile( fp );
return( len_read / size );
}

View File

@ -0,0 +1,157 @@
/****************************************************************************
*
* 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: Implementation of fseek - set stream position.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "fileacc.h"
#include "rtdata.h"
#include "seterrno.h"
#include "flush.h"
static int __update_buffer( long diff, FILE *fp )
{
/*
diff is relative to fp->_ptr
if diff is within the buffer update the pointers and return 0
otherwise update the pointers and return 1
*/
if( diff <= fp->_cnt && diff >= (_FP_BASE(fp) - fp->_ptr) ) {
fp->_flag &= ~(_EOF);
fp->_ptr += diff;
fp->_cnt -= diff;
return( 0 );
}
return( 1 );
}
/*
* This used to be in __update_buffer(), but we don't want to do this until
* AFTER we've made certain that lseek() will be a successful one.
*/
static void __reset_buffer( FILE *fp )
{
fp->_flag &= ~(_EOF);
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
}
_WCRTLINK int fseek( FILE *fp, long offset, int origin )
{
_ValidFile( fp, -1 );
_AccessFile( fp );
/*
if the file is open for any sort of writing we must ensure that
the buffer is flushed when dirty so that the integrity of the
data is preserved.
if there is an ungotten character in the buffer then the data must
be discarded to ensure the integrity of the data
*/
if( fp->_flag & (_WRITE | _UNGET) ) {
if( fp->_flag & _DIRTY ) {
/*
the __flush routine aligns the DOS file pointer with the
start of the resulting cleared buffer, as such, the SEEK_CUR
code used for the non-_DIRTY buffer case is not required
*/
if( __flush( fp ) ) {
// assume __flush set the errno value
// if erroneous input, override errno value
if( origin == SEEK_SET && offset < 0 ) {
__set_errno( EINVAL );
}
_ReleaseFile( fp );
return( -1 );
}
} else {
if( origin == SEEK_CUR ) {
offset -= fp->_cnt;
}
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
}
fp->_flag &= ~(_EOF|_UNGET);
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
} else {
// file is open for read only,
// no characters have been ungotten
// the OS file pointer is at fp->_ptr + fp->_cnt relative to the
// FILE* buffer
switch( origin ) {
case SEEK_CUR:
{ long ptr_delta = fp->_cnt;
if( __update_buffer( offset, fp ) ) {
offset -= ptr_delta;
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
__reset_buffer(fp);
}
} break;
case SEEK_SET:
{ long file_ptr = tell( fileno( fp ) );
file_ptr -= fp->_cnt;
if( __update_buffer( offset - file_ptr, fp ) ) {
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
__reset_buffer(fp);
}
} break;
case SEEK_END:
fp->_flag &= ~(_EOF);
fp->_ptr = _FP_BASE(fp);
fp->_cnt = 0;
if( lseek( fileno( fp ), offset, origin ) == -1 ) {
_ReleaseFile( fp );
return( -1 );
}
break;
default:
__set_errno( EINVAL );
_ReleaseFile( fp );
return( -1 );
}
}
_ReleaseFile( fp );
return( 0 ); /* indicate success */
}

View File

@ -0,0 +1,61 @@
/****************************************************************************
*
* 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 ftell() implementaiton.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "fileacc.h"
_WCRTLINK long ftell( FILE *fp )
{
long pos;
_ValidFile( fp, -1 );
if( fp->_flag & _APPEND && fp->_flag & _DIRTY ) {
fflush( fp ); /* if data written in append mode, OS must know */
}
pos = tell( fileno( fp ) );
if( pos == -1 ) {
return( -1L );
}
_AccessFile( fp );
if( fp->_cnt != 0 ) { /* if something in buffer */
if( fp->_flag & _DIRTY ) { /* last operation was a put */
pos += fp->_cnt;
} else { /* last operation was a get */
pos -= fp->_cnt;
}
}
_ReleaseFile( fp );
return( pos );
}

View File

@ -0,0 +1,45 @@
/****************************************************************************
*
* 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: Prototypes for floating-point formatting routines.
*
****************************************************************************/
#ifndef _FTOS_H_INCLUDED
#define _FTOS_H_INCLUDED
#include "variety.h"
#include "farsupp.h"
_WCRTLINK extern FAR_STRING (*__EFG_printf)();
_WCRTLINK extern void (*__EFG_scanf)();
extern FAR_STRING _EFG_Format();
extern void __cnvs2d();
_WMRTLINK extern FAR_STRING (*__get_EFG_Format())();
_WMRTLINK extern void (*__get__cnvs2d())();
#endif

View File

@ -0,0 +1,50 @@
/****************************************************************************
*
* 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 <conio.h>
#include <stdio.h>
#include "rtdata.h"
_WCRTLINK int getche()
{
unsigned c;
unsigned stashed;
stashed = _RWD_cbyte;
c = getch();
if( c != EOF && stashed == 0 ) {
putch( c );
}
return( c );
}

View File

@ -0,0 +1,41 @@
/****************************************************************************
*
* 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: prototypes for handleio internal functions
*
****************************************************************************/
/* __plusplus_fstat and __plusplus_open are used by C++ run-time library */
_WCRTLINK extern int __plusplus_fstat( int handle, int *pios_mode );
_WCRTLINK extern int __plusplus_open( const char *name, int *pios_mode, int prot );
extern unsigned __IOMode( int handle );
extern void __set_handles( int num );
extern void __grow_iomode( int num );
extern void __shrink_iomode( void );
extern unsigned *__io_mode;

View File

@ -48,23 +48,6 @@
#include "seterrno.h"
#include "handleio.h"
#ifdef DLHEAP
void* _cdecl dlmalloc(size_t);
void _cdecl dlfree(void*);
void _cdecl mf_init();
#define malloc dlmalloc
#define free dlfree
#define realloc dlrealloc
#define lib_malloc dlmalloc
#define lib_free dlfree
#define lib_realloc dlrealloc
#endif
#undef __getOSHandle
extern unsigned __NFiles; // the size of the iomode array
@ -153,6 +136,7 @@ HANDLE __getOSHandle( int hid )
return( __OSHandles[ hid ] );
}
int __setOSHandle( unsigned hid, HANDLE hdl )
{
// call the Win32 API for a standard file handle
@ -184,24 +168,11 @@ static int __topFakeHandle = 0;
HANDLE __NTGetFakeHandle( void )
{
HANDLE os_handle;
static DWORD fakeHandle = 0x80000000L;
_AccessFList();
// os_handle = CreateEvent( 0, 0, 0, 0 );
os_handle = 0;
if( os_handle == NULL )
{
// win32s does not support event handles
static DWORD fakeHandle = 0x80000000L;
fakeHandle++;
os_handle = (HANDLE)fakeHandle;
}
else
{
__FakeHandles = lib_realloc( __FakeHandles, (__topFakeHandle+1) * sizeof( HANDLE ) );
__FakeHandles[ __topFakeHandle ] = os_handle;
__topFakeHandle++;
}
fakeHandle++;
os_handle = (HANDLE)fakeHandle;
_ReleaseFList();
return( os_handle );
}

View File

@ -0,0 +1,207 @@
/****************************************************************************
*
* 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: Heap library configuration for various platforms.
*
****************************************************************************/
#include "variety.h"
#if defined(_M_IX86)
#include <i86.h>
#endif
#if !defined(__DOS_EXT__)
#if defined(__386__) && \
!defined(__WINDOWS_386__) && \
!defined(__WINDOWS__) && \
!defined(__OS2__) && \
!defined(__NT__) && \
!defined(__OSI__) && \
!defined(__UNIX__)
#define __DOS_EXT__
#endif
#endif
typedef unsigned int tag;
typedef struct freelistp frl;
typedef struct freelistp _WCNEAR *frlptr;
typedef struct freelist _WCFAR *farfrlptr;
typedef unsigned char _WCNEAR *PTR;
typedef unsigned char _WCFAR *FARPTR;
typedef struct miniheapblkp _WCNEAR *mheapptr;
/*
** NOTE: the size of these data structures is critical to the alignemnt
** of the pointers returned by malloc().
*/
struct freelist {
tag len; /* length of block in free list */
unsigned int prev; /* offset of previous block in free list */
unsigned int next; /* offset of next block in free list */
};
struct heapblk {
tag heaplen; /* size of heap (0 = 64K) */
unsigned int prevseg; /* segment selector for previous heap */
unsigned int nextseg; /* segment selector for next heap */
unsigned int rover; /* roving pointer into free list */
unsigned int b4rover; /* largest block before rover */
unsigned int largest_blk; /* largest block in the heap */
unsigned int numalloc; /* number of allocated blocks in heap */
unsigned int numfree; /* number of free blocks in the heap */
struct freelist freehead; /* listhead of free blocks in heap */
};
struct freelistp {
tag len;
frlptr prev;
frlptr next;
};
struct heapblkp {
tag heaplen;
unsigned int prevseg;
unsigned int nextseg;
frlptr rover;
unsigned int b4rover;
unsigned int largest_blk;
unsigned int numalloc;
unsigned int numfree;
frl freehead;
};
struct miniheapblkp {
tag len;
mheapptr prev;
mheapptr next;
frlptr rover;
unsigned int b4rover;
unsigned int largest_blk;
unsigned int numalloc;
unsigned int numfree;
frl freehead;
};
struct heapstart {
struct heapblk h;
struct freelist first;
};
struct heapend {
tag last_tag;
struct freelist last;
};
#ifdef __DOS_EXT__
struct dpmi_hdr {
unsigned long dpmi_handle;
tag dos_seg_value; // 0 => DPMI block, else DOS segment
};
#endif
extern unsigned _curbrk;
extern mheapptr _WCNEAR __nheapbeg;
#if defined(_M_IX86)
extern __segment __fheap;
extern __segment __bheap;
extern __segment __fheapRover;
#endif
extern int __heap_enabled;
extern unsigned int __LargestSizeB4Rover;
extern struct miniheapblkp _WCNEAR *__MiniHeapRover;
extern unsigned int __LargestSizeB4MiniHeapRover;
extern struct miniheapblkp _WCNEAR *__MiniHeapFreeRover;
extern size_t __LastFree( void );
extern int __NHeapWalk( struct _heapinfo *entry, mheapptr heapbeg );
extern int __ExpandDGROUP( unsigned int __amt );
#if defined(_M_IX86)
extern unsigned __AllocSeg( unsigned int __amt );
extern unsigned __GrowSeg( __segment __seg, unsigned int __amt );
extern int __FreeSeg( __segment seg );
extern int __HeapWalk( struct _heapinfo *entry, __segment seg, unsigned all );
extern int __HeapMin( __segment seg, unsigned one_seg );
extern int __HeapSet( __segment seg, unsigned fill );
#endif
#if defined(__DOS_EXT__)
extern void __FreeDPMIBlocks( void );
extern void *__ReAllocDPMIBlock( frlptr p1, unsigned req_size );
extern void *__ExpandDPMIBlock( frlptr, unsigned );
#endif
extern int __HeapManager_expand( __segment seg, unsigned offset,
size_t req_size, size_t *growth_size );
extern void _WCFAR __HeapInit( void _WCNEAR *start, unsigned int amount );
_WCRTLINK extern void _WCNEAR *__brk( unsigned );
#if defined(_M_IX86)
#define _DGroup() FP_SEG((&__nheapbeg))
#else
#define _DGroup() 0
#endif
// __IsCtsNHeap() is used to determine whether the operating system provides
// a continuous near heap block. __ExpandDGroup should slice for more near
// heap under those operating systems with __IsCtsNHeap() == 1.
#if defined(__WARP__) || \
defined(__NT__) || \
defined(__WINDOWS_386__) || \
defined(__WINDOWS_286__)
#define __IsCtsNHeap() 0
#elif defined(__DOS_EXT__)
#define __IsCtsNHeap() ((_IsRationalZeroBase() || _IsCodeBuilder()) ? 0 : 1)
#else
#define __IsCtsNHeap() 1
#endif
extern unsigned __MemAllocator( unsigned __sz, unsigned __seg, unsigned __off );
extern void __MemFree( unsigned __ptr, unsigned __seg, unsigned __off );
#if defined(_M_IX86)
#if defined(__386__)
#pragma aux __MemAllocator "*" parm [eax] [edx] [ebx];
#pragma aux __MemFree "*" parm [eax] [edx] [ebx];
#else
#pragma aux __MemAllocator "*" parm [ax] [dx] [bx];
#pragma aux __MemFree "*" parm [ax] [dx] [bx];
#endif
#endif
#define PARAS_IN_64K (0x1000)
#define END_TAG (~0)
#define TAG_SIZE (sizeof(tag))
#if defined(M_I86)
#define ROUND_SIZE (TAG_SIZE-1)
#else
#define ROUND_SIZE (TAG_SIZE+TAG_SIZE-1)
#endif
#define FRL_SIZE ((sizeof(frl)+ROUND_SIZE)&~ROUND_SIZE)
#define __HM_SUCCESS 0
#define __HM_FAIL 1
#define __HM_TRYGROW 2

View File

@ -0,0 +1,59 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
#ifndef _HEAPACC_H_INCLUDED
#define _HEAPACC_H_INCLUDED
/* macros for serialization of accesses to the heap */
#if defined(__SW_BM)
#if defined(__386__) || defined(__AXP__) || defined(__PPC__)
extern void (*_AccessFHeap)();
extern void (*_ReleaseFHeap)();
extern void (*_AccessNHeap)();
extern void (*_ReleaseNHeap)();
#else
extern void __AccessFHeap();
extern void __ReleaseFHeap();
extern void __AccessNHeap();
extern void __ReleaseNHeap();
#define _AccessFHeap() __AccessFHeap()
#define _ReleaseFHeap() __ReleaseFHeap()
#define _AccessNHeap() __AccessNHeap()
#define _ReleaseNHeap() __ReleaseNHeap()
#endif
#else
#define _AccessFHeap()
#define _ReleaseFHeap()
#define _AccessNHeap()
#define _ReleaseNHeap()
#endif
#endif

View File

@ -0,0 +1,70 @@
/****************************************************************************
*
* 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: prototypes and definitions for iomode array manipulation
*
****************************************************************************/
#ifndef _IOMODE_H_INCLUDED
#define _IOMODE_H_INCLUDED
#if defined(__NT__)
#include <windows.h>
#define NULL_HANDLE (HANDLE)-1
#define DUMMY_HANDLE (HANDLE)-2
extern unsigned __NHandles;
extern void __initPOSIXHandles( void );
extern unsigned __growPOSIXHandles( unsigned num );
extern int __allocPOSIXHandle( HANDLE hdl );
extern void __freePOSIXHandle( int hid );
extern HANDLE __getOSHandle( int hid );
extern int __setOSHandle( unsigned hid, HANDLE hdl );
extern HANDLE __NTGetFakeHandle( void );
extern HANDLE *__OSHandles;
#define __getOSHandle( hid ) __OSHandles[ hid ]
#define NT_STDIN_FILENO (__getOSHandle( STDIN_FILENO ))
#define NT_STDOUT_FILENO (__getOSHandle( STDOUT_FILENO ))
#define NT_STDERR_FILENO (__getOSHandle( STDERR_FILENO ))
#endif
#if !defined(__NETWARE__)
extern unsigned __GetIOMode( int __handle );
extern int __SetIOMode( int __handle, unsigned __value );
extern void __SetIOMode_nogrow( int __handle, unsigned __value );
extern void __ChkTTYIOMode( int __handle );
#endif
#endif

View File

@ -0,0 +1,105 @@
#ifdef __cplusplus
extern "C"
{
#endif
#define FONT0 0x00000000
#define FONT1 0x10000000
#define BT_NORMAL 0x00000000
#define BT_NOFRAME 0x20000000
#define BT_HIDE 0x40000000
#define BT_DEL 0x80000000
#define EV_REDRAW 1
#define EV_KEY 2
#define EV_BUTTON 3
#define REL_SCREEN 0
#define REL_WINDOW 1
#define FILE_NOT_FOUND 5
#define FILE_EOF 6
typedef unsigned int DWORD;
typedef unsigned short int WORD;
typedef struct
{ DWORD pci_cmd;
DWORD irq;
DWORD glob_cntrl;
DWORD glob_sta;
DWORD codec_io_base;
DWORD ctrl_io_base;
DWORD codec_mem_base;
DWORD ctrl_mem_base;
DWORD codec_id;
} CTRL_INFO;
typedef struct
{ DWORD cmd;
DWORD offset;
DWORD r1;
DWORD count;
DWORD buff;
char r2;
char *name;
} FILEIO;
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;
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);
DWORD _stdcall GetMousePos(DWORD rel_type);
void _stdcall debug_out_hex(DWORD val);
void debug_out_str(char* str);
int _stdcall get_fileinfo(const char *name,FILEINFO* pinfo);
int _stdcall read_file (const char *name,char*buff,DWORD offset, DWORD count,DWORD *reads);
int _stdcall write_file(const char *name,char*buff,int offset,int count,int *writes);
//void exit();
int _stdcall get_key(int *key);
int _stdcall remap_key(int key);
int _cdecl get_button_id();
void delay(int val);
int wait_for_event(int time);
int wait_for_event_infinite();
void BeginDraw(void);
void EndDraw(void);
void _stdcall GetScreenSize(int *x, int*y);
void _stdcall DrawWindow(int x,int y, int sx, int sy,int workcolor,int style,
int captioncolor,int windowtype,int bordercolor);
void _stdcall debug_out(int ch);
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);
#ifdef __cplusplus
extern "C"
}
#endif

View File

@ -0,0 +1,113 @@
/****************************************************************************
*
* 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: Establish common stuff for a target environment for
* language-related processors.
*
****************************************************************************/
#ifndef __LANGENV_H__
#define __LANGENV_H__
// This file uses __TGT_SYS to figure out the required target.
//
// langenvd.h contains the possible values.
//
// __TGT_SYS_X86 is the default
//
#include "langenvd.h"
#ifndef __TGT_SYS
#define __TGT_SYS __TGT_SYS_X86
#endif
#if __TGT_SYS == __TGT_SYS_X86
#define TS_SEG_CODE "_TEXT"
#define TS_SEG_CONST "CONST"
#define TS_SEG_CONST2 "CONST2"
#define TS_SEG_DATA "_DATA"
#define TS_SEG_TIB "TIB"
#define TS_SEG_TI "TI"
#define TS_SEG_TIE "TIE"
#define TS_SEG_XIB "XIB"
#define TS_SEG_XI "XI"
#define TS_SEG_XIE "XIE"
#define TS_SEG_YIB "YIB"
#define TS_SEG_YI "YI"
#define TS_SEG_YIE "YIE"
#define TS_SEG_YC "YC"
#define TS_SEG_BSS "_BSS"
#define TS_SEG_STACK "STACK"
#define TS_SEG_DEPENDS "not used"
#define TS_SEG_TLSB ".tls"
#define TS_SEG_TLS ".tls$"
#define TS_SEG_TLSE ".tls$ZZZ"
#define TS_SEG_TLS_CLASS "TLS"
#define TS_MAX_OBJNAME 256
#define TS_DATA_MANGLE "_*"
#define TS_CODE_MANGLE "*_"
#elif __TGT_SYS == __TGT_SYS_AXP_NT || __TGT_SYS == __TGT_SYS_PPC_NT || __TGT_SYS == __TGT_SYS_MIPS
#define TS_SEG_CODE ".text"
#define TS_SEG_CONST ".const"
#define TS_SEG_CONST2 ".const2"
#define TS_SEG_DATA ".data"
#define TS_SEG_TIB ".rtl$tib"
#define TS_SEG_TI ".rtl$tid"
#define TS_SEG_TIE ".rtl$tie"
#define TS_SEG_XIB ".rtl$xib"
#define TS_SEG_XI ".rtl$xid"
#define TS_SEG_XIE ".rtl$xie"
#define TS_SEG_YIB ".rtl$yib"
#define TS_SEG_YI ".rtl$yid"
#define TS_SEG_YIE ".rtl$yie"
#define TS_SEG_YC ".rtl$yc"
#define TS_SEG_BSS ".bss"
#define TS_SEG_STACK ".stack"
#define TS_SEG_DEPENDS ".depend"
#define TS_SEG_TLSB ".tls"
#define TS_SEG_TLS ".tls$"
#define TS_SEG_TLSE ".tls$ZZZ"
#define TS_SEG_TLS_CLASS NULL
#define TS_MAX_OBJNAME 1024
#define TS_DATA_MANGLE "*"
#define TS_CODE_MANGLE "*"
#else
#error Invalid target system
#endif
#undef __TGT_SYS
#endif

View File

@ -0,0 +1,40 @@
/****************************************************************************
*
* 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: Define values for language targets.
*
****************************************************************************/
#ifndef __LANGENVD_H__
#define __LANGENVD_H__
#define __TGT_SYS_X86 0 // All x86 systems to date
#define __TGT_SYS_AXP_NT 1 // Win32 on DEC Alpha AXP
#define __TGT_SYS_PPC_NT 2 // Win32 on IBM/Motorola PowerPC
#define __TGT_SYS_MIPS 3 // MIPS RISC Architecture
#endif

View File

@ -0,0 +1,90 @@
/****************************************************************************
*
* 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: These are macros that define the 'real' functions that
* the library memory allocators use.
*
****************************************************************************/
#ifndef _LIBALLOC_H_INCLUDED
#define _LIBALLOC_H_INCLUDED
#include "variety.h"
#include <malloc.h>
#ifdef __NETWARE__
/*
// NetWare uses Alloc and Free because the heap will not have
// been initialised at _Prelude time...
*/
#define lib_malloc( x ) _NW_malloc( x )
#define lib_free( x ) _NW_free( x )
#if defined (_NETWARE_CLIB)
#define lib_realloc( x, y, z) _NW_realloc( x, y, z )
#else
#define lib_realloc( x, y) _NW_realloc( x, y)
#endif
#define lib_calloc( x, y ) _NW_calloc( x, y )
extern void *_NW_calloc( size_t __n,size_t __size );
extern void *_NW_malloc( size_t );
#if defined (_NETWARE_CLIB)
extern void *_NW_realloc( void *ptr,size_t size,size_t old);
#else
extern void *_NW_realloc( void *ptr,size_t size);
#endif
extern void _NW_free( void *ptr );
#else
#define lib_malloc( x ) malloc( x )
#define lib_free( x ) free( x )
#define lib_realloc( x, y ) realloc( x, y )
#define lib_nmalloc( x ) _nmalloc( x )
#define lib_nfree( x ) _nfree( x )
#define lib_nrealloc( x, y ) _nrealloc( x, y )
#define lib_fmalloc( x ) _fmalloc( x )
#define lib_ffree( x ) _ffree( x )
#define lib_frealloc( x, y ) _frealloc( x, y )
#define lib_calloc( x, y ) calloc( x, y )
#endif
// these are used by the C++ library
// they are real routines so that the C++ library
// remains platform independent.
#ifdef __cplusplus
extern "C" {
#endif
_WCRTLINK extern void _plib_free( void *ptr );
_WCRTLINK extern void *_plib_malloc( size_t size );
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,55 @@
/****************************************************************************
*
* 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: lseek wrapper with positive -> extend file check
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#ifdef __NT__
#include <windows.h>
#endif
#include "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
#include "lseek.h"
_WCRTLINK long lseek( int handle, long offset, int origin )
{
unsigned iomode_flags;
__handle_check( handle, -1 );
/*** Set the _FILEEXT iomode_flags bit if positive offset ***/
iomode_flags = __GetIOMode( handle );
if( offset > 0 && !(iomode_flags & _APPEND) )
__SetIOMode( handle, iomode_flags | _FILEEXT );
return( __lseek( handle, offset, origin ) );
}

View File

@ -0,0 +1,41 @@
/****************************************************************************
*
* 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: basic __lseek (without file extend) definition/prototype
*
****************************************************************************/
#ifndef _LSEEK_H_INCLUDED
#define _LSEEK_H_INCLUDED
#if defined(__DOS__) || defined(__OS2__) || defined(__NT__) || defined(__WINDOWS__)
_WCRTLINK extern long __lseek( int handle, long offset, int origin );
#else
#define __lseek lseek
#endif
#endif

View File

@ -1,66 +1,105 @@
/****************************************************************************
*
* 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: low level lseek without file extend for Windows NT
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
#include "lseek.h"
#include "handleio.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
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
_WCRTLINK long __lseek( int hid, long offset, int origin )
{
DWORD rc;
__handle_check( hid, -1 );
rc = offset;
// rc = SetFilePointer( __getOSHandle( hid ), offset, 0, origin );
// if( rc == INVALID_SET_FILE_POINTER ) {
// return( __set_errno_nt() );
// }
return( rc );
}
/****************************************************************************
*
* 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: low level lseek without file extend for Windows NT
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include <unistd.h>
#include "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
#include "lseek.h"
#include "handleio.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
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
typedef struct
{
char *name;
unsigned int offset;
}__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 )
{
__file_handle *fh;
long rc;
__handle_check( hid, -1 );
fh = (__file_handle*) __getOSHandle( hid );
switch(origin)
{
case SEEK_SET:
rc = offset;
break;
case SEEK_CUR:
rc = fh->offset + offset;
break;
case SEEK_END:
{
FILEINFO info;
get_fileinfo(fh->name,&info);
rc = offset + info.size;
break;
}
default:
return -1;
};
fh->offset = rc;
return( rc );
}

View File

@ -0,0 +1,57 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
#if !defined(MBCHARdotH)
#define MBCHARdotH
/* Prototype for initialization function */
extern int __mbinit( int codepage );
#define _MBINIT_CP_ANSI (-1)
#define _MBINIT_CP_OEM (-2)
#define _MBINIT_CP_SBCS (-3)
#define _MBINIT_CP_932 (-4)
/* Current code page */
#if !defined(__UNIX__)
extern unsigned int __MBCodePage;
#define _MB_CODE_PAGE_DEFINED
#endif
/* See if a packed DBCS char has no lead byte, i.e. is a skinny char */
#define SINGLE_BYTE_CHAR(__c) ( !( (__c)&0xFF00 ) )
#endif

View File

@ -0,0 +1,358 @@
;*****************************************************************************
;*
;* 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: Memory model setup for interfacing with C code.
;*
;*****************************************************************************
_SMALL_CODE = 00h
_BIG_CODE = 01h
_SMALL_DATA = 00h
_BIG_DATA = 02h
_HUGE_DATA = 04h
_LONG_INTS = 08h
_USE_32_SEGS = 10h
_386 = 10h ; from old clib
_DS_PEGGED = 20h ; from old clib (used for Windows)
_TINY = 40h ; from old clib (formerly 10h)
_FLAT = ( _SMALL_CODE or _SMALL_DATA or _USE_32_SEGS )
_SMALL = ( _SMALL_CODE or _SMALL_DATA )
_COMPACT = ( _SMALL_CODE or _BIG_DATA )
_MEDIUM = ( _BIG_CODE or _SMALL_DATA )
_LARGE = ( _BIG_CODE or _BIG_DATA )
_HUGE = ( _BIG_CODE or _HUGE_DATA )
_EMULATION = 00h
_8087 = 01h
ifdef __WASM__
ifdef __FLAT__
_MODEL = _FLAT
endif
ifdef __SMALL__
_MODEL = _SMALL
endif
ifdef __COMPACT__
_MODEL = _COMPACT
endif
ifdef __MEDIUM__
_MODEL = _MEDIUM
endif
ifdef __LARGE__
_MODEL = _LARGE
endif
ifdef __HUGE__
_MODEL = _HUGE
endif
ifdef __386__
_MODEL = ( _MODEL or _USE_32_SEGS )
endif
ifdef __WINDOWS__
if _MODEL and (_BIG_DATA or _HUGE_DATA)
_MODEL = ( _MODEL or _DS_PEGGED )
endif
endif
ifdef __FPC__
_MATH = _EMULATION
endif
ifdef __FPI__
_MATH = _8087
endif
ifdef __FPI87__
_MATH = _8087
endif
else
include .\model.inc ; defines _MODEL, _MATH symbols
endif
if _MODEL and _BIG_CODE
modstart macro modname,alignment
ifdef NDEBUG
name modname
endif
ifb <alignment>
_TEXT segment word public 'CODE'
else
_TEXT segment alignment public 'CODE'
endif
assume cs:_TEXT
endm
calli macro regname
call dword ptr [regname]
endm
codeptr macro p1,p2
ifb <p2>
extrn p1 : dword
else
extrn "&p1",p2 : dword
endif
endm
docall macro dest
call far ptr dest
endm
dojmp macro dest
jmp far ptr dest
endm
defp macro dsym,exp
dsym proc far exp
endm
defpe macro dsym
ifdef _EXPORT
dsym proc far export
else
dsym proc far
endif
endm
defn macro dsym
dsym proc near
endm
endproc macro dsym
dsym endp
endm
epilog macro
if _MODEL and _USE_32_SEGS
pop EBP
dec EBP
mov ESP,EBP
else
pop BP
dec BP
endif
endm
prolog macro
if _MODEL and _USE_32_SEGS
inc EBP
push EBP
mov EBP,ESP
else
inc BP
push BP
mov BP,SP
endif
endm
xdefp macro p1,p2
ifb <p2>
public p1
else
public "&p1",p2
endif
endm
xref macro p1,p2
ifb <p2>
extrn `p1` : far
else
extrn "&p1",`p2` : far
endif
endm
lcall macro dest
push cs
call near ptr dest
endm
else
modstart macro modname,alignment
ifdef NDEBUG
name modname
endif
if _MODEL and _USE_32_SEGS
_TEXT segment use32 alignment public 'CODE'
else
_TEXT segment alignment public 'CODE'
endif
assume cs:_TEXT
endm
calli macro regname
call regname
endm
codeptr macro p1,p2
if _MODEL and _USE_32_SEGS
ifb <p2>
extrn p1 : dword
else
extrn "&p1",p2 : dword
endif
else
ifb <p2>
extrn p1 : word
else
extrn "&p1",p2 : word
endif
endif
endm
defn macro dsym
dsym proc near
endm
defp macro dsym,exp
dsym proc near exp
endm
defpe macro dsym
ifdef _EXPORT
dsym proc near export
else
dsym proc near
endif
endm
docall macro dest
call dest
endm
dojmp macro dest
jmp dest
endm
endproc macro dsym
dsym endp
endm
epilog macro
if _MODEL and _USE_32_SEGS
pop EBP
else
pop BP
endif
endm
prolog macro
if _MODEL and _USE_32_SEGS
push EBP
mov EBP,ESP
else
push BP
mov BP,SP
endif
endm
xdefp macro p1,p2
ifb <p2>
public p1
else
public "&p1",p2
endif
endm
xref macro p1,p2
ifb <p2>
extrn `p1` : near
else
extrn "&p1",`p2` : near
endif
endm
lcall macro dest
call dest
endm
endif
endmod macro
_TEXT ends
endm
dataseg macro
DGROUP group _DATA
assume ds:DGROUP,ss:DGROUP
if _MODEL and _USE_32_SEGS
_DATA segment use32 dword public 'DATA'
else
_DATA segment word public 'DATA'
endif
endm
datasegment macro
dataseg ; should be phased out
endm
enddata macro
_DATA ends
endm
bss_segment macro
if _MODEL and _USE_32_SEGS
_BSS segment use32 dword public 'BSS'
else
_BSS segment word public 'BSS'
endif
DGROUP group _BSS
assume ds:DGROUP
endm
endbss macro
_BSS ends
endm
alias_function macro alias, function
ifb <function>
xref "C",_&alias
else
xref "C",function
endif
.code
public "C",`alias`
ifdef _EXPORT
`alias` proc export
else
`alias` proc
endif
ifb <function>
jmp _&alias
else
jmp `function`
endif
`alias` endp
endm
xred macro p1,p2,p3
ifb <p3>
extrn p1 : p2
else
extrn "&p1",p2 : p3
endif
endm

View File

@ -0,0 +1,100 @@
//#include "kolibc.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef unsigned int dword;
typedef unsigned int size_t;
#define PINUSE_BIT 1
#define CINUSE_BIT 2
#define INUSE_BITS 3
struct m_seg
{
char* base; /* base address */
dword size; /* allocated size */
struct m_seg* next; /* ptr to next segment */
dword flags; /* mmap and extern flag */
};
struct m_chunk
{
dword prev_foot; /* Size of previous chunk (if free). */
dword head; /* Size and inuse bits. */
struct m_chunk* fd; /* double links -- used only if free. */
struct m_chunk* bk;
};
typedef struct m_chunk* mchunkptr;
struct t_chunk
{
/* The first four fields must be compatible with malloc_chunk */
dword prev_foot;
dword head;
struct t_chunk* fd;
struct t_chunk* bk;
struct t_chunk* child[2];
struct t_chunk* parent;
dword index;
};
typedef struct t_chunk* tchunkptr;
typedef struct t_chunk* tbinptr;
typedef struct m_state
{
dword smallmap;
dword treemap;
// DWORD dvsize;
dword topsize;
char* least_addr;
// mchunkptr dv;
mchunkptr top;
dword magic;
struct m_chunk smallbins[32];
tbinptr treebins[32];
};
void _cdecl init_malloc(void* p);
void* _cdecl dlmalloc(size_t);
void _cdecl dlfree(void*);
void* _cdecl dlrealloc(void *,size_t);
dword compute_tree_index(size_t s);
static void insert_chunk(mchunkptr P, size_t S);
static void insert_large_chunk(tchunkptr X, size_t S);
static void unlink_large_chunk(tchunkptr X);
//void replace_dv(mchunkptr P, size_t S);
static void* malloc_small(size_t nb);
static void* malloc_large(size_t nb);
#define leftshift_for_tree_index(i) \
((i == 31)? 0 : (31 - (i >> 1) + 8 - 2))
#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])
#define chunk2mem(p) (void*)((char*)p + 8)
#define mem2chunk(mem) (mchunkptr)((char*)mem - 8)
#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -0,0 +1,49 @@
/****************************************************************************
*
* 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: Mask differences between platforms where va_list is an
* array and platforms where it's not.
*
****************************************************************************/
#ifndef _MYVALIST_H_INCLUDED
#include "variety.h"
#include <stdarg.h>
typedef struct my_va_list {
va_list v;
} my_va_list;
#if defined(__AXP__) || defined(__PPC__) || defined(__MIPS__)
#define MY_VA_LIST( a ) (*(my_va_list *)&(a))
#else
#define MY_VA_LIST( a ) (*(my_va_list *)(a))
#endif
#define _MYVALIST_H_INCLUDED
#endif

View File

@ -0,0 +1,404 @@
/****************************************************************************
*
* 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: Win32 implementation of open() and sopen().
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <share.h>
#include "liballoc.h"
#include "iomode.h"
#include "fileacc.h"
#include "openmode.h"
#include "rtdata.h"
#include "seterrno.h"
extern unsigned __NFiles;
extern char *__appcwd;
extern int __appcwdlen;
#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);
typedef struct
{
char *name;
unsigned int offset;
}__file_handle;
static char* getfullpath(const char* path)
{
int prev_is_slash=0;
int len=0, depth=0, i;
char* buff;
char c;
if(*path == '/')
{
buff = (char*)lib_malloc(strlen(path)+1);
buff[0] = '\0';
len=0;
}
else
{
len= __appcwdlen;
buff = (char*)lib_malloc(len+strlen(path)+1);
strncpy(buff, __appcwd, __appcwdlen);
prev_is_slash = 1;
buff[len] = 0;
for(i=0; buff[i]; i++)
if(buff[i] == '/' && i < len-1) depth++;
}
while(c=*path++)
{
switch (c)
{
case '.':
if((*path == '.')&&
(*path+1)== '/')
{ if(!depth)
{ free(buff);
return 0;
};
buff[len-1] = 0;
len = strrchr(buff, '/') + 1 - buff;
buff[len] = 0;
depth--;
path +=2;
prev_is_slash = 1;
continue;
}
if(*path == '/')
{
path++;
prev_is_slash = 1;
continue;
}
buff[len++] = c;
continue;
case '/':
prev_is_slash = 1;
buff[len++] = c;
continue;
default:
prev_is_slash = 0;
buff[len++] = c;
continue;
};
};
buff[len]= '\0';
return buff;
};
size_t FileSize(FILE *fp)
{
int hdl;
__file_handle *fh;
FILEINFO info;
hdl = fileno( fp );
// __handle_check( hdl, -1 );
fh = (__file_handle*) __getOSHandle(hdl);
get_fileinfo(fh->name,&info);
return info.size;
}
int access(const char *path, int mode)
{ size_t retval;
FILEINFO info;
char *p;
p = getfullpath(path);
retval=get_fileinfo(p,&info);
free(p);
return retval;
}
static HANDLE __createFileHandle(const CHAR_TYPE *name)
{
FILEINFO info;
__file_handle *handle;
char *path;
path = getfullpath(name);
if(get_fileinfo(path,&info))
{
// printf("failed getfileinfo %s\n\r", path);
lib_free(path);
return (HANDLE)-1;
};
if ( !(handle=(__file_handle*)lib_malloc(sizeof( __file_handle) )))
{ lib_free(path);
return (HANDLE)-1;
};
handle->name = path;
handle->offset = 0;
return (HANDLE)handle;
};
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
{
HANDLE handle;
int hid, rwmode;
unsigned iomode_flags;
// First try to get the required slot.
// No point in creating a file only to not use it. JBS 99/10/26
hid = __allocPOSIXHandle( DUMMY_HANDLE );
if( hid == -1 )
{
return( -1 );
}
rwmode = mode;
/*** Open the file ***/
handle = __createFileHandle( name);
if( handle==(HANDLE)-1 )
{
printf("handle = -1 \n\r");
if( mode&O_CREAT )
{
// handle = CreateFileA( name, desired_access,
// share_mode, NULL, create_disp,
// fileattr, NULL );
}
if( handle == (HANDLE)-1 )
{
__freePOSIXHandle( hid );
return( -1 ); //error
}
}
// Now use the slot we got.
__setOSHandle( hid, handle ); // JBS 99/11/01
iomode_flags = 0;
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE;
else if( rwmode == O_RDONLY) iomode_flags |= _READ;
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE;
if( mode & O_APPEND ) iomode_flags |= _APPEND;
if( mode & (O_BINARY|O_TEXT) ) {
if( mode & O_BINARY ) iomode_flags |= _BINARY;
} else {
if( _RWD_fmode == O_BINARY ) iomode_flags |= _BINARY;
}
__SetIOMode( hid, iomode_flags );
return( hid );
}
#elif
static int __F_NAME(_sopen,__wsopen)( const CHAR_TYPE *name, int mode, int share, va_list args )
{
DWORD create_disp, exists_disp;
DWORD perm, fileattr;
DWORD desired_access, share_mode;
SECURITY_ATTRIBUTES security;
HANDLE handle;
int hid, rwmode;
unsigned iomode_flags;
// First try to get the required slot.
// No point in creating a file only to not use it. JBS 99/10/26
hid = __allocPOSIXHandle( DUMMY_HANDLE );
if( hid == -1 ) {
return( -1 );
}
rwmode = mode & OPENMODE_ACCESS_MASK;
__GetNTAccessAttr( rwmode, &desired_access, &perm );
__GetNTShareAttr( share|rwmode, &share_mode );
fileattr = FILE_ATTRIBUTE_NORMAL;
security.nLength = sizeof( SECURITY_ATTRIBUTES );
security.lpSecurityDescriptor = NULL;
security.bInheritHandle = mode&O_NOINHERIT ? FALSE : TRUE;
#ifdef DEFAULT_WINDOWING
#ifdef __WIDECHAR__
if( _WindowsNewWindow != 0 && !_wcsicmp( name, L"con" ) )
#else
if( _WindowsNewWindow != 0 && !stricmp( name, "con" ) )
#endif
{
handle = (HANDLE) __NTGetFakeHandle();
// Now use the slot we got.
__setOSHandle( hid, handle ); // JBS 99/11/01
_WindowsNewWindow( NULL, hid, -1 );
iomode_flags = _ISTTY;
} else {
#endif
if( mode & O_CREAT ) {
perm = va_arg( args, int );
va_end( args );
perm &= ~_RWD_umaskval; /* 05-jan-95 */
if( ( perm & S_IREAD ) && !( perm & S_IWRITE ) ) {
fileattr = FILE_ATTRIBUTE_READONLY;
}
if( mode & O_EXCL ) {
create_disp = CREATE_NEW;
exists_disp = CREATE_NEW;
} else if( mode & O_TRUNC ) {
create_disp = CREATE_ALWAYS;
exists_disp = CREATE_NEW;
} else {
create_disp = OPEN_ALWAYS;
exists_disp = OPEN_EXISTING;
}
} else if( mode & O_TRUNC ) {
exists_disp = TRUNCATE_EXISTING;
} else {
exists_disp = OPEN_EXISTING;
}
/*** Open the file ***/
#ifdef __WIDECHAR__
handle = __lib_CreateFileW( name, desired_access, share_mode,
&security, exists_disp, fileattr,
NULL );
#else
handle = CreateFileA( name, desired_access, share_mode,
&security, exists_disp, fileattr, NULL );
#endif
if( handle==(HANDLE)-1 ) {
if( mode&O_CREAT ) {
#ifdef __WIDECHAR__
handle = __lib_CreateFileW( name, desired_access,
share_mode, NULL, create_disp,
fileattr, NULL );
#else
handle = CreateFileA( name, desired_access,
share_mode, NULL, create_disp,
fileattr, NULL );
#endif
}
if( handle == (HANDLE)-1 ) {
__freePOSIXHandle( hid );
return( __set_errno_nt() );
}
}
// Now use the slot we got.
__setOSHandle( hid, handle ); // JBS 99/11/01
iomode_flags = 0;
if( isatty(hid) ) {
iomode_flags = _ISTTY;
}
#ifdef DEFAULT_WINDOWING
}
#endif
if( rwmode == O_RDWR ) iomode_flags |= _READ | _WRITE;
else if( rwmode == O_RDONLY) iomode_flags |= _READ;
else if( rwmode == O_WRONLY) iomode_flags |= _WRITE;
if( mode & O_APPEND ) iomode_flags |= _APPEND;
if( mode & (O_BINARY|O_TEXT) ) {
if( mode & O_BINARY ) iomode_flags |= _BINARY;
} else {
if( _RWD_fmode == O_BINARY ) iomode_flags |= _BINARY;
}
__SetIOMode( hid, iomode_flags );
return( hid );
}
#endif
_WCRTLINK int __F_NAME(open,_wopen)( const CHAR_TYPE *name, int mode, ... )
{
int permission;
va_list args;
va_start( args, mode );
permission = va_arg( args, int );
va_end( args );
return( __F_NAME(sopen,_wsopen)( name, mode, SH_COMPAT, permission ) );
}
_WCRTLINK int __F_NAME(sopen,_wsopen)( const CHAR_TYPE *name, int mode, int shflag, ... )
{
va_list args;
va_start( args, shflag );
return( __F_NAME(_sopen,__wsopen)( name, mode, shflag, args ) );
}

View File

@ -0,0 +1,75 @@
/****************************************************************************
*
* 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!
*
****************************************************************************/
#ifndef _OPENMODE_H_INCLUDED
#define _OPENMODE_H_INCLUDED
enum {
FILEATTR_MASK = 0x003f,
FILEATTR_NORMAL = 0x0000,
FILEATTR_READONLY = 0x0001,
FILEATTR_HIDDEN = 0x0002,
FILEATTR_SYSTEM = 0x0004,
FILEATTR_DIRECTORY = 0x0010,
FILEATTR_ARCHIVED = 0x0020
};
enum {
OPENFLAG_FAIL_IF_EXISTS = 0x0000,
OPENFLAG_OPEN_IF_EXISTS = 0x0001,
OPENFLAG_REPLACE_IF_EXISTS = 0x0002,
OPENFLAG_FAIL_IF_NOT_EXISTS = 0x0000,
OPENFLAG_CREATE_IF_NOT_EXISTS = 0x0010
};
enum {
OPENMODE_DASD = 0x8000,
OPENMODE_WRITE_THROUGH = 0x4000,
OPENMODE_FAIL_ERRORS = 0x2000,
OPENMODE_NO_CACHE = 0x1000,
OPENMODE_LOCALITY_MASK = 0x0700,
OPENMODE_LOCALITY_RANDSEQ = 0x0300,
OPENMODE_LOCALITY_RANDOM = 0x0200,
OPENMODE_LOCALITY_SEQUENTIAL = 0x0100,
OPENMODE_LOCALITY_NONE = 0x0000,
OPENMODE_INHERITANCE = 0x0080,
OPENMODE_SHARE_MASK = 0x0070,
OPENMODE_DENY_COMPAT = 0x0000,
OPENMODE_DENY_ALL = 0x0010,
OPENMODE_DENY_WRITE = 0x0020,
OPENMODE_DENY_READ = 0x0030,
OPENMODE_DENY_NONE = 0x0040,
OPENMODE_ACCESS_MASK = 0x0007,
OPENMODE_ACCESS_RDONLY = 0x0000,
OPENMODE_ACCESS_WRONLY = 0x0001,
OPENMODE_ACCESS_RDWR = 0x0002
};
#endif

View File

@ -0,0 +1,57 @@
/****************************************************************************
*
* 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: Macro to deal with stream orientation.
*
****************************************************************************/
#ifdef __NETWARE__
/* One less thing to worry about */
#define ORIENT_STREAM(stream,error_return)
#else
#ifdef __WIDECHAR__
#define ORIENT_STREAM(stream,error_return) \
if( _FP_ORIENTATION(stream) != _WIDE_ORIENTED ) { \
if( _FP_ORIENTATION(stream) == _NOT_ORIENTED ) { \
_FP_ORIENTATION(stream) = _WIDE_ORIENTED; \
} else { \
_ReleaseFile( stream ); \
return( error_return ); \
} \
}
#else
#define ORIENT_STREAM(stream,error_return) \
if( _FP_ORIENTATION(stream) != _BYTE_ORIENTED ) { \
if( _FP_ORIENTATION(stream) == _NOT_ORIENTED ) { \
_FP_ORIENTATION(stream) = _BYTE_ORIENTED; \
} else { \
_ReleaseFile( stream ); \
return( error_return ); \
} \
}
#endif
#endif

View File

@ -0,0 +1,183 @@
/****************************************************************************
*
* 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: Definitions needed by callers to internal string formatter
* __prtf() for printf() style handling.
*
****************************************************************************/
#ifndef _PRINTF_H_INCLUDED
#define _PRINTF_H_INCLUDED
#include "variety.h"
#include "widechar.h"
#if defined(__QNX__)
#if defined(__386__)
#define __SLIB_CALLBACK _WCFAR
#define __SLIB
#pragma aux slib_callback_t __far parm [eax] [edx] modify [eax edx];
#elif defined( __SMALL_DATA__ )
#define __SLIB_CALLBACK _WCFAR __loadds
#define __SLIB _WCFAR
#else
#define __SLIB_CALLBACK _WCFAR
#define __SLIB _WCFAR
#endif
#else
#if defined( __HUGE__ )
#define __SLIB _WCFAR
#define __SLIB_CALLBACK
#else
#define __SLIB
#define __SLIB_CALLBACK
#endif
#endif
#define SPECS_VERSION 200
/*
* This is the __prtf specs structure. NB - should be naturally aligned.
*
* There are both wide and MBCS versions explicitly because part of __wprtf
* needs to access both kinds of structure.
*/
typedef struct
{
char __SLIB *_dest;
short _flags; // flags (see below)
short _version; // structure version # (2.0 --> 200)
int _fld_width; // field width
int _prec; // precision
int _output_count; // # of characters outputted for %n
int _n0; // number of chars to deliver first
int _nz0; // number of zeros to deliver next
int _n1; // number of chars to deliver next
int _nz1; // number of zeros to deliver next
int _n2; // number of chars to deliver next
int _nz2; // number of zeros to deliver next
char _character; // format character
char _pad_char;
char _padding[2]; // to keep struct aligned
} _mbcs_SPECS;
typedef struct
{
wchar_t __SLIB *_dest;
short _flags; // flags (see below)
short _version; // structure version # (2.0 --> 200)
int _fld_width; // field width
int _prec; // precision
int _output_count; // # of characters outputted for %n
int _n0; // number of chars to deliver first
int _nz0; // number of zeros to deliver next
int _n1; // number of chars to deliver next
int _nz1; // number of zeros to deliver next
int _n2; // number of chars to deliver next
int _nz2; // number of zeros to deliver next
wchar_t _character; // format character
wchar_t _pad_char;
} _wide_SPECS;
#ifdef __WIDECHAR__
#define SPECS _wide_SPECS
#else
#define SPECS _mbcs_SPECS
#endif
typedef void (__SLIB_CALLBACK slib_callback_t)( SPECS __SLIB *, int );
/* specification flags... (values for _flags field above) */
#define SPF_ALT 0x0001
#define SPF_BLANK 0x0002
#define SPF_FORCE_SIGN 0x0004
#define SPF_LEFT_ADJUST 0x0008
#define SPF_CHAR 0x0010
#define SPF_SHORT 0x0020
#define SPF_LONG 0x0040
#define SPF_LONG_LONG 0x0080
#define SPF_LONG_DOUBLE 0x0100 // may be also used for __int64
#define SPF_NEAR 0x0200
#define SPF_FAR 0x0400
#define SPF_CVT 0x0800 // __cvt function
#ifdef __QNX__
#define SPF_ZERO_PAD 0x8000
#endif // __QNX__
#if defined( __STDC_WANT_LIB_EXT1__ ) && __STDC_WANT_LIB_EXT1__ == 1
#if !defined( __WIDECHAR__ )
int __prtf_s( void __SLIB *dest, /* parm for use by out_putc */
const char * __restrict format, /* pointer to format string */
va_list args, /* pointer to pointer to args*/
const char **errmsg, /* constraint violation msg */
slib_callback_t *out_putc ); /* character output routine */
#else
int __wprtf_s( void __SLIB *dest, /* parm for use by out_putc */
const CHAR_TYPE * __restrict format,/* pointer to format string */
va_list args, /* pointer to pointer to args*/
const char **errmsg, /* constraint violation msg */
slib_callback_t *out_putc ); /* character output routine */
#endif
#else
#if !defined(__WIDECHAR__)
int __prtf( void __SLIB *dest, /* parm for use by out_putc */
const char *format, /* pointer to format string */
va_list args, /* pointer to pointer to args*/
slib_callback_t *out_putc ); /* character output routine */
#else
int __wprtf( void __SLIB *dest, /* parm for use by out_putc */
const CHAR_TYPE *format, /* pointer to format string */
va_list args, /* pointer to pointer to args*/
slib_callback_t *out_putc ); /* character output routine */
#endif
#ifdef __QNX__
int __prtf_slib( void __SLIB *dest, /* parm for use by out_putc */
const char * format, /* pointer to format string */
char **args, /* pointer to pointer to args*/
slib_callback_t *out_putc, /* character output routine */
int ptr_size );
#if !defined(IN_SLIB) && !defined(__386__)
extern int ( _WCFAR * ( _WCFAR *__f)) ();
#define __prtf(a,b,c,d) __prtf_slib(a,b,c,d,sizeof(void *))
#define __prtf_slib(a,b,c,d,e) ((int(_WCFAR *) (void _WCFAR *,const char _WCFAR *,char * _WCFAR *args,void (_WCFAR *__out)(SPECS _WCFAR *,int),int)) __f[24])(a,b,c,d,e)
#endif
#endif
#endif /* Safer C */
#endif

View File

@ -0,0 +1,91 @@
/****************************************************************************
*
* 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: Configure 'j', 'z', and 't' modifiers for __scnf and __prtf.
*
****************************************************************************/
#ifndef PTRSCNF_H_INCLUDED
#define PTRSCNF_H_INCLUDED
#include <limits.h>
#include <stdint.h>
/* Currently size_t is always 'unsigned int', but won't be on LP64 systems */
#if SIZE_MAX == UINT_MAX
#define ZSPEC_IS_INT
#elif SIZE_MAX == ULONG_MAX
#define ZSPEC_IS_LONG
#else
#error Could not configure zspec
#endif
/* Currently intmax_t is always 'long long int' but might be something
* else, in theory at least
*/
#if INTMAX_MAX == LLONG_MAX
#define JSPEC_IS_LLONG
#define JSPEC_CASE_LLONG case 'j':
#else
#error Could not configure jspec
#endif
/* Currently ptrdiff_t can be either 'long int' or 'int' */
#if PTRDIFF_MAX == INT_MAX
#define TSPEC_IS_INT
#elif PTRDIFF_MAX == LONG_MAX
#define TSPEC_IS_LONG
#else
#error Could not configure tspec
#endif
#ifdef ZSPEC_IS_INT
#define ZSPEC_CASE_INT case 'z':
#else
#define ZSPEC_CASE_INT
#endif
#ifdef ZSPEC_IS_LONG
#define ZSPEC_CASE_LONG case 'z':
#else
#define ZSPEC_CASE_LONG
#endif
#ifdef TSPEC_IS_INT
#define TSPEC_CASE_INT case 't':
#else
#define TSPEC_CASE_INT
#endif
#ifdef TSPEC_IS_LONG
#define TSPEC_CASE_LONG case 't':
#else
#define TSPEC_CASE_LONG
#endif
#endif

View File

@ -0,0 +1,68 @@
/****************************************************************************
*
* 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 "iomode.h"
#include "rtcheck.h"
#include "seterrno.h"
#include "qread.h"
#include <stdio.h>
typedef struct
{
char *name;
unsigned int offset;
}__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 )
{
__file_handle *fh;
unsigned amount_read=0;
__handle_check( handle, -1 );
fh = (__file_handle*) __getOSHandle( handle );
if(read_file(fh->name,buffer,fh->offset,len,&amount_read))
{
if ( amount_read == 0)
return (-1);
}
fh->offset+=amount_read;
return( amount_read );
};

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: Prototype for __qread() internal helper.
*
****************************************************************************/
#ifdef __NETWARE__
#define __qread( h, b, l ) read( h, b, l )
#else
extern int __qread( int handle, void *buffer, unsigned len );
#endif

Some files were not shown because too many files have changed in this diff Show More