sprintf_s uses that function and VS2010 does not strip it off even if it is unused. Also do not use 64-bit integer division in the timer code because that will create unwanted references to ___moddi3 and ___divdi3.tags/v0.99.beta19
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* libcaca Colour ASCII-Art library | * libcaca Colour ASCII-Art library | ||||
* Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net> | |||||
* Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net> | |||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
* This library is free software. It comes without any warranty, to | * This library is free software. It comes without any warranty, to | ||||
@@ -31,6 +31,7 @@ | |||||
#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 | #if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 | ||||
int sprintf_s(char *s, size_t n, const char *fmt, ...) CACA_WEAK; | int sprintf_s(char *s, size_t n, const char *fmt, ...) CACA_WEAK; | ||||
int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) CACA_WEAK; | |||||
#endif | #endif | ||||
struct caca_charfont | struct caca_charfont | ||||
@@ -640,6 +641,11 @@ int sprintf_s(char *s, size_t n, const char *fmt, ...) | |||||
va_end(args); | va_end(args); | ||||
return ret; | return ret; | ||||
} | } | ||||
int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) | |||||
{ | |||||
return 0; | |||||
} | |||||
#endif | #endif | ||||
/* | /* | ||||
@@ -38,7 +38,8 @@ | |||||
#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 | #if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 | ||||
int vsnprintf_s(char *s, size_t n, size_t c, | int vsnprintf_s(char *s, size_t n, size_t c, | ||||
const char *fmt, va_list args) CACA_WEAK; | |||||
const char *fmt, va_list ap) CACA_WEAK; | |||||
int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) CACA_WEAK; | |||||
#endif | #endif | ||||
/** \brief Set cursor position. | /** \brief Set cursor position. | ||||
@@ -607,9 +608,14 @@ int caca_set_canvas_boundaries(caca_canvas_t *cv, int x, int y, int w, int h) | |||||
*/ | */ | ||||
#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 | #if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3 | ||||
int vsnprintf_s(char *s, size_t n, size_t c, const char *fmt, va_list args) | |||||
int vsnprintf_s(char *s, size_t n, size_t c, const char *fmt, va_list ap) | |||||
{ | { | ||||
return vsnprintf(s, n, fmt, args); | |||||
return vsnprintf(s, n, fmt, ap); | |||||
} | |||||
int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) | |||||
{ | |||||
return 0; | |||||
} | } | ||||
#endif | #endif | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* libcaca Colour ASCII-Art library | * libcaca Colour ASCII-Art library | ||||
* Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net> | |||||
* Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net> | |||||
* All Rights Reserved | * All Rights Reserved | ||||
* | * | ||||
* This library is free software. It comes without any warranty, to | * This library is free software. It comes without any warranty, to | ||||
@@ -35,10 +35,10 @@ | |||||
void _caca_sleep(int usec) | void _caca_sleep(int usec) | ||||
{ | { | ||||
#if defined(HAVE_USLEEP) | |||||
usleep(usec); | |||||
#elif defined(HAVE_SLEEP) | |||||
#if defined(HAVE_SLEEP) | |||||
Sleep((usec + 500) / 1000); | Sleep((usec + 500) / 1000); | ||||
#elif defined(HAVE_USLEEP) | |||||
usleep(usec); | |||||
#else | #else | ||||
/* SLEEP */ | /* SLEEP */ | ||||
#endif | #endif | ||||
@@ -46,29 +46,33 @@ void _caca_sleep(int usec) | |||||
int _caca_getticks(caca_timer_t *timer) | int _caca_getticks(caca_timer_t *timer) | ||||
{ | { | ||||
#if defined(HAVE_GETTIMEOFDAY) | |||||
#if defined(USE_WIN32) | |||||
LARGE_INTEGER tmp; | |||||
static double freq = -1.0; /* FIXME: can this move to caca_context? */ | |||||
double seconds; | |||||
#elif defined(HAVE_GETTIMEOFDAY) | |||||
struct timeval tv; | struct timeval tv; | ||||
#elif defined(USE_WIN32) | |||||
static __int64 freq = -1; /* FIXME: can this move to caca_context? */ | |||||
__int64 usec; | |||||
#endif | #endif | ||||
int ticks = 0; | int ticks = 0; | ||||
int new_sec, new_usec; | int new_sec, new_usec; | ||||
#if defined(HAVE_GETTIMEOFDAY) | |||||
gettimeofday(&tv, NULL); | |||||
new_sec = tv.tv_sec; | |||||
new_usec = tv.tv_usec; | |||||
#elif defined(USE_WIN32) | |||||
if(freq == -1) | |||||
#if defined(USE_WIN32) | |||||
if (freq < 0.0) | |||||
{ | { | ||||
if(!QueryPerformanceFrequency((LARGE_INTEGER *)&freq)) | |||||
freq = 0; | |||||
if(!QueryPerformanceFrequency(&tmp)) | |||||
freq = 0.0; | |||||
else | |||||
freq = 1.0 / (double)tmp.QuadPart; | |||||
} | } | ||||
QueryPerformanceCounter((LARGE_INTEGER *)&usec); | |||||
new_sec = (int)(usec * 1000000 / freq / 1000000); | |||||
new_usec = (int)((usec * 1000000 / freq) % 1000000); | |||||
QueryPerformanceCounter(&tmp); | |||||
seconds = freq * (double)tmp.QuadPart; | |||||
new_sec = (int)seconds; | |||||
new_usec = (int)((seconds - new_sec) * 1000000.0); | |||||
#elif defined(HAVE_GETTIMEOFDAY) | |||||
gettimeofday(&tv, NULL); | |||||
new_sec = tv.tv_sec; | |||||
new_usec = tv.tv_usec; | |||||
#endif | #endif | ||||
if(timer->last_sec != 0) | if(timer->last_sec != 0) | ||||