Created
July 14, 2022 01:05
-
-
Save AlexAtkinson/631ecd558402a3b579a0334148d4f366 to your computer and use it in GitHub Desktop.
C: Get date +'%s%N' out of macos...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
cat << EOF > epochInµsec.c | |
#include <stdio.h> | |
#include <sys/time.h> | |
__asm__(".symver realpath,realpath@GLIBC_2.0"); | |
int main(void) | |
{ | |
struct timeval time_now; | |
gettimeofday(&time_now,NULL); | |
int s = time_now.tv_sec; | |
int us = time_now.tv_usec; | |
//printf("%ld%ld\n",time_now.tv_sec,time_now.tv_usec); | |
printf("%10d%06d\n",s,us); | |
return 0; | |
} | |
EOF | |
cc -o ts epochInµsec.c | |
./ts | |
rm -f ts epochInµsec.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment