[BACK]Return to gc_risa.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / parse

Diff for /OpenXM_contrib2/asir2000/parse/gc_risa.c between version 1.5 and 1.18

version 1.5, 2009/02/05 11:21:38 version 1.18, 2018/03/12 02:37:08
Line 1 
Line 1 
   /* $OpenXM: OpenXM_contrib2/asir2000/parse/gc_risa.c,v 1.17 2017/08/30 09:40:30 ohara Exp $ */
   
   #if defined(VISUAL) || defined(__MINGW32__)
   #include "private/gcconfig.h"
   #endif
 #include "gc.h"  #include "gc.h"
 #include <time.h>  #include <time.h>
   #include <signal.h>
   
 void error(char *);  void error(char *);
   void int_handler();
   
 int *StackBottom;  int *StackBottom;
   int in_gc, caught_intr;
   
   void check_caught_intr()
   {
           if ( caught_intr == 1 ) {
                   caught_intr = 0;
                   int_handler(SIGINT);
           } else if ( caught_intr == 2 ) {
                   caught_intr = 0;
                   ox_usr1_handler(SIGUSR1);
       }
   }
   
 void *Risa_GC_malloc(size_t d)  void *Risa_GC_malloc(size_t d)
 {  {
         void *ret;          void *ret;
   
           in_gc = 1;
         ret = (void *)GC_malloc(d);          ret = (void *)GC_malloc(d);
           in_gc = 0;
           check_caught_intr();
         if ( !ret )          if ( !ret )
                 error("GC_malloc : failed to allocate memory");                  error("GC_malloc : failed to allocate memory");
         return ret;          return ret;
Line 19  void *Risa_GC_malloc_atomic(size_t d)
Line 41  void *Risa_GC_malloc_atomic(size_t d)
 {  {
         void *ret;          void *ret;
   
           in_gc = 1;
         ret = (void *)GC_malloc_atomic(d);          ret = (void *)GC_malloc_atomic(d);
           in_gc = 0;
           check_caught_intr();
         if ( !ret )          if ( !ret )
                 error("GC_malloc_atomic : failed to allocate memory");                  error("GC_malloc_atomic : failed to allocate memory");
         return ret;          return ret;
 }  }
   
   void *Risa_GC_malloc_atomic_ignore_off_page(size_t d)
   {
           void *ret;
   
           in_gc = 1;
           ret = (void *)GC_malloc_atomic_ignore_off_page(d);
           in_gc = 0;
           check_caught_intr();
           if ( !ret )
                   error("GC_malloc_atomic_ignore_off_page : failed to allocate memory");
           return ret;
   }
   
 void *Risa_GC_realloc(void *p,size_t d)  void *Risa_GC_realloc(void *p,size_t d)
 {  {
         void *ret;          void *ret;
   
           in_gc = 1;
         ret = (void *)GC_realloc(p,d);          ret = (void *)GC_realloc(p,d);
           in_gc = 0;
           check_caught_intr();
         if ( !ret )          if ( !ret )
                 error("GC_realloc : failed to reallocate memory");                  error("GC_realloc : failed to reallocate memory");
         return ret;          return ret;
 }  }
   
 int get_heapsize()  void Risa_GC_free(void *p)
 {  {
           in_gc = 1;
           GC_free(p);
           in_gc = 0;
           check_caught_intr();
   }
   
   size_t get_heapsize()
   {
         return GC_get_heap_size();          return GC_get_heap_size();
 }  }
   
Line 44  int get_heapsize()
Line 93  int get_heapsize()
 #define BYTES_TO_WORDS(x)   ((x)>>2)  #define BYTES_TO_WORDS(x)   ((x)>>2)
 #endif  #endif
   
 long get_allocwords()  size_t get_allocwords()
 {  {
         size_t n = GC_get_total_bytes();          size_t n = GC_get_total_bytes();
         return (long)BYTES_TO_WORDS(n); /* bytes to words */          return BYTES_TO_WORDS(n); /* bytes to words */
 }  }
   
 double gctime;  static double asir_start_time;
 static double gcstart,asir_start_time;  
   
 double get_clock(), get_rtime(), get_current_time();  double get_clock(), get_rtime(), get_current_time();
   
Line 72  double get_rtime()
Line 120  double get_rtime()
         return get_current_time() - asir_start_time;          return get_current_time() - asir_start_time;
 }  }
   
 #if defined(THINK_C) || defined(__MWERKS__) || defined(VISUAL) || defined(MSWIN32)  #if defined(VISUAL) || defined(__MINGW32__)
   
 #if defined(VISUAL)  
 #include <windows.h>  #include <windows.h>
   
 extern int recv_intr,doing_batch;  extern int recv_intr,doing_batch;
Line 82  void send_intr();
Line 128  void send_intr();
   
 BOOL set_ctrlc_flag(DWORD type)  BOOL set_ctrlc_flag(DWORD type)
 {  {
         if ( doing_batch )          enter_signal_cs();
           if ( doing_batch ) {
                 send_intr();                  send_intr();
         else          }else {
                 recv_intr = 1;                  recv_intr = 1;
           }
           leave_signal_cs();
         return TRUE;          return TRUE;
 }  }
   
Line 129  double get_clock()
Line 178  double get_clock()
         } else          } else
                 return get_current_time();                  return get_current_time();
 }  }
 #else  #elif defined(THINK_C) || defined(__MWERKS__) || defined(MSWIN32)
 double get_current_time()  double get_current_time()
 {  {
         return get_clock();          return get_clock();
Line 142  double get_clock()
Line 191  double get_clock()
         c = clock();          c = clock();
         return (double)c/(double)CLOCKS_PER_SEC;          return (double)c/(double)CLOCKS_PER_SEC;
 }  }
 #endif  
   
 #else  #else
 #include <sys/time.h>  #include <sys/time.h>
   
Line 170  double get_clock()
Line 217  double get_clock()
 }  }
 #else  #else
   
 #include <sys/time.h>  
 #include <sys/resource.h>  #include <sys/resource.h>
   
 double get_clock()  double get_clock()
Line 186  double get_clock()
Line 232  double get_clock()
 #endif  #endif
 #endif  #endif
   
   #if !defined(NO_ASIR_GC)
 extern int GC_free_space_numerator;  extern int GC_free_space_numerator;
   
 void Risa_GC_get_adj(int *nm, int *dn) {  void Risa_GC_get_adj(int *nm, int *dn) {
Line 197  void Risa_GC_set_adj(int nm, int dn) {
Line 244  void Risa_GC_set_adj(int nm, int dn) {
         GC_free_space_numerator = nm;          GC_free_space_numerator = nm;
         GC_free_space_divisor = dn;          GC_free_space_divisor = dn;
 }  }
   #else
   void Risa_GC_get_adj(int *nm, int *dn) {
           *nm = 1;
           *dn = GC_free_space_divisor;
   }
   
 void GC_timerstart() {  void Risa_GC_set_adj(int nm, int dn) {
         gcstart = get_clock();          GC_free_space_divisor = dn/nm;
 }  }
   
 void GC_timerstop() {  double GC_get_gctime() {
         gctime += get_clock() - gcstart;          return 0.0;
 }  }
   #endif
   
 #if defined(MSWIN32) && !defined(VISUAL)  #if defined(MSWIN32) && !defined(VISUAL) && !defined(__MINGW32__)
 #include <signal.h>  #include <signal.h>
 void process_events() {  void process_events() {
         if ( check_break() )          if ( check_break() )
Line 239  void process_events() {
Line 292  void process_events() {
 }  }
 #endif  #endif
   
 #if defined(VISUAL) && !defined(MSWIN32)  #if (defined(VISUAL) || defined(__MINGW32__)) && !defined(MSWIN32)
 int sigsetmask(mask) int mask; { return 0; }  int sigsetmask(mask) int mask; { return 0; }
   
 void process_events() {  void process_events() {
Line 251  int c;
Line 304  int c;
 #else  #else
                 if ( c == ('c' & 037 ) )                  if ( c == ('c' & 037 ) )
 #endif  #endif
                         int_handler();                          int_handler(SIGINT);
 }  }
 #endif  #endif

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.18

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>