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