Blame SOURCES/xmlrpc-c-longlong.patch

3cfbe1
From 4d3bbc5d59418666a5fc91c8fe3e301ee9c89b32 Mon Sep 17 00:00:00 2001
3cfbe1
From: Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
3cfbe1
Date: Sat, 5 Apr 2008 11:41:34 +0200
3cfbe1
Subject: [PATCH 3/8] Use proper datatypes for 'long long'
3cfbe1
3cfbe1
xmlrpc-c uses 'long long' at some places (e.g. in printf
3cfbe1
statements with PRId64) under the assumption that it has a
3cfbe1
width of exactly 64 bits.
3cfbe1
3cfbe1
On 64 bit machines 'long long' has a width of 128 bit and
3cfbe1
will cause overhead both in memory and cpu usage there. As
3cfbe1
'long long' is used only to handle <i8> datatypes, the patch
3cfbe1
uses a plain 64 integer type there.
3cfbe1
3cfbe1
It is arguable whether 'int_least64_t' (and 'int_least32_t')
3cfbe1
would be a better choice for 'int64_t' (and 'int32_t'), but
3cfbe1
for now, the patch uses datatypes with exact widths.
3cfbe1
---
3cfbe1
 include/xmlrpc-c/base.h     |    7 ++++---
3cfbe1
 lib/libutil/string_number.c |    1 +
3cfbe1
 src/cpp/param_list.cpp      |    8 ++++----
3cfbe1
 3 files changed, 9 insertions(+), 7 deletions(-)
3cfbe1
3cfbe1
diff --git a/include/xmlrpc-c/base.h b/include/xmlrpc-c/base.h
3cfbe1
index cdc9161..cbdf3d0 100644
3cfbe1
--- a/include/xmlrpc-c/base.h
3cfbe1
+++ b/include/xmlrpc-c/base.h
3cfbe1
@@ -5,6 +5,7 @@
3cfbe1
 
3cfbe1
 #include <stddef.h>
3cfbe1
 #include <stdarg.h>
3cfbe1
+#include <stdint.h>
3cfbe1
 #include <time.h>
3cfbe1
 #include <xmlrpc-c/c_util.h>
3cfbe1
 #include <xmlrpc-c/util.h>
3cfbe1
@@ -50,9 +51,9 @@ xmlrpc_version(unsigned int * const majorP,
3cfbe1
 
3cfbe1
 typedef signed int xmlrpc_int;  
3cfbe1
     /* An integer of the type defined by XML-RPC <int>; i.e. 32 bit */
3cfbe1
-typedef XMLRPC_INT32 xmlrpc_int32;
3cfbe1
+typedef int32_t xmlrpc_int32;
3cfbe1
     /* An integer of the type defined by XML-RPC <i4>; i.e. 32 bit */
3cfbe1
-typedef XMLRPC_INT64 xmlrpc_int64;
3cfbe1
+typedef int64_t xmlrpc_int64;
3cfbe1
     /* An integer of the type defined by "XML-RPC" <i8>; i.e. 64 bit */
3cfbe1
 typedef int xmlrpc_bool;
3cfbe1
     /* A boolean (of the type defined by XML-RPC <boolean>, but there's
3cfbe1
@@ -89,7 +90,7 @@ typedef int xmlrpc_socket;
3cfbe1
 #define XMLRPC_INT32_MAX 0x7fffffff
3cfbe1
 #define XMLRPC_INT32_MIN (-XMLRPC_INT32_MAX - 1)
3cfbe1
 
3cfbe1
-#define XMLRPC_INT64_MAX 0x7fffffffffffffffll
3cfbe1
+#define XMLRPC_INT64_MAX ((xmlrpc_int64)0x7fffffffffffffffll)
3cfbe1
 #define XMLRPC_INT64_MIN (-XMLRPC_INT64_MAX - 1)
3cfbe1
 
3cfbe1
 
3cfbe1
diff --git a/lib/libutil/string_number.c b/lib/libutil/string_number.c
3cfbe1
index 1c284af..a7e78ad 100644
3cfbe1
--- a/lib/libutil/string_number.c
3cfbe1
+++ b/lib/libutil/string_number.c
3cfbe1
@@ -6,6 +6,7 @@
3cfbe1
 ============================================================================*/
3cfbe1
 #include <stdlib.h>
3cfbe1
 #include <string.h>
3cfbe1
+#include <inttypes.h>
3cfbe1
 #include <errno.h>
3cfbe1
 
3cfbe1
 #include <xmlrpc-c/base.h>
3cfbe1
diff --git a/src/cpp/param_list.cpp b/src/cpp/param_list.cpp
3cfbe1
index 67c636b..60f7df9 100644
3cfbe1
--- a/src/cpp/param_list.cpp
3cfbe1
+++ b/src/cpp/param_list.cpp
3cfbe1
@@ -265,10 +265,10 @@ paramList::getNil(unsigned int const paramNumber) const {
3cfbe1
 
3cfbe1
 
3cfbe1
 
3cfbe1
-long long
3cfbe1
+xmlrpc_int64
3cfbe1
 paramList::getI8(unsigned int const paramNumber,
3cfbe1
-                 long long    const minimum,
3cfbe1
-                 long long    const maximum) const {
3cfbe1
+                 xmlrpc_int64 const minimum,
3cfbe1
+                 xmlrpc_int64 const maximum) const {
3cfbe1
 
3cfbe1
     if (paramNumber >= this->paramVector.size())
3cfbe1
         throw(fault("Not enough parameters", fault::CODE_TYPE));
3cfbe1
@@ -277,7 +277,7 @@ paramList::getI8(unsigned int const paramNumber,
3cfbe1
         throw(fault("Parameter that is supposed to be 64-bit integer is not", 
3cfbe1
                     fault::CODE_TYPE));
3cfbe1
 
3cfbe1
-    long long const longlongvalue(static_cast<long long>(
3cfbe1
+    xmlrpc_int64 const longlongvalue(static_cast<xmlrpc_int64>(
3cfbe1
         value_i8(this->paramVector[paramNumber])));
3cfbe1
 
3cfbe1
     if (longlongvalue < minimum)
3cfbe1
-- 
3cfbe1
1.7.4
3cfbe1