/* $Header:crt0.c 12.0$ */
/* $ACIS:crt0.c 12.0$ */
/* $Source: /ibm/acis/usr/src/lib/libc/ca/csu/RCS/crt0.c,v $ */

#ifndef lint
static char *rcsid = "$Header:crt0.c 12.0$";
#endif

/*
 *      C start up routine.
 *      Robert Henry, UCB, 20 Oct 81
 *      J.Christensen IBM, 10 Jan 84 adapted to Workstation Unix
 *
 *      We make the following (true) assumptions:
 *
 *      1) The only register variable that we can trust is sp,
 *      which points to the base of the kernel calling frame.
 */

char **environ = (char **)0;
int  errno;
extern	unsigned char	etext;
 
start( kf ) 
/********
/* NOTE: Change "_start" to "start" in the assembler output ! */
/*       even worse we modify trace table values also!        */
        struct {
                int     kargc;
                char    *kargv[1];      /* size depends on kargc */
                char    kargstr[1];     /* size varies */
                char    kenvstr[1];     /* size varies */
        } kf;
{
	register int r11;	/* for init - not used otherwise - WEW */
	int *ip;

        environ = &kf.kargv[kf.kargc+1];
#ifdef MCRT0
	monstartup( *(ip = (int *)start), &etext);
#endif MCRT0
        exit( main( kf.kargc, kf.kargv, environ ));
}

#ifdef MCRT0
/*ARGSUSED*/
exit(code)
	register int code;	/* r11 */
{
	monitor(0);
	_cleanup();
	_exit(code);
}
#endif MCRT0

#ifdef CRT0
/*
 * null mcount and moncontrol,
 * just in case some routine is compiled for profiling
 */
moncontrol(val)
	int val;
{

}
mcount (cntp,selfpc)
	long **cntp;
	int *selfpc;
{
}
#endif CRT0
