stylistic changes for the windows support ifdefs
This commit is contained in:
@@ -14,13 +14,12 @@ $ ./run
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#ifndef _WIN32
|
#if defined _WIN32
|
||||||
#include <unistd.h>
|
#include "win.h"
|
||||||
#include <sys/mman.h>
|
|
||||||
#else
|
#else
|
||||||
#include "win.h"
|
#include <unistd.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Transformer and RunState structs, and related memory management
|
// Transformer and RunState structs, and related memory management
|
||||||
|
|
||||||
@@ -366,17 +365,14 @@ int argmax(float* v, int n) {
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
long time_in_ms() {
|
long time_in_ms() {
|
||||||
#ifndef _WIN32
|
#if defined _WIN32
|
||||||
struct timespec time;
|
// windows specific way to get time
|
||||||
// Get the current time with nanosecond precision
|
|
||||||
if (clock_gettime(CLOCK_REALTIME, &time) == 0) {
|
|
||||||
return time.tv_sec * 1000 + time.tv_nsec / 1000000;
|
|
||||||
} else {
|
|
||||||
perror("clock_gettime");
|
|
||||||
return -1; // Return -1 to indicate an error
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return GetTickCount();
|
return GetTickCount();
|
||||||
|
#else
|
||||||
|
// linux specific way to get time
|
||||||
|
struct timespec time;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &time);
|
||||||
|
return time.tv_sec * 1000 + time.tv_nsec / 1000000;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user