[Spice-commits] 2 commits - common/vdcommon.h common/vdlog.cpp common/vdlog.h

Christophe Fergau teuf at kemper.freedesktop.org
Tue Jan 22 03:45:05 PST 2013


 common/vdcommon.h |    4 ++++
 common/vdlog.cpp  |    5 +----
 common/vdlog.h    |   16 ++--------------
 3 files changed, 7 insertions(+), 18 deletions(-)

New commits:
commit 05af7a9786507cd729cb7505e5b103b47aa29852
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Fri Dec 21 09:33:41 2012 +0100

    Add OLDMSVCRT fallback for _ftime_s
    
    Aliasing _ftime_s to _ftime when OLDMSVCRT is defined makes it
    possible to remove the timestamp-less implementation of LOG()
    while still getting a binary working on Windows XP. I've tested
    this with a MinGW build, hopefully this won't break VC++ builds...

diff --git a/common/vdcommon.h b/common/vdcommon.h
index e50f2b0..cc3bd3d 100644
--- a/common/vdcommon.h
+++ b/common/vdcommon.h
@@ -46,5 +46,9 @@ typedef CRITICAL_SECTION mutex_t;
 #define swprintf_s(buf, sz, format...) swprintf(buf, format)
 #endif
 
+#ifdef OLDMSVCRT
+#define _ftime_s(timeb) _ftime(timeb)
+#endif
+
 #endif
 
diff --git a/common/vdlog.h b/common/vdlog.h
index 2ca03f3..6d0413b 100644
--- a/common/vdlog.h
+++ b/common/vdlog.h
@@ -25,6 +25,8 @@
 #include <time.h>
 #include <sys/timeb.h>
 
+#include "vdcommon.h"
+
 class VDLog {
 public:
     ~VDLog();
@@ -57,19 +59,6 @@ static unsigned int log_level = LOG_INFO;
     printf("%lu::%s::%s,%.3d::%s::" format "\n", GetCurrentThreadId(), type, datetime, ms, \
            __FUNCTION__, ## __VA_ARGS__);
 
-#ifdef OLDMSVCRT
-#define LOG(type, format, ...) do {                                     \
-    if (type >= log_level && type <= LOG_FATAL) {                       \
-        VDLog* log = VDLog::get();                                      \
-        const char *type_as_char[] = { "DEBUG", "INFO", "WARN", "ERROR", "FATAL" }; \
-        if (log) {                                                      \
-            log->PRINT_LINE(type_as_char[type], format, "", 0, ## __VA_ARGS__); \
-        } else {                                                        \
-            PRINT_LINE(type_as_char[type], format, "", 0, ## __VA_ARGS__); \
-        }                                                               \
-    }                                                                   \
-} while(0)
-#else
 #define LOG(type, format, ...) do {                                     \
     if (type >= log_level && type <= LOG_FATAL) {                       \
         VDLog* log = VDLog::get();                                      \
@@ -87,7 +76,6 @@ static unsigned int log_level = LOG_INFO;
         }                                                               \
     }                                                                   \
 } while(0)
-#endif
 
 
 #define vd_printf(format, ...) LOG(LOG_INFO, format, ## __VA_ARGS__)
commit 1e543873ead9507cc62f615c6cf0cc283733a97b
Author: Christophe Fergeau <cfergeau at redhat.com>
Date:   Thu Dec 20 20:25:32 2012 +0100

    vdlog: Get swprinft_s definition from vdcommon.h
    
    vdlog.cpp has an #ifdef check for OLDMSVC to choose between using
    swprintf or swprintf_s. Since vdcommon.h provides a compat #define
    for swprintf_s when OLDMSVC is set, it's better to use this one.

diff --git a/common/vdlog.cpp b/common/vdlog.cpp
index f84b5b3..76f4297 100644
--- a/common/vdlog.cpp
+++ b/common/vdlog.cpp
@@ -15,6 +15,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "vdcommon.h"
 #include "vdlog.h"
 #include <stdio.h>
 #include <stdarg.h>
@@ -52,11 +53,7 @@ VDLog* VDLog::get(TCHAR* path)
     }
     if (size != INVALID_FILE_SIZE && size > LOG_ROLL_SIZE) {
         TCHAR roll_path[MAX_PATH];
-#ifdef OLDMSVCRT
-        swprintf(roll_path, L"%s.1", path);
-#else
         swprintf_s(roll_path, MAX_PATH, L"%s.1", path);
-#endif
         if (!MoveFileEx(path, roll_path, MOVEFILE_REPLACE_EXISTING)) {
             return NULL;
         }


More information about the Spice-commits mailing list