diff options
| author | 2010-12-27 02:18:43 +0000 | |
|---|---|---|
| committer | 2010-12-27 02:18:43 +0000 | |
| commit | 26ef0cff00c368487a8a95a5c66dc2b0a85f1efa (patch) | |
| tree | 2202884c2789c5eb543993ef0885c4fee37a8d90 /src/kvilib/system | |
| parent | Kill system memmove, ix86 asm and kvi_memmove stuff: modern gcc coupled to gl... (diff) | |
| download | KVIrc-26ef0cff00c368487a8a95a5c66dc2b0a85f1efa.tar.gz KVIrc-26ef0cff00c368487a8a95a5c66dc2b0a85f1efa.tar.bz2 KVIrc-26ef0cff00c368487a8a95a5c66dc2b0a85f1efa.zip | |
Yet more renaming and cleanup
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5236 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/kvilib/system')
| -rw-r--r-- | src/kvilib/system/KviByteOrder.h | 92 | ||||
| -rw-r--r-- | src/kvilib/system/KviLocale.cpp | 4 | ||||
| -rw-r--r-- | src/kvilib/system/KviThread.cpp | 2 | ||||
| -rw-r--r-- | src/kvilib/system/KviTimeUtils.h | 17 |
4 files changed, 83 insertions, 32 deletions
diff --git a/src/kvilib/system/KviByteOrder.h b/src/kvilib/system/KviByteOrder.h index c7d1b56d6..6fcc50308 100644 --- a/src/kvilib/system/KviByteOrder.h +++ b/src/kvilib/system/KviByteOrder.h @@ -5,9 +5,11 @@ // // File : KviByteOrder.h // Creation date : Mon Dec 25 2006 19:56:16 CEST by Szymon Stefanek +// Based on file : kvi_bswap.h +// Creation date : Fri Mar 19 1999 03:15:21 CEST by Szymon Stefanek // // This file is part of the KVirc irc client distribution -// Copyright (C) 2006-2010 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 1999-2010 Szymon Stefanek (pragma at kvirc dot net) // // This program is FREE software. You can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -26,57 +28,100 @@ //============================================================================= #include "kvi_settings.h" -#include "kvi_bswap.h" #include "kvi_inttypes.h" namespace KviByteOrder { + /** + * \brief Swaps the endianess of a kvi_u64_t + * + * \param i the original value + * \return kvi_u64_t + */ + inline kvi_u64_t swap64(kvi_u64_t i) + { + // abcdefgh to hgfedcba + return ((i << 56) | /* h to a */ + ((i & 0xff00) << 40) | /* g to b */ + ((i & 0xff0000) << 24) | /* f to c */ + ((i & 0xff000000) << 8) | /* e to d */ + ((i >> 8) & 0xff000000) | /* d to e */ + ((i >> 24) & 0xff0000) | /* c to f */ + ((i >> 40) & 0xff00) | /* b to g */ + (i >> 56)); /* a to h */ + } + + /** + * \brief Swaps the endianess of a kvi_u32_t + * + * \param i the original value + * \return kvi_u32_t + */ + inline kvi_u32_t swap32(kvi_u32_t i) + { + // abcd to dcba + return ((i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24)); + } + + /** + * \brief Swaps the endianess of a kvi_u16_t + * + * \param i the original value + * \return kvi_u16_t + */ + inline kvi_u16_t swap16(kvi_u16_t i) + { + // ab to ba + return ((i << 8) | (i >> 8)); + } + -// -// Byte Orders Reminder -// Number 0xaabbccdd -// Little Endian Stores 0xdd 0xcc 0xbb 0xaa -// Big Endian Stores 0xaa 0xbb 0xcc 0xdd -// Perverse Middle Endian 0xbb 0xaa 0xdd 0xcc or another braindamaged combination (unsupported) -// Network Byte Order is Big Endian -// Intel Stuff uses Little Endian -// PPC is Big Endian -// Universal binaries on MacOSX use both Big and Little Endian -// + // + // Byte Orders Reminder + // Number 0xaabbccdd + // Little Endian Stores 0xdd 0xcc 0xbb 0xaa + // Big Endian Stores 0xaa 0xbb 0xcc 0xdd + // Perverse Middle Endian 0xbb 0xaa 0xdd 0xcc or another braindamaged combination (unsupported) + // Network Byte Order is Big Endian + // Intel Stuff uses Little Endian + // PPC is Big Endian + // Universal binaries on MacOSX use both Big and Little Endian + // #ifdef BIG_ENDIAN_MACHINE_BYTE_ORDER inline kvi_u16_t localCpuToLittleEndian16(kvi_u16_t u) { - return kvi_swap16(u); + return swap16(u); } inline kvi_u32_t localCpuToLittleEndian32(kvi_u32_t u) { - return kvi_swap32(u); + return swap32(u); } inline kvi_u64_t localCpuToLittleEndian64(kvi_u64_t u) { - return kvi_swap64(u); + return swap64(u); } inline kvi_u16_t littleEndianToLocalCpu16(kvi_u16_t u) { - return kvi_swap16(u); + return swap16(u); } inline kvi_u32_t littleEndianToLocalCpu32(kvi_u32_t u) { - return kvi_swap32(u); + return swap32(u); } inline kvi_u64_t littleEndianToLocalCpu64(kvi_u64_t u) { - return kvi_swap64(u); + return swap64(u); } -#else +#else //!BIG_ENDIAN_MACHINE_BYTE_ORDER + // We ASSUME that the local cpu is little endian.. if it isn't.. well :) #define LOCAL_CPU_LITTLE_ENDIAN 1 @@ -110,9 +155,14 @@ namespace KviByteOrder return u; } -#endif +#endif //!BIG_ENDIAN_MACHINE_BYTE_ORDER } // namespace KviByteOrder + + + + + #endif // !_KVI_BYTEORDER_H_ diff --git a/src/kvilib/system/KviLocale.cpp b/src/kvilib/system/KviLocale.cpp index 5fff1d47c..5399a6f5d 100644 --- a/src/kvilib/system/KviLocale.cpp +++ b/src/kvilib/system/KviLocale.cpp @@ -27,7 +27,7 @@ //#define _KVI_DEBUG_CHECK_RANGE_ #include "kvi_debug.h" #include "KviMemory.h" -#include "kvi_bswap.h" +#include "KviByteOrder.h" #define _KVI_LOCALE_CPP_ #include "KviLocale.h" @@ -367,7 +367,7 @@ struct GnuMoStringDescriptor kvi_u32_t offset; }; -#define KVI_SWAP_IF_NEEDED(flag,value) (flag ? kvi_swap32(value) : (value)) +#define KVI_SWAP_IF_NEEDED(flag,value) (flag ? KviByteOrder::swap32(value) : (value)) //////////////////////////////////////////////////////////////////////////////////////// End of gettext.h & gettextP.h ////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/kvilib/system/KviThread.cpp b/src/kvilib/system/KviThread.cpp index 17506a1b0..f44453d96 100644 --- a/src/kvilib/system/KviThread.cpp +++ b/src/kvilib/system/KviThread.cpp @@ -43,7 +43,7 @@ #include "KviCString.h" #include "kvi_settings.h" -#include "kvi_error.h" +#include "KviError.h" #include <QApplication> diff --git a/src/kvilib/system/KviTimeUtils.h b/src/kvilib/system/KviTimeUtils.h index 98c82e4fb..d84a6a121 100644 --- a/src/kvilib/system/KviTimeUtils.h +++ b/src/kvilib/system/KviTimeUtils.h @@ -105,18 +105,11 @@ public: */ namespace KviTimeUtils { - /** \enum FormatTimeSpanFlags */ - enum FormatTimeSpanFlags { - NoLeadingEmptyIntervals = 1, /**< Causes the leading empty intervals to be omitted */ - NoLeadingZeroes = 2, /**< No leading zeroes are printed in hours and seconds */ - FillWithHypens = 4 /**< Uses only -- %d -- %h -- etc.. discards all other flags */ - }; - /** * \brief Returns the current time mills * \return long long */ - long long getCurrentTimeMills(); + KVILIB_API long long getCurrentTimeMills(); /** * \brief Splits the time span uSecs in days, hours, minutes and seconds @@ -130,6 +123,14 @@ namespace KviTimeUtils KVILIB_API void secondsToDaysHoursMinsSecs(unsigned int uSecs, unsigned int * uD, unsigned int * uH, unsigned int * uM, unsigned int * uS); + /** \enum FormatTimeSpanFlags */ + enum FormatTimeSpanFlags + { + NoLeadingEmptyIntervals = 1, /**< Causes the leading empty intervals to be omitted */ + NoLeadingZeroes = 2, /**< No leading zeroes are printed in hours and seconds */ + FillWithHypens = 4 /**< Uses only -- %d -- %h -- etc.. discards all other flags */ + }; + /** * \brief Returns a string formatted like x d x h xx m xx s * \param uSeconds The number of seconds to format |
