[Spice-commits] 12 commits - client/application.cpp client/common.h client/jpeg_decoder.cpp client/jpeg_decoder.h client/Makefile.am client/mjpeg_decoder.cpp client/red_gdi_canvas.cpp client/windows common/backtrace.c common/backtrace.h common/bitops.h common/gdi_canvas.c common/ssl_verify.h common/sw_canvas.c

Alon Levy alon at kemper.freedesktop.org
Fri Jan 13 07:45:02 PST 2012


 client/Makefile.am                |   15 ++++++++++++++-
 client/application.cpp            |    7 +++++++
 client/common.h                   |    4 ++--
 client/jpeg_decoder.cpp           |    2 +-
 client/jpeg_decoder.h             |    2 +-
 client/mjpeg_decoder.cpp          |    2 +-
 client/red_gdi_canvas.cpp         |    3 +++
 client/windows/main.cpp           |    8 ++++++++
 client/windows/platform_utils.cpp |    4 ++--
 client/windows/red_pixmap_gdi.cpp |    3 +++
 client/windows/red_pixmap_sw.cpp  |    3 +++
 client/windows/red_window.cpp     |    3 +--
 common/backtrace.c                |   25 ++++++++++++++++++++++---
 common/backtrace.h                |    2 +-
 common/bitops.h                   |   28 ++++++++++++++--------------
 common/gdi_canvas.c               |   27 ++++++++++++---------------
 common/ssl_verify.h               |    2 +-
 common/sw_canvas.c                |    3 +++
 18 files changed, 99 insertions(+), 44 deletions(-)

New commits:
commit 8a36c625a64dee573c157256fe2a681a93a6aefe
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:58:08 2012 +0200

    common/ssl_verify: special case to WIN32 that isn't MINGW32

diff --git a/common/ssl_verify.h b/common/ssl_verify.h
index 8235c13..b8306f3 100644
--- a/common/ssl_verify.h
+++ b/common/ssl_verify.h
@@ -19,7 +19,7 @@
 #ifndef SSL_VERIFY_H
 #define SSL_VERIFY_H
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
 #include <windows.h>
 #include <wincrypt.h>
 #endif
commit 7a63185b9bf063fe23a470be4ecac6082cbb1a91
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:57:35 2012 +0200

    common/bitops: mingw32: reorder so __GNUC__ define is checked first

diff --git a/common/bitops.h b/common/bitops.h
index 449409b..bdd862a 100644
--- a/common/bitops.h
+++ b/common/bitops.h
@@ -27,7 +27,20 @@
 extern "C" {
 #endif
 
-#if defined(WIN32) && !defined(_WIN64)
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+static inline int spice_bit_find_msb(unsigned int val)
+{
+    int ret;
+
+    asm ("bsrl %1,%0\n\t"
+         "jnz 1f\n\t"
+         "movl $-1,%0\n"
+         "1:"
+         : "=r"(ret) : "r"(val));
+    return ret + 1;
+}
+
+#elif defined(WIN32) && !defined(_WIN64)
 static INLINE int spice_bit_find_msb(uint32_t val)
 {
     uint32_t r;
@@ -42,19 +55,6 @@ found:
     return r + 1;
 }
 
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
-static inline int spice_bit_find_msb(unsigned int val)
-{
-    int ret;
-
-    asm ("bsrl %1,%0\n\t"
-         "jnz 1f\n\t"
-         "movl $-1,%0\n"
-         "1:"
-         : "=r"(ret) : "r"(val));
-    return ret + 1;
-}
-
 #else
 static INLINE int spice_bit_find_msb(unsigned int val)
 {
commit c7f4e52000bfdd7a0f502abecd5da444c3709c38
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:56:59 2012 +0200

    common/backtrace: for mingw32 no pipe/wait_pid, just disable

diff --git a/common/backtrace.c b/common/backtrace.c
index 650dc1d..6fabdf0 100644
--- a/common/backtrace.c
+++ b/common/backtrace.c
@@ -26,8 +26,12 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
+#include <unistd.h>
 #include <sys/types.h>
+#ifndef __MINGW32__
 #include <sys/wait.h>
+#endif
+
 #include "spice_common.h"
 
 #define GSTACK_PATH "/usr/bin/gstack"
@@ -49,6 +53,10 @@ static void spice_backtrace_backtrace(void)
 }
 #endif
 
+/* XXX perhaps gstack can be available in windows but pipe/waitpid isn't,
+ * so until it is ported properly just compile it out, we lose the
+ * backtrace only. */
+#ifndef __MINGW32__
 static int spice_backtrace_gstack(void)
 {
     pid_t kidpid;
@@ -104,11 +112,22 @@ static int spice_backtrace_gstack(void)
     }
     return 0;
 }
+#else
+static int spice_backtrace_gstack(void)
+{
+    /* empty failing implementation */
+    return -1;
+}
+#endif
+
+void spice_backtrace(void)
+{
+    int ret = -1;
 
-void spice_backtrace() {
     if (!access(GSTACK_PATH, X_OK)) {
-        spice_backtrace_gstack();
-    } else {
+        ret = spice_backtrace_gstack();
+    }
+    if (ret != 0) {
         spice_backtrace_backtrace();
     }
 }
diff --git a/common/backtrace.h b/common/backtrace.h
index 8fcbb78..894c027 100644
--- a/common/backtrace.h
+++ b/common/backtrace.h
@@ -23,7 +23,7 @@
 
 SPICE_BEGIN_DECLS
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
 #define spice_backtrace()
 #else
 void spice_backtrace(void);
commit a9bf7497797ca24ae23e0c5e7f7e0a4a6096c309
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:56:07 2012 +0200

    client/windows: fix several assigned but not used errors

diff --git a/client/windows/red_window.cpp b/client/windows/red_window.cpp
index 981fe9a..89a33c9 100644
--- a/client/windows/red_window.cpp
+++ b/client/windows/red_window.cpp
@@ -179,9 +179,8 @@ LRESULT CALLBACK RedWindow_p::WindowProc(HWND hWnd, UINT message, WPARAM wParam,
     switch (message) {
     case WM_PAINT: {
         PAINTSTRUCT ps;
-        HDC hdc;
 
-        hdc = BeginPaint(hWnd, &ps);
+        BeginPaint(hWnd, &ps);
         SpicePoint origin = window->get_origin();
         SpiceRect r;
         r.left = ps.rcPaint.left - origin.x;
diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c
index 64fbbf5..5db3e83 100644
--- a/common/gdi_canvas.c
+++ b/common/gdi_canvas.c
@@ -461,9 +461,6 @@ static void copy_bitmap_alpha(const uint8_t *src_alpha, int height, int width, i
     uint8_t i_offset;
     int i_count = 0;
     int i = 0;
-    int width_div_stride;
-
-    width_div_stride = width / src_stride;
 
     if (alpha_bits_size == 1) {
         i_offset = 1;
@@ -1602,7 +1599,6 @@ static void gdi_canvas_draw_text(SpiceCanvas *spice_canvas, SpiceRect *bbox, Spi
 
 static uint32_t *gdi_get_userstyle(GdiCanvas *canvas, uint8_t nseg, SPICE_FIXED28_4* style, int start_is_gap)
 {
-    double offset = 0;
     uint32_t *local_style;
     int i;
 
@@ -1612,7 +1608,6 @@ static uint32_t *gdi_get_userstyle(GdiCanvas *canvas, uint8_t nseg, SPICE_FIXED2
     local_style = spice_new(uint32_t , nseg);
 
     if (start_is_gap) {
-        offset = (uint32_t)fix_to_double(*style);
         local_style[nseg - 1] = (uint32_t)fix_to_double(*style);
         style++;
 
@@ -1815,24 +1810,23 @@ SpiceCanvas *gdi_canvas_create(int width, int height,
                             )
 {
     GdiCanvas *canvas;
-    int init_ok;
 
     if (need_init) {
         return NULL;
     }
     canvas = spice_new0(GdiCanvas, 1);
-    init_ok = canvas_base_init(&canvas->base, &gdi_canvas_ops,
-                               width, height, format
+    canvas_base_init(&canvas->base, &gdi_canvas_ops,
+                     width, height, format,
 #ifdef SW_CANVAS_CACHE
-                               ,bits_cache
-                               ,palette_cache
+                     bits_cache,
+                     palette_cache,
 #elif defined(SW_CANVAS_IMAGE_CACHE)
-                               , bits_cache
+                     bits_cache,
 #endif
-                               , surfaces
-                               , glz_decoder
-                               , jpeg_decoder
-                               , zlib_decoder);
+                     surfaces,
+                     glz_decoder,
+                     jpeg_decoder,
+                     zlib_decoder);
     canvas->dc = dc;
     canvas->lock = lock;
     return (SpiceCanvas *)canvas;
commit 96c292a0b491ac1ed8d352b4ee0bb099a6ec7332
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:55:30 2012 +0200

    client/windows: arraysize(inf.bmiColors) == 1 in mingw32

diff --git a/client/windows/red_pixmap_gdi.cpp b/client/windows/red_pixmap_gdi.cpp
index 4336f46..2d93113 100644
--- a/client/windows/red_pixmap_gdi.cpp
+++ b/client/windows/red_pixmap_gdi.cpp
@@ -64,9 +64,12 @@ RedPixmapGdi::RedPixmapGdi(int width, int height, RedDrawable::Format format, bo
         bitmap_info.inf.bmiColors[0].rgbRed = 0;
         bitmap_info.inf.bmiColors[0].rgbGreen = 0;
         bitmap_info.inf.bmiColors[0].rgbBlue = 0;
+#ifndef __MINGW32__
+        // inf.bmiColors is [1] in mingw/include/wingdi.h
         bitmap_info.inf.bmiColors[1].rgbRed = 0xff;
         bitmap_info.inf.bmiColors[1].rgbGreen = 0xff;
         bitmap_info.inf.bmiColors[1].rgbBlue = 0xff;
+#endif
         break;
      case RedDrawable::RGB16_565:
         pixel_format = (DWORD *)bitmap_info.inf.bmiColors;
diff --git a/client/windows/red_pixmap_sw.cpp b/client/windows/red_pixmap_sw.cpp
index 991b673..9ed1460 100644
--- a/client/windows/red_pixmap_sw.cpp
+++ b/client/windows/red_pixmap_sw.cpp
@@ -77,9 +77,12 @@ RedPixmapSw::RedPixmapSw(int width, int height, RedDrawable::Format format,
         bitmap_info.inf.bmiColors[0].rgbRed = 0;
         bitmap_info.inf.bmiColors[0].rgbGreen = 0;
         bitmap_info.inf.bmiColors[0].rgbBlue = 0;
+#ifndef __MINGW32__
+        // inf.bmiColors is [1] in mingw/include/wingdi.h
         bitmap_info.inf.bmiColors[1].rgbRed = 0xff;
         bitmap_info.inf.bmiColors[1].rgbGreen = 0xff;
         bitmap_info.inf.bmiColors[1].rgbBlue = 0xff;
+#endif
         break;
     case RedDrawable::RGB16_565:
         pixel_format = (DWORD *)bitmap_info.inf.bmiColors;
commit fe6119764379e20336989585fb13ab1a3ba945bc
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:54:50 2012 +0200

    client/windows: fix typo, make error messages unique

diff --git a/client/windows/platform_utils.cpp b/client/windows/platform_utils.cpp
index b57e921..a4405c1 100644
--- a/client/windows/platform_utils.cpp
+++ b/client/windows/platform_utils.cpp
@@ -51,7 +51,7 @@ HBITMAP get_bitmap_res(int id)
 {
     HBITMAP bitmap = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(id));
     if (!bitmap) {
-        THROW("get bitmpa #%d failed", id);
+        THROW("get bitmap #%d failed", id);
     }
     return bitmap;
 }
@@ -61,7 +61,7 @@ HBITMAP get_alpha_bitmap_res(int id)
     AutoGDIObject bitmap(LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0,
                                    LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_SHARED));
     if (!bitmap.valid()) {
-        THROW("get bitmpa #%d failed", id);
+        THROW("get alpha bitmap #%d failed", id);
     }
 
     BITMAP src_info;
commit 54a7b36a57618b7c43d64c6b063fe367d700be48
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:42:09 2012 +0200

    client/windows/main: mingw32 provides PACKAGE_VERSION

diff --git a/client/windows/main.cpp b/client/windows/main.cpp
index 6204498..46af699 100644
--- a/client/windows/main.cpp
+++ b/client/windows/main.cpp
@@ -41,6 +41,13 @@ static void init_winsock()
     }
 }
 
+#ifdef __MINGW32__
+// XXX: for mingw32 we can do both actually, but it seems easier
+// to just use the autoconf provided PACKAGE_VERSION.
+static void init_version_string()
+{
+}
+#else
 const char* PACKAGE_VERSION = "???";
 static char _version_string[40];
 
@@ -68,6 +75,7 @@ static void init_version_string()
         (int)(file_info->dwFileVersionLS & 0x0ffff));
     PACKAGE_VERSION = _version_string;
 }
+#endif
 
 int WINAPI WinMain(HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
commit 4236d1440b328223fec50a0367647740f38abcd6
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:41:18 2012 +0200

    client/common: mingw32: workaround HAVE_STDLIB_H redefined in jconfig.h

diff --git a/client/red_gdi_canvas.cpp b/client/red_gdi_canvas.cpp
index ed091af..6ac2e8a 100644
--- a/client/red_gdi_canvas.cpp
+++ b/client/red_gdi_canvas.cpp
@@ -15,6 +15,9 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 #ifdef HAVE_CONFIG_H
+#ifdef __MINGW32__
+#undef HAVE_STDLIB_H
+#endif
 #include <config.h>
 #endif
 
diff --git a/common/gdi_canvas.c b/common/gdi_canvas.c
index f67aadf..64fbbf5 100644
--- a/common/gdi_canvas.c
+++ b/common/gdi_canvas.c
@@ -16,6 +16,9 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 #ifdef HAVE_CONFIG_H
+#ifdef __MINGW32__
+#undef HAVE_STDLIB_H
+#endif
 #include <config.h>
 #endif
 
diff --git a/common/sw_canvas.c b/common/sw_canvas.c
index 651c52b..0f67c80 100644
--- a/common/sw_canvas.c
+++ b/common/sw_canvas.c
@@ -16,6 +16,9 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 #ifdef HAVE_CONFIG_H
+#ifdef __MINGW32__
+#undef HAVE_STDLIB_H
+#endif
 #include <config.h>
 #endif
 
commit be3711f8b476c4da9b32676757e57c63596f9890
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:39:49 2012 +0200

    client: mingw32 build needs the jpeg_boolean define

diff --git a/client/jpeg_decoder.cpp b/client/jpeg_decoder.cpp
index 4bc4f18..19d22e3 100644
--- a/client/jpeg_decoder.cpp
+++ b/client/jpeg_decoder.cpp
@@ -23,7 +23,7 @@
 #include "debug.h"
 #include "utils.h"
 
-#if !defined(jpeg_boolean) && !defined(__MINGW32__)
+#if !defined(jpeg_boolean)
 #define jpeg_boolean boolean
 #endif
 
diff --git a/client/jpeg_decoder.h b/client/jpeg_decoder.h
index 34aa336..45d75d7 100644
--- a/client/jpeg_decoder.h
+++ b/client/jpeg_decoder.h
@@ -22,7 +22,7 @@
 #include "common.h"
 #include "red_canvas_base.h"
 
-#ifdef WIN32
+#if defined(WIN32) && !defined(__MINGW32__)
 /* We need some hacks to avoid warnings from the jpeg headers */
 #define XMD_H
 #undef FAR
diff --git a/client/mjpeg_decoder.cpp b/client/mjpeg_decoder.cpp
index 0ac6eae..28d4f08 100644
--- a/client/mjpeg_decoder.cpp
+++ b/client/mjpeg_decoder.cpp
@@ -24,7 +24,7 @@
 #include "utils.h"
 #include "mjpeg_decoder.h"
 
-#if !defined(jpeg_boolean) && !defined(__MINGW32__)
+#if !defined(jpeg_boolean)
 #define jpeg_boolean boolean
 #endif
 
commit 5430f3a61f63b75fef1785de411fe0c0b82002bf
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:37:42 2012 +0200

    client/common.h: mingw32 fix
    
    define PACKAGE_VERSION only ifndef __GNUC__
    Since it is defined by autoconf and so it kinda comes with using the GNU
    compilers.

diff --git a/client/common.h b/client/common.h
index 8b4e39d..e9572bd 100644
--- a/client/common.h
+++ b/client/common.h
@@ -58,12 +58,12 @@
 #pragma warning(disable:4355)
 #pragma warning(disable:4996)
 #pragma warning(disable:4200)
+
+extern const char* PACKAGE_VERSION;
 #endif
 
 #define strcasecmp stricmp
 
-extern const char* PACKAGE_VERSION;
-
 #else
 #include <unistd.h>
 #include <X11/X.h>
commit 01102ff62b96ac67089f75bc5dc404f3d49f1d88
Author: Alon Levy <alevy at redhat.com>
Date:   Fri Jan 13 12:35:38 2012 +0200

    client/Makefile.am: mingw32 fixes
    
    * build resource file with windres
    * include client/windows and not client/x11
    * use CXIMAGE_CFLAGS (it's already set to -DDISABLE_CXIMAGE correctly)

diff --git a/client/Makefile.am b/client/Makefile.am
index f7c9c56..c4b5fe1 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -136,6 +136,11 @@ spicec_SOURCES +=			\
 	windows/stdint.h		\
 	windows/win_platform.h		\
 	$(NULL)
+
+spicec_resource_LDADD = windows/redc.o
+
+windows/redc.o: windows/redc.rc
+	$(WINDRES) $< -o $@
 else
 spicec_SOURCES +=			\
 	x11/atomic_count.h		\
@@ -167,6 +172,12 @@ spicec_SOURCES +=			\
 	$(NULL)
 endif
 
+if OS_WIN32
+PLATFORM_INCLUDES=-I$(top_srcdir)/client/windows
+else
+PLATFORM_INCLUDES=-I$(top_srcdir)/client/x11
+endif
+
 if SUPPORT_TUNNEL
 spicec_SOURCES +=		\
 	tunnel_channel.cpp	\
@@ -210,7 +221,7 @@ endif
 
 INCLUDES = \
 	-D__STDC_LIMIT_MACROS				\
-	-I$(top_srcdir)/client/x11			\
+	$(PLATFORM_INCLUDES)				\
 	-I$(top_srcdir)/common				\
 	$(ALSA_CFLAGS)					\
 	$(CEGUI_CFLAGS)					\
@@ -227,6 +238,7 @@ INCLUDES = \
 	$(XFIXES_CFLAGS)				\
 	$(WARN_CFLAGS)					\
 	$(XINERAMA_CFLAGS)				\
+	$(CXIMAGE_CFLAGS)				\
 	$(NULL)
 
 spicec_LDFLAGS = $(SPICEC_STATIC_LINKAGE_BSTATIC)
@@ -248,6 +260,7 @@ spicec_LDADD =						\
 	$(XRANDR_LIBS)					\
 	$(Z_LIBS)					\
 	$(XINERAMA_LIBS)				\
+	$(spicec_resource_LDADD)			\
 	$(NULL)
 
 EXTRA_DIST =				\
commit 9d2768d7de0d17fea15b5bfaff5b73eee5f57891
Author: Alon Levy <alevy at redhat.com>
Date:   Mon Dec 19 15:33:45 2011 +0200

    client: log command line (rhbz 767581)

diff --git a/client/application.cpp b/client/application.cpp
index e120dfe..b92b648 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -2645,6 +2645,13 @@ int Application::main(int argc, char** argv, const char* version_str)
 
     init_globals();
     LOG_INFO("starting %s", version_str);
+    std::string command_line = argv[0];
+    for (int i = 1 ; i < argc ; ++i) {
+        command_line += " ";
+        command_line += argv[i];
+    }
+    LOG_INFO("command line: %s", command_line.c_str());
+
     std::auto_ptr<Application> app(new Application());
     AutoAbort auto_abort(*app.get());
     if (app->process_cmd_line(argc, argv, full_screen)) {


More information about the Spice-commits mailing list