[Spice-commits] 9 commits - client/application.cpp client/cmd_line_parser.cpp client/common.h client/mjpeg_decoder.cpp client/threads.cpp client/x11 common/lines.c configure.ac

Alexander Larsson alexl at kemper.freedesktop.org
Wed Sep 29 06:08:52 PDT 2010


 client/application.cpp     |    9 +--------
 client/cmd_line_parser.cpp |   18 +-----------------
 client/common.h            |    4 ++++
 client/mjpeg_decoder.cpp   |    4 ----
 client/threads.cpp         |   10 +++++++++-
 client/x11/Makefile.am     |    3 +--
 client/x11/atomic_count.h  |    2 ++
 client/x11/main.cpp        |    1 -
 client/x11/platform.cpp    |   14 +++++++++++---
 common/lines.c             |    2 +-
 configure.ac               |   22 ++++++++++++++++++++++
 11 files changed, 52 insertions(+), 37 deletions(-)

New commits:
commit 92d286c6b51f6ef363d35e3482792fddc8c3af7d
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 15:08:05 2010 +0200

    client: Re-enable USE_XRANDR_1_2
    
    This was disabled by mistake before.

diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index 65af063..1133414 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -66,7 +66,7 @@
 //#define X_DEBUG_SYNC(display) XSync(display, False)
 #define X_DEBUG_SYNC(display)
 #ifdef HAVE_XRANDR12
-//#define USE_XRANDR_1_2
+#define USE_XRANDR_1_2
 #endif
 
 static Display* x_display = NULL;
commit d8faf813e77996200cd3f4ce75031122c1936c2c
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 13:37:48 2010 +0200

    client: Don't hardcode -lrt
    
    -lrt is already included in SPICE_NONPKGCONFIG_LIBS if needed so no
    need to add it to the command line manually.

diff --git a/client/x11/Makefile.am b/client/x11/Makefile.am
index 101f6dd..a992aa1 100644
--- a/client/x11/Makefile.am
+++ b/client/x11/Makefile.am
@@ -203,5 +203,4 @@ spicec_LDADD =						\
 	$(GL_LIBS)					\
 	$(XRANDR_LIBS)					\
 	$(MISC_X_LIBS)					\
-	$(CEGUI_LIBS)					\
-	-lrt
+	$(CEGUI_LIBS)
commit 3f3283ee17d3318fa9bfb5c9900c06dbec434568
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 13:35:18 2010 +0200

    client: Fall back to gettimeofday if clock_gettime not found

diff --git a/client/threads.cpp b/client/threads.cpp
index a9b8ea5..eb4b7a1 100644
--- a/client/threads.cpp
+++ b/client/threads.cpp
@@ -22,6 +22,9 @@
 #ifdef WIN32
 #include <sys/timeb.h>
 #endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
 
 Thread::Thread(thread_main_t thread_main, void* opaque)
 {
@@ -43,8 +46,13 @@ static inline void rel_time(struct timespec& time, uint64_t delta_nano)
     _ftime_s(&now);
     time.tv_sec = (long)now.time;
     time.tv_nsec = now.millitm * 1000 * 1000;
-#else
+#elif defined(HAVE_CLOCK_GETTIME)
     clock_gettime(CLOCK_MONOTONIC, &time);
+#else
+    struct timeval tv;
+    gettimeofday(&tv,NULL);
+    time.tv_sec = tv.tv_sec;
+    time.tv_nsec = tv.tv_usec*1000;
 #endif
     delta_nano += (uint64_t)time.tv_sec * 1000 * 1000 * 1000;
     delta_nano += time.tv_nsec;
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index a87dcfa..65af063 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -41,6 +41,9 @@
 #include <values.h>
 #include <signal.h>
 #include <sys/shm.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
 
 #include "platform.h"
 #include "application.h"
@@ -425,9 +428,15 @@ void Platform::send_quit_request()
 
 uint64_t Platform::get_monolithic_time()
 {
+#ifdef HAVE_CLOCK_GETTIME
     struct timespec time_space;
     clock_gettime(CLOCK_MONOTONIC, &time_space);
     return uint64_t(time_space.tv_sec) * 1000 * 1000 * 1000 + uint64_t(time_space.tv_nsec);
+#else
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    return uint64_t(tv.tv_sec) * 1000 * 1000 * 1000 + uint64_t(tv.tv_usec) * 1000;
+#endif
 }
 
 void Platform::get_temp_dir(std::string& path)
diff --git a/configure.ac b/configure.ac
index 76f9071..278e708 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,8 @@ AM_PROG_CC_C_O
 AC_C_BIGENDIAN
 AC_PATH_PROGS(PYTHON, python2 python)
 
+AC_CHECK_HEADERS([sys/time.h])
+
 SPICE_LT_VERSION=m4_format("%d:%d:%d", 1, 0, 2)
 AC_SUBST(SPICE_LT_VERSION)
 
commit 93dc13c91a2634c59d2ff233fa8ba79a534205b0
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 13:26:21 2010 +0200

    client: Include config.h from common.h
    
    config.h should be availible everywhere, so move its inclusion
    to the top of common.h.

diff --git a/client/application.cpp b/client/application.cpp
index 3bd3330..1258067 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -15,10 +15,6 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef WIN32
-#include "config.h"
-#endif
-
 #include "common.h"
 #ifdef WIN32
 #include <io.h>
diff --git a/client/common.h b/client/common.h
index c0ce442..e1c149c 100644
--- a/client/common.h
+++ b/client/common.h
@@ -18,6 +18,10 @@
 #ifndef _H_COMMON
 #define _H_COMMON
 
+#ifndef WIN32
+#include "config.h"
+#endif
+
 #ifndef _WIN32_WCE
 #include <errno.h>
 #endif
diff --git a/client/mjpeg_decoder.cpp b/client/mjpeg_decoder.cpp
index 8a3aede..2470fb1 100644
--- a/client/mjpeg_decoder.cpp
+++ b/client/mjpeg_decoder.cpp
@@ -16,10 +16,6 @@
    License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef WIN32
-#include "config.h"
-#endif
-
 #include "common.h"
 #include "debug.h"
 #include "utils.h"
diff --git a/client/x11/main.cpp b/client/x11/main.cpp
index 4f49c70..dfcc101 100644
--- a/client/x11/main.cpp
+++ b/client/x11/main.cpp
@@ -17,7 +17,6 @@
 
 #include "common.h"
 #include "application.h"
-#include "config.h"
 
 static void cleanup()
 {
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index a9b4449..a87dcfa 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -40,7 +40,6 @@
 #include <set>
 #include <values.h>
 #include <signal.h>
-#include <config.h>
 #include <sys/shm.h>
 
 #include "platform.h"
commit 44631aa023c58990f13ca50050567033cfa9da3f
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 13:16:45 2010 +0200

    client: Check for pthread yield function using autoconf

diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index cc1502b..a9b4449 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -463,7 +463,7 @@ void Platform::msleep(unsigned int millisec)
 
 void Platform::yield()
 {
-    pthread_yield();
+    POSIX_YIELD_FUNC;
 }
 
 void Platform::term_printf(const char* format, ...)
diff --git a/configure.ac b/configure.ac
index 3369dde..76f9071 100644
--- a/configure.ac
+++ b/configure.ac
@@ -128,6 +128,26 @@ AC_SUBST(LIBRT)
 
 SPICE_NONPKGCONFIG_LIBS+=" -pthread $LIBM $LIBRT"
 
+dnl The client needs a yield function
+AC_MSG_CHECKING(for posix yield function)
+for yield_func in pthread_yield pthread_yield_np sched_yield \
+					thr_yield; do
+    spice_save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $SPICE_NONPKGCONFIG_LIBS"
+    AC_TRY_LINK([#include <pthread.h>],
+		[$yield_func()],
+		[posix_yield_func="$yield_func"
+		break])
+    CPPFLAGS="spice_save_CPPFLAGS"
+done
+if test x"$posix_yield_func" = xnone; then
+    AC_MSG_ERROR([No posix yield function found])
+else
+    AC_MSG_RESULT($posix_yield_func)
+    posix_yield_func="$posix_yield_func()"
+fi
+AC_DEFINE_UNQUOTED(POSIX_YIELD_FUNC,$posix_yield_func,[The POSIX RT yield function])
+
 SPICE_REQUIRES=""
 
 if test "x$use_gui" = "xyes"; then
commit 1670b220b5a60bb957967a5d5424d129cbd909ee
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 12:47:15 2010 +0200

    Initialize variable to avoid compiler warning
    
    Seems the OSX gcc warns on saveRight not being initialzied.

diff --git a/common/lines.c b/common/lines.c
index d2e997e..1a14c18 100644
--- a/common/lines.c
+++ b/common/lines.c
@@ -2985,7 +2985,7 @@ miWideDashSegment (GCPtr pGC,
     double L, l;
     double k;
     PolyVertexRec vertices[4];
-    PolyVertexRec saveRight, saveBottom;
+    PolyVertexRec saveRight = { 0 }, saveBottom;
     PolySlopeRec slopes[4];
     PolyEdgeRec left[2], right[2];
     LineFaceRec lcapFace, rcapFace;
commit 8e14489621194a261cbf95f037f1b7ddfff0018f
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 12:44:33 2010 +0200

    client: Include stdint.h for uint32_t

diff --git a/client/x11/atomic_count.h b/client/x11/atomic_count.h
index f48c667..db20ad9 100644
--- a/client/x11/atomic_count.h
+++ b/client/x11/atomic_count.h
@@ -18,6 +18,8 @@
 #ifndef _H_ATOMIC_COUNT
 #define _H_ATOMIC_COUNT
 
+#include <stdint.h>
+
 class AtomicCount {
 public:
     AtomicCount(uint32_t count = 0) : _count (count) {}
commit 2626419da67577161eaacd6927bc91b6474b0691
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 12:40:48 2010 +0200

    client: Don't use basename for argv[0] in --help output
    
    This isn't what other apps do, and it had issues in the OSX port,
    so just remove this.

diff --git a/client/cmd_line_parser.cpp b/client/cmd_line_parser.cpp
index ef72dba..3f45551 100644
--- a/client/cmd_line_parser.cpp
+++ b/client/cmd_line_parser.cpp
@@ -428,29 +428,13 @@ char* CmdLineParser::next_argument()
     return _argv[optind++];
 }
 
-#ifdef WIN32
-char* basename(char *str)
-{
-    char *base;
-    if ((base = strrchr(str, '\\'))) {
-        return base;
-    }
-
-    if ((base = strrchr(str, ':'))) {
-        return base;
-    }
-    return str;
-}
-
-#endif
-
 void CmdLineParser::show_help()
 {
     static const int HELP_START_POS = 30;
     static const int HELP_WIDTH = 80 - HELP_START_POS;
     std::ostringstream os;
 
-    os << basename(_argv[0]) << " - " << _description.c_str() << "\n\noptions:\n\n";
+    os << _argv[0] << " - " << _description.c_str() << "\n\noptions:\n\n";
 
     Options::iterator iter = _options.begin();
     for (; iter != _options.end(); ++iter) {
commit a5abceccb2df8931456277f6f572c3dbbe6d8962
Author: Alexander Larsson <alexl at redhat.com>
Date:   Wed Sep 29 12:36:39 2010 +0200

    Fix warning from OSX compiler
    
    The OSX compiler warns about uninitialized variable, so we change
    a bit how size is initialized.

diff --git a/client/application.cpp b/client/application.cpp
index 490cd8c..3bd3330 100644
--- a/client/application.cpp
+++ b/client/application.cpp
@@ -647,13 +647,10 @@ RedScreen* Application::get_screen(int id)
 
     if (!(screen = _screens[id])) {
         Monitor* mon = find_monitor(id);
-        SpicePoint size;
+        SpicePoint size = {SCREEN_INIT_WIDTH, SCREEN_INIT_HEIGHT};
 
         if (_full_screen && mon) {
             size = mon->get_size();
-        } else {
-            size.x = SCREEN_INIT_WIDTH;
-            size.y = SCREEN_INIT_HEIGHT;
         }
         screen = _screens[id] = new RedScreen(*this, id, _title, size.x, size.y);
 #ifdef USE_GUI


More information about the Spice-commits mailing list