version 1.3, 2007/11/11 15:54:03 |
version 1.13, 2013/06/13 18:40:31 |
|
|
#include "private/gc_priv.h" |
/* $OpenXM: OpenXM_contrib2/asir2000/parse/gc_risa.c,v 1.12 2013/06/13 07:45:28 ohara Exp $ */ |
|
|
|
#if defined(VISUAL) |
|
#include "private/gcconfig.h" |
|
#endif |
|
#include "gc.h" |
#include <time.h> |
#include <time.h> |
|
|
void error(char *); |
void error(char *); |
|
void int_handler(); |
|
|
int *StackBottom; |
int *StackBottom; |
|
int in_gc, caught_intr; |
|
|
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; |
|
if ( caught_intr ) { caught_intr = 0; int_handler(); } |
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 29 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; |
|
if ( caught_intr ) { caught_intr = 0; int_handler(); } |
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; |
|
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 *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; |
|
if ( caught_intr ) { caught_intr = 0; int_handler(); } |
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) |
{ |
{ |
return GC_heapsize; |
in_gc = 1; |
|
GC_free(p); |
|
in_gc = 0; |
|
if ( caught_intr ) { caught_intr = 0; int_handler(); } |
} |
} |
|
|
long get_allocwords() |
size_t get_heapsize() |
{ |
{ |
#if !defined(GC7) |
return GC_get_heap_size(); |
return GC_words_allocd_before_gc + GC_words_allocd; |
} |
#else |
|
long n = GC_bytes_allocd_before_gc + GC_bytes_allocd; |
#if !defined(BYTES_TO_WORDS) |
return BYTES_TO_WORDS(n); |
#define BYTES_TO_WORDS(x) ((x)>>2) |
#endif |
#endif |
|
|
|
size_t get_allocwords() |
|
{ |
|
size_t n = GC_get_total_bytes(); |
|
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 108 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) |
#if defined(VISUAL) |
#include <windows.h> |
#include <windows.h> |
|
|
Line 129 double get_clock() |
|
Line 163 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 176 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 202 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 217 double get_clock() |
|
#endif |
#endif |
#endif |
#endif |
|
|
void GC_timerstart() { |
#if !defined(NO_ASIR_GC) |
gcstart = get_clock(); |
extern int GC_free_space_numerator; |
|
|
|
void Risa_GC_get_adj(int *nm, int *dn) { |
|
*nm = GC_free_space_numerator; |
|
*dn = GC_free_space_divisor; |
} |
} |
|
|
void GC_timerstop() { |
void Risa_GC_set_adj(int nm, int dn) { |
gctime += get_clock() - gcstart; |
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 Risa_GC_set_adj(int nm, int dn) { |
|
GC_free_space_divisor = dn/nm; |
|
} |
|
|
|
double GC_get_gctime() { |
|
return 0.0; |
|
} |
|
#endif |
|
|
#if defined(MSWIN32) && !defined(VISUAL) |
#if defined(MSWIN32) && !defined(VISUAL) |
#include <signal.h> |
#include <signal.h> |