/*
 *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 *%       Copyright (C) 1986,1991 by WATCOM Systems Inc. All rights %
 *%       reserved. No part of this software may be reproduced      %
 *%       in any form or by any means - graphic, electronic or      %
 *%       mechanical, including photocopying, recording, taping     %
 *%       or information storage and retrieval systems - except     %
 *%       with the written permission of WATCOM Systems Inc.        %
 *%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  Modified:     By:             Reason:
  ---------     ---             -------
  22-nov-86     F.W.Crigger     Initial implementation
  19-nov-92	F.W.Crigger	__CommonInit() and _init_files moved to cinit
--------------------------------------------------------Version-11.0---------
  22-feb-95	Greg Bentz	alpha support
  13-sep-95	T. Schiller	Removed broken stack checking fix for NT.
  15-sep-95	Greg Bentz	ppc support
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

extern	void	__CommonInit( void );
#if !defined(__OSI__)
extern	unsigned	__ASTACKSIZ;	/* alternate stack size */
extern	char		*__ASTACKPTR;	/* alternate stack pointer */
#if defined(_M_IX86)
 #pragma	aux	__ASTACKPTR "*"
 #pragma	aux	__ASTACKSIZ "*"
#endif
#endif

#ifdef __WIDECHAR__
    _WCRTLINK extern    int	     ___wArgc;	/* argument count */
    _WCRTLINK extern    wchar_t    **___wArgv;	/* argument vector */
    extern	int	wmain( int, wchar_t ** );
    #if defined(_M_IX86)
	#pragma aux     __wCMain  "*";
    #endif
    void __wCMain()
    {
	#if !defined(__OSI__)
	    /* allocate alternate stack for F77 */
	    __ASTACKPTR = (char *)alloca( __ASTACKSIZ ) + __ASTACKSIZ;
	#endif
	__CommonInit();
	exit( wmain( ___wArgc, ___wArgv ) );
    }
#else
    _WCRTLINK extern    int	  ___Argc;	/* argument count */
    _WCRTLINK extern    char    **___Argv;	/* argument vector */
    extern	int	main( int, char ** );
    #if defined(_M_IX86)
	#pragma aux     __CMain  "*";
    #endif
    void __CMain()
    {
	#if !defined(__OSI__)
	    /* allocate alternate stack for F77 */
	    __ASTACKPTR = (char *)alloca( __ASTACKSIZ ) + __ASTACKSIZ;
	#endif
	__CommonInit();
	exit( main( ___Argc, ___Argv ) );
    }
#endif
