home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / acornet / dev / oberon / potsrc.spk / lib / Core / c / _OS < prev    next >
Text File  |  1995-02-21  |  2KB  |  112 lines

  1. /* This code is generated by pOt. */
  2.  
  3. #include <pOtRTL.h>
  4. #include <stddef.h>
  5. #include <string.h>
  6. #include <time.h>
  7. #include <limits.h>
  8.  
  9. #ifdef __linux__
  10. #ifndef CLK_TCK
  11. #define CLK_TCK 100
  12. #endif
  13. #endif
  14.  
  15.  
  16. #ifdef __sun__
  17. #include <sys/param.h>
  18. #include <sys/types.h>
  19. #include <sys/times.h>
  20. #include <unistd.h>
  21. #define CLK_TCK HZ
  22. static struct tms tm;
  23. static clock_t clock()
  24. {
  25.   times(&tm);
  26.   return tm.tms_utime + tm.tms_stime;
  27. }
  28. #endif
  29.  
  30. #ifdef __riscos
  31. #include "hi.OS"
  32. #else
  33. #include "OS.hi"
  34. #endif
  35.  
  36. extern void pOt__gc pOt__ARGS((void));
  37.  
  38. static struct {void *next, *vars[0x1L];} pOt__gc_ptrs = {pOt_NIL,{
  39.   pOt_NIL
  40. }};
  41. static struct {void *next, *vars[0x1L];} pOt__gc_strs = {&pOt__gc_ptrs,{
  42.   pOt_NIL
  43. }};
  44.  
  45. extern pOt_LONGINT pOt_Time_OS()
  46. {
  47.   pOt_LONGINT pOt__retval;
  48.   struct {void*next;} pOt__gc_ptrs;
  49.   pOt__gc_ptrs.next = pOt__gc_root;
  50.  
  51.   pOt__retval = (clock()*300)/CLK_TCK;
  52.   goto pOt__Epilogue;
  53.  
  54.   pOt__halt(__FILE__,__LINE__,0x11);
  55. pOt__Epilogue:;
  56.   pOt__gc_root=(struct pOt__tag_gc_node*)pOt__gc_ptrs.next;
  57.   return pOt__retval;
  58. }
  59.  
  60. extern void pOt_GetClock_OS(pOt_date, pOt_time)
  61.     pOt_LONGINT *pOt_date; pOt_LONGINT *pOt_time;
  62. {
  63.   pOt_LONGINT pOt_tm;
  64.   struct {void*next;} pOt__gc_ptrs;
  65.   pOt__gc_ptrs.next = pOt__gc_root;
  66.  
  67.   pOt_tm = time(NULL);
  68.   *pOt_date = pOt_tm/86400L;
  69.   *pOt_time = pOt_tm%86400L;
  70.  
  71. pOt__Epilogue:;
  72.   pOt__gc_root=(struct pOt__tag_gc_node*)pOt__gc_ptrs.next;
  73. }
  74.  
  75. extern void pOt_GetParFile_OS(pOt_fname)
  76.     pOt__DynArr *pOt_fname;
  77. {
  78.   struct {void*next;} pOt__gc_ptrs;
  79.   pOt__gc_ptrs.next = pOt__gc_root;
  80.  
  81.   if(strlen(pOt__parfilename) < (*(pOt__ArrTypDsc**)pOt_fname)->nofel) {
  82.     strcpy((char*)(pOt_fname + 1), pOt__parfilename);
  83.   } else pOt__halt(__FILE__,__LINE__,3);
  84.  
  85. pOt__Epilogue:;
  86.   pOt__gc_root=(struct pOt__tag_gc_node*)pOt__gc_ptrs.next;
  87. }
  88.  
  89. extern void pOt_GC_OS()
  90. {
  91.   struct {void*next;} pOt__gc_ptrs;
  92.   pOt__gc_ptrs.next = pOt__gc_root;
  93.  
  94.   pOt__gc();
  95.  
  96. pOt__Epilogue:;
  97.   pOt__gc_root=(struct pOt__tag_gc_node*)pOt__gc_ptrs.next;
  98. }
  99.  
  100. void pOt_OS__body()
  101. {
  102.   static int pOt__OS_loaded=0;
  103.   if(!pOt__OS_loaded){
  104.     pOt__OS_loaded=1;
  105.  
  106.     pOt__gc_ptrs.next=pOt__gc_root;
  107.     pOt__gc_root=(struct pOt__tag_gc_node*)&pOt__gc_strs;
  108.  
  109.   pOt__Epilogue:;
  110.   }
  111. }
  112.