|
|
1.1.1.9 ! root 1: /* 1.1 root 2: * UAE - The Un*x Amiga Emulator 1.1.1.9 ! root 3: * 1.1 root 4: * Miscellaneous machine dependent support functions and definitions 5: * 6: * Copyright 1996 Bernd Schmidt 7: */ 8: 9: 10: #include "sysconfig.h" 11: #include "sysdeps.h" 12: 13: #include "config.h" 14: #include "options.h" 15: #include "machdep/m68k.h" 1.1.1.3 root 16: #include "events.h" 1.1.1.5 root 17: #include "custom.h" 1.1 root 18: 1.1.1.2 root 19: #ifndef USE_UNDERSCORE 20: #define LARGE_ALIGNMENT ".align 16\n" 21: #else 22: #define LARGE_ALIGNMENT ".align 4,0x90\n" 23: #endif 24: 1.1 root 25: struct flag_struct regflags; 26: 1.1.1.6 root 27: /* All the Win32 configurations handle this in od-win32/win32.c */ 28: #ifndef _WIN32 1.1 root 29: 1.1.1.6 root 30: #include <signal.h> 1.1.1.2 root 31: 1.1.1.6 root 32: static volatile frame_time_t last_time, best_time; 33: static volatile int loops_to_go; 1.1.1.2 root 34: 1.1.1.6 root 35: #ifndef HAVE_SETITIMER 36: #define TIME_UNIT 1000000 1.1.1.2 root 37: #else 1.1.1.6 root 38: #define TIME_UNIT 100000 1.1.1.2 root 39: #endif 40: 1.1.1.6 root 41: static void set_alarm (void) 42: { 43: #ifndef HAVE_SETITIMER 44: alarm (1); 45: #else 46: struct itimerval t; 47: t.it_value.tv_sec = 0; 48: t.it_value.tv_usec = TIME_UNIT; 49: t.it_interval.tv_sec = 0; 50: t.it_interval.tv_usec = TIME_UNIT; 51: setitimer (ITIMER_REAL, &t, NULL); 1.1.1.2 root 52: #endif 1.1 root 53: } 1.1.1.2 root 54: 1.1.1.6 root 55: static int first_loop = 1; 1.1.1.2 root 56: 57: #ifdef __cplusplus 58: static RETSIGTYPE alarmhandler(...) 59: #else 60: static RETSIGTYPE alarmhandler(int foo) 61: #endif 62: { 63: frame_time_t bar; 64: bar = read_processor_time (); 1.1.1.6 root 65: if (! first_loop && bar - last_time < best_time) 1.1.1.2 root 66: best_time = bar - last_time; 1.1.1.6 root 67: first_loop = 0; 1.1.1.2 root 68: if (--loops_to_go > 0) { 69: signal (SIGALRM, alarmhandler); 70: last_time = read_processor_time(); 1.1.1.6 root 71: set_alarm (); 1.1.1.8 root 72: } else { 73: alarm (0); 74: signal (SIGALRM, SIG_IGN); 1.1.1.2 root 75: } 76: } 77: 1.1.1.4 root 78: #include <setjmp.h> 79: jmp_buf catch_test; 80: 1.1.1.3 root 81: #ifdef __cplusplus 82: static RETSIGTYPE illhandler(...) 83: #else 84: static RETSIGTYPE illhandler(int foo) 85: #endif 86: { 87: rpt_available = 0; 1.1.1.4 root 88: longjmp(catch_test,1); 1.1.1.3 root 89: } 90: 1.1.1.2 root 91: void machdep_init (void) 92: { 1.1.1.3 root 93: rpt_available = 1; 1.1.1.7 root 94: write_log ("Testing the RDTSC instruction ... "); 1.1.1.3 root 95: signal (SIGILL, illhandler); 1.1.1.5 root 96: if (setjmp (catch_test) == 0) 97: read_processor_time (); 1.1.1.3 root 98: signal (SIGILL, SIG_DFL); 1.1.1.7 root 99: write_log ("done.\n"); 1.1.1.3 root 100: if (! rpt_available) { 1.1.1.7 root 101: write_log ("Your processor does not support the RDTSC instruction.\n"); 1.1.1.3 root 102: return; 103: } 1.1.1.7 root 104: write_log ("Calibrating delay loop.. "); 1.1.1.3 root 105: fflush (stderr); 1.1.1.2 root 106: best_time = (frame_time_t)-1; 107: loops_to_go = 5; 108: signal (SIGALRM, alarmhandler); 109: /* We want exact values... */ 110: sync (); sync (); sync (); 111: last_time = read_processor_time(); 1.1.1.6 root 112: set_alarm (); 1.1.1.2 root 113: while (loops_to_go != 0) 1.1.1.6 root 114: usleep (10000); 1.1.1.7 root 115: write_log ("ok - %.2f BogoMIPS\n", 1.1.1.6 root 116: ((double)best_time / TIME_UNIT), best_time); 117: syncbase = best_time * (1000000 / TIME_UNIT); 1.1.1.2 root 118: } 119: 120: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.