home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / unixlib36d / UnixLib36d / clib / sys / h / syslib < prev    next >
Encoding:
Text File  |  1994-03-01  |  4.8 KB  |  161 lines

  1. /* sys/syslib.h (c) Copyright 1990 H.Rogers */
  2.  
  3. #ifndef __SYS_SYSLIB_H
  4. #define __SYS_SYSLIB_H
  5.  
  6. #ifndef __SYS_OS_H
  7. #include <sys/os.h>
  8. #endif
  9.  
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13.  
  14. extern void __main(void);    /* assembler initialization */
  15. extern void _main(void);    /* C initialization */
  16.  
  17. extern void _exit(int);     /* C exit */
  18. extern void __exit(int);    /* assembler exit */
  19.  
  20.  
  21. #define STAKSIZ 2048
  22.  
  23. /* __break is initialised to __lomem & __stack to __himem - STAKSIZ;
  24.  * __stack is extended downwards in 512 byte chunks by x$stack_overflow()
  25.  * and __break is extended upwards by brk() and sbrk(). The sl
  26.  * register is kept equal to __stack + 256. Should x$stack_overflow()
  27.  * attempt to extend __stack below __break then SIGEMT is raised.
  28.  * Should brk() or sbrk() be asked to extend __break above __stack
  29.  * then they return with ENOMEM. */
  30.  
  31. extern char *__cli;        /* command line from OS_GetEnv */
  32.  
  33. extern void __svccli(char *);    /* strcpy __cli in SVC mode */
  34.  
  35. extern void *__base;        /* BASE = Image$$RO$$Base */
  36. extern void *__lomem;        /* LOMEM = Image$$RW$$Limit */
  37. extern void *__himem;        /* HIMEM from OS_GetEnv */
  38.  
  39. extern void *__break;        /* end of data area */
  40. extern void *__stack;        /* bottom of stack */
  41.  
  42. extern unsigned int __time[2];    /* start time */
  43.  
  44. extern int __riscos_ver;    /* What version of RISC-OS is running - this is used internally */
  45. #define __OS_ARTHUR    0xA0
  46. #define __OS_RISCOS_200    0xA1
  47. #define __OS_RISCOS_201    0xA2
  48. #define __OS_RISCOS_300    0xA3
  49. #define __OS_RISCOS_310    0xA4
  50.  
  51. /* setjmp() and longjmp() modify their behaviour according to __fpflag */
  52.  
  53. extern void __fpinit(void);    /* check FP presence & set/clear FP flag */
  54.  
  55. extern int __fpflag;        /* FP flag */
  56.  
  57. extern void __fptest(void);    /* perform FP test */
  58. extern void __fpclr(int);    /* FP test SIGILL handler */
  59.  
  60.  
  61. /* OS_ChangeEnvironment is used to set up exception handlers. These
  62.  * handlers use OS_CallBack to raise signals in the foreground process.
  63.  * RTFM (RiscOS PRM - 'The Program Environment') for more info. */
  64.  
  65. /* __reset() performs all the functions of exit(), but returns without
  66.  * exiting - note that after a call to __reset() all handlers are
  67.  * in their original state, and *all* stdio & UNIX I/O has been shut down.
  68.  * You should use __exit() to exit after __reset(). */
  69.  
  70. extern void __reset(void);    /* reset handlers, etc. back to orig. state */
  71.  
  72.  
  73. /* struct handler contains all the information about an
  74.  * OS_ChangeEnvironment handler */
  75.  
  76. struct handler
  77.   {
  78.   void            (*h)(void);    /* address of handler (0 = default) */
  79.   unsigned int        r;        /* r12/0 handler arg. (0 = default) */
  80.   void            *b;        /* buffer pointer (0 = default) */
  81.   };
  82.  
  83. /* struct env contains all the info. needed to restore
  84.  * the RiscOS environment prior to a call to OS_Exit */
  85.  
  86. struct env
  87.   {
  88.   struct handler    h[13];        /* handlers 0-12 */
  89.   };
  90.  
  91. extern struct env __Cenv[1];        /* this C environment */
  92. extern struct env __Oenv[1];        /* the old (calling) environment */
  93.  
  94. extern os_error *__rdenv(int,struct handler *); /* OS_ChangeEnvironment */
  95. extern os_error *__wrenv(int,struct handler *); /* OS_ChangeEnvironment */
  96.  
  97. /* The asterisked handlers do nothing; the others raise signals. */
  98.  
  99. extern void __h_sigill(void);    /*   undefined instruction handler */
  100. extern void __h_sigbus(void);    /*   address exception handler */
  101. extern void __h_sigsegv0(void); /*   prefetch abort handler */
  102. extern void __h_sigsegv1(void); /*   data abort handler */
  103.  
  104. extern void __h_sigfpe(void);    /*   FPE handler */
  105.  
  106. extern void __h_error(void);    /*   error handler */
  107. extern void __h_sigint(void);    /*   escape handler */
  108. extern void __h_event(void);    /* * event handler */
  109.  
  110. extern void __h_sigsys(void);    /* * unused SWI handler */
  111.  
  112. extern void __h_sigalrm(void);    /*   SIGALRM handler */
  113.  
  114. extern void __h_cback(void);    /*   CallBack handler */
  115.  
  116.  
  117. extern void __h_exit(void);    /*   exit handler - calls _exit() */
  118.  
  119.  
  120. extern unsigned int __cbreg[16];    /* callback handler register buffer */
  121.  
  122. extern char *__h_errbuf;        /* error handler string buffer */
  123.  
  124.  
  125. /* vfork() & exec() */
  126.  
  127. extern int vfork(void);     /* fork to child - calls __vfork() */
  128. extern void __vret(int);    /* return from child - calls __vexit() */
  129.  
  130. extern int *__vfork(void);    /* fork to child context */
  131. extern int *__vexit(int);    /* restore to parent context */
  132.  
  133. /* execve() execs a RiscOS command - calls __exec() */
  134.  
  135. extern int execve(char *,char **,char **);
  136.  
  137. extern void __exret(void);    /* return from __exec() - calls __vret() */
  138.  
  139. extern void (*__exptr)(char *); /* pointer to __exec() routine */
  140. extern int __exlen;        /* length of __exec() routine */
  141. extern os_error *__exerr;
  142. extern int __exshift;        /* __exec() shift */
  143.  
  144. /* vfork weak link */
  145.  
  146. extern void (*___vret)(int);
  147.  
  148. /* stdio weak links */
  149.  
  150. extern void (*___stdioinit)(void);
  151. extern void (*___stdioexit)(void);
  152.  
  153. /* C++ global constructor weak link */
  154. extern void (*___do_global_ctors)(void);
  155.  
  156. #ifdef __cplusplus
  157.     }
  158. #endif
  159.  
  160. #endif
  161.