qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgiu...@apache.org
Subject svn commit: r1485250 - in /qpid/proton/trunk: proton-c/src/engine/engine.c tests/tools/apps/c/CMakeLists.txt tests/tools/apps/c/msgr-common.c tests/tools/apps/c/msgr-common.h tests/tools/apps/c/msgr-recv.c tests/tools/apps/c/msgr-send.c
Date Wed, 22 May 2013 15:26:23 GMT
Author: kgiusti
Date: Wed May 22 15:26:23 2013
New Revision: 1485250

URL: http://svn.apache.org/r1485250
Log:
NO-JIRA: fix the C++ build of msgr-send/msgr-receive

Modified:
    qpid/proton/trunk/proton-c/src/engine/engine.c
    qpid/proton/trunk/tests/tools/apps/c/CMakeLists.txt
    qpid/proton/trunk/tests/tools/apps/c/msgr-common.c
    qpid/proton/trunk/tests/tools/apps/c/msgr-common.h
    qpid/proton/trunk/tests/tools/apps/c/msgr-recv.c
    qpid/proton/trunk/tests/tools/apps/c/msgr-send.c

Modified: qpid/proton/trunk/proton-c/src/engine/engine.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1485250&r1=1485249&r2=1485250&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine.c (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine.c Wed May 22 15:26:23 2013
@@ -815,7 +815,7 @@ pn_session_state_t *pn_session_get_state
   PN_ENSURE(transport->sessions, transport->session_capacity, ssn->id + 1, pn_session_state_t);
   for (unsigned i = old_capacity; i < transport->session_capacity; i++)
   {
-    pn_session_state_t t = {NULL, -1, -1};
+    pn_session_state_t t = {NULL, (uint16_t)-1, (uint16_t)-1};
     transport->sessions[i] = t;
     pn_delivery_buffer_init(&transport->sessions[i].incoming, 0, PN_SESSION_WINDOW);
     pn_delivery_buffer_init(&transport->sessions[i].outgoing, 0, PN_SESSION_WINDOW);

Modified: qpid/proton/trunk/tests/tools/apps/c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/tools/apps/c/CMakeLists.txt?rev=1485250&r1=1485249&r2=1485250&view=diff
==============================================================================
--- qpid/proton/trunk/tests/tools/apps/c/CMakeLists.txt (original)
+++ qpid/proton/trunk/tests/tools/apps/c/CMakeLists.txt Wed May 22 15:26:23 2013
@@ -17,6 +17,16 @@
 # under the License.
 #
 
+include(CheckIncludeFiles)
+
+CHECK_INCLUDE_FILES("inttypes.h" INTTYPES_AVAILABLE)
+if (INTTYPES_AVAILABLE)
+  list(APPEND PLATFORM_DEFINITIONS "USE_INTTYPES")
+else (INTTYPES_AVAILABLE)
+  # since inttypes.h provides portable printf format macros
+  set (COMPILE_WARNING_FLAGS "${COMPILE_WARNING_FLAGS} -Wno-format")
+endif (INTTYPES_AVAILABLE)
+
 add_executable(msgr-recv msgr-recv.c msgr-common.c)
 add_executable(msgr-send msgr-send.c msgr-common.c)
 
@@ -27,8 +37,9 @@ set_target_properties (
   msgr-recv msgr-send
   PROPERTIES
   COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS}"
+  COMPILE_DEFINITIONS "${PLATFORM_DEFINITIONS}"
 )
 
 if (BUILD_WITH_CXX)
-  set_source_files_properties (msgr-recv.c msgr-send.c PROPERTIES LANGUAGE CXX)
+  set_source_files_properties (msgr-recv.c msgr-send.c msgr-common.c PROPERTIES LANGUAGE
CXX)
 endif (BUILD_WITH_CXX)

Modified: qpid/proton/trunk/tests/tools/apps/c/msgr-common.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/tools/apps/c/msgr-common.c?rev=1485250&r1=1485249&r2=1485250&view=diff
==============================================================================
--- qpid/proton/trunk/tests/tools/apps/c/msgr-common.c (original)
+++ qpid/proton/trunk/tests/tools/apps/c/msgr-common.c Wed May 22 15:26:23 2013
@@ -130,12 +130,12 @@ void statistics_msg_received( Statistics
   }
 }
 
-void statistics_report( Statistics_t *s, unsigned long long sent, unsigned long long received
)
+void statistics_report( Statistics_t *s, uint64_t sent, uint64_t received )
 {
   pn_timestamp_t end = msgr_now() - s->start;
   double secs = end/(double)1000.0;
 
-  fprintf(stdout, "Messages sent: %llu recv: %llu\n", sent, received );
+  fprintf(stdout, "Messages sent: %" PRIu64 " recv: %" PRIu64 "\n", sent, received );
   fprintf(stdout, "Total time: %f sec\n", secs );
   fprintf(stdout, "Throughput: %f msgs/sec\n",  (secs != 0.0) ? (double)sent/secs : 0);
   fprintf(stdout, "Latency (sec): %f min %f max %f avg\n",
@@ -158,3 +158,19 @@ void parse_password( const char *input, 
         fclose(f);
     }
 }
+
+static int log = 0;
+void enable_logging()
+{
+    log = 1;
+}
+
+void LOG( const char *fmt, ... )
+{
+    if (log) {
+        va_list ap;
+        va_start(ap, fmt);
+        vfprintf( stdout, fmt, ap );
+        va_end(ap);
+    }
+}

Modified: qpid/proton/trunk/tests/tools/apps/c/msgr-common.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/tools/apps/c/msgr-common.h?rev=1485250&r1=1485249&r2=1485250&view=diff
==============================================================================
--- qpid/proton/trunk/tests/tools/apps/c/msgr-common.h (original)
+++ qpid/proton/trunk/tests/tools/apps/c/msgr-common.h Wed May 22 15:26:23 2013
@@ -18,6 +18,25 @@
  *
  */
 
+#if defined(_WIN32) && ! defined(__CYGWIN__)
+#include "../wincompat/getopt.h"
+#else
+#include <getopt.h>
+#endif
+
+#if defined(USE_INTTYPES)
+#include <inttypes.h>
+#endif
+
+/* should be defined in inttypes.h, if not, best guess */
+#if !defined(SCNu64)
+#define SCNu64 "ul"
+#endif
+#if !defined(PRIu64)
+#define PRIu64 "ul"
+#endif
+
+
 #include "proton/types.h"
 #include "proton/message.h"
 
@@ -59,11 +78,8 @@ typedef struct {
 
 void statistics_start( Statistics_t *s );
 void statistics_msg_received( Statistics_t *s, pn_message_t *message );
-void statistics_report( Statistics_t *s, unsigned long long sent, unsigned long long received
);
+void statistics_report( Statistics_t *s, uint64_t sent, uint64_t received );
 
+void enable_logging();
+void LOG( const char *fmt, ... );
 
-#if defined(_WIN32) && ! defined(__CYGWIN__)
-#include "../wincompat/getopt.h"
-#else
-#include <getopt.h>
-#endif

Modified: qpid/proton/trunk/tests/tools/apps/c/msgr-recv.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/tools/apps/c/msgr-recv.c?rev=1485250&r1=1485249&r2=1485250&view=diff
==============================================================================
--- qpid/proton/trunk/tests/tools/apps/c/msgr-recv.c (original)
+++ qpid/proton/trunk/tests/tools/apps/c/msgr-recv.c Wed May 22 15:26:23 2013
@@ -30,7 +30,7 @@
 
 typedef struct {
     Addresses_t subscriptions;
-    unsigned long long msg_count;
+    uint64_t msg_count;
     int recv_count;
     int incoming_window;
     int timeout;  // seconds
@@ -46,9 +46,6 @@ typedef struct {
     char *ca_db;        // trusted CA database
 } Options_t;
 
-static int log = 0;
-#define LOG(...)                                        \
-    if (log) { fprintf( stdout, __VA_ARGS__ ); }
 
 static void usage(int rc)
 {
@@ -90,7 +87,7 @@ static void parse_options( int argc, cha
         switch (c) {
         case 'a': addresses_merge( &opts->subscriptions, optarg ); break;
         case 'c':
-            if (sscanf( optarg, "%llu", &opts->msg_count ) != 1) {
+            if (sscanf( optarg, "%" SCNu64, &opts->msg_count ) != 1) {
                 fprintf(stderr, "Option -%c requires an integer argument.\n", optopt);
                 usage(1);
             }
@@ -128,7 +125,7 @@ static void parse_options( int argc, cha
             }
             break;
         case 'F': addresses_merge( &opts->forwarding_targets, optarg ); break;
-        case 'V': log = 1; break;
+        case 'V': enable_logging(); break;
         case 'N': opts->name = optarg; break;
         case 'X': opts->ready_text = optarg; break;
         case 'T': opts->ca_db = optarg; break;
@@ -152,8 +149,8 @@ int main(int argc, char** argv)
 {
     Options_t opts;
     Statistics_t stats;
-    unsigned long long sent = 0;
-    unsigned long long received = 0;
+    uint64_t sent = 0;
+    uint64_t received = 0;
     int forwarding_index = 0;
     int rc;
 

Modified: qpid/proton/trunk/tests/tools/apps/c/msgr-send.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/tools/apps/c/msgr-send.c?rev=1485250&r1=1485249&r2=1485250&view=diff
==============================================================================
--- qpid/proton/trunk/tests/tools/apps/c/msgr-send.c (original)
+++ qpid/proton/trunk/tests/tools/apps/c/msgr-send.c Wed May 22 15:26:23 2013
@@ -29,10 +29,9 @@
 #include <ctype.h>
 
 
-
 typedef struct {
     Addresses_t targets;
-    unsigned long long msg_count;
+    uint64_t msg_count;
     uint32_t msg_size;  // of body
     uint32_t send_batch;
     int   outgoing_window;
@@ -50,9 +49,6 @@ typedef struct {
     char *ca_db;        // trusted CA database
 } Options_t;
 
-static int log = 0;
-#define LOG(...)                                        \
-    if (log) { fprintf( stdout, __VA_ARGS__ ); }
 
 static void usage(int rc)
 {
@@ -96,7 +92,7 @@ static void parse_options( int argc, cha
         switch(c) {
         case 'a': addresses_merge( &opts->targets, optarg ); break;
         case 'c':
-            if (sscanf( optarg, "%llu", &opts->msg_count ) != 1) {
+            if (sscanf( optarg, "%" SCNu64, &opts->msg_count ) != 1) {
                 fprintf(stderr, "Option -%c requires an integer argument.\n", optopt);
                 usage(1);
             }
@@ -145,7 +141,7 @@ static void parse_options( int argc, cha
                 usage(1);
             }
             break;
-        case 'V': log = 1; break;
+        case 'V': enable_logging(); break;
         case 'N': opts->name = optarg; break;
         case 'T': opts->ca_db = optarg; break;
         case 'C': opts->certificate = optarg; break;
@@ -190,8 +186,8 @@ int main(int argc, char** argv)
 {
     Options_t opts;
     Statistics_t stats;
-    unsigned long long sent = 0;
-    unsigned long long received = 0;
+    uint64_t sent = 0;
+    uint64_t received = 0;
     int target_index = 0;
     int rc;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message