Skip to content

Instantly share code, notes, and snippets.

Created July 6, 2015 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1af32dd7103295aba4e5 to your computer and use it in GitHub Desktop.
Save anonymous/1af32dd7103295aba4e5 to your computer and use it in GitHub Desktop.
static void taia_now_packed(u8 output[TAIA_LEN], int secoffset)
{
struct timeval now;
u64 sec;
u32 nano;
do_gettimeofday(&now);
sec = 4611686018427387914ULL + (u64)now.tv_sec + secoffset;
output[0] = (sec >> 56) & 0xff;
output[1] = (sec >> 48) & 0xff;
output[2] = (sec >> 40) & 0xff;
output[3] = (sec >> 32) & 0xff;
output[4] = (sec >> 24) & 0xff;
output[5] = (sec >> 16) & 0xff;
output[6] = (sec >> 8) & 0xff;
output[7] = (sec >> 0) & 0xff;
nano = 1000 * now.tv_usec + 500;
output[8] = (nano >> 24) & 0xff;
output[9] = (nano >> 16) & 0xff;
output[10] = (nano >> 8) & 0xff;
output[11] = (nano >> 0) & 0xff;
if (++output[15] == 0 && ++output[14] == 0 && ++output[13] == 0)
++output[12];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment