Changeset 4823 for libcaca


Ignore:
Timestamp:
Jun 17, 2012, 4:05:44 PM (7 years ago)
Author:
Sam Hocevar
Message:

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.

Location:
libcaca/trunk/caca
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/canvas.c

    r4822 r4823  
    11/*
    22 *  libcaca       Colour ASCII-Art library
    3  *  Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net>
     3 *  Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
  • libcaca/trunk/caca/figfont.c

    r4822 r4823  
    3232#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3
    3333int sprintf_s(char *s, size_t n, const char *fmt, ...) CACA_WEAK;
     34int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) CACA_WEAK;
    3435#endif
    3536
     
    641642    return ret;
    642643}
     644
     645int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
     646{
     647    return 0;
     648}
    643649#endif
    644650
  • libcaca/trunk/caca/string.c

    r4822 r4823  
    3939#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3
    4040int vsnprintf_s(char *s, size_t n, size_t c,
    41                 const char *fmt, va_list args) CACA_WEAK;
     41                const char *fmt, va_list ap) CACA_WEAK;
     42int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) CACA_WEAK;
    4243#endif
    4344
     
    608609
    609610#if defined _WIN32 && defined __GNUC__ && __GNUC__ >= 3
    610 int vsnprintf_s(char *s, size_t n, size_t c, const char *fmt, va_list args)
    611 {
    612     return vsnprintf(s, n, fmt, args);
     611int vsnprintf_s(char *s, size_t n, size_t c, const char *fmt, va_list ap)
     612{
     613    return vsnprintf(s, n, fmt, ap);
     614}
     615
     616int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
     617{
     618    return 0;
    613619}
    614620#endif
  • libcaca/trunk/caca/time.c

    r4369 r4823  
    11/*
    22 *  libcaca       Colour ASCII-Art library
    3  *  Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net>
     3 *  Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    3636void _caca_sleep(int usec)
    3737{
    38 #if defined(HAVE_USLEEP)
     38#if defined(HAVE_SLEEP)
     39    Sleep((usec + 500) / 1000);
     40#elif defined(HAVE_USLEEP)
    3941    usleep(usec);
    40 #elif defined(HAVE_SLEEP)
    41     Sleep((usec + 500) / 1000);
    4242#else
    4343    /* SLEEP */
     
    4747int _caca_getticks(caca_timer_t *timer)
    4848{
    49 #if defined(HAVE_GETTIMEOFDAY)
     49#if defined(USE_WIN32)
     50    LARGE_INTEGER tmp;
     51    static double freq = -1.0; /* FIXME: can this move to caca_context? */
     52    double seconds;
     53#elif defined(HAVE_GETTIMEOFDAY)
    5054    struct timeval tv;
    51 #elif defined(USE_WIN32)
    52     static __int64 freq = -1; /* FIXME: can this move to caca_context? */
    53     __int64 usec;
    5455#endif
    5556    int ticks = 0;
    5657    int new_sec, new_usec;
    5758
    58 #if defined(HAVE_GETTIMEOFDAY)
     59#if defined(USE_WIN32)
     60    if (freq < 0.0)
     61    {
     62        if(!QueryPerformanceFrequency(&tmp))
     63            freq = 0.0;
     64        else
     65            freq = 1.0 / (double)tmp.QuadPart;
     66    }
     67
     68    QueryPerformanceCounter(&tmp);
     69    seconds = freq * (double)tmp.QuadPart;
     70    new_sec = (int)seconds;
     71    new_usec = (int)((seconds - new_sec) * 1000000.0);
     72#elif defined(HAVE_GETTIMEOFDAY)
    5973    gettimeofday(&tv, NULL);
    6074    new_sec = tv.tv_sec;
    6175    new_usec = tv.tv_usec;
    62 #elif defined(USE_WIN32)
    63     if(freq == -1)
    64     {
    65         if(!QueryPerformanceFrequency((LARGE_INTEGER *)&freq))
    66             freq = 0;
    67     }
    68 
    69     QueryPerformanceCounter((LARGE_INTEGER *)&usec);
    70     new_sec = (int)(usec * 1000000 / freq / 1000000);
    71     new_usec = (int)((usec * 1000000 / freq) % 1000000);
    7276#endif
    7377
Note: See TracChangeset for help on using the changeset viewer.