update clib

git-svn-id: svn://kolibrios.org@701 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-01-23 19:23:33 +00:00
parent 7941c117bc
commit 275695e8c3
41 changed files with 4614 additions and 3937 deletions

View File

@ -4,8 +4,8 @@ projectIdent
VpeMain
1
WRect
-32
330
32
460
10304
9950
2
@ -16,28 +16,48 @@ MCommand
4
MCommand
0
1
2
5
WFileName
10
clib_r.tgt
6
WVList
1
WFileName
7
VComponent
crt.tgt
7
WVList
2
8
VComponent
9
WRect
2760
200
2496
30
5712
7390
0
0
9
10
WFileName
10
clib_r.tgt
24
52
11
VComponent
12
WRect
0
0
5712
7300
0
0
13
WFileName
7
crt.tgt
0
29
11

View File

@ -1,70 +0,0 @@
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

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

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

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

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

@ -24,22 +24,61 @@
*
* ========================================================================
*
* Description: Prototypes for floating-point formatting routines.
* Description: I/O streams shutdown.
*
****************************************************************************/
#ifndef _FTOS_H_INCLUDED
#define _FTOS_H_INCLUDED
#include "variety.h"
#include "farsupp.h"
#include <stdio.h>
#include "rtdata.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())();
extern void __purgefp(void);
extern int __shutdown_stream( FILE *fp, int );
static int docloseall( unsigned dont_close )
{
FILE *fp;
int number_of_files_closed;
__stream_link *link;
__stream_link *next;
FILE *bottom;
FILE *standards;
int close_handle;
bottom = &_RWD_iob[dont_close];
standards = &_RWD_iob[NUM_STD_STREAMS];
number_of_files_closed = 0;
for( link = _RWD_ostream; link != NULL; link = next ) {
next = link->next;
fp = link->stream;
close_handle = 1;
if ((fp->_flag & _DYNAMIC) || (fp->_flag & _TMPFIL))
{
__shutdown_stream( fp, close_handle );
++number_of_files_closed;
}
else if( fp >= bottom ) {
#ifndef __NETWARE__
/* close the file, but leave the handle open */
if( fp < standards ) {
close_handle = 0;
}
#endif
__shutdown_stream( fp, close_handle );
++number_of_files_closed;
}
}
return( number_of_files_closed );
}
_WCRTLINK int fcloseall( void )
{
return( docloseall( NUM_STD_STREAMS ) );
}
void __full_io_exit( void )
{
docloseall( 0 );
__purgefp();
}

View File

@ -1,33 +0,0 @@
#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

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

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

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

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

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

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

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

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

@ -24,25 +24,31 @@
*
* ========================================================================
*
* Description: Routine to bring in real floating-point formatting code.
* Description: Implementation of isatty() for Win32.
*
****************************************************************************/
#include "variety.h"
#include <stdio.h>
#include "ftos.h"
#include "farsupp.h"
#include <unistd.h>
//#include <windows.h>
//#include "defwin.h"
#include "iomode.h"
#include "fileacc.h"
/* This routine will be called by cstart if "_fltused" is referenced. */
/*
DWORD GetFileType(
HANDLE hFile // handle to file
);
Return value can be:
FILE_TYPE_CHAR The specified file is a character file,
typically an LPT device or a console
*/
void __setEFGfmt( void )
_WCRTLINK int isatty( int hid )
{
#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
// if( GetFileType( __getOSHandle( hid ) ) == FILE_TYPE_CHAR ) {
// return( 1 );
// }
return( 0 );
}

View File

@ -30,6 +30,31 @@
****************************************************************************/
#define _ERRNO errno
#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,103 @@
/****************************************************************************
*
* 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 data and routines for "Safer C", or bounds-checking
* library extension.
*
****************************************************************************/
#ifndef _SAFERLIB_H_INCLUDED
#define _SAFERLIB_H_INCLUDED
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
#include <stdint.h>
// Maximum length of runtime-constraint error message
#define RTCT_MSG_MAX 128
#define _RWD_rtcthandler __runtime_constraint_handler
extern constraint_handler_t __runtime_constraint_handler;
extern void __rtct_fail( const char *fn, const char *reason, void *reserved );
// Runtime-constraint validation macros. Call the handler and return zero if check
// failed, return non-zero value if check succeeded.
#define __check_constraint_nullptr( arg ) \
((arg == NULL) ? __rtct_fail( __func__, #arg " == NULL", NULL ), 0 : 1)
#define __check_constraint_maxsize( arg ) \
((arg > RSIZE_MAX) ? __rtct_fail( __func__, #arg " > RSIZE_MAX", NULL ), 0 : 1)
#define __check_constraint_zero( arg ) \
((arg == 0) ? __rtct_fail( __func__, #arg " == 0", NULL ), 0 : 1)
#define __check_constraint_toosmall( name, left ) \
((left == 0) ? __rtct_fail( __func__, #name " is too small to hold data", NULL ), 0 : 1)
// Runtime-constraint validation macros. Construct the message and return
// zero if check failed, return non-zero value if check succeeded.
// __rtct_fail has to be explicitly called later.
#define __check_constraint_nullptr_msg( msg, arg ) \
((arg == NULL) ? ( msg = #arg " == NULL" ), 0 : 1)
#define __check_constraint_maxsize_msg( msg, arg ) \
((arg > RSIZE_MAX) ? ( msg = #arg " > RSIZE_MAX" ), 0 : 1)
#define __check_constraint_zero_msg( msg, arg ) \
((arg == 0) ? ( msg = #arg " == 0" ), 0 : 1)
#define __check_constraint_toosmall_msg( msg, name, left ) \
((left == 0) ? ( msg = #name " is too small to hold data" ), 0 : 1)
#define __check_constraint_a_gt_b_msg( msg, a, b ) \
((a > b) ? ( msg = #a " > " #b ), 0 : 1)
#define __check_constraint_overlap_msg( msg, p1, len1, p2, len2 ) \
(((p1 == p2) || ( (p1 > p2) && ( p1 < (CHAR_TYPE *)p2 + len2 * sizeof( CHAR_TYPE ))) \
|| ( (p2 > p1) && ( p2 < (CHAR_TYPE *)p1 + len1 * sizeof( CHAR_TYPE )))) \
? ( msg = #p1 " overlap " #p2 ), 0 : 1)
// For 16-bit targets, the RSIZE_MAX check is effectively no-op. Object sizes
// up to SIZE_MAX are legal and not uncommon.
#if RSIZE_MAX == SIZE_MAX
#undef __check_constraint_maxsize
#define __check_constraint_maxsize( arg ) 1
#undef __check_constraint_maxsize_msg
#define __check_constraint_maxsize_msg( msg, arg ) 1
#define __lte_rsizmax( arg ) 1
#else
#define __lte_rsizmax( arg ) (arg <= RSIZE_MAX)
#endif
#endif // _SAFERLIB_H_INCLUDED

View File

@ -24,17 +24,18 @@
*
* ========================================================================
*
* Description: Define values for language targets.
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef __LANGENVD_H__
#define __LANGENVD_H__
#ifndef __STRDUP_H_INCLUDED
#define __STRDUP_H_INCLUDED
#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
#include "variety.h"
#include "widechar.h"
_WCRTLINK extern char *__clib_strdup( const char *str );
_WCRTLINK extern wchar_t *__clib_wcsdup( const wchar_t *str );
#endif

View File

@ -0,0 +1,399 @@
/****************************************************************************
*
* 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);
int _stdcall create_file(const char *name);
typedef struct
{
char *name;
unsigned int offset;
}__file_handle;
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 __openFileHandle(const CHAR_TYPE *name, int mode)
{
FILEINFO info;
__file_handle *handle;
char *path;
int err;
path = getfullpath(name);
if(err=get_fileinfo(path,&info))
{
// printf("failed getfileinfo %s\n\r", path);
if(mode & O_CREAT)
err=create_file(path);
if(err)
{
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 = __openFileHandle( name, mode);
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

@ -31,10 +31,11 @@
#include "variety.h"
#include "87state.h"
#include "rtdata.h"
#include <sys/types.h>
#include <unistd.h>
#include "lseek.h"
static void _do_nothing( _87state *st ) {}
void (*_RWD_Save8087)(_87state *) = _do_nothing;
void (*_RWD_Rest8087)(_87state *) = _do_nothing;
_WCRTLINK long int tell( int handle )
{
return( __lseek( handle, 0L, SEEK_CUR ) );
}

View File

@ -0,0 +1,306 @@
/****************************************************************************
*
* 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 <string.h>
#include <mbstring.h>
#include "mbchar.h"
unsigned int __MBCodePage = 0; /* default code page */
static void set_dbcs_table( int low, int high )
{
memset( __MBCSIsTable + low + 1, _MB_LEAD, high - low + 1 );
}
static void clear_dbcs_table( void )
{
__IsDBCS = 0; /* SBCS for now */
__MBCodePage = 0;
memset( __MBCSIsTable, 0, 257 );
}
/****
***** Initialize a multi-byte character set. Returns 0 on success.
****/
int __mbinit( int codepage )
{
/*** Handle values from _setmbcp ***/
if( codepage == _MBINIT_CP_ANSI )
{
codepage = 0;
}
else
if( codepage == _MBINIT_CP_OEM )
{
codepage = 0;
}
else
if( codepage == _MBINIT_CP_SBCS )
{
clear_dbcs_table();
return( 0 );
}
else
if( codepage == _MBINIT_CP_932 )
{
clear_dbcs_table();
set_dbcs_table( 0x81, 0x9F );
set_dbcs_table( 0xE0, 0xFC );
__IsDBCS = 1;
__MBCodePage = 932;
return( 0 );
}
return( 0 ); /* return success code */
}
/****
***** Query DOS to find the valid lead byte ranges.
****/
#if defined(__DOS__) && !defined(__OSI__)
#ifndef __386__
// for some unknown reason NT DPMI returns for DOS service 6300h
// Carry=0, odd SI value and DS stay unchanged
// this case is also tested as wrong int 21h result
#if 1
#pragma aux dos_get_dbcs_lead_table = \
"push ds" \
"xor ax,ax" \
"mov ds,ax" \
"mov ah,63h" /* get DBCS vector table */ \
"int 21h" \
"mov di,ds" \
"jnc label1" \
"xor di,di" \
"label1:" \
"test di,di" \
"jnz exit1" \
"mov si,di" \
"exit1:" \
"pop ds" \
value [di si] \
modify [ax bx cx dx si di es];
#else
unsigned short _WCFAR *dos_get_dbcs_lead_table( void )
/****************************************************/
{
union REGS regs;
struct SREGS sregs;
regs.w.ax = 0x6300; /* get lead byte table code */
sregs.ds = 0;
sregs.es = 0;
intdosx( &regs, &regs, &sregs ); /* call DOS */
if( regs.w.cflag || ( sregs.ds == 0 )) /* ensure function succeeded */
return( NULL );
return( MK_FP( sregs.ds, regs.w.si ) ); /* return pointer to table */
}
#endif
#if 0
unsigned short dos_get_code_page( void )
/**************************************/
{
union REGS regs;
struct SREGS sregs;
unsigned char buf[7];
regs.w.ax = 0x6501; /* get international info */
regs.w.bx = 0xFFFF; /* global code page */
regs.w.cx = 7; /* buffer size */
regs.w.dx = 0xFFFF; /* current country */
regs.w.di = FP_OFF( (void __far*)buf ); /* buffer offset */
sregs.es = FP_SEG( (void __far*)buf ); /* buffer segment */
sregs.ds = 0; /* in protected mode (dos16m) DS must be initialized */
intdosx( &regs, &regs, &sregs ); /* call DOS */
if( regs.w.cflag ) return( 0 ); /* ensure function succeeded */
return( * (unsigned short*)(buf+5) ); /* return code page */
}
#else
#pragma aux dos_get_code_page = \
"push ds" \
"push bp" \
"mov bp,sp" \
"sub sp,8" \
"xor ax,ax" \
"mov ds,ax" \
"mov ax,6501h" /* get international info */ \
"mov bx,0ffffh" /* global code page */ \
"mov cx,0007h" /* buffer size */ \
"mov dx,0ffffh" /* current country */ \
"lea di,[bp-8]" /* buffer offset */ \
"push ss" \
"pop es" /* buffer segment */ \
"int 21h" /* call DOS */ \
"mov ax,[bp-8+5]" /* code page */ \
"jnc NoError" \
"xor ax,ax" \
"NoError:" \
"mov sp,bp" \
"pop bp" \
"pop ds" \
value [ax] \
modify [ax bx cx dx di es];
#endif
#else
#pragma pack(__push,1);
typedef struct {
unsigned short int_num;
unsigned short real_ds;
unsigned short real_es;
unsigned short real_fs;
unsigned short real_gs;
unsigned long real_eax;
unsigned long real_edx;
} PHARLAP_block;
#pragma pack(__pop);
unsigned short _WCFAR *dos_get_dbcs_lead_table( void )
/****************************************************/
{
union REGPACK regs;
if( _IsPharLap() ) {
PHARLAP_block pblock;
memset( &pblock, 0, sizeof( pblock ) );
memset( &regs, 0, sizeof( regs ) );
pblock.real_eax = 0x6300; /* get DBCS vector table */
pblock.int_num = 0x21; /* DOS call */
regs.x.eax = 0x2511; /* issue real-mode interrupt */
regs.x.edx = FP_OFF( &pblock ); /* DS:EDX -> parameter block */
regs.w.ds = FP_SEG( &pblock );
intr( 0x21, &regs );
if( pblock.real_ds != 0xFFFF ) { /* weird OS/2 value */
return( MK_FP( _ExtenderRealModeSelector,
(((unsigned)pblock.real_ds)<<4) + regs.w.si ) );
}
} else if( _IsRational() ) {
rm_call_struct dblock;
memset( &dblock, 0, sizeof( dblock ) );
dblock.eax = 0x6300; /* get DBCS vector table */
DPMISimulateRealModeInterrupt( 0x21, 0, 0, &dblock );
if( (dblock.flags & 1) == 0 ) {
return( MK_FP( _ExtenderRealModeSelector,
(((unsigned)dblock.ds)<<4) + dblock.esi ) );
}
}
return( NULL );
}
unsigned short dos_get_code_page( void )
/**************************************/
{
union REGPACK regs;
unsigned short __far * temp;
unsigned short real_seg;
unsigned short codepage = 0;
/*** Get the code page ***/
if( _IsPharLap() ) {
union REGS r;
PHARLAP_block pblock;
/*** Alloc DOS Memory under Phar Lap ***/
memset( &r, 0, sizeof( r ) );
r.x.ebx = 1;
r.x.eax = 0x25c0;
intdos( &r, &r );
real_seg = r.w.ax;
memset( &pblock, 0, sizeof( pblock ) );
memset( &regs, 0, sizeof( regs ) );
pblock.real_eax = 0x6501; /* get international info */
pblock.real_edx = 0xFFFF; /* current country */
pblock.real_es = real_seg; /* buffer segment */
regs.x.ebx = 0xFFFF; /* global code page */
regs.x.ecx = 7; /* buffer size */
regs.x.edi = 0; /* buffer offset */
pblock.int_num = 0x21; /* DOS call */
regs.x.eax = 0x2511; /* issue real-mode interrupt */
regs.x.edx = FP_OFF( &pblock ); /* DS:EDX -> parameter block */
regs.w.ds = FP_SEG( &pblock );
intr( 0x21, &regs );
if( pblock.real_ds != 0xFFFF ) { /* weird OS/2 value */
temp = MK_FP( _ExtenderRealModeSelector, (real_seg<<4) + 5 );
codepage = *temp;
}
/*** Free DOS Memory under Phar Lap ***/
r.x.ecx = real_seg;
r.x.eax = 0x25c1;
intdos( &r, &r );
} else if( _IsRational() ) {
unsigned long dpmi_rc;
unsigned short selector;
rm_call_struct dblock;
/*** Allocate some DOS memory with DPMI ***/
dpmi_rc = DPMIAllocateDOSMemoryBlock( 1 ); /* one paragraph is enough */
real_seg = (unsigned short) dpmi_rc;
selector = (unsigned short) (dpmi_rc>>16);
memset( &dblock, 0, sizeof( dblock ) );
dblock.eax = 0x6501; /* get international info */
dblock.ebx = 0xFFFF; /* global code page */
dblock.ecx = 7; /* buffer size */
dblock.edx = 0xFFFF; /* current country */
dblock.edi = 0; /* buffer offset */
dblock.es = real_seg; /* buffer segment */
DPMISimulateRealModeInterrupt( 0x21, 0, 0, &dblock );
if( (dblock.flags & 1) == 0 ) {
temp = MK_FP( _ExtenderRealModeSelector, (real_seg<<4) + 5 );
codepage = *temp;
}
/*** Free DOS memory with DPMI ***/
DPMIFreeDOSMemoryBlock( selector );
}
return( codepage );
}
#endif
#endif

View File

@ -24,11 +24,14 @@
*
* ========================================================================
*
* Description: declaration for set commit mode function
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
/* see note in commode.c */
_WCRTLINK extern void _WCI86FAR __set_commode( void );
#pragma aux __set_commode "*_";
#include "variety.h"
#include <mbstring.h>
#include "rtinit.h"
_WCRTLINKD int __IsDBCS;

View File

@ -30,31 +30,30 @@
****************************************************************************/
#if defined(__OS2__) || defined(__NT__)
#if defined(__SW_BM)
#include "variety.h"
#include <mbstring.h>
#include "mbchar.h"
#include "rtinit.h"
#include "thread.h"
_WCRTLINKD unsigned char __MBCSIsTable[257];
#define _ERRNO (__THREADDATAPTR->__errnoP)
#define _DOSERRNO (__THREADDATAPTR->__doserrnoP)
/**
* Determine whether or not the specified byte is a lead byte.
*/
#else
_WCRTLINK int (_ismbblead)( const unsigned int ch )
{
return( __MBCSIsTable[ch+1] & _MB_LEAD );
}
#define _ERRNO errno
#define _DOSERRNO _doserrno
/**
* If this module is linked in, the startup code will call this function,
* which will initialize the default multibyte code page.
*/
#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
static void __mbInitOnStartup( void )
{
__mbinit( 0 );
}
#ifndef __NETWARE__
#define _DOSERRNO _doserrno
#endif
#endif
AXI( __mbInitOnStartup, INIT_PRIORITY_LIBRARY )

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: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include <mbstring.h>
#include "farfunc.h"
/****
***** Convert a multibyte character to a wide character.
****/
_WCRTLINK int _NEARFAR(mbtowc,_fmbtowc)( wchar_t _FFAR *pwc, const char _FFAR *ch, size_t n )
{
/*** Catch special cases ***/
if( ch == NULL ) return( 0 );
if( n == 0 ) return( -1 );
if( *ch == '\0' ) {
if( pwc != NULL ) *pwc = L'\0';
return( 0 );
}
if( _ismbblead( ch[0] ) && ch[1] == '\0' ) return( -1 ); /* invalid */
/*** Convert the character ***/
if( _ismbblead(*ch) && n>=2 ) { /* lead byte present? */
if( pwc != NULL ) {
*pwc = (((wchar_t)ch[0])<<8) | /* convert to lead:trail */
(wchar_t)ch[1];
}
return( 2 ); /* return char size */
} else if( !_ismbblead(*ch) ) {
if( pwc != NULL ) {
*pwc = (wchar_t)ch[0]; /* convert to 00:byte */
}
return( 1 ); /* return char size */
} else {
return( -1 ); /* n==1, but char 2 bytes */
}
}

View File

@ -24,29 +24,38 @@
*
* ========================================================================
*
* Description: errno related CLIB internal declarations.
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#ifndef _SETERNO_H_INCLUDED
#define _SETERNO_H_INCLUDED
#include "variety.h"
#include <mbstring.h>
#include "farfunc.h"
// defined in _dos\c\dosret.c
_WCRTLINK extern int __set_errno_dos( unsigned int );
#if defined(__NT__)
_WCRTLINK extern int __set_errno_nt( void );
#endif
// defined in startup\c\seterrno.c
_WCRTLINK extern void __set_errno( unsigned int );
_WCRTLINK extern int __set_EINVAL( void );
_WCRTLINK extern void __set_EDOM( void );
_WCRTLINK extern void __set_ERANGE( void );
#if !defined(__UNIX__)
_WCRTLINK extern void __set_doserrno( unsigned int );
#endif
#endif
/****
***** Convert a wide character to a multibyte character.
****/
_WCRTLINK int _NEARFAR(wctomb,_fwctomb)( char _FFAR *ch, wchar_t wchar )
{
/*** Catch special cases ***/
if( ch == 0 ) return( 0 );
/*** Convert the character ***/
if( wchar & 0xFF00 )
{
ch[0] = (wchar&0xFF00) >> 8; /* store lead byte */
ch[1] = wchar & 0x00FF; /* store trail byte */
return( 2 ); /* return size in bytes */
}
else
{
ch[0] = wchar & 0x00FF; /* store char byte */
return( 1 ); /* return size in bytes */
}
}

View File

@ -0,0 +1,127 @@
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: WHEN YOU FIGURE OUT WHAT THIS FILE DOES, PLEASE
* DESCRIBE IT HERE!
*
****************************************************************************/
#include "variety.h"
#include "widechar.h"
#include <stdio.h>
#include <stdarg.h>
#include <limits.h>
#include "printf.h"
/*
* mem_putc -- append a character to a string in memory
*/
#ifdef __WIDECHAR__
struct vswprtf_buf {
CHAR_TYPE *bufptr;
int chars_output;
int max_chars;
};
static slib_callback_t mem_putc; // setup calling convention
static void __SLIB_CALLBACK mem_putc( SPECS __SLIB *specs, int op_char )
{
struct vswprtf_buf *info;
info = (struct vswprtf_buf*) specs->_dest;
if( info->chars_output + 1 <= info->max_chars ) {
*( info->bufptr++ ) = op_char;
specs->_output_count++;
info->chars_output++;
}
}
#else
static slib_callback_t mem_putc; // setup calling convention
static void __SLIB_CALLBACK mem_putc( SPECS __SLIB *specs, int op_char )
{
*( specs->_dest++ ) = op_char;
specs->_output_count++;
}
#endif
#ifdef __WIDECHAR__
_WCRTLINK int vswprintf( CHAR_TYPE *dest, size_t n, const CHAR_TYPE *format, va_list arg )
{
slib_callback_t *tmp;
auto struct vswprtf_buf info;
#if defined( __386__ ) && defined( __QNX__ )
/* avoid some segment relocations for 32-bit QNX */
tmp = (void (*)())mem_putc;
#else
tmp = mem_putc;
#endif
if( n != 0 ) {
info.bufptr = dest;
info.chars_output = 0;
info.max_chars = n - 1;
__wprtf( &info, format, arg, tmp );
dest[info.chars_output] = NULLCHAR;
}
return( info.chars_output );
}
#endif
_WCRTLINK int __F_NAME(vsprintf,_vswprintf) ( CHAR_TYPE *dest, const CHAR_TYPE *format, va_list arg )
{
slib_callback_t *tmp;
#ifndef __WIDECHAR__
register int len;
#else
auto struct vswprtf_buf info;
#endif
#if defined( __386__ ) && defined( __QNX__ )
/* avoid some segment relocations for 32-bit QNX */
tmp = (void (*)())mem_putc;
#else
tmp = mem_putc;
#endif
#ifdef __WIDECHAR__
info.bufptr = dest;
info.chars_output = 0;
info.max_chars = INT_MAX;
__wprtf( &info, format, arg, tmp );
dest[info.chars_output] = NULLCHAR;
return( info.chars_output );
#else
len = __prtf( dest, format, arg, tmp );
dest[len] = NULLCHAR;
return( len );
#endif
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,860 @@
40
targetIdent
0
MProject
1
MComponent
0
2
WString
3
LIB
3
WString
5
n_2sn
1
0
1
4
MCommand
0
5
MCommand
0
6
MItem
7
crt.lib
7
WString
3
LIB
8
WVList
0
9
WVList
1
10
ActionStates
11
WString
5
&Make
12
WVList
0
-1
1
1
0
13
WPickList
35
14
MItem
5
*.asm
15
WString
6
ASMOBJ
16
WVList
5
17
MVState
18
WString
4
WASM
19
WString
25
n????Include directories:
1
20
WString
80
$(%watcom)\h;$(%watcom)\h\nt; "E:\Kos\programs\develop\open watcom\trunk\clib\h"
0
21
MRState
22
WString
4
WASM
23
WString
21
?????Compiler default
1
0
24
MRState
25
WString
4
WASM
26
WString
37
?????In-line Pentium Pro instructions
1
1
27
MRState
28
WString
4
WASM
29
WString
21
?????Compiler default
1
0
30
MRState
31
WString
4
WASM
32
WString
29
?????In-line with coprocessor
1
1
33
WVList
0
-1
1
1
0
34
MItem
21
CLIB\CRT\_8087386.asm
35
WString
6
ASMOBJ
36
WVList
0
37
WVList
0
14
1
1
0
38
MItem
16
CLIB\CRT\chk.asm
39
WString
6
ASMOBJ
40
WVList
0
41
WVList
0
14
1
1
0
42
MItem
20
CLIB\CRT\crwd386.asm
43
WString
6
ASMOBJ
44
WVList
0
45
WVList
0
14
1
1
0
46
MItem
21
CLIB\CRT\cstrtwnt.asm
47
WString
6
ASMOBJ
48
WVList
0
49
WVList
0
14
1
1
0
50
MItem
21
CLIB\CRT\segdefns.asm
51
WString
6
ASMOBJ
52
WVList
0
53
WVList
0
14
1
1
0
54
MItem
21
CLIB\CRT\stjmp386.asm
55
WString
6
ASMOBJ
56
WVList
0
57
WVList
0
14
1
1
0
58
MItem
19
CLIB\CRT\stkwnt.asm
59
WString
6
ASMOBJ
60
WVList
0
61
WVList
0
14
1
1
0
62
MItem
3
*.c
63
WString
4
COBJ
64
WVList
9
65
MVState
66
WString
3
WCC
67
WString
25
n????Include directories:
1
68
WString
80
$(%watcom)\h;$(%watcom)\h\nt; "E:\Kos\programs\develop\open watcom\trunk\clib\h"
0
69
MRState
70
WString
3
WCC
71
WString
27
?????Default byte alignment
1
0
72
MRState
73
WString
3
WCC
74
WString
21
?????1 byte alignment
1
1
75
MRState
76
WString
3
WCC
77
WString
21
?????No optimizations
1
0
78
MRState
79
WString
3
WCC
80
WString
26
?????Fastest possible code
1
1
81
MCState
82
WString
3
WCC
83
WString
30
?????Call/return optimizations
1
1
84
MRState
85
WString
3
WCC
86
WString
21
?????Compiler default
1
0
87
MRState
88
WString
3
WCC
89
WString
21
?????Compiler default
1
0
90
MRState
91
WString
3
WCC
92
WString
37
?????In-line Pentium Pro instructions
1
1
93
WVList
0
-1
1
1
0
94
MItem
17
CLIB\CRT\8087cw.c
95
WString
4
COBJ
96
WVList
0
97
WVList
0
62
1
1
0
98
MItem
19
CLIB\CRT\_8087osi.c
99
WString
4
COBJ
100
WVList
0
101
WVList
0
62
1
1
0
102
MItem
18
CLIB\CRT\___argc.c
103
WString
4
COBJ
104
WVList
0
105
WVList
0
62
1
1
0
106
MItem
16
CLIB\CRT\_exit.c
107
WString
4
COBJ
108
WVList
0
109
WVList
0
62
1
1
0
110
MItem
16
CLIB\CRT\abort.c
111
WString
4
COBJ
112
WVList
0
113
WVList
0
62
1
1
0
114
MItem
16
CLIB\CRT\argcv.c
115
WString
4
COBJ
116
WVList
0
117
WVList
0
62
1
1
0
118
MItem
17
CLIB\CRT\atexit.c
119
WString
4
COBJ
120
WVList
0
121
WVList
0
62
1
1
0
122
MItem
18
CLIB\CRT\binmode.c
123
WString
4
COBJ
124
WVList
0
125
WVList
0
62
1
1
0
126
MItem
18
CLIB\CRT\chk8087.c
127
WString
4
COBJ
128
WVList
0
129
WVList
0
62
1
1
0
130
MItem
16
CLIB\CRT\cinit.c
131
WString
4
COBJ
132
WVList
0
133
WVList
0
62
1
1
0
134
MItem
18
CLIB\CRT\cmdname.c
135
WString
4
COBJ
136
WVList
0
137
WVList
0
62
1
1
0
138
MItem
18
CLIB\CRT\commode.c
139
WString
4
COBJ
140
WVList
0
141
WVList
0
62
1
1
0
142
MItem
17
CLIB\CRT\cvtbuf.c
143
WString
4
COBJ
144
WVList
0
145
WVList
0
62
1
1
0
146
MItem
16
CLIB\CRT\errno.c
147
WString
4
COBJ
148
WVList
0
149
WVList
0
62
1
1
0
150
MItem
19
CLIB\CRT\errnovar.c
151
WString
4
COBJ
152
WVList
0
153
WVList
0
62
1
1
0
154
MItem
15
CLIB\CRT\exit.c
155
WString
4
COBJ
156
WVList
0
157
WVList
0
62
1
1
0
158
MItem
18
CLIB\CRT\fltused.c
159
WString
4
COBJ
160
WVList
0
161
WVList
0
62
1
1
0
162
MItem
19
CLIB\CRT\fpexcept.c
163
WString
4
COBJ
164
WVList
0
165
WVList
0
62
1
1
0
166
MItem
19
CLIB\CRT\initargv.c
167
WString
4
COBJ
168
WVList
0
169
WVList
0
62
1
1
0
170
MItem
19
CLIB\CRT\initrtns.c
171
WString
4
COBJ
172
WVList
0
173
WVList
0
62
1
1
0
174
MItem
17
CLIB\CRT\ioexit.c
175
WString
4
COBJ
176
WVList
0
177
WVList
0
62
1
1
0
178
MItem
18
CLIB\CRT\ljmphdl.c
179
WString
4
COBJ
180
WVList
0
181
WVList
0
62
1
1
0
182
MItem
19
CLIB\CRT\main2wnt.c
183
WString
4
COBJ
184
WVList
0
185
WVList
0
62
1
1
0
186
MItem
19
CLIB\CRT\seterrno.c
187
WString
4
COBJ
188
WVList
0
189
WVList
0
62
1
1
0
190
MItem
19
CLIB\CRT\stackwnt.c
191
WString
4
COBJ
192
WVList
0
193
WVList
0
62
1
1
0
194
MItem
18
CLIB\CRT\xmsgwnt.c
195
WString
4
COBJ
196
WVList
0
197
WVList
0
62
1
1
0

View File

@ -14,7 +14,7 @@
</Platforms>
<ToolFiles>
<ToolFile
RelativePath="..\..\..\VStudio 8\Common7\IDE\fasm.rules"
RelativePath="..\fasm.rules"
/>
</ToolFiles>
<Configurations>

View File

@ -2,25 +2,38 @@ format MS COFF
include "proc32.inc"
section '.text' code readable executable
section '.text' align 16 code readable executable
public _InitHeap@4
public _UserAlloc@4
public _UserFree@4
public _GetNotify@4
public _CreateThread@8
public _GetMousePos@4
public _get_fileinfo@8
public _create_file@4
public _read_file@20
public _write_file@20
public _get_key@4
public _remap_key@4
public _get_button_id
public _GetScreenSize@8
public _DrawWindow@36
public _make_button@24
public _draw_bar@20
public _write_text@20
public _debug_out@4
public _debug_out_hex@4
public _create_thread@12
public _memset
;public _memset
struc FILEIO
{ .cmd dd ?
@ -32,6 +45,40 @@ struc FILEIO
.name dd ?
};
struc CTRL_INFO
{ .pci_cmd dd ?
.irq dd ?
.glob_cntrl dd ?
.glob_sta dd ?
.codec_io_base dd ?
.ctrl_io_base dd ?
.codec_mem_base dd ?
.ctrl_mem_base dd ?
.codec_id dd ?
}
CTRL_INFO_SIZE equ 9*4
align 4
_GetScreenSize@8:
.x equ esp+12
.y equ esp+16
push ebx
push ecx
mov eax, 14
int 0x40
mov ebx, [.y]
movzx ecx, ax
inc ecx
mov [ebx], ecx
mov ebx, [.x]
shr eax, 16
inc eax
mov [ebx], eax
pop ecx
pop ebx
ret 8
align 4
_create_thread@12:
.thr_proc equ esp+4
@ -74,7 +121,6 @@ restore .thr_proc
restore .param
restore .stack_size
align 4
proc _get_button_id
mov eax,17
@ -92,6 +138,7 @@ endp
align 4
proc _get_fileinfo@8 stdcall, name:dword, info:dword
push ebx
push ecx
push esi
push edi
xor eax, eax
@ -111,6 +158,28 @@ proc _get_fileinfo@8 stdcall, name:dword, info:dword
int 0x40
pop edi
pop esi
pop ecx
pop ebx
ret
endp
align 4
proc _create_file@4 stdcall, name:dword
push ebx
xor eax, eax
mov ebx, [name]
mov [fileio.cmd], 2
mov [fileio.offset], eax
mov [fileio.offset+4], eax
mov [fileio.count], eax
mov [fileio.buff], eax
mov byte [fileio.buff+4], al
mov [fileio.name], ebx
mov eax, 70
lea ebx, [fileio]
int 0x40
pop ebx
ret
endp
@ -121,6 +190,7 @@ proc _read_file@20 stdcall,name:dword, buff:dword, offset:dword,\
push ebx
push esi
push edi
push edx
xor eax, eax
mov ebx, [name]
mov edx, [offset]
@ -143,6 +213,44 @@ proc _read_file@20 stdcall,name:dword, buff:dword, offset:dword,\
jz @f
mov [esi], ebx
@@:
pop edx
pop edi
pop esi
pop ebx
ret
endp
align 4
proc _write_file@20 stdcall,name:dword, buff:dword, offset:dword,\
count:dword,writes:dword
push ebx
push esi
push edi
push edx
xor eax, eax
mov ebx, [name]
mov edx, [offset]
mov esi, [buff]
mov edi, [count]
mov [fileio.cmd], 3
mov [fileio.offset], edx
mov [fileio.offset+4], eax
mov [fileio.count], edi
mov [fileio.buff], esi
mov byte [fileio.buff+4], al
mov [fileio.name], ebx
mov eax, 70
lea ebx, [fileio]
int 0x40
mov esi, [writes]
test esi, esi
jz @f
mov [esi], ebx
@@:
pop edx
pop edi
pop esi
pop ebx
@ -165,39 +273,72 @@ proc _get_key@4 stdcall, key:dword
ret
endp
align 4
proc _InitHeap@4 stdcall, heap_size:dword
push ebx
mov eax, 68
mov ebx, 11
mov ecx, [heap_size]
int 0x40
pop ebx
ret
push ebx
push ecx
mov eax, 68
mov ebx, 11
mov ecx, [heap_size]
int 0x40
pop ecx
pop ebx
ret
endp
align 4
proc _UserAlloc@4 stdcall, alloc_size:dword
push ebx
mov eax, 68
mov ebx, 12
mov ecx, [alloc_size]
int 0x40
pop ebx
ret
push ebx
push ecx
mov eax, 68
mov ebx, 12
mov ecx, [alloc_size]
int 0x40
pop ecx
pop ebx
ret
endp
align 4
proc _UserFree@4 stdcall, pmem:dword
push ebx
push ecx
mov eax, 68
mov ebx, 13
mov ecx, [pmem]
int 0x40
pop ecx
pop ebx
ret
endp
align 4
proc _GetNotify@4 stdcall, p_ev:dword
push ebx
push ecx
mov eax, 68
mov ebx, 14
mov ecx, [p_ev]
int 0x40
pop ecx
pop ebx
ret
endp
align 4
proc _CreateThread@8 stdcall, fn:dword, p_stack:dword
push ebx
push ecx
push edx
mov eax, 51
mov ebx, 1
mov ecx, [fn]
mov edx,[p_stack]
int 0x40
pop ebx
ret
int 0x40
pop edx
pop ecx
pop ebx
ret
endp
align 4
@ -210,12 +351,16 @@ proc _GetMousePos@4 stdcall,rel_type:dword
ret
endp
align 4
proc _DrawWindow@36 stdcall, x:dword, y:dword, sx:dword, sy:dword,\
workcolor:dword, style:dword, captioncolor:dword,\
windowtype:dword, bordercolor:dword
push ebx edi esi
push ebx
push ecx
push edx
push edi
push esi
mov ebx, [x]
mov ecx, [y]
shl ebx, 16
@ -231,7 +376,11 @@ proc _DrawWindow@36 stdcall, x:dword, y:dword, sx:dword, sy:dword,\
mov edi,[bordercolor]
xor eax,eax
int 0x40
pop esi edi ebx
pop esi
pop edi
pop edx
pop ecx
pop ebx
ret
endp
@ -244,7 +393,9 @@ _make_button@24:
;arg5 - id
;arg6 - color
push ebx esi
push ebx
push ecx
push esi
mov ebx,[esp+12]
shl ebx,16
mov bx,[esp+20]
@ -255,7 +406,7 @@ _make_button@24:
mov esi,[esp+32]
mov eax,8
int 0x40
pop esi ebx
pop esi ecx ebx
ret 24
align 4
@ -265,7 +416,7 @@ _draw_bar@20:
;arg3 - xsize
;arg4 - ysize
;arg5 - color
push ebx
push ebx ecx
mov eax,13
mov ebx,[esp+8]
shl ebx,16
@ -275,7 +426,7 @@ _draw_bar@20:
mov cx,[esp+20]
mov edx,[esp+24]
int 0x40
pop ebx
pop ecx ebx
ret 20
_write_text@20:
@ -284,7 +435,7 @@ _write_text@20:
;arg3 - color
;arg4 - text
;arg5 - len
push ebx esi
push ebx ecx esi
mov eax,4
mov ebx,[esp+12]
shl ebx,16
@ -293,16 +444,18 @@ _write_text@20:
mov edx,[esp+24]
mov esi,[esp+28]
int 0x40
pop esi ebx
pop esi ecx ebx
ret 20
align 4
proc _debug_out@4 stdcall, val:dword
push ebx
push ecx
mov ecx,[val]
mov ebx,1
mov eax,63
int 0x40
pop ecx
pop ebx
ret
endp
@ -327,6 +480,15 @@ proc _debug_out_hex@4 stdcall val:dword
ret
endp
align 4
proc _remap_key@4 stdcall, key:dword
mov eax, [key]
and eax, 0x7F
movzx eax, byte [keymap+eax]
ret
endp
align 4
_memset:
mov edx,[esp + 0ch]
@ -393,16 +555,206 @@ toend:
ret
;public __allmul
__allmul:
mov eax, [esp+8]
mov ecx, [esp+16]
or ecx,eax
mov ecx, [esp+12]
jnz .hard
mov eax, [esp+4]
mul ecx
ret 16
.hard:
push ebx
mul ecx
mov ebx,eax
mov eax, [esp+8]
mul dword [esp+20]
add ebx,eax
mov eax,[esp+8]
mul ecx
add edx,ebx
pop ebx
ret 16
;public __allshr
align 4
__allshr:
cmp cl,64
jae .sign
cmp cl, 32
jae .MORE32
shrd eax,edx,cl
sar edx,cl
ret
.MORE32:
mov eax,edx
sar edx,31
and cl,31
sar eax,cl
ret
.sign:
sar edx,31
mov eax,edx
ret
;public _scalbn
align 4
proc _scalbn
fild dword [esp+12]
fld qword [esp+4]
fscale
fstp st1
ret
endp
;public __alloca_probe_8
;public __alloca_probe_16
__alloca_probe_16: ; 16 byte aligned alloca
push ecx
lea ecx, [esp + 8] ; TOS before entering this function
sub ecx, eax ; New TOS
and ecx, (16 - 1) ; Distance from 16 bit align (align down)
add eax, ecx ; Increase allocation size
sbb ecx, ecx ; ecx = 0xFFFFFFFF if size wrapped around
or eax, ecx ; cap allocation size on wraparound
pop ecx ; Restore ecx
jmp __chkstk
alloca_8: ; 8 byte aligned alloca
__alloca_probe_8:
push ecx
lea ecx, [esp+8] ; TOS before entering this function
sub ecx, eax ; New TOS
and ecx, (8 - 1) ; Distance from 8 bit align (align down)
add eax, ecx ; Increase allocation Size
sbb ecx, ecx ; ecx = 0xFFFFFFFF if size wrapped around
or eax, ecx ; cap allocation size on wraparound
pop ecx ; Restore ecx
jmp __chkstk
;public __chkstk
;public _alloca_probe
align 4
;_alloca_probe:
__chkstk:
push ecx
lea ecx, [esp+8-4] ; TOS before entering function + size for ret value
sub ecx, eax ; new TOS
; Handle allocation size that results in wraparound.
; Wraparound will result in StackOverflow exception.
sbb eax, eax ; 0 if CF==0, ~0 if CF==1
not eax ; ~0 if TOS did not wrapped around, 0 otherwise
and ecx, eax ; set to 0 if wraparound
mov eax, esp ; current TOS
and eax, -4096 ; Round down to current page boundary
cs10:
cmp ecx, eax ; Is new TOS
jb short cs20 ; in probed page?
mov eax, ecx ; yes.
pop ecx
xchg esp, eax ; update esp
mov eax, [eax] ; get return address
mov [esp], eax ; and put it at new TOS
ret
; Find next lower page and probe
cs20:
sub eax, 4096 ; decrease by PAGESIZE
test [eax],eax ; probe page.
jmp short cs10
public __ftol2_sse
align 4
__ftol2_sse:
push ebp
mov ebp, esp
sub esp, 20
and esp, 0xFFFFFFF0
fld st0
fst dword [esp+18]
fistp qword [esp+10]
fild qword [esp+10]
mov edx, [esp+18]
mov eax, [esp+10]
test eax, eax
jz .QnaNZ
.not_QnaNZ:
fsubp st1, st0
test edx, edx
jns .pos
fstp dword [esp]
mov ecx, [esp]
xor ecx, 0x80000000
add ecx, 0x7FFFFFFF
adc eax, 0
mov edx, [esp+14]
adc edx, 0
jmp .exit
.pos:
fstp dword [esp]
mov ecx, [esp]
add ecx, 0x7FFFFFFF
sbb eax, 0
jmp .exit
.QnaNZ:
mov edx, [esp+14]
test edx, 0x7FFFFFFF
jne .not_QnaNZ
fstp dword [esp+18]
fstp dword [esp+18]
.exit:
leave
ret
section '.data' align 16 data readable writable
align 16
__hexdigits db '0123456789ABCDEF'
; 0 1 2 3 4 5 6 7
; 8 9 a b c d e f
keymap:
db 0, 27, '1', '2', '3', '4', '5', '6' ;00
db '7', '8', '9', '0', '-', '=',0x7F, 0x9 ;08
db 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i' ;10
db 'o', 'p', '[', ']', 13,0x9D, 'a', 's' ;18
db 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';' ;20
db 0, '~',0xB6, '|',0x7A,0x87, 'c', 'v' ;28
db 'b', 'n', 'm', ',', '.', '/',0xB6, '*' ;30
db 0xB8, ' ', 0,0xBB,0xBC,0xBD,0xBE,0xBF ;38
db 0xC0,0xC1,0xC2,0xC3,0xC4, 0, 0, 0 ;40
db 0xAD, 0, 0,0xAC, 0,0xAE, 0, 0 ;48
db 0xAF, 0, 0, 0, 0, 0, 0, 0 ;50
db 0, 0, 0, 0, 0, 0, 0, 0 ;58
db 0, 0, 0, 0, 0, 0, 0, 0 ;60
db 0, 0, 0, 0, 0, 0, 0, 0 ;68
db 0, 0, 0, 0, 0, 0, 0, 0 ;70
db 0, 0, 0, 0, 0, 0, 0, 0 ;78
public ___sse2_available
___sse2_available dd 0
public __fltused
__fltused dd 0
align 4
__hexdigits db '0123456789ABCDEF'
align 4
fileio FILEIO

View File

@ -14,7 +14,7 @@
</Platforms>
<ToolFiles>
<ToolFile
RelativePath="..\..\..\VStudio 8\Common7\IDE\fasm.rules"
RelativePath="..\fasm.rules"
/>
</ToolFiles>
<Configurations>