=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/parse/gc_risa.c,v retrieving revision 1.5 retrieving revision 1.15 diff -u -p -r1.5 -r1.15 --- OpenXM_contrib2/asir2000/parse/gc_risa.c 2009/02/05 11:21:38 1.5 +++ OpenXM_contrib2/asir2000/parse/gc_risa.c 2015/08/06 10:55:52 1.15 @@ -1,15 +1,25 @@ +/* $OpenXM: OpenXM_contrib2/asir2000/parse/gc_risa.c,v 1.14 2015/08/06 10:01:53 fujimoto Exp $ */ + +#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) +#include "private/gcconfig.h" +#endif #include "gc.h" #include void error(char *); +void int_handler(); int *StackBottom; +int in_gc, caught_intr; void *Risa_GC_malloc(size_t d) { void *ret; + in_gc = 1; ret = (void *)GC_malloc(d); + in_gc = 0; + if ( caught_intr ) { caught_intr = 0; int_handler(); } if ( !ret ) error("GC_malloc : failed to allocate memory"); return ret; @@ -19,24 +29,51 @@ void *Risa_GC_malloc_atomic(size_t d) { void *ret; + in_gc = 1; ret = (void *)GC_malloc_atomic(d); + in_gc = 0; + if ( caught_intr ) { caught_intr = 0; int_handler(); } if ( !ret ) error("GC_malloc_atomic : failed to allocate memory"); 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; + if ( caught_intr ) { caught_intr = 0; int_handler(); } + 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 *ret; + in_gc = 1; ret = (void *)GC_realloc(p,d); + in_gc = 0; + if ( caught_intr ) { caught_intr = 0; int_handler(); } if ( !ret ) error("GC_realloc : failed to reallocate memory"); return ret; } -int get_heapsize() +void Risa_GC_free(void *p) { + in_gc = 1; + GC_free(p); + in_gc = 0; + if ( caught_intr ) { caught_intr = 0; int_handler(); } +} + +size_t get_heapsize() +{ return GC_get_heap_size(); } @@ -44,14 +81,13 @@ int get_heapsize() #define BYTES_TO_WORDS(x) ((x)>>2) #endif -long get_allocwords() +size_t get_allocwords() { 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 gcstart,asir_start_time; +static double asir_start_time; double get_clock(), get_rtime(), get_current_time(); @@ -72,9 +108,7 @@ double get_rtime() return get_current_time() - asir_start_time; } -#if defined(THINK_C) || defined(__MWERKS__) || defined(VISUAL) || defined(MSWIN32) - -#if defined(VISUAL) +#if defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__) #include extern int recv_intr,doing_batch; @@ -129,7 +163,7 @@ double get_clock() } else return get_current_time(); } -#else +#elif defined(THINK_C) || defined(__MWERKS__) || defined(MSWIN32) double get_current_time() { return get_clock(); @@ -142,8 +176,6 @@ double get_clock() c = clock(); return (double)c/(double)CLOCKS_PER_SEC; } -#endif - #else #include @@ -170,7 +202,6 @@ double get_clock() } #else -#include #include double get_clock() @@ -186,6 +217,7 @@ double get_clock() #endif #endif +#if !defined(NO_ASIR_GC) extern int GC_free_space_numerator; void Risa_GC_get_adj(int *nm, int *dn) { @@ -197,16 +229,22 @@ void Risa_GC_set_adj(int nm, int dn) { GC_free_space_numerator = nm; 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() { - gcstart = get_clock(); +void Risa_GC_set_adj(int nm, int dn) { + GC_free_space_divisor = dn/nm; } -void GC_timerstop() { - gctime += get_clock() - gcstart; +double GC_get_gctime() { + return 0.0; } +#endif -#if defined(MSWIN32) && !defined(VISUAL) +#if defined(MSWIN32) && !defined(VISUAL) && !defined(__MINGW32__) && !defined(__MINGW64__) #include void process_events() { if ( check_break() ) @@ -239,7 +277,7 @@ void process_events() { } #endif -#if defined(VISUAL) && !defined(MSWIN32) +#if (defined(VISUAL) || defined(__MINGW32__) || defined(__MINGW64__)) && !defined(MSWIN32) int sigsetmask(mask) int mask; { return 0; } void process_events() {