+int errno;
+static char empty[1];
+char *__progname = empty;
+#endif
+
+/*
+ * We need these system calls, but can't use library stubs
+ */
+#define _exit(v) __syscall(SYS_exit, (v))
+#define open(name, f, m) __syscall(SYS_open, (name), (f), (m))
+#define close(fd) __syscall(SYS_close, (fd))
+#define read(fd, s, n) __syscall(SYS_read, (fd), (s), (n))
+#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n))
+#define dup(fd) __syscall(SYS_dup, (fd))
+#define dup2(fd, fdnew) __syscall(SYS_dup2, (fd), (fdnew))
+#ifdef sun
+#define mmap(addr, len, prot, flags, fd, off) \
+ __syscall(SYS_mmap, (addr), (len), (prot), _MAP_NEW|(flags), (fd), (off))
+#else
+#define mmap(addr, len, prot, flags, fd, off) \
+ __syscall(SYS_mmap, (addr), (len), (prot), (flags), (fd), (off))
+#endif
+
+#define _FATAL(str) \
+ write(2, str, sizeof(str)), \
+ _exit(1);
+
+
+#ifdef sparc
+asm (" .global start");
+asm (" .text");
+asm (" start:");
+
+/* Set up `argc', `argv', and `envp' into local registers (from GNU Emacs). */
+asm (" mov 0, %fp");
+asm (" ld [%sp + 64], %l0"); /* argc */
+asm (" add %sp, 68, %l1"); /* argv */
+asm (" sll %l0, 2, %l2"); /**/
+asm (" add %l2, 4, %l2"); /* envp = argv + (argc << 2) + 4 */
+asm (" add %l1, %l2, %l2"); /**/
+asm (" sethi %hi(_environ), %l3");
+asm (" st %l2, [%l3+%lo(_environ)]"); /* *environ = l2 */
+
+/* Finish diddling with stack. */
+asm (" andn %sp, 7, %sp");
+asm (" sub %sp, 24, %sp");
+
+#ifdef DYNAMIC
+/* Resolve symbols in dynamic libraries */
+asm (" call ___do_dynamic_link");
+asm (" nop");
+#endif
+
+/* From here, all symbols should have been resolved, so we can use libc */
+#ifdef MCRT0
+asm (" call ___do_mcrt");
+asm (" nop");
+#endif
+
+/* Stay Sun compatible (currently (SunOS 4.1.2) does nothing on sun4) */
+asm (" call start_float");
+asm (" nop");
+
+/* Move `argc', `argv', and `envp' from locals to parameters for `main'. */
+asm (" mov %l0,%o0");
+asm (" mov %l1,%o1");
+asm ("__callmain:"); /* Defined for the benefit of debuggers */
+asm (" call _main");
+asm (" mov %l2,%o2");
+
+asm (" call _exit");
+asm (" nop");
+
+#ifdef MCRT0
+static void
+__do_mcrt ()
+{
+ extern unsigned char eprol, etext;
+ extern void _mcleanup();
+
+ on_exit(_mcleanup, 0);
+ monstartup(&eprol, &etext);
+ return;
+}
+#endif
+
+#endif /* sparc */
+
+
+#ifdef i386