1 #include <u.h> 2 #include <libc.h> 3 4 #define U32(x) (((((((x)[0]<<8)|(x)[1])<<8)|(x)[2])<<8)|(x)[3]) 5 6 vlong nsec(void)7nsec(void) 8 { 9 uchar b[8]; 10 int f, n; 11 12 if((f = open("/dev/bintime", OREAD)) >= 0){ 13 n = pread(f, b, sizeof(b), 0); 14 close(f); 15 if(n == sizeof(b)) 16 return (u64int)U32(b)<<32 | U32(b+4); 17 } 18 return 0; 19 } 20