1*53ee8cc1Swenshuai.xi /* 2*53ee8cc1Swenshuai.xi * time.h 3*53ee8cc1Swenshuai.xi * 4*53ee8cc1Swenshuai.xi * Struct and function declarations for dealing with time. 5*53ee8cc1Swenshuai.xi */ 6*53ee8cc1Swenshuai.xi 7*53ee8cc1Swenshuai.xi #ifndef _TIME_H_ 8*53ee8cc1Swenshuai.xi #define _TIME_H_ 9*53ee8cc1Swenshuai.xi 10*53ee8cc1Swenshuai.xi #include "_ansi.h" 11*53ee8cc1Swenshuai.xi #include <sys/reent.h> 12*53ee8cc1Swenshuai.xi 13*53ee8cc1Swenshuai.xi #ifndef NULL 14*53ee8cc1Swenshuai.xi #define NULL 0 15*53ee8cc1Swenshuai.xi #endif 16*53ee8cc1Swenshuai.xi 17*53ee8cc1Swenshuai.xi /* Get _CLOCKS_PER_SEC_ */ 18*53ee8cc1Swenshuai.xi #include <machine/time.h> 19*53ee8cc1Swenshuai.xi 20*53ee8cc1Swenshuai.xi #ifndef _CLOCKS_PER_SEC_ 21*53ee8cc1Swenshuai.xi #define _CLOCKS_PER_SEC_ 1000 22*53ee8cc1Swenshuai.xi #endif 23*53ee8cc1Swenshuai.xi 24*53ee8cc1Swenshuai.xi #define CLOCKS_PER_SEC _CLOCKS_PER_SEC_ 25*53ee8cc1Swenshuai.xi #define CLK_TCK CLOCKS_PER_SEC 26*53ee8cc1Swenshuai.xi #define __need_size_t 27*53ee8cc1Swenshuai.xi #include <stddef.h> 28*53ee8cc1Swenshuai.xi 29*53ee8cc1Swenshuai.xi #include <sys/types.h> 30*53ee8cc1Swenshuai.xi 31*53ee8cc1Swenshuai.xi _BEGIN_STD_C 32*53ee8cc1Swenshuai.xi 33*53ee8cc1Swenshuai.xi struct tm 34*53ee8cc1Swenshuai.xi { 35*53ee8cc1Swenshuai.xi int tm_sec; 36*53ee8cc1Swenshuai.xi int tm_min; 37*53ee8cc1Swenshuai.xi int tm_hour; 38*53ee8cc1Swenshuai.xi int tm_mday; 39*53ee8cc1Swenshuai.xi int tm_mon; 40*53ee8cc1Swenshuai.xi int tm_year; 41*53ee8cc1Swenshuai.xi int tm_wday; 42*53ee8cc1Swenshuai.xi int tm_yday; 43*53ee8cc1Swenshuai.xi int tm_isdst; 44*53ee8cc1Swenshuai.xi }; 45*53ee8cc1Swenshuai.xi 46*53ee8cc1Swenshuai.xi clock_t _EXFUN(clock, (void)); 47*53ee8cc1Swenshuai.xi double _EXFUN(difftime, (time_t _time2, time_t _time1)); 48*53ee8cc1Swenshuai.xi time_t _EXFUN(mktime, (struct tm *_timeptr)); 49*53ee8cc1Swenshuai.xi time_t _EXFUN(time, (time_t *_timer)); 50*53ee8cc1Swenshuai.xi #ifndef _REENT_ONLY 51*53ee8cc1Swenshuai.xi char *_EXFUN(asctime, (const struct tm *_tblock)); 52*53ee8cc1Swenshuai.xi char *_EXFUN(ctime, (const time_t *_time)); 53*53ee8cc1Swenshuai.xi struct tm *_EXFUN(gmtime, (const time_t *_timer)); 54*53ee8cc1Swenshuai.xi struct tm *_EXFUN(localtime,(const time_t *_timer)); 55*53ee8cc1Swenshuai.xi #endif 56*53ee8cc1Swenshuai.xi size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t)); 57*53ee8cc1Swenshuai.xi 58*53ee8cc1Swenshuai.xi char *_EXFUN(asctime_r, (const struct tm *, char *)); 59*53ee8cc1Swenshuai.xi char *_EXFUN(ctime_r, (const time_t *, char *)); 60*53ee8cc1Swenshuai.xi struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *)); 61*53ee8cc1Swenshuai.xi struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *)); 62*53ee8cc1Swenshuai.xi 63*53ee8cc1Swenshuai.xi #if defined(AEONSIM) || defined(XGEN) 64*53ee8cc1Swenshuai.xi #include <sys/syscall.h> 65*53ee8cc1Swenshuai.xi 66*53ee8cc1Swenshuai.xi #define AEONSIM_MAX_TIMER 16 67*53ee8cc1Swenshuai.xi #define AEONSIM_ALL_TIMER -1 68*53ee8cc1Swenshuai.xi #define XGEN_MAX_TIMER AEONSIM_MAX_TIMER 69*53ee8cc1Swenshuai.xi #define XGEN_ALL_TIMER AEONSIM_ALL_TIMER 70*53ee8cc1Swenshuai.xi #define AEONSIM_MAX_COUNTER 16 71*53ee8cc1Swenshuai.xi #define AEONSIM_ALL_COUNTER -1 72*53ee8cc1Swenshuai.xi #define XGEN_MAX_COUNTER AEONSIM_MAX_COUNTER 73*53ee8cc1Swenshuai.xi #define XGEN_ALL_COUNTER AEONSIM_ALL_COUNTER 74*53ee8cc1Swenshuai.xi 75*53ee8cc1Swenshuai.xi void __timer_reset(int timer_id); 76*53ee8cc1Swenshuai.xi void __timer_start(int timer_id); 77*53ee8cc1Swenshuai.xi void __timer_stop(int timer_id); 78*53ee8cc1Swenshuai.xi void __timer_cancel(int timer_id); 79*53ee8cc1Swenshuai.xi void __timer_report(int timer_id); 80*53ee8cc1Swenshuai.xi int __timer_started(int timer_id); 81*53ee8cc1Swenshuai.xi int __timer_n_start(int timer_id); 82*53ee8cc1Swenshuai.xi 83*53ee8cc1Swenshuai.xi long long __timer_last_cycles(int timer_id); // number of cycles elapse 84*53ee8cc1Swenshuai.xi long long __timer_last_cycles_due_to_i_miss(int timer_id); // number of cycles elapse due to i-cache miss 85*53ee8cc1Swenshuai.xi long long __timer_last_cycles_due_to_d_miss(int timer_id); // number of cycles elapse due to i-cache miss 86*53ee8cc1Swenshuai.xi long long __timer_last_instructions(int timer_id); // number of instruction executed 87*53ee8cc1Swenshuai.xi long long __timer_last_data_prefetch(int timer_id);// data prefetch in byte 88*53ee8cc1Swenshuai.xi long long __timer_last_data_read(int timer_id); // data read in byte 89*53ee8cc1Swenshuai.xi long long __timer_last_data_write(int timer_id); // data write in byte 90*53ee8cc1Swenshuai.xi long long __timer_last_instruction_fetch(int timer_id); // instruction fetch in byte 91*53ee8cc1Swenshuai.xi long long __timer_last_bus_prefetch(int timer_id);// data prefetch in byte which miss cache/scratch and involve memroy bus 92*53ee8cc1Swenshuai.xi long long __timer_last_bus_read(int timer_id); // data read in byte which miss cache/scratch and involve memroy bus 93*53ee8cc1Swenshuai.xi long long __timer_last_bus_write(int timer_id); // data write in byte which miss cache/scratch and involve memroy bus 94*53ee8cc1Swenshuai.xi long long __timer_last_bus_fetch(int timer_id); // instruction fetch in byte which miss cache/scratch and involve memroy bus 95*53ee8cc1Swenshuai.xi long long __timer_last_qbus_read(int timer_id); // data read in byte from QMEM 96*53ee8cc1Swenshuai.xi long long __timer_last_qbus_write(int timer_id); // data write in byte to QMEM 97*53ee8cc1Swenshuai.xi long long __timer_last_qbus_fetch(int timer_id); // instruction fetch in byte from QMEM 98*53ee8cc1Swenshuai.xi 99*53ee8cc1Swenshuai.xi long long __timer_total_cycles(int timer_id); 100*53ee8cc1Swenshuai.xi long long __timer_total_cycles_due_to_i_miss(int timer_id); 101*53ee8cc1Swenshuai.xi long long __timer_total_cycles_due_to_d_miss(int timer_id); 102*53ee8cc1Swenshuai.xi long long __timer_total_instructions(int timer_id); 103*53ee8cc1Swenshuai.xi long long __timer_total_data_prefetch(int timer_id); 104*53ee8cc1Swenshuai.xi long long __timer_total_data_read(int timer_id); 105*53ee8cc1Swenshuai.xi long long __timer_total_data_write(int timer_id); 106*53ee8cc1Swenshuai.xi long long __timer_total_instruction_fetch(int timer_id); 107*53ee8cc1Swenshuai.xi long long __timer_total_bus_prefetch(int timer_id); 108*53ee8cc1Swenshuai.xi long long __timer_total_bus_read(int timer_id); 109*53ee8cc1Swenshuai.xi long long __timer_total_bus_write(int timer_id); 110*53ee8cc1Swenshuai.xi long long __timer_total_bus_fetch(int timer_id); 111*53ee8cc1Swenshuai.xi long long __timer_total_qbus_read(int timer_id); 112*53ee8cc1Swenshuai.xi long long __timer_total_qbus_write(int timer_id); 113*53ee8cc1Swenshuai.xi long long __timer_total_qbus_fetch(int timer_id); 114*53ee8cc1Swenshuai.xi 115*53ee8cc1Swenshuai.xi long long __timer_total_microsecond(int timer_id); 116*53ee8cc1Swenshuai.xi void __timer_add_last(int dest_timer_id, int src_timer_id); 117*53ee8cc1Swenshuai.xi 118*53ee8cc1Swenshuai.xi void __counter_reset(int timer_id); 119*53ee8cc1Swenshuai.xi void __counter_increment(int timer_id, unsigned divisor); 120*53ee8cc1Swenshuai.xi void __counter_report(int timer_id); 121*53ee8cc1Swenshuai.xi long long __counter_value(int timer_id); 122*53ee8cc1Swenshuai.xi 123*53ee8cc1Swenshuai.xi // __timer_start/stop short-hand 124*53ee8cc1Swenshuai.xi #ifdef AEONSIM 125*53ee8cc1Swenshuai.xi #define __timer0_start() __asm__ __volatile__ ("l.nop %0\t# void __timer0_start()" : : "K"(NOP_AEONSIM_TIMER0_START+0)); 126*53ee8cc1Swenshuai.xi #define __timer1_start() __asm__ __volatile__ ("l.nop %0\t# void __timer1_start()" : : "K"(NOP_AEONSIM_TIMER0_START+1)); 127*53ee8cc1Swenshuai.xi #define __timer2_start() __asm__ __volatile__ ("l.nop %0\t# void __timer2_start()" : : "K"(NOP_AEONSIM_TIMER0_START+2)); 128*53ee8cc1Swenshuai.xi #define __timer3_start() __asm__ __volatile__ ("l.nop %0\t# void __timer3_start()" : : "K"(NOP_AEONSIM_TIMER0_START+3)); 129*53ee8cc1Swenshuai.xi #define __timer4_start() __asm__ __volatile__ ("l.nop %0\t# void __timer4_start()" : : "K"(NOP_AEONSIM_TIMER0_START+4)); 130*53ee8cc1Swenshuai.xi #define __timer5_start() __asm__ __volatile__ ("l.nop %0\t# void __timer5_start()" : : "K"(NOP_AEONSIM_TIMER0_START+5)); 131*53ee8cc1Swenshuai.xi #define __timer6_start() __asm__ __volatile__ ("l.nop %0\t# void __timer6_start()" : : "K"(NOP_AEONSIM_TIMER0_START+6)); 132*53ee8cc1Swenshuai.xi #define __timer7_start() __asm__ __volatile__ ("l.nop %0\t# void __timer7_start()" : : "K"(NOP_AEONSIM_TIMER0_START+7)); 133*53ee8cc1Swenshuai.xi #define __timer8_start() __asm__ __volatile__ ("l.nop %0\t# void __timer8_start()" : : "K"(NOP_AEONSIM_TIMER0_START+8)); 134*53ee8cc1Swenshuai.xi #define __timer9_start() __asm__ __volatile__ ("l.nop %0\t# void __timer9_start()" : : "K"(NOP_AEONSIM_TIMER0_START+9)); 135*53ee8cc1Swenshuai.xi #define __timer10_start() __asm__ __volatile__ ("l.nop %0\t# void __timer10_start()" : : "K"(NOP_AEONSIM_TIMER0_START+10)); 136*53ee8cc1Swenshuai.xi #define __timer11_start() __asm__ __volatile__ ("l.nop %0\t# void __timer11_start()" : : "K"(NOP_AEONSIM_TIMER0_START+11)); 137*53ee8cc1Swenshuai.xi #define __timer12_start() __asm__ __volatile__ ("l.nop %0\t# void __timer12_start()" : : "K"(NOP_AEONSIM_TIMER0_START+12)); 138*53ee8cc1Swenshuai.xi #define __timer13_start() __asm__ __volatile__ ("l.nop %0\t# void __timer13_start()" : : "K"(NOP_AEONSIM_TIMER0_START+13)); 139*53ee8cc1Swenshuai.xi #define __timer14_start() __asm__ __volatile__ ("l.nop %0\t# void __timer14_start()" : : "K"(NOP_AEONSIM_TIMER0_START+14)); 140*53ee8cc1Swenshuai.xi #define __timer15_start() __asm__ __volatile__ ("l.nop %0\t# void __timer15_start()" : : "K"(NOP_AEONSIM_TIMER0_START+15)); 141*53ee8cc1Swenshuai.xi 142*53ee8cc1Swenshuai.xi #define __timer0_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer0_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+0)); 143*53ee8cc1Swenshuai.xi #define __timer1_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer1_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+1)); 144*53ee8cc1Swenshuai.xi #define __timer2_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer2_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+2)); 145*53ee8cc1Swenshuai.xi #define __timer3_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer3_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+3)); 146*53ee8cc1Swenshuai.xi #define __timer4_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer4_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+4)); 147*53ee8cc1Swenshuai.xi #define __timer5_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer5_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+5)); 148*53ee8cc1Swenshuai.xi #define __timer6_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer6_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+6)); 149*53ee8cc1Swenshuai.xi #define __timer7_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer7_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+7)); 150*53ee8cc1Swenshuai.xi #define __timer8_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer8_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+8)); 151*53ee8cc1Swenshuai.xi #define __timer9_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer9_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+9)); 152*53ee8cc1Swenshuai.xi #define __timer10_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer10_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+10)); 153*53ee8cc1Swenshuai.xi #define __timer11_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer11_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+11)); 154*53ee8cc1Swenshuai.xi #define __timer12_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer12_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+12)); 155*53ee8cc1Swenshuai.xi #define __timer13_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer13_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+13)); 156*53ee8cc1Swenshuai.xi #define __timer14_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer14_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+14)); 157*53ee8cc1Swenshuai.xi #define __timer15_stop() __asm__ __volatile__ ("l.nop %0\t# void __timer15_stop()" : : "K"(NOP_AEONSIM_TIMER0_STOP+15)); 158*53ee8cc1Swenshuai.xi 159*53ee8cc1Swenshuai.xi #define __timer0_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer0_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+0)); 160*53ee8cc1Swenshuai.xi #define __timer1_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer1_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+1)); 161*53ee8cc1Swenshuai.xi #define __timer2_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer2_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+2)); 162*53ee8cc1Swenshuai.xi #define __timer3_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer3_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+3)); 163*53ee8cc1Swenshuai.xi #define __timer4_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer4_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+4)); 164*53ee8cc1Swenshuai.xi #define __timer5_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer5_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+5)); 165*53ee8cc1Swenshuai.xi #define __timer6_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer6_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+6)); 166*53ee8cc1Swenshuai.xi #define __timer7_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer7_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+7)); 167*53ee8cc1Swenshuai.xi #define __timer8_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer8_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+8)); 168*53ee8cc1Swenshuai.xi #define __timer9_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer9_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+9)); 169*53ee8cc1Swenshuai.xi #define __timer10_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer10_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+10)); 170*53ee8cc1Swenshuai.xi #define __timer11_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer11_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+11)); 171*53ee8cc1Swenshuai.xi #define __timer12_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer12_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+12)); 172*53ee8cc1Swenshuai.xi #define __timer13_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer13_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+13)); 173*53ee8cc1Swenshuai.xi #define __timer14_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer14_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+14)); 174*53ee8cc1Swenshuai.xi #define __timer15_cancel() __asm__ __volatile__ ("l.nop %0\t# void __timer15_cancel()" : : "K"(NOP_AEONSIM_TIMER0_CANCEL+15)); 175*53ee8cc1Swenshuai.xi 176*53ee8cc1Swenshuai.xi // __counter_increment short-hand 177*53ee8cc1Swenshuai.xi #define __counter0_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter0_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+0)); 178*53ee8cc1Swenshuai.xi #define __counter1_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter1_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+1)); 179*53ee8cc1Swenshuai.xi #define __counter2_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter2_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+2)); 180*53ee8cc1Swenshuai.xi #define __counter3_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter3_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+3)); 181*53ee8cc1Swenshuai.xi #define __counter4_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter4_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+4)); 182*53ee8cc1Swenshuai.xi #define __counter5_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter5_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+5)); 183*53ee8cc1Swenshuai.xi #define __counter6_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter6_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+6)); 184*53ee8cc1Swenshuai.xi #define __counter7_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter7_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+7)); 185*53ee8cc1Swenshuai.xi #define __counter8_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter8_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+8)); 186*53ee8cc1Swenshuai.xi #define __counter9_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter9_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+9)); 187*53ee8cc1Swenshuai.xi #define __counter10_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter10_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+10)); 188*53ee8cc1Swenshuai.xi #define __counter11_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter11_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+11)); 189*53ee8cc1Swenshuai.xi #define __counter12_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter12_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+12)); 190*53ee8cc1Swenshuai.xi #define __counter13_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter13_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+13)); 191*53ee8cc1Swenshuai.xi #define __counter14_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter14_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+14)); 192*53ee8cc1Swenshuai.xi #define __counter15_increment() __asm__ __volatile__ ("l.nop %0\t# void __counter15_increment()" : : "K"(NOP_AEONSIM_COUNTER0_INCREMENT+15)); 193*53ee8cc1Swenshuai.xi 194*53ee8cc1Swenshuai.xi #else 195*53ee8cc1Swenshuai.xi //!AEONSIM 196*53ee8cc1Swenshuai.xi void __timer0_start(); 197*53ee8cc1Swenshuai.xi void __timer1_start(); 198*53ee8cc1Swenshuai.xi void __timer2_start(); 199*53ee8cc1Swenshuai.xi void __timer3_start(); 200*53ee8cc1Swenshuai.xi void __timer4_start(); 201*53ee8cc1Swenshuai.xi void __timer5_start(); 202*53ee8cc1Swenshuai.xi void __timer6_start(); 203*53ee8cc1Swenshuai.xi void __timer7_start(); 204*53ee8cc1Swenshuai.xi void __timer8_start(); 205*53ee8cc1Swenshuai.xi void __timer9_start(); 206*53ee8cc1Swenshuai.xi void __timer10_start(); 207*53ee8cc1Swenshuai.xi void __timer11_start(); 208*53ee8cc1Swenshuai.xi void __timer12_start(); 209*53ee8cc1Swenshuai.xi void __timer13_start(); 210*53ee8cc1Swenshuai.xi void __timer14_start(); 211*53ee8cc1Swenshuai.xi void __timer15_start(); 212*53ee8cc1Swenshuai.xi 213*53ee8cc1Swenshuai.xi void __timer0_stop(); 214*53ee8cc1Swenshuai.xi void __timer1_stop(); 215*53ee8cc1Swenshuai.xi void __timer2_stop(); 216*53ee8cc1Swenshuai.xi void __timer3_stop(); 217*53ee8cc1Swenshuai.xi void __timer4_stop(); 218*53ee8cc1Swenshuai.xi void __timer5_stop(); 219*53ee8cc1Swenshuai.xi void __timer6_stop(); 220*53ee8cc1Swenshuai.xi void __timer7_stop(); 221*53ee8cc1Swenshuai.xi void __timer8_stop(); 222*53ee8cc1Swenshuai.xi void __timer9_stop(); 223*53ee8cc1Swenshuai.xi void __timer10_stop(); 224*53ee8cc1Swenshuai.xi void __timer11_stop(); 225*53ee8cc1Swenshuai.xi void __timer12_stop(); 226*53ee8cc1Swenshuai.xi void __timer13_stop(); 227*53ee8cc1Swenshuai.xi void __timer14_stop(); 228*53ee8cc1Swenshuai.xi void __timer15_stop(); 229*53ee8cc1Swenshuai.xi 230*53ee8cc1Swenshuai.xi void __timer0_cancel(); 231*53ee8cc1Swenshuai.xi void __timer1_cancel(); 232*53ee8cc1Swenshuai.xi void __timer2_cancel(); 233*53ee8cc1Swenshuai.xi void __timer3_cancel(); 234*53ee8cc1Swenshuai.xi void __timer4_cancel(); 235*53ee8cc1Swenshuai.xi void __timer5_cancel(); 236*53ee8cc1Swenshuai.xi void __timer6_cancel(); 237*53ee8cc1Swenshuai.xi void __timer7_cancel(); 238*53ee8cc1Swenshuai.xi void __timer8_cancel(); 239*53ee8cc1Swenshuai.xi void __timer9_cancel(); 240*53ee8cc1Swenshuai.xi void __timer10_cancel(); 241*53ee8cc1Swenshuai.xi void __timer11_cancel(); 242*53ee8cc1Swenshuai.xi void __timer12_cancel(); 243*53ee8cc1Swenshuai.xi void __timer13_cancel(); 244*53ee8cc1Swenshuai.xi void __timer14_cancel(); 245*53ee8cc1Swenshuai.xi void __timer15_cancel(); 246*53ee8cc1Swenshuai.xi 247*53ee8cc1Swenshuai.xi void __counter0_increment(); 248*53ee8cc1Swenshuai.xi void __counter1_increment(); 249*53ee8cc1Swenshuai.xi void __counter2_increment(); 250*53ee8cc1Swenshuai.xi void __counter3_increment(); 251*53ee8cc1Swenshuai.xi void __counter4_increment(); 252*53ee8cc1Swenshuai.xi void __counter5_increment(); 253*53ee8cc1Swenshuai.xi void __counter6_increment(); 254*53ee8cc1Swenshuai.xi void __counter7_increment(); 255*53ee8cc1Swenshuai.xi void __counter8_increment(); 256*53ee8cc1Swenshuai.xi void __counter9_increment(); 257*53ee8cc1Swenshuai.xi void __counter10_increment(); 258*53ee8cc1Swenshuai.xi void __counter11_increment(); 259*53ee8cc1Swenshuai.xi void __counter12_increment(); 260*53ee8cc1Swenshuai.xi void __counter13_increment(); 261*53ee8cc1Swenshuai.xi void __counter14_increment(); 262*53ee8cc1Swenshuai.xi void __counter15_increment(); 263*53ee8cc1Swenshuai.xi 264*53ee8cc1Swenshuai.xi #endif /* AEONSIM */ 265*53ee8cc1Swenshuai.xi #endif /* AEONSIM || XGEN */ 266*53ee8cc1Swenshuai.xi 267*53ee8cc1Swenshuai.xi _END_STD_C 268*53ee8cc1Swenshuai.xi 269*53ee8cc1Swenshuai.xi #ifdef __cplusplus 270*53ee8cc1Swenshuai.xi extern "C" { 271*53ee8cc1Swenshuai.xi #endif 272*53ee8cc1Swenshuai.xi 273*53ee8cc1Swenshuai.xi #ifndef __STRICT_ANSI__ 274*53ee8cc1Swenshuai.xi char *_EXFUN(strptime, (const char *, const char *, struct tm *)); 275*53ee8cc1Swenshuai.xi _VOID _EXFUN(tzset, (_VOID)); 276*53ee8cc1Swenshuai.xi _VOID _EXFUN(_tzset_r, (struct _reent *)); 277*53ee8cc1Swenshuai.xi 278*53ee8cc1Swenshuai.xi typedef struct __tzrule_struct 279*53ee8cc1Swenshuai.xi { 280*53ee8cc1Swenshuai.xi char ch; 281*53ee8cc1Swenshuai.xi int m; 282*53ee8cc1Swenshuai.xi int n; 283*53ee8cc1Swenshuai.xi int d; 284*53ee8cc1Swenshuai.xi int s; 285*53ee8cc1Swenshuai.xi time_t change; 286*53ee8cc1Swenshuai.xi long offset; /* Match type of _timezone. */ 287*53ee8cc1Swenshuai.xi } __tzrule_type; 288*53ee8cc1Swenshuai.xi 289*53ee8cc1Swenshuai.xi typedef struct __tzinfo_struct 290*53ee8cc1Swenshuai.xi { 291*53ee8cc1Swenshuai.xi int __tznorth; 292*53ee8cc1Swenshuai.xi int __tzyear; 293*53ee8cc1Swenshuai.xi __tzrule_type __tzrule[2]; 294*53ee8cc1Swenshuai.xi } __tzinfo_type; 295*53ee8cc1Swenshuai.xi 296*53ee8cc1Swenshuai.xi __tzinfo_type *_EXFUN (__gettzinfo, (_VOID)); 297*53ee8cc1Swenshuai.xi 298*53ee8cc1Swenshuai.xi /* getdate functions */ 299*53ee8cc1Swenshuai.xi 300*53ee8cc1Swenshuai.xi #ifdef HAVE_GETDATE 301*53ee8cc1Swenshuai.xi #ifndef _REENT_ONLY 302*53ee8cc1Swenshuai.xi #define getdate_err (*__getdate_err()) 303*53ee8cc1Swenshuai.xi int *_EXFUN(__getdate_err,(_VOID)); 304*53ee8cc1Swenshuai.xi 305*53ee8cc1Swenshuai.xi struct tm * _EXFUN(getdate, (const char *)); 306*53ee8cc1Swenshuai.xi /* getdate_err is set to one of the following values to indicate the error. 307*53ee8cc1Swenshuai.xi 1 the DATEMSK environment variable is null or undefined, 308*53ee8cc1Swenshuai.xi 2 the template file cannot be opened for reading, 309*53ee8cc1Swenshuai.xi 3 failed to get file status information, 310*53ee8cc1Swenshuai.xi 4 the template file is not a regular file, 311*53ee8cc1Swenshuai.xi 5 an error is encountered while reading the template file, 312*53ee8cc1Swenshuai.xi 6 memory allication failed (not enough memory available), 313*53ee8cc1Swenshuai.xi 7 there is no line in the template that matches the input, 314*53ee8cc1Swenshuai.xi 8 invalid input specification */ 315*53ee8cc1Swenshuai.xi #endif /* !_REENT_ONLY */ 316*53ee8cc1Swenshuai.xi 317*53ee8cc1Swenshuai.xi /* getdate_r returns the error code as above */ 318*53ee8cc1Swenshuai.xi int _EXFUN(getdate_r, (const char *, struct tm *)); 319*53ee8cc1Swenshuai.xi #endif /* HAVE_GETDATE */ 320*53ee8cc1Swenshuai.xi 321*53ee8cc1Swenshuai.xi /* defines for the opengroup specifications Derived from Issue 1 of the SVID. */ 322*53ee8cc1Swenshuai.xi extern __IMPORT long _timezone; 323*53ee8cc1Swenshuai.xi extern __IMPORT int _daylight; 324*53ee8cc1Swenshuai.xi extern __IMPORT char *_tzname[2]; 325*53ee8cc1Swenshuai.xi 326*53ee8cc1Swenshuai.xi /* POSIX defines the external tzname being defined in time.h */ 327*53ee8cc1Swenshuai.xi #ifndef tzname 328*53ee8cc1Swenshuai.xi #define tzname _tzname 329*53ee8cc1Swenshuai.xi #endif 330*53ee8cc1Swenshuai.xi #endif /* !__STRICT_ANSI__ */ 331*53ee8cc1Swenshuai.xi 332*53ee8cc1Swenshuai.xi #ifdef __cplusplus 333*53ee8cc1Swenshuai.xi } 334*53ee8cc1Swenshuai.xi #endif 335*53ee8cc1Swenshuai.xi 336*53ee8cc1Swenshuai.xi #include <sys/features.h> 337*53ee8cc1Swenshuai.xi 338*53ee8cc1Swenshuai.xi #ifdef __CYGWIN__ 339*53ee8cc1Swenshuai.xi #include <cygwin/time.h> 340*53ee8cc1Swenshuai.xi #endif /*__CYGWIN__*/ 341*53ee8cc1Swenshuai.xi 342*53ee8cc1Swenshuai.xi #if defined(_POSIX_TIMERS) 343*53ee8cc1Swenshuai.xi 344*53ee8cc1Swenshuai.xi #include <signal.h> 345*53ee8cc1Swenshuai.xi 346*53ee8cc1Swenshuai.xi #ifdef __cplusplus 347*53ee8cc1Swenshuai.xi extern "C" { 348*53ee8cc1Swenshuai.xi #endif 349*53ee8cc1Swenshuai.xi 350*53ee8cc1Swenshuai.xi /* Clocks, P1003.1b-1993, p. 263 */ 351*53ee8cc1Swenshuai.xi 352*53ee8cc1Swenshuai.xi int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp)); 353*53ee8cc1Swenshuai.xi int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp)); 354*53ee8cc1Swenshuai.xi int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res)); 355*53ee8cc1Swenshuai.xi 356*53ee8cc1Swenshuai.xi /* Create a Per-Process Timer, P1003.1b-1993, p. 264 */ 357*53ee8cc1Swenshuai.xi 358*53ee8cc1Swenshuai.xi int _EXFUN(timer_create, 359*53ee8cc1Swenshuai.xi (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)); 360*53ee8cc1Swenshuai.xi 361*53ee8cc1Swenshuai.xi /* Delete a Per_process Timer, P1003.1b-1993, p. 266 */ 362*53ee8cc1Swenshuai.xi 363*53ee8cc1Swenshuai.xi int _EXFUN(timer_delete, (timer_t timerid)); 364*53ee8cc1Swenshuai.xi 365*53ee8cc1Swenshuai.xi /* Per-Process Timers, P1003.1b-1993, p. 267 */ 366*53ee8cc1Swenshuai.xi 367*53ee8cc1Swenshuai.xi int _EXFUN(timer_settime, 368*53ee8cc1Swenshuai.xi (timer_t timerid, int flags, const struct itimerspec *value, 369*53ee8cc1Swenshuai.xi struct itimerspec *ovalue)); 370*53ee8cc1Swenshuai.xi int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value)); 371*53ee8cc1Swenshuai.xi int _EXFUN(timer_getoverrun, (timer_t timerid)); 372*53ee8cc1Swenshuai.xi 373*53ee8cc1Swenshuai.xi /* High Resolution Sleep, P1003.1b-1993, p. 269 */ 374*53ee8cc1Swenshuai.xi 375*53ee8cc1Swenshuai.xi int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp)); 376*53ee8cc1Swenshuai.xi 377*53ee8cc1Swenshuai.xi #ifdef __cplusplus 378*53ee8cc1Swenshuai.xi } 379*53ee8cc1Swenshuai.xi #endif 380*53ee8cc1Swenshuai.xi #endif /* _POSIX_TIMERS */ 381*53ee8cc1Swenshuai.xi 382*53ee8cc1Swenshuai.xi #ifdef __cplusplus 383*53ee8cc1Swenshuai.xi extern "C" { 384*53ee8cc1Swenshuai.xi #endif 385*53ee8cc1Swenshuai.xi 386*53ee8cc1Swenshuai.xi /* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */ 387*53ee8cc1Swenshuai.xi 388*53ee8cc1Swenshuai.xi /* values for the clock enable attribute */ 389*53ee8cc1Swenshuai.xi 390*53ee8cc1Swenshuai.xi #define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */ 391*53ee8cc1Swenshuai.xi #define CLOCK_DISABLED 0 /* clock is disabled */ 392*53ee8cc1Swenshuai.xi 393*53ee8cc1Swenshuai.xi /* values for the pthread cputime_clock_allowed attribute */ 394*53ee8cc1Swenshuai.xi 395*53ee8cc1Swenshuai.xi #define CLOCK_ALLOWED 1 /* If a thread is created with this value a */ 396*53ee8cc1Swenshuai.xi /* CPU-time clock attached to that thread */ 397*53ee8cc1Swenshuai.xi /* shall be accessible. */ 398*53ee8cc1Swenshuai.xi #define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */ 399*53ee8cc1Swenshuai.xi /* thread shall not have a CPU-time clock */ 400*53ee8cc1Swenshuai.xi /* accessible. */ 401*53ee8cc1Swenshuai.xi 402*53ee8cc1Swenshuai.xi /* Manifest Constants, P1003.1b-1993, p. 262 */ 403*53ee8cc1Swenshuai.xi 404*53ee8cc1Swenshuai.xi #define CLOCK_REALTIME (clockid_t)1 405*53ee8cc1Swenshuai.xi 406*53ee8cc1Swenshuai.xi /* Flag indicating time is "absolute" with respect to the clock 407*53ee8cc1Swenshuai.xi associated with a time. */ 408*53ee8cc1Swenshuai.xi 409*53ee8cc1Swenshuai.xi #define TIMER_ABSTIME 4 410*53ee8cc1Swenshuai.xi 411*53ee8cc1Swenshuai.xi /* Manifest Constants, P1003.4b/D8, p. 55 */ 412*53ee8cc1Swenshuai.xi 413*53ee8cc1Swenshuai.xi #if defined(_POSIX_CPUTIME) 414*53ee8cc1Swenshuai.xi 415*53ee8cc1Swenshuai.xi /* When used in a clock or timer function call, this is interpreted as 416*53ee8cc1Swenshuai.xi the identifier of the CPU_time clock associated with the PROCESS 417*53ee8cc1Swenshuai.xi making the function call. */ 418*53ee8cc1Swenshuai.xi 419*53ee8cc1Swenshuai.xi #define CLOCK_PROCESS_CPUTIME (clockid_t)2 420*53ee8cc1Swenshuai.xi 421*53ee8cc1Swenshuai.xi #endif 422*53ee8cc1Swenshuai.xi 423*53ee8cc1Swenshuai.xi #if defined(_POSIX_THREAD_CPUTIME) 424*53ee8cc1Swenshuai.xi 425*53ee8cc1Swenshuai.xi /* When used in a clock or timer function call, this is interpreted as 426*53ee8cc1Swenshuai.xi the identifier of the CPU_time clock associated with the THREAD 427*53ee8cc1Swenshuai.xi making the function call. */ 428*53ee8cc1Swenshuai.xi 429*53ee8cc1Swenshuai.xi #define CLOCK_THREAD_CPUTIME (clockid_t)3 430*53ee8cc1Swenshuai.xi 431*53ee8cc1Swenshuai.xi #endif 432*53ee8cc1Swenshuai.xi 433*53ee8cc1Swenshuai.xi #if defined(_POSIX_CPUTIME) 434*53ee8cc1Swenshuai.xi 435*53ee8cc1Swenshuai.xi /* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */ 436*53ee8cc1Swenshuai.xi 437*53ee8cc1Swenshuai.xi int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id)); 438*53ee8cc1Swenshuai.xi 439*53ee8cc1Swenshuai.xi #endif /* _POSIX_CPUTIME */ 440*53ee8cc1Swenshuai.xi 441*53ee8cc1Swenshuai.xi #if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME) 442*53ee8cc1Swenshuai.xi 443*53ee8cc1Swenshuai.xi /* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */ 444*53ee8cc1Swenshuai.xi 445*53ee8cc1Swenshuai.xi int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr)); 446*53ee8cc1Swenshuai.xi int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr)); 447*53ee8cc1Swenshuai.xi 448*53ee8cc1Swenshuai.xi #endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */ 449*53ee8cc1Swenshuai.xi 450*53ee8cc1Swenshuai.xi #ifdef __cplusplus 451*53ee8cc1Swenshuai.xi } 452*53ee8cc1Swenshuai.xi #endif 453*53ee8cc1Swenshuai.xi 454*53ee8cc1Swenshuai.xi #endif /* _TIME_H_ */ 455*53ee8cc1Swenshuai.xi 456