Show
Ignore:
Timestamp:
04/09/08 22:55:17 (9 months ago)
Author:
aturner
Message:

writing to the ioport is complex enough it prolly doesn't belong full bore in
the header. refs #41

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • features/performance/src/sleep.h

    r1971 r1972  
    8787 
    8888/*  
    89  * Not sure if this is any better then a gettimeofday() loop, but  
    90  * in order to find out, nap needs to be a timespec (nanosec precision) 
     89 * Apple's AbsoluteTime functions give at least .1usec precision 
     90 * which is pretty damn sweet 
    9191 */ 
    9292static inline void 
     
    140140void ioport_sleep_init(void); 
    141141 
    142 static inline void  
    143 ioport_sleep(const struct timespec nap)  
    144 { 
    145     struct timeval nap_for; 
    146     u_int32_t usec; 
    147     time_t i; 
    148      
    149     TIMESPEC_TO_TIMEVAL(&nap_for, &nap); 
    150      
    151     /*  
    152      * process the seconds, we do this in a loop so we don't have to  
    153      * use slower 64bit integers or worry about integer overflows. 
    154      */ 
    155     for (i = 0; i < nap_for.tv_sec; i ++) { 
    156         usec = SEC_TO_MICROSEC(nap_for.tv_sec); 
    157         while (usec > 0) { 
    158             usec --; 
    159             outb(ioport_sleep_value, 0x80); 
    160         } 
    161     } 
    162      
    163     /* process the usec */ 
    164     usec = nap.tv_nsec / 1000; 
    165     usec --; /* fudge factor for all the above */ 
    166     while (usec > 0) { 
    167         usec --; 
    168         outb(ioport_sleep_value, 0x80); 
    169     } 
    170 } 
     142void ioport_sleep(const struct timespec nap); 
    171143 
    172144#endif /* __SLEEP_H__ */