BSD 4_3_Net_2 release
[unix-history] / usr / src / lib / csu.hp300 / crt0.c
index 6915453..db0bf65 100644 (file)
@@ -1,12 +1,39 @@
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)crt0.c     5.3 (Berkeley) 3/9/86";
-#endif LIBC_SCCS and not lint
+#ifndef lint
+static char sccsid[] = "@(#)crt0.c     5.6 (Berkeley) 7/3/91";
+#endif /* not lint */
 
 /*
  *     C start up routine.
 
 /*
  *     C start up routine.
@@ -31,15 +58,12 @@ static char sccsid[] = "@(#)crt0.c  5.3 (Berkeley) 3/9/86";
 char **environ = (char **)0;
 static int fd;
 
 char **environ = (char **)0;
 static int fd;
 
-asm("#define _start start");
-asm("#define _eprol eprol");
+extern unsigned char   etext;
+extern unsigned char   eprol asm ("eprol");
+extern                 start() asm("start");
 
 
-#ifdef hp300
-asm("#define link .long 0; linkw");    /* Yuk!! */
-#endif
+asm(".text; orb #0,d0");       /* 32 bits of zero at location 0 */
 
 
-extern unsigned char   etext;
-extern unsigned char   eprol;
 start()
 {
        struct kframe {
 start()
 {
        struct kframe {
@@ -51,22 +75,17 @@ start()
        /*
         *      ALL REGISTER VARIABLES!!!
         */
        /*
         *      ALL REGISTER VARIABLES!!!
         */
-       register int d7;                /* needed for init (this will be
-                                          a problem with GCC) */
-       register struct kframe *kfp;    /* PCC a5 */
+       register struct kframe *kfp;    /* r10 */
        register char **targv;
        register char **argv;
        extern int errno;
        register char **targv;
        register char **argv;
        extern int errno;
+       extern void _mcleanup();
 
 #ifdef lint
        kfp = 0;
        initcode = initcode = 0;
 #else not lint
 
 #ifdef lint
        kfp = 0;
        initcode = initcode = 0;
 #else not lint
-#ifdef __GNUC__
        asm("lea a6@(4),%0" : "=r" (kfp));      /* catch it quick */
        asm("lea a6@(4),%0" : "=r" (kfp));      /* catch it quick */
-#else
-       asm("   lea     a6@(4),a5");    /* catch it quick */
-#endif
 #endif not lint
        for (argv = targv = &kfp->kargv[0]; *targv++; /* void */)
                /* void */ ;
 #endif not lint
        for (argv = targv = &kfp->kargv[0]; *targv++; /* void */)
                /* void */ ;
@@ -91,32 +110,12 @@ asm("eprol:");
 #endif paranoid
 
 #ifdef MCRT0
 #endif paranoid
 
 #ifdef MCRT0
+       atexit(_mcleanup);
        monstartup(&eprol, &etext);
 #endif MCRT0
        errno = 0;
        exit(main(kfp->kargc, argv, environ));
 }
        monstartup(&eprol, &etext);
 #endif MCRT0
        errno = 0;
        exit(main(kfp->kargc, argv, environ));
 }
-asm("#undef link");
-asm("#undef _start");
-asm("#undef _eprol");
-
-#ifdef MCRT0
-/*ARGSUSED*/
-exit(code)
-       register int code;      /* PCC d7 */
-{
-       monitor(0);
-       _cleanup();
-#ifdef __GNUC__
-       asm("movl %1,sp@-" : "=m" (*(char *)0) : "r" (code));
-#else
-       asm("   movl d7,sp@-");
-#endif
-       asm("   subql #4,sp");
-       asm("   movl #1,d0");
-       asm("   trap #0");
-}
-#endif MCRT0
 
 #ifdef CRT0
 /*
 
 #ifdef CRT0
 /*
@@ -128,6 +127,6 @@ moncontrol(val)
 {
 
 }
 {
 
 }
-asm("  .globl  mcount");
-asm("mcount:   rts");
+asm(".globl mcount");
+asm("mcount: rts");
 #endif CRT0
 #endif CRT0