home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / source / rayce27s / ibmtcc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-02  |  2.0 KB  |  126 lines

  1. /*
  2.  * 
  3.  ibmtcc.c -- device dependent stuff for Turbo C compiler (DOS)
  4.  * 
  5.  * (c) 1993, 1994 by Han Wen Nienhuys <hanwen@stack.urc.tue.nl>
  6.  * 
  7.  * This program is free software; you can redistribute it and/or modify it
  8.  * der the terms of the GNU General Public License as published by the
  9.  * e Software Foundation;
  10.  * 
  11.  * This program is distributed in the hope that it will be useful, but
  12.  * T ANY WARRANTY; without even the implied warranty of
  13.  MERCHANTABILITY
  14.  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  General Public
  16.  * License for more details.
  17.  * 
  18.  * You should have received a copy of the GNU General Public License along
  19.  * th this program; if not, write to the Free Software Foundation, Inc.,
  20.  * 75 Mass Ave, Cambridge, MA 02139, USA.
  21. */  
  22.  
  23. #include <stdio.h>
  24. #include <bios.h>
  25. #include <stdlib.h>
  26. #include <time.h>
  27. #include <signal.h>
  28. #include <alloc.h>
  29.  
  30.  
  31.  
  32. #include "ray.h"
  33. #include "proto.h"
  34. #include "extern.h"
  35.  
  36. extern unsigned int _stklen = (unsigned) 16384;
  37.  
  38.  
  39.  
  40. /* check for an abort condition, such as keypress */ 
  41. PUBLIC void    
  42. check_abort(void) 
  43. {
  44.     
  45.     if (keyboard_exit)
  46.     
  47.     if (bioskey(1)) {
  48.         
  49.         abort_trace(0);
  50.         
  51.     } else
  52.         
  53.         return;
  54.     
  55. }
  56.  
  57.  
  58.  
  59. PRIVATE clock_t ts;
  60.  
  61.  
  62. /* start the timer. Using clock ticks isn't exactly elegant, but it works */ 
  63. PUBLIC void    
  64. timer_start(void) 
  65. {
  66.     
  67.     ts = clock();
  68.     
  69. }
  70.  
  71.  
  72.  
  73. /*
  74.  * 
  75.  stop the timer, and return difference in time, measured in tenth of
  76.  * econds from last call to timer_start()
  77. */ 
  78. PUBLIC long    
  79. timer_stop(void) 
  80. {
  81.     
  82.     clock_t st;
  83.     
  84.     
  85.     st = clock();
  86.     
  87.     return (long) ((10 * (st - ts)) / CLOCKS_PER_SEC);
  88.     
  89. }
  90.  
  91.  
  92.  
  93. /*
  94.  * 
  95.  131 == div by zer 129 == domain
  96. */ 
  97.  
  98. PRIVATE void   
  99. sigcatch(int sig, int type, int *reglist) 
  100. {
  101.     
  102.     printf("trapped sig %d, type %d\n", sig, type);
  103.     
  104. }
  105.  
  106.  
  107.  
  108. PUBLIC void    
  109. init_machine(void) 
  110. {
  111.     
  112.     signal(SIGFPE, sigcatch);
  113.     
  114.     return;
  115.     
  116. }
  117.  
  118.  
  119.  
  120.  
  121. /* this is used for debugging memory. */ 
  122. PUBLIC unsigned long 
  123. memory_left(void) 
  124. {
  125.     
  126.     return coreleft();
  127.     
  128. }
  129.  
  130.  
  131.