mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
avoid redefining CLOCK_MONOTONIC and shit
This commit is contained in:
parent
5e17e23393
commit
2714708ca9
2 changed files with 31 additions and 17 deletions
|
@ -32,6 +32,7 @@ typedef double f64;
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__)
|
||||||
#include <_mingw.h>
|
#include <_mingw.h>
|
||||||
#if !defined(__MINGW64_VERSION_MAJOR)
|
#if !defined(__MINGW64_VERSION_MAJOR)
|
||||||
|
@ -40,4 +41,5 @@ typedef long ssize_t;
|
||||||
typedef ptrdiff_t ssize_t;
|
typedef ptrdiff_t ssize_t;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
#endif // _ULTRA64_TYPES_H_
|
||||||
|
|
|
@ -40,8 +40,6 @@
|
||||||
#define MAX_LIGHTS 2
|
#define MAX_LIGHTS 2
|
||||||
#define MAX_VERTICES 64
|
#define MAX_VERTICES 64
|
||||||
|
|
||||||
#define CLOCK_MONOTONIC 0
|
|
||||||
|
|
||||||
struct RGBA {
|
struct RGBA {
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
};
|
};
|
||||||
|
@ -157,23 +155,37 @@ static size_t buf_vbo_num_tris;
|
||||||
static struct GfxWindowManagerAPI *gfx_wapi;
|
static struct GfxWindowManagerAPI *gfx_wapi;
|
||||||
static struct GfxRenderingAPI *gfx_rapi;
|
static struct GfxRenderingAPI *gfx_rapi;
|
||||||
|
|
||||||
#if defined(__MINGW32__)
|
#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) && !defined(__APPLE__)
|
||||||
#include <_mingw.h>
|
// old mingw
|
||||||
#if !defined(__MINGW64_VERSION_MAJOR)
|
# include <_mingw.h>
|
||||||
|
# define NO_CLOCK_GETTIME
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_CLOCK_GETTIME
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
//https://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows
|
#define CLOCK_MONOTONIC 0
|
||||||
struct timespec { long tv_sec; long tv_nsec; }; //header part
|
// https://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows
|
||||||
int clock_gettime(int arg, struct timespec *spec) //C-file part
|
struct timespec { long tv_sec; long tv_nsec; };
|
||||||
{ __int64 wintime; GetSystemTimeAsFileTime((FILETIME*)&wintime);
|
int clock_gettime(int arg, struct timespec *spec) {
|
||||||
wintime -=116444736000000000LL; //1jan1601 to 1jan1970
|
__int64 wintime;
|
||||||
spec->tv_sec =wintime / 10000000LL; //seconds
|
GetSystemTimeAsFileTime((FILETIME*)&wintime);
|
||||||
spec->tv_nsec =wintime % 10000000LL*100; //nano-seconds
|
wintime -= 116444736000000000LL; //1jan1601 to 1jan1970
|
||||||
return 0;
|
spec->tv_sec = wintime / 10000000LL; //seconds
|
||||||
|
spec->tv_nsec = wintime % 10000000LL*100; //nano-seconds
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else // _WIN32
|
||||||
|
#error "Add a clock_gettime() impl for your platform!"
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
#else // NO_CLOCK_GETTIME
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
|
||||||
#endif
|
#endif // NO_CLOCK_GETTIME
|
||||||
|
|
||||||
static unsigned long get_time(void) {
|
static unsigned long get_time(void) {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
|
Loading…
Reference in a new issue