home *** CD-ROM | disk | FTP | other *** search
- /* sys/syslib.h (c) Copyright 1990 H.Rogers */
-
- #ifndef __SYS_SYSLIB_H
- #define __SYS_SYSLIB_H
-
- #ifndef __SYS_OS_H
- #include <sys/os.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- extern void __main(void); /* assembler initialization */
- extern void _main(void); /* C initialization */
-
- extern void _exit(int); /* C exit */
- extern void __exit(int); /* assembler exit */
-
-
- #define STAKSIZ 2048
-
- /* __break is initialised to __lomem & __stack to __himem - STAKSIZ;
- * __stack is extended downwards in 512 byte chunks by x$stack_overflow()
- * and __break is extended upwards by brk() and sbrk(). The sl
- * register is kept equal to __stack + 256. Should x$stack_overflow()
- * attempt to extend __stack below __break then SIGEMT is raised.
- * Should brk() or sbrk() be asked to extend __break above __stack
- * then they return with ENOMEM. */
-
- extern char *__cli; /* command line from OS_GetEnv */
-
- extern void __svccli(char *); /* strcpy __cli in SVC mode */
-
- extern void *__base; /* BASE = Image$$RO$$Base */
- extern void *__lomem; /* LOMEM = Image$$RW$$Limit */
- extern void *__himem; /* HIMEM from OS_GetEnv */
-
- extern void *__break; /* end of data area */
- extern void *__stack; /* bottom of stack */
-
- extern unsigned int __time[2]; /* start time */
-
- extern int __riscos_ver; /* What version of RISC-OS is running - this is used internally */
- #define __OS_ARTHUR 0xA0
- #define __OS_RISCOS_200 0xA1
- #define __OS_RISCOS_201 0xA2
- #define __OS_RISCOS_300 0xA3
- #define __OS_RISCOS_310 0xA4
-
- /* setjmp() and longjmp() modify their behaviour according to __fpflag */
-
- extern void __fpinit(void); /* check FP presence & set/clear FP flag */
-
- extern int __fpflag; /* FP flag */
-
- extern void __fptest(void); /* perform FP test */
- extern void __fpclr(int); /* FP test SIGILL handler */
-
-
- /* OS_ChangeEnvironment is used to set up exception handlers. These
- * handlers use OS_CallBack to raise signals in the foreground process.
- * RTFM (RiscOS PRM - 'The Program Environment') for more info. */
-
- /* __reset() performs all the functions of exit(), but returns without
- * exiting - note that after a call to __reset() all handlers are
- * in their original state, and *all* stdio & UNIX I/O has been shut down.
- * You should use __exit() to exit after __reset(). */
-
- extern void __reset(void); /* reset handlers, etc. back to orig. state */
-
-
- /* struct handler contains all the information about an
- * OS_ChangeEnvironment handler */
-
- struct handler
- {
- void (*h)(void); /* address of handler (0 = default) */
- unsigned int r; /* r12/0 handler arg. (0 = default) */
- void *b; /* buffer pointer (0 = default) */
- };
-
- /* struct env contains all the info. needed to restore
- * the RiscOS environment prior to a call to OS_Exit */
-
- struct env
- {
- struct handler h[13]; /* handlers 0-12 */
- };
-
- extern struct env __Cenv[1]; /* this C environment */
- extern struct env __Oenv[1]; /* the old (calling) environment */
-
- extern os_error *__rdenv(int,struct handler *); /* OS_ChangeEnvironment */
- extern os_error *__wrenv(int,struct handler *); /* OS_ChangeEnvironment */
-
- /* The asterisked handlers do nothing; the others raise signals. */
-
- extern void __h_sigill(void); /* undefined instruction handler */
- extern void __h_sigbus(void); /* address exception handler */
- extern void __h_sigsegv0(void); /* prefetch abort handler */
- extern void __h_sigsegv1(void); /* data abort handler */
-
- extern void __h_sigfpe(void); /* FPE handler */
-
- extern void __h_error(void); /* error handler */
- extern void __h_sigint(void); /* escape handler */
- extern void __h_event(void); /* * event handler */
-
- extern void __h_sigsys(void); /* * unused SWI handler */
-
- extern void __h_sigalrm(void); /* SIGALRM handler */
-
- extern void __h_cback(void); /* CallBack handler */
-
-
- extern void __h_exit(void); /* exit handler - calls _exit() */
-
-
- extern unsigned int __cbreg[16]; /* callback handler register buffer */
-
- extern char *__h_errbuf; /* error handler string buffer */
-
-
- /* vfork() & exec() */
-
- extern int vfork(void); /* fork to child - calls __vfork() */
- extern void __vret(int); /* return from child - calls __vexit() */
-
- extern int *__vfork(void); /* fork to child context */
- extern int *__vexit(int); /* restore to parent context */
-
- /* execve() execs a RiscOS command - calls __exec() */
-
- extern int execve(char *,char **,char **);
-
- extern void __exret(void); /* return from __exec() - calls __vret() */
-
- extern void (*__exptr)(char *); /* pointer to __exec() routine */
- extern int __exlen; /* length of __exec() routine */
- extern os_error *__exerr;
- extern int __exshift; /* __exec() shift */
-
- /* vfork weak link */
-
- extern void (*___vret)(int);
-
- /* stdio weak links */
-
- extern void (*___stdioinit)(void);
- extern void (*___stdioexit)(void);
-
- /* C++ global constructor weak link */
- extern void (*___do_global_ctors)(void);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-