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