Browse Source

build: ship a weak symbol for vsnprintf, too, because our weak symbol for

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
Sam Hocevar sam 12 years ago
parent
commit
cd61fce90e
4 changed files with 39 additions and 23 deletions
  1. +1
    -1
      caca/canvas.c
  2. +6
    -0
      caca/figfont.c
  3. +9
    -3
      caca/string.c
  4. +23
    -19
      caca/time.c

+ 1
- 1
caca/canvas.c View File

@@ -1,6 +1,6 @@
/*
* 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
*
* This library is free software. It comes without any warranty, to


+ 6
- 0
caca/figfont.c View File

@@ -31,6 +31,7 @@

#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3
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

struct caca_charfont
@@ -640,6 +641,11 @@ int sprintf_s(char *s, size_t n, const char *fmt, ...)
va_end(args);
return ret;
}

int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
{
return 0;
}
#endif

/*


+ 9
- 3
caca/string.c View File

@@ -38,7 +38,8 @@

#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3
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

/** \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
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



+ 23
- 19
caca/time.c View File

@@ -1,6 +1,6 @@
/*
* 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
*
* This library is free software. It comes without any warranty, to
@@ -35,10 +35,10 @@

void _caca_sleep(int usec)
{
#if defined(HAVE_USLEEP)
usleep(usec);
#elif defined(HAVE_SLEEP)
#if defined(HAVE_SLEEP)
Sleep((usec + 500) / 1000);
#elif defined(HAVE_USLEEP)
usleep(usec);
#else
/* SLEEP */
#endif
@@ -46,29 +46,33 @@ void _caca_sleep(int usec)

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;
#elif defined(USE_WIN32)
static __int64 freq = -1; /* FIXME: can this move to caca_context? */
__int64 usec;
#endif
int ticks = 0;
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

if(timer->last_sec != 0)


Loading…
Cancel
Save