From: Eduardo Ramos Testillano Date: Tue, 12 May 2015 07:01:15 +0000 (+0200) Subject: Usage of stdint.h types X-Git-Tag: REFACTORING_TESTING_LIBRARY~143 X-Git-Url: https://git.teslayout.com/public/public/public/?a=commitdiff_plain;h=706c5ba5c35199816446453e6e144200cf79265b;p=anna.git Usage of stdint.h types --- diff --git a/README.md b/README.md index 56a695f..29e3fef 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,6 @@ Execute 'sudo scons uninstall' sudo apt-get install libboost-test-dev Development module is no longer needed, but still unit testing is done through boost. - + Pending migration to google test framework. diff --git a/example/comm/blocker/SConscript b/example/comm/blocker/SConscript index 81e9833..74c575c 100644 --- a/example/comm/blocker/SConscript +++ b/example/comm/blocker/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/comm/client/SConscript b/example/comm/client/SConscript index 58147db..0d41dbd 100644 --- a/example/comm/client/SConscript +++ b/example/comm/client/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/comm/rrClient/SConscript b/example/comm/rrClient/SConscript index 7d91aee..d199352 100644 --- a/example/comm/rrClient/SConscript +++ b/example/comm/rrClient/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/diameter/launcher/DEPLOY.sh b/example/diameter/launcher/DEPLOY.sh index ceb04b1..d593fdc 100755 --- a/example/diameter/launcher/DEPLOY.sh +++ b/example/diameter/launcher/DEPLOY.sh @@ -131,19 +131,19 @@ case $option in a) echo "Advanced deployment" DEPLOYMENTS_DIR=deployments/advanced - DPATH_dflt=$HOME/ADL-advanced + DPATH_dflt=$HOME/ADL/advanced ;; b) echo "Basic deployment" DEPLOYMENTS_DIR=deployments/basic - DPATH_dflt=$HOME/ADL-basic + DPATH_dflt=$HOME/ADL/basic ;; f) echo "FT deployment" DEPLOYMENTS_DIR=deployments/ft-client - DPATH_dflt=$HOME/ADL-ft-client + DPATH_dflt=$HOME/ADL/ft-client ;; *) diff --git a/example/diameter/launcher/SConscript b/example/diameter/launcher/SConscript index b7d1cda..c0dc64d 100644 --- a/example/diameter/launcher/SConscript +++ b/example/diameter/launcher/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/http/client/SConscript b/example/http/client/SConscript index b6836e5..c7b411b 100644 --- a/example/http/client/SConscript +++ b/example/http/client/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/http/wims20XClient/SConscript b/example/http/wims20XClient/SConscript index b6836e5..c7b411b 100644 --- a/example/http/wims20XClient/SConscript +++ b/example/http/wims20XClient/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/http/xmlClient/SConscript b/example/http/xmlClient/SConscript index b6836e5..c7b411b 100644 --- a/example/http/xmlClient/SConscript +++ b/example/http/xmlClient/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/ldap/tSearch/SConscript b/example/ldap/tSearch/SConscript index 1812e93..e0c02b2 100644 --- a/example/ldap/tSearch/SConscript +++ b/example/ldap/tSearch/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'ldap', 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'lber', 'ldap', 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/timex/ArithmeticHTTPServer/SConscript b/example/timex/ArithmeticHTTPServer/SConscript index ff6df40..c196b74 100644 --- a/example/timex/ArithmeticHTTPServer/SConscript +++ b/example/timex/ArithmeticHTTPServer/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'pthread' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/example/xml/xmlBinary/SConscript b/example/xml/xmlBinary/SConscript index 5087263..c357fa0 100644 --- a/example/xml/xmlBinary/SConscript +++ b/example/xml/xmlBinary/SConscript @@ -26,7 +26,7 @@ localEnv = env.Clone() anna_library = { 'LIBS' : anna_rlibs } localEnv.MergeFlags (anna_library) -system_library = { 'LIBS' : [ 'xml2', 'rt' ] } +system_library = { 'LIBS' : [ 'xml2', 'rt', 'z' ] } localEnv.MergeFlags (system_library) localEnv.Append(LIBPATH = anna_libpaths) diff --git a/include/anna/config/defines.hpp b/include/anna/config/defines.hpp index 7d03fad..a8e995b 100644 --- a/include/anna/config/defines.hpp +++ b/include/anna/config/defines.hpp @@ -9,7 +9,10 @@ #ifndef anna_config_defines_hpp #define anna_config_defines_hpp -#include +//#include +#include +// For cstd0x compatibility we will use stdint.h types instead of std:: ones on cstdint: +//#include when C++11 available #ifdef ANNA_FILE_LOCATION #undef ANNA_FILE_LOCATION @@ -94,13 +97,16 @@ namespace anna { #ifndef __x86_64__ #undef __anna64__ -/** Defines required data type to conversion from pointer to integer */ -typedef int ptrnumber; +///** Defines required data type to conversion from pointer to integer */ +//typedef int ptrnumber; #else #define __anna64__ -/** Defines required data type to conversion from pointer to integer */ -typedef long ptrnumber; +///** Defines required data type to conversion from pointer to integer */ +//typedef long ptrnumber; #endif + +typedef intptr_t ptrnumber; + } /** diff --git a/include/anna/core/functions.hpp b/include/anna/core/functions.hpp index d43dcd0..b2a24ab 100644 --- a/include/anna/core/functions.hpp +++ b/include/anna/core/functions.hpp @@ -99,15 +99,25 @@ struct functions { /** \param number Numero a convertir. - @return Un literal con el numero convertido a cadena decimal. + @return Un literal con el numero sin signo convertido a cadena decimal. */ - static std::string asString(const unsigned long number) throw(); + static std::string asString(const unsigned int number) throw(); /** \param number Numero a convertir. @return Un literal con el numero sin signo convertido a cadena decimal. */ - static std::string asString(const unsigned int number) throw(); + static std::string asString(const unsigned long long int number) throw() { + return asString((U64)number); + } + + /** + \param number Numero a convertir. + @return Un literal con el numero sin signo convertido a cadena decimal. + */ + static std::string asString(const long long int number) throw() { + return asString((S64)number); + } /** Devuelve un literal con tel numero convertido a cadena decimal @@ -232,12 +242,6 @@ struct functions { */ static std::string asHexString(const S64 number) throw(); - /** - \param number Numero a convertir. - @return Un literal con el numero convertido a cadena hexadecimal. - */ - static std::string asHexString(const long number) throw(); - /** \param number Numero a convertir. @return Un literal con el numero convertido a cadena hexadecimal. diff --git a/include/anna/core/util/defines.hpp b/include/anna/core/util/defines.hpp index 506a9fd..7e56b7d 100644 --- a/include/anna/core/util/defines.hpp +++ b/include/anna/core/util/defines.hpp @@ -16,6 +16,9 @@ #include +#include +// For cstd0x compatibility we will use stdint.h types instead of std:: ones on cstdint: +//#include when C++11 available // Decoding helpers @@ -30,78 +33,52 @@ namespace anna { -// type bits (bytes) % Diameter Data typedef -// ----------------------------------------------------------------------- -// unsigned short int 16 (2) hu U16 -// short int 16 (2) hd S16 -// unsigned int 32 (4) u Unsigned32 (*) U32 -// int 32 (4) d Integer32 (*) S32 -// -// Integer. Its length traditionally depends on the length of the system's Word type, thus in MSDOS -// it is 16 bits long, whereas in 32 bit systems (like Windows 9x/2000/NT and systems that work under -// protected mode in x86 systems) it is 32 bits long (4 bytes) -// -// Como está previsto que en algunas máquinas la palabra sea de 16 bits, los enteros serían -// de 16 y por ello C contempla: int (serían 16 bits), long int (32), long long int (64). Sin embargo -// en la práctica, 'int = long int = 32' y 'long long int = 64'. -// -// (*) Por un mal hábito, representamos enteros de 32 bits con el tipo 'int'/'unsigned int' de -// toda la vida, sin darnos cuenta de que en alguna máquina antigua, no tendría 32 bits. -// Corregir lo anterior sería tan sencillo como poner S32 = long int (no int), -// y U32 = unsigned long int (no unsigned int). Pero no lo vamos a hacer. -// -// El tipo 'long' tiene un tamaño que corresponde con el ancho de palabra del S.O. -// En Solaris (palabra de 64) tenemos long = 64 = long long -// En linux (palabra de 32) tenemos long = 32, long long = 64 -// En linux64 (palabra de 64) tenemos long = 64 = long long -// +#ifndef __x86_64__ +#undef __anna64__ +#else +#define __anna64__ +#endif + +// TYPE BITS (bytes) Format +// ----------------------- ------------------ --------------------------- // unsigned long int 32/64 (4/8) lu // long int 32/64 (4/8) ld // -// unsigned long long int 64 (8) llu Unsigned64 U64 -// long long int 64 (8) lld Integer64 S64 +// unsigned long long int 64 (8) llu +// long long int 64 (8) lld // // float 32 (4) f // double 64 (8) lf // long double 80 (10) Lf +// +// pointer = S.O. word 32/64 p -/** Alias for unsigned char: unsigned integer with 8 bits */ +/** Alias for unsigned integer with 8 bits */ +//typedef uint8_t U8; typedef unsigned char U8; -/** Alias for char: signed integer with 8 bits */ +/** Alias for signed integer with 8 bits */ +//typedef int8_t S8; typedef char S8; -/** Alias for unsigned short int: unsigned integer with 16 bits */ -typedef unsigned short int U16; +/** Alias for unsigned integer with 16 bits */ +typedef uint16_t U16; -/** Alias for short int: signed integer with 16 bits */ -typedef short int S16; +/** Alias for signed integer with 16 bits */ +typedef int16_t S16; -/** Alias for unsigned int: unsigned integer with 32 bits */ -typedef unsigned int U32; +/** Alias for unsigned integer with 32 bits */ +typedef uint32_t U32; -/** Alias for int: signed integer with 32 bits */ -typedef int S32; +/** Alias for signed integer with 32 bits */ +typedef int32_t S32; -///** Alias for unsigned long long: unsigned integer with 64 bits */ -//typedef unsigned long long int U64; -// -///** Alias for long long: signed integer with 64 bits */ -//typedef long long int S64; -#ifndef __x86_64__ -#undef __anna64__ -/** Alias for long long: signed integer with 64 bits */ -typedef int64_t S64 -/** Alias for unsigned long long: unsigned integer with 64 bits */ -typedef u_int64_t U64; -#else -#define __anna64__ -/** Alias for long long: signed integer with 64 bits */ -typedef long long int S64; -/** Alias for unsigned long long: unsigned integer with 64 bits */ -typedef unsigned long long int U64; -#endif +/** Alias for unsigned integer with 64 bits */ +typedef uint64_t U64; + +/** Alias for signed integer with 64 bits */ +typedef int64_t S64; /** Alias for float: floating number with 32 bits (1-8-23) */ typedef float F32; @@ -109,7 +86,10 @@ typedef float F32; /** Alias for double: floating number with 64 bits (1-11-52) */ typedef double F64; -/** Alias for unsigned int: unsigned integer with 32 bits used to contain 24 bits */ +/** Alias for long double: floating number with 80 bits (1-15-64) */ +typedef long double F80; + +/** Alias for unsigned integer with 32 bits used to contain 24 bits */ typedef U32 U24; diff --git a/source/core/functions.cpp b/source/core/functions.cpp index 14ba7fc..6a660df 100644 --- a/source/core/functions.cpp +++ b/source/core/functions.cpp @@ -91,11 +91,6 @@ throw() { return string(aux); } -string functions::asString(const unsigned long number) -throw() { - return asString((U64)number); -} - string functions::asString(const S64 number) throw() { char aux [24]; @@ -173,11 +168,6 @@ throw() { return string(aux); } -string functions::asHexString(const long number) -throw() { - return asHexString((S64)number); -} - string functions::asHexString(const S64 number) throw() { char aux [32];