Example #1
0
/*
 *  read binary time info.  all numbers are little endian.
 *  ticks and nsec are syncronized.
 */
static int
readbintime(char *buf, int n)
{
	int i;
	int64_t nsec, ticks;
	uint8_t *b = (uint8_t*)buf;

	i = 0;
	if(fasthz == 0LL)
		fastticks((uint64_t*)&fasthz);
	nsec = todget(&ticks);
	if(n >= 3*sizeof(uint64_t)){
		int64_t2le(b+2*sizeof(uint64_t), fasthz);
		i += sizeof(uint64_t);
	}
	if(n >= 2*sizeof(uint64_t)){
		int64_t2le(b+sizeof(uint64_t), ticks);
		i += sizeof(uint64_t);
	}
	if(n >= 8){
		int64_t2le(b, nsec);
		i += sizeof(int64_t);
	}
	return i;
}
Example #2
0
/*
 *  read binary time info.  all numbers are little endian.
 *  ticks and nsec are syncronized.
 */
static int readbintime(char *buf, int n)
{
    int i;
    int64_t nsec, ticks;
    uint8_t *b = (uint8_t *) buf;

    i = 0;
    if (fasthz == 0LL)
        fasthz = system_timing.tsc_freq;
#if 0
    fastticks((uint64_t *) & fasthz);
    nsec = todget(&ticks);
#endif
    ticks = read_tsc();
    nsec = tsc2nsec(ticks);
    if (n >= 3 * sizeof(uint64_t)) {
        int64_t2le(b + 2 * sizeof(uint64_t), fasthz);
        i += sizeof(uint64_t);
    }
    if (n >= 2 * sizeof(uint64_t)) {
        int64_t2le(b + sizeof(uint64_t), ticks);
        i += sizeof(uint64_t);
    }
    if (n >= 8) {
        int64_t2le(b, nsec);
        i += sizeof(int64_t);
    }
    return i;
}