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

Annotation of OpenXM_contrib2/asir2000/gc/gc_risa.c, Revision 1.1

1.1     ! noro        1: #include "gc_priv.h"
        !             2: #include <time.h>
        !             3:
        !             4: int *StackBottom;
        !             5:
        !             6: void *Risa_GC_malloc(size_t d)
        !             7: {
        !             8:        void *ret;
        !             9:
        !            10:        ret = GC_malloc(d);
        !            11:        if ( !ret )
        !            12:                error("GC_malloc : failed to allocate memory");
        !            13:        return ret;
        !            14: }
        !            15:
        !            16: void *Risa_GC_malloc_atomic(size_t d)
        !            17: {
        !            18:        void *ret;
        !            19:
        !            20:        ret = GC_malloc_atomic(d);
        !            21:        if ( !ret )
        !            22:                error("GC_malloc_atomic : failed to allocate memory");
        !            23:        return ret;
        !            24: }
        !            25:
        !            26: void *Risa_GC_realloc(void *p,size_t d)
        !            27: {
        !            28:        void *ret;
        !            29:
        !            30:        ret = GC_realloc(p,d);
        !            31:        if ( !ret )
        !            32:                error("GC_realloc : failed to reallocate memory");
        !            33:        return ret;
        !            34: }
        !            35:
        !            36: int get_heapsize()
        !            37: {
        !            38:        return GC_heapsize;
        !            39: }
        !            40:
        !            41: int get_allocwords()
        !            42: {
        !            43:        return GC_words_allocd_before_gc;
        !            44: }
        !            45:
        !            46: double gctime;
        !            47: static double gcstart,asir_start_time;
        !            48:
        !            49: double get_clock(), get_rtime(), get_current_time();
        !            50:
        !            51: void rtime_init()
        !            52: {
        !            53: #if defined(i386) && defined(linux)
        !            54:        unsigned short cw;
        !            55:
        !            56: #define fldcw(addr)             __asm("fldcw %0" : : "m" (*addr))
        !            57: #define fnstcw(addr)            __asm("fnstcw %0" : "=m" (*addr) : "0" (*addr))
        !            58:        fnstcw(&cw); cw &= 0xfeff; cw |= 0x0200; fldcw(&cw);
        !            59: #endif
        !            60:        asir_start_time = get_current_time();
        !            61: }
        !            62:
        !            63: double get_rtime()
        !            64: {
        !            65:        return get_current_time() - asir_start_time;
        !            66: }
        !            67:
        !            68: #if defined(THINK_C) || defined(__MWERKS__) || defined(VISUAL) || defined(MSWIN32)
        !            69:
        !            70: #if defined(VISUAL)
        !            71: #include <windows.h>
        !            72:
        !            73: extern int recv_intr,doing_batch;
        !            74: void send_intr();
        !            75:
        !            76: BOOL set_ctrlc_flag(DWORD type)
        !            77: {
        !            78:        if ( doing_batch )
        !            79:                send_intr();
        !            80:        else
        !            81:                recv_intr = 1;
        !            82:        return TRUE;
        !            83: }
        !            84:
        !            85: void register_ctrlc_handler() {
        !            86:        SetConsoleCtrlHandler((PHANDLER_ROUTINE)set_ctrlc_flag,TRUE);
        !            87: }
        !            88:
        !            89: int mythreadid() {
        !            90:        return GetCurrentThreadId();
        !            91: }
        !            92:
        !            93: double get_current_time()
        !            94: {
        !            95: //     return (double)clock()/(double)CLOCKS_PER_SEC;
        !            96:        return ((double)GetTickCount())/1000.0;
        !            97: }
        !            98:
        !            99: double get_clock()
        !           100: {
        !           101:        static int initialized = 0;
        !           102:        static int is_winnt = 0;
        !           103:        static HANDLE curproc;
        !           104:
        !           105:        if ( !initialized ) {
        !           106:                OSVERSIONINFO vinfo;
        !           107:
        !           108:                curproc = GetCurrentProcess();
        !           109:                vinfo.dwOSVersionInfoSize = sizeof(vinfo);
        !           110:                GetVersionEx(&vinfo);
        !           111:                if ( vinfo.dwPlatformId == VER_PLATFORM_WIN32_NT )
        !           112:                        is_winnt = 1;
        !           113:                else
        !           114:                        is_winnt = 0;
        !           115:        }
        !           116:        if ( is_winnt ) {
        !           117:                FILETIME c,e,k,u;
        !           118:
        !           119:                GetProcessTimes(curproc,&c,&e,&k,&u);
        !           120:                return ((double)k.dwLowDateTime+(double)u.dwLowDateTime
        !           121:                        +4294967296.0*((double)k.dwHighDateTime+(double)u.dwHighDateTime))/10000000.0;
        !           122:        } else
        !           123:                return get_current_time();
        !           124: }
        !           125: #else
        !           126: double get_current_time()
        !           127: {
        !           128:        return get_clock();
        !           129: }
        !           130:
        !           131: double get_clock()
        !           132: {
        !           133:        clock_t c;
        !           134:
        !           135:        c = clock();
        !           136:        return (double)c/(double)CLOCKS_PER_SEC;
        !           137: }
        !           138: #endif
        !           139:
        !           140: #else
        !           141: #include <sys/time.h>
        !           142:
        !           143: double get_current_time()
        !           144: {
        !           145:        struct timeval t;
        !           146:        struct timezone z;
        !           147:
        !           148:        gettimeofday(&t,&z);
        !           149:        return (double)t.tv_sec + ((double)t.tv_usec)/((double)1000000);
        !           150: }
        !           151:
        !           152: #if defined(_PA_RISC1_1) || defined(__svr4__)
        !           153:
        !           154: #include <sys/times.h>
        !           155: #include <limits.h>
        !           156:
        !           157: double get_clock()
        !           158: {
        !           159:        struct tms buf;
        !           160:
        !           161:        times(&buf);
        !           162:        return (double)(buf.tms_utime+buf.tms_stime)/(double)CLK_TCK;
        !           163: }
        !           164: #else
        !           165:
        !           166: #include <sys/time.h>
        !           167: #include <sys/resource.h>
        !           168:
        !           169: double get_clock()
        !           170: {
        !           171:        int tv_sec,tv_usec;
        !           172:        struct rusage ru;
        !           173:
        !           174:        getrusage(RUSAGE_SELF,&ru);
        !           175:        tv_sec = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
        !           176:        tv_usec = ru.ru_utime.tv_usec + ru.ru_stime.tv_usec;
        !           177:        return (double)tv_sec+(double)tv_usec/(double)1000000;
        !           178: }
        !           179: #endif
        !           180: #endif
        !           181:
        !           182: void GC_timerstart() {
        !           183:        gcstart = get_clock();
        !           184: }
        !           185:
        !           186: void GC_timerstop() {
        !           187:        gctime += get_clock() - gcstart;
        !           188: }
        !           189:
        !           190: #if defined(MSWIN32) && !defined(VISUAL)
        !           191: #include <signal.h>
        !           192: void process_events() {
        !           193:        if ( check_break() )
        !           194:                raise(SIGINT);
        !           195: }
        !           196: #endif
        !           197:
        !           198: #if defined(THINK_C) || defined(__MWERKS__)
        !           199: #include <signal.h>
        !           200: #include <Events.h>
        !           201:
        !           202: int sigsetmask(int mask){ return 0; }
        !           203:
        !           204: void process_events() {
        !           205:
        !           206:        register EvQElPtr q;
        !           207: #if 0
        !           208:        extern void (*app_process_events)();
        !           209: #endif
        !           210:
        !           211:        for (q = (EvQElPtr) GetEventQueue()->qHead; q; q = (EvQElPtr) q->qLink)
        !           212:                if (q->evtQWhat == keyDown && (char) q->evtQMessage == '.')
        !           213:                        if (q->evtQModifiers & cmdKey) {
        !           214:                                raise(SIGINT); break;
        !           215:                        }
        !           216: #if 0
        !           217:        if ( app_process_events )
        !           218:                (*app_process_events)();
        !           219: #endif
        !           220: }
        !           221: #endif
        !           222:
        !           223: #if defined(VISUAL) && !defined(MSWIN32)
        !           224: int sigsetmask(mask) int mask; { return 0; }
        !           225:
        !           226: void process_events() {
        !           227: int c;
        !           228:
        !           229:        while ( c = read_cons() )
        !           230: #if defined(GO32)
        !           231:                if ( c == ('x' & 037 ) )
        !           232: #else
        !           233:                if ( c == ('c' & 037 ) )
        !           234: #endif
        !           235:                        int_handler();
        !           236: }
        !           237: #endif

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