home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / g / gcc / !GCC / UnixLib / sys / h / syslib < prev    next >
Encoding:
Text File  |  1993-09-01  |  4.5 KB  |  155 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.  
  45. /* setjmp() and longjmp() modify their behaviour according to __fpflag */
  46.  
  47. extern void __fpinit(void);    /* check FP presence & set/clear FP flag */
  48.  
  49. extern int __fpflag;        /* FP flag */
  50.  
  51. extern void __fptest(void);    /* perform FP test */
  52. extern void __fpclr(int);    /* FP test SIGILL handler */
  53.  
  54.  
  55. /* OS_ChangeEnvironment is used to set up exception handlers. These
  56.  * handlers use OS_CallBack to raise signals in the foreground process.
  57.  * RTFM (RiscOS PRM - 'The Program Environment') for more info. */
  58.  
  59. /* __reset() performs all the functions of exit(), but returns without
  60.  * exiting - note that after a call to __reset() all handlers are
  61.  * in their original state, and *all* stdio & UNIX I/O has been shut down.
  62.  * You should use __exit() to exit after __reset(). */
  63.  
  64. extern void __reset(void);    /* reset handlers, etc. back to orig. state */
  65.  
  66.  
  67. /* struct handler contains all the information about an
  68.  * OS_ChangeEnvironment handler */
  69.  
  70. struct handler
  71.   {
  72.   void            (*h)(void);    /* address of handler (0 = default) */
  73.   unsigned int        r;        /* r12/0 handler arg. (0 = default) */
  74.   void            *b;        /* buffer pointer (0 = default) */
  75.   };
  76.  
  77. /* struct env contains all the info. needed to restore
  78.  * the RiscOS environment prior to a call to OS_Exit */
  79.  
  80. struct env
  81.   {
  82.   struct handler    h[13];        /* handlers 0-12 */
  83.   };
  84.  
  85. extern struct env __Cenv[1];        /* this C environment */
  86. extern struct env __Oenv[1];        /* the old (calling) environment */
  87.  
  88. extern os_error *__rdenv(int,struct handler *); /* OS_ChangeEnvironment */
  89. extern os_error *__wrenv(int,struct handler *); /* OS_ChangeEnvironment */
  90.  
  91. /* The asterisked handlers do nothing; the others raise signals. */
  92.  
  93. extern void __h_sigill(void);    /*   undefined instruction handler */
  94. extern void __h_sigbus(void);    /*   address exception handler */
  95. extern void __h_sigsegv0(void); /*   prefetch abort handler */
  96. extern void __h_sigsegv1(void); /*   data abort handler */
  97.  
  98. extern void __h_sigfpe(void);    /*   FPE handler */
  99.  
  100. extern void __h_error(void);    /*   error handler */
  101. extern void __h_sigint(void);    /*   escape handler */
  102. extern void __h_event(void);    /* * event handler */
  103.  
  104. extern void __h_sigsys(void);    /* * unused SWI handler */
  105.  
  106. extern void __h_sigalrm(void);    /*   SIGALRM handler */
  107.  
  108. extern void __h_cback(void);    /*   CallBack handler */
  109.  
  110.  
  111. extern void __h_exit(void);    /*   exit handler - calls _exit() */
  112.  
  113.  
  114. extern unsigned int __cbreg[16];    /* callback handler register buffer */
  115.  
  116. extern char *__h_errbuf;        /* error handler string buffer */
  117.  
  118.  
  119. /* vfork() & exec() */
  120.  
  121. extern int vfork(void);     /* fork to child - calls __vfork() */
  122. extern void __vret(int);    /* return from child - calls __vexit() */
  123.  
  124. extern int *__vfork(void);    /* fork to child context */
  125. extern int *__vexit(int);    /* restore to parent context */
  126.  
  127. /* execve() execs a RiscOS command - calls __exec() */
  128.  
  129. extern int execve(char *,char **,char **);
  130.  
  131. extern void __exret(void);    /* return from __exec() - calls __vret() */
  132.  
  133. extern void (*__exptr)(char *); /* pointer to __exec() routine */
  134. extern int __exlen;        /* length of __exec() routine */
  135.  
  136. extern int __exshift;        /* __exec() shift */
  137.  
  138. /* vfork weak link */
  139.  
  140. extern void (*___vret)(int);
  141.  
  142. /* stdio weak links */
  143.  
  144. extern void (*___stdioinit)(void);
  145. extern void (*___stdioexit)(void);
  146.  
  147. /* C++ global constructor weak link */
  148. extern void (*___do_global_ctors)(void);
  149.  
  150. #ifdef __cplusplus
  151.     }
  152. #endif
  153.  
  154. #endif
  155.