Created
October 4, 2017 21:41
-
-
Save ConorOBrien-Foxx/821a3983d4aeaf2bd620990c1070039d to your computer and use it in GitHub Desktop.
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
#ifndef INCLUDE_MILLISECONDS | |
#define INCLUDE_MILLISECONDS | |
#include <time.h> | |
#ifdef __WIN32 | |
#include <windows.h> | |
#define M_OS_WINDOWS | |
#else | |
#include <sys/time.h> | |
#define M_OS_SANE | |
#endif | |
uint64_t milliseconds(void) { | |
#ifdef M_OS_WINDOWS | |
SYSTEMTIME time; | |
GetSystemTime(&time); | |
return (time.wSecond * 1000) + time.wMilliseconds; | |
#endif | |
#ifdef M_OS_SANE | |
struct timeval te; | |
gettimeofday(&te, NULL); | |
return te.tv_sec * 1000 + te.tv_usec / 1000; | |
#endif | |
} | |
#endif |
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
#include "milliseconds.h" | |
int main() { | |
printf("%llu", milliseconds()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment