From 41b0a1139d039c486983ad3ca020217f17fd7414 Mon Sep 17 00:00:00 2001 From: Ron Lee Date: Mon, 26 Nov 2001 03:53:32 +0000 Subject: [PATCH] added wx(U)int64, then added it to wxDataStream so contrib should (hopefully) now build on alpha, ia64, s/390 without the kludge from 2.2 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12701 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- debian/changelog | 19 +++++++++++ include/wx/datstrm.h | 5 +++ include/wx/defs.h | 73 ++++++++++++++++++++++-------------------- src/common/datstrm.cpp | 35 ++++++++++++++++++++ 4 files changed, 98 insertions(+), 34 deletions(-) diff --git a/debian/changelog b/debian/changelog index 737f8b8dbc..8cc9649263 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,25 @@ wxwindows2.3 (2.3.0) unstable; urgency=low -- Ron Lee Sat, 27 Jan 2001 01:51:24 -0800 +wxwindows2.2 (2.2.8.4) unstable; urgency=low + + * Put the (modified) size_t == ulong kludge back into sndwav.cpp + it's still needed until wxDataOutputStream is made 64 bit + friendly, which may not happen for 2.2 since it will probably + not be binary compatible. + * caps a memory leak in the jpeg handler. + + -- Ron Lee Sun, 25 Nov 2001 11:53:59 -0800 + +wxwindows2.2 (2.2.8.3) unstable; urgency=low + + * Backported size_t test from 2.3 tree, removes the need for + specific tests for various 64 bit platforms including now + S/390 (thanks to Gerhard Tonn for the report). + Closes: #120768 + + -- Ron Lee Fri, 23 Nov 2001 20:53:49 -0800 + wxwindows2.2 (2.2.8.2) unstable; urgency=low * python-dev doesn't get me python? More bytes in Build-Dep then diff --git a/include/wx/datstrm.h b/include/wx/datstrm.h index f1043cb33d..a222f1bc1a 100644 --- a/include/wx/datstrm.h +++ b/include/wx/datstrm.h @@ -17,6 +17,7 @@ #endif #include "wx/stream.h" +#include "wx/longlong.h" #if wxUSE_STREAMS @@ -28,6 +29,7 @@ public: bool IsOk() { return m_input->IsOk(); } + wxUint64 Read64(); wxUint32 Read32(); wxUint16 Read16(); wxUint8 Read8(); @@ -41,6 +43,7 @@ public: wxDataInputStream& operator>>(wxUint8& c); wxDataInputStream& operator>>(wxUint16& i); wxDataInputStream& operator>>(wxUint32& i); + wxDataInputStream& operator>>(wxUint64& i); wxDataInputStream& operator>>(double& i); wxDataInputStream& operator>>(float& f); @@ -59,6 +62,7 @@ public: bool IsOk() { return m_output->IsOk(); } + void Write64(wxUint64 i); void Write32(wxUint32 i); void Write16(wxUint16 i); void Write8(wxUint8 i); @@ -73,6 +77,7 @@ public: wxDataOutputStream& operator<<(wxUint8 c); wxDataOutputStream& operator<<(wxUint16 i); wxDataOutputStream& operator<<(wxUint32 i); + wxDataOutputStream& operator<<(wxUint64 i); wxDataOutputStream& operator<<(double f); wxDataOutputStream& operator<<(float f); diff --git a/include/wx/defs.h b/include/wx/defs.h index 160d4b82f7..91b788c8f8 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -164,13 +164,11 @@ #endif // compilers #endif // HAVE_BOOL -#if !defined(HAVE_BOOL) && !defined(bool) +#if !defined(HAVE_BOOL) && !defined(bool) && !defined(VMS) // NB: of course, this doesn't replace the standard type, because, for // example, overloading based on bool/int parameter doesn't work and // so should be avoided in portable programs -#ifndef VMS typedef unsigned int bool; -#endif #endif // bool typedef short int WXTYPE; @@ -433,47 +431,27 @@ enum #define wxInt8 char signed #define wxUint8 char unsigned -#ifdef __WIN16__ +#if defined(__WIN16__) || (defined(SIZEOF_INT) && (SIZEOF_INT == 2)) #define wxInt16 int signed #define wxUint16 int unsigned #define wxInt32 long signed #define wxUint32 long unsigned -#endif - -#ifdef __WIN32__ -#define wxInt16 short signed -#define wxUint16 short unsigned -#define wxInt32 int signed -#define wxUint32 int unsigned -#endif - -#ifdef __WXMAC__ -#define wxInt16 short signed -#define wxUint16 short unsigned -#define wxInt32 int signed -#define wxUint32 int unsigned -#endif - -#ifdef __WXOS2__ +#else #define wxInt16 short signed #define wxUint16 short unsigned #define wxInt32 int signed #define wxUint32 int unsigned #endif -#if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXOS2__) - #if defined(SIZEOF_INT) - /* well, this shouldn't happen... */ - #define wxInt16 short signed - #define wxUint16 short unsigned - #define wxInt32 int signed - #define wxUint32 int unsigned - #else - #define wxInt16 short signed - #define wxUint16 short unsigned - #define wxInt32 int signed - #define wxUint32 int unsigned - #endif +#if defined(SIZEOF_LONG) && (SIZEOF_LONG == 8) +#define wxInt64 long signed +#define wxUint64 long unsigned +#elif defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG_LONG == 8) +#define wxInt64 long long signed +#define wxUint64 long long unsigned +#else // FIXME: what else can we do here aside from implementing wxULongLong +#define wxInt64 wxLongLong +#define wxUint64 wxLongLong #endif #define wxByte wxUint8 @@ -572,6 +550,29 @@ typedef float wxFloat32 ; #endif // machine specific byte swapping +#define wxUINT64_SWAP_ALWAYS(val) \ + ((wxUint64) ( \ + ((wxLongLong(val) & wxLongLong(0L, 0x000000ffU)) << 56) | \ + ((wxLongLong(val) & wxLongLong(0L, 0x0000ff00U)) << 40) | \ + ((wxLongLong(val) & wxLongLong(0L, 0x00ff0000U)) << 24) | \ + ((wxLongLong(val) & wxLongLong(0L, 0xff000000U)) << 8) | \ + ((wxLongLong(val) & wxLongLong(0x000000ffL, 0U)) >> 8) | \ + ((wxLongLong(val) & wxLongLong(0x0000ff00L, 0U)) >> 24) | \ + ((wxLongLong(val) & wxLongLong(0x00ff0000L, 0U)) >> 40) | \ + ((wxLongLong(val) & wxLongLong(0xff000000L, 0U)) >> 56)).GetValue()) + +#define wxINT64_SWAP_ALWAYS(val) \ + ((wxInt64) ( \ + ((wxLongLong(val) & wxLongLong(0L, 0x000000ffU)) << 56) | \ + ((wxLongLong(val) & wxLongLong(0L, 0x0000ff00U)) << 40) | \ + ((wxLongLong(val) & wxLongLong(0L, 0x00ff0000U)) << 24) | \ + ((wxLongLong(val) & wxLongLong(0L, 0xff000000U)) << 8) | \ + ((wxLongLong(val) & wxLongLong(0x000000ffL, 0U)) >> 8) | \ + ((wxLongLong(val) & wxLongLong(0x0000ff00L, 0U)) >> 24) | \ + ((wxLongLong(val) & wxLongLong(0x00ff0000L, 0U)) >> 40) | \ + ((wxLongLong(val) & wxLongLong(0xff000000L, 0U)) >> 56)).GetValue()) + + #ifdef WORDS_BIGENDIAN #define wxUINT16_SWAP_ON_BE(val) wxUINT16_SWAP_ALWAYS(val) #define wxINT16_SWAP_ON_BE(val) wxINT16_SWAP_ALWAYS(val) @@ -581,6 +582,8 @@ typedef float wxFloat32 ; #define wxINT32_SWAP_ON_BE(val) wxINT32_SWAP_ALWAYS(val) #define wxUINT32_SWAP_ON_LE(val) (val) #define wxINT32_SWAP_ON_LE(val) (val) + #define wxUINT64_SWAP_ON_BE(val) wxUINT64_SWAP_ALWAYS(val) + #define wxUINT64_SWAP_ON_LE(val) (val) #else #define wxUINT16_SWAP_ON_LE(val) wxUINT16_SWAP_ALWAYS(val) #define wxINT16_SWAP_ON_LE(val) wxINT16_SWAP_ALWAYS(val) @@ -590,6 +593,8 @@ typedef float wxFloat32 ; #define wxINT32_SWAP_ON_LE(val) wxINT32_SWAP_ALWAYS(val) #define wxUINT32_SWAP_ON_BE(val) (val) #define wxINT32_SWAP_ON_BE(val) (val) + #define wxUINT64_SWAP_ON_LE(val) wxUINT64_SWAP_ALWAYS(val) + #define wxUINT64_SWAP_ON_BE(val) (val) #endif // ---------------------------------------------------------------------------- diff --git a/src/common/datstrm.cpp b/src/common/datstrm.cpp index e0bd854d4c..f9f974012e 100644 --- a/src/common/datstrm.cpp +++ b/src/common/datstrm.cpp @@ -37,6 +37,18 @@ wxDataInputStream::~wxDataInputStream() { } +wxUint64 wxDataInputStream::Read64() +{ + wxUint64 i64; + + m_input->Read(&i64, 8); + + if (m_be_order) + return wxUINT64_SWAP_ON_LE(i64); + else + return wxUINT64_SWAP_ON_BE(i64); +} + wxUint32 wxDataInputStream::Read32() { wxUint32 i32; @@ -151,6 +163,12 @@ wxDataInputStream& wxDataInputStream::operator>>(wxUint32& i) return *this; } +wxDataInputStream& wxDataInputStream::operator>>(wxUint64& i) +{ + i = Read64(); + return *this; +} + wxDataInputStream& wxDataInputStream::operator>>(double& i) { i = ReadDouble(); @@ -176,6 +194,17 @@ wxDataOutputStream::~wxDataOutputStream() { } +void wxDataOutputStream::Write64(wxUint64 i) +{ + wxUint64 i64; + + if (m_be_order) + i64 = wxUINT64_SWAP_ON_LE(i); + else + i64 = wxUINT64_SWAP_ON_BE(i); + m_output->Write(&i64, 8); +} + void wxDataOutputStream::Write32(wxUint32 i) { wxUint32 i32; @@ -279,6 +308,12 @@ wxDataOutputStream& wxDataOutputStream::operator<<(wxUint32 i) return *this; } +wxDataOutputStream& wxDataOutputStream::operator<<(wxUint64 i) +{ + Write64(i); + return *this; +} + wxDataOutputStream& wxDataOutputStream::operator<<(double f) { WriteDouble(f); -- 2.45.2