home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixlib36d
/
src
/
sys
/
c
/
syslib
< prev
next >
Wrap
Text File
|
1994-03-08
|
3KB
|
147 lines
static char sccs_id[] = "@(#) syslib.c 4.2 " __DATE__ " HJR";
/* syslib.c (c) Copyright 1990 H.Rogers */
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include "sys/syslib.h"
#include "sys/os.h"
#include "sys/unix.h"
struct env __Cenv[1] =
{
{
{
{0, 0, 0}, /* MemoryLimit */
{__h_sigill, 0, 0}, /* Undefined Inst. */
{__h_sigsegv0, 0, 0}, /* Prefetch Abort */
{__h_sigsegv1, 0, 0}, /* Data Abort */
{__h_sigbus, 0, 0}, /* Address Exception */
{0, 0, 0}, /* Other Exception */
{__h_error, 0, 0}, /* Error */
{__h_cback, 0, (void *) __cbreg}, /* CallBack */
{0, 0, 0}, /* BreakPoint */
{__h_sigint, 0, 0}, /* Escape */
{__h_event, 0, 0}, /* Event */
{__h_exit, 0, 0}, /* Exit */
{0 /* __h_sigsys */ , 0, 0} /* Unknown SWI */
}
}
};
struct env __Oenv[1];
struct proc *__u;
int __riscos_ver;
extern int main (int, char **);
void
_main (void)
{
register struct env *e;
register int i;
int regs[3];
e = __Oenv;
for (i = 0; i < 13; i++)
__rdenv (i, e->h + i);
__h_errbuf = (char *) e->h[6].b;
__sigrec = 0;
for (i = 0; i < 20; i++)
__sigvec[i] = __sigdfl[i]; /*signal handlers */
e = __Cenv;
for (i = 0; i < 13; i++)
__wrenv (i, e->h + i);
/* handlers installed */
__fpinit (); /* flag FP presence */
__allocinit (); /* initialise malloc() & c. */
__unixinit (); /* initialise UNIX */
if (___stdioinit)
(*___stdioinit) (); /* initialise stdin,stdout & stderr */
if (___do_global_ctors)
(*___do_global_ctors) (); /* if C++ call constructors */
/* bits for __uname() */
if (__uname_dont_pack_ptr)
__uname_dont_pack__ = *__uname_dont_pack_ptr;
/* find out what version of RISC-OS is running */
os_byte (129, 0, 0xFF, regs);
__riscos_ver = regs[1];
exit (main (__u->argc, __u->argv)); /* ... ignition */
/* not reached */
}
void (*__ax[__MAX_AXCNT]) (void);
int __axcnt = 0;
void
exit (int r)
{
register int i;
i = __axcnt;
while (i)
(*__ax[--i]) ();
if (___stdioexit)
(*___stdioexit) (); /* close streams & delete tmpfile() */
_exit (r);
}
void
__reset (void)
{
register int i;
register struct env *e;
if (__u)
__unixexit (); /* shutdown UNIX (close all fds etc.) */
e = __Oenv;
for (i = 0; i < 13; i++)
__wrenv (i, e->h + i);
}
void
_exit (register int r)
{
if (__u)
alarm (0);
if (!__u || !(__u->flag & __U_PPROC) || !___vret)
{
__reset ();
__exit (r); /* OS_Exit with return value <r> */
}
else
(*___vret) (r);
}
void
__fpinit (void)
{
__fpflag = -1;
signal (SIGILL, __fpclr);
__fptest ();
signal (SIGILL, SIG_DFL);
}