From: <m97...@us...> - 2008-09-14 19:11:44
|
Revision: 8222 http://openmsx.svn.sourceforge.net/openmsx/?rev=8222&view=rev Author: m9710797 Date: 2008-09-14 19:11:52 +0000 (Sun, 14 Sep 2008) Log Message: ----------- small cleanups Modified Paths: -------------- openmsx/trunk/src/utils/Base64.cc openmsx/trunk/src/utils/Base64.hh openmsx/trunk/src/utils/CRC16.cc openmsx/trunk/src/utils/CRC16.hh openmsx/trunk/src/utils/DivModByConst.hh openmsx/trunk/src/utils/DivModBySame.cc openmsx/trunk/src/utils/DivModBySame.hh openmsx/trunk/src/utils/HexDump.cc openmsx/trunk/src/utils/HexDump.hh openmsx/trunk/src/utils/Math.hh openmsx/trunk/src/utils/Subject.hh openmsx/trunk/src/utils/TypeInfo.hh openmsx/trunk/src/utils/ref.hh openmsx/trunk/src/utils/tuple.hh openmsx/trunk/src/utils/type_traits.hh openmsx/trunk/src/utils/uint128.cc openmsx/trunk/src/utils/uint128.hh Modified: openmsx/trunk/src/utils/Base64.cc =================================================================== --- openmsx/trunk/src/utils/Base64.cc 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/Base64.cc 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id: $ + #include "Base64.hh" #include <cassert> Modified: openmsx/trunk/src/utils/Base64.hh =================================================================== --- openmsx/trunk/src/utils/Base64.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/Base64.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id: $ + #ifndef BASE64_HH #define BASE64_HH Modified: openmsx/trunk/src/utils/CRC16.cc =================================================================== --- openmsx/trunk/src/utils/CRC16.cc 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/CRC16.cc 2008-09-14 19:11:52 UTC (rev 8222) @@ -2,11 +2,9 @@ #include "CRC16.hh" - namespace openmsx { // Accelerator table to compute the CRC eight bits at a time - const word CRC16::CRC16Table[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, Modified: openmsx/trunk/src/utils/CRC16.hh =================================================================== --- openmsx/trunk/src/utils/CRC16.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/CRC16.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -39,7 +39,7 @@ /** Get current CRC value */ - word getValue() + word getValue() const { return crc; } Modified: openmsx/trunk/src/utils/DivModByConst.hh =================================================================== --- openmsx/trunk/src/utils/DivModByConst.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/DivModByConst.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #ifndef DIVMODBYCONST #define DIVMODBYCONST Modified: openmsx/trunk/src/utils/DivModBySame.cc =================================================================== --- openmsx/trunk/src/utils/DivModBySame.cc 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/DivModBySame.cc 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #include "DivModBySame.hh" #include "uint128.hh" #include <cassert> Modified: openmsx/trunk/src/utils/DivModBySame.hh =================================================================== --- openmsx/trunk/src/utils/DivModBySame.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/DivModBySame.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #ifndef DIVISIONBYCONST_HH #define DIVISIONBYCONST_HH Modified: openmsx/trunk/src/utils/HexDump.cc =================================================================== --- openmsx/trunk/src/utils/HexDump.cc 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/HexDump.cc 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id: $ + #include "HexDump.hh" namespace HexDump { Modified: openmsx/trunk/src/utils/HexDump.hh =================================================================== --- openmsx/trunk/src/utils/HexDump.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/HexDump.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id: $ + #ifndef HEXDUMP_HH #define HEXDUMP_HH Modified: openmsx/trunk/src/utils/Math.hh =================================================================== --- openmsx/trunk/src/utils/Math.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/Math.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -17,6 +17,10 @@ */ unsigned powerOfTwo(unsigned a); +/** Returns two gaussian distributed random numbers. + * We return two numbers instead of one because the second number comes for + * free in the current implementation. + */ void gaussian2(double& r1, double& r2); /** Clips x to the range [LO,HI]. @@ -94,6 +98,12 @@ return ((a * 0x0802LU & 0x22110LU) | (a * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16; } +/** Returns the smallest number of the form 2^n-1 that is greater or equal + * to the given number. + * The resulting number has the same number of leading zeros as the input, + * but starting from the first 1-bit in the input all bits more to the right + * are also 1. + */ inline unsigned floodRight(unsigned x) { x |= x >> 1; Modified: openmsx/trunk/src/utils/Subject.hh =================================================================== --- openmsx/trunk/src/utils/Subject.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/Subject.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -83,6 +83,6 @@ #endif } -} +} // namespace openmsx #endif Modified: openmsx/trunk/src/utils/TypeInfo.hh =================================================================== --- openmsx/trunk/src/utils/TypeInfo.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/TypeInfo.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #ifndef TYPEINFO_HH #define TYPEINFO_HH Modified: openmsx/trunk/src/utils/ref.hh =================================================================== --- openmsx/trunk/src/utils/ref.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/ref.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #ifndef REF_HH #define REF_HH Modified: openmsx/trunk/src/utils/tuple.hh =================================================================== --- openmsx/trunk/src/utils/tuple.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/tuple.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #ifndef TUPLE_HH #define TUPLE_HH @@ -134,5 +136,4 @@ } }; - #endif Modified: openmsx/trunk/src/utils/type_traits.hh =================================================================== --- openmsx/trunk/src/utils/type_traits.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/type_traits.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #ifndef TYPE_TRAITS_HH #define TYPE_TRAITS_HH Modified: openmsx/trunk/src/utils/uint128.cc =================================================================== --- openmsx/trunk/src/utils/uint128.cc 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/uint128.cc 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #include "uint128.hh" uint128& uint128::operator*=(const uint128& b) Modified: openmsx/trunk/src/utils/uint128.hh =================================================================== --- openmsx/trunk/src/utils/uint128.hh 2008-09-14 18:14:26 UTC (rev 8221) +++ openmsx/trunk/src/utils/uint128.hh 2008-09-14 19:11:52 UTC (rev 8222) @@ -1,3 +1,5 @@ +// $Id:$ + #ifndef UINT128_HH #define UINT128_HH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2008-10-29 22:16:39
|
Revision: 8327 http://openmsx.svn.sourceforge.net/openmsx/?rev=8327&view=rev Author: m9710797 Date: 2008-10-29 22:16:35 +0000 (Wed, 29 Oct 2008) Log Message: ----------- small tweak in 64-bit asm division routines: Also move shift instruction from c++ to asm. This especially helps on older versions of gcc (pre gcc-4.2). Modified Paths: -------------- openmsx/trunk/src/utils/DivModByConst.hh openmsx/trunk/src/utils/DivModBySame.hh Modified: openmsx/trunk/src/utils/DivModByConst.hh =================================================================== --- openmsx/trunk/src/utils/DivModByConst.hh 2008-10-29 22:16:25 UTC (rev 8326) +++ openmsx/trunk/src/utils/DivModByConst.hh 2008-10-29 22:16:35 UTC (rev 8327) @@ -196,7 +196,9 @@ "add %[TH],%[CL]\n\t" "adc $0,%[CH]\n\t" - : [CH] "=&rm" (ch) + "shrd %[SH],%[CH],%[CL]\n\t" + + : [CH] "=&r" (ch) , [CL] "=rm" (cl) , [TH] "=&r" (th) , [TL] "=&r" (tl) @@ -204,10 +206,11 @@ , [AL] "g" (al) , [BH] "rm" (bh) , [BL] "[CL]" (bl) + , [SH] "i" (R::S2) : "eax","edx" ); - uint64 c = (uint64(ch) << 32) | cl; - return c >> R::S2; + return cl; + #elif defined(__arm__) unsigned res; unsigned th,tl; @@ -286,7 +289,9 @@ "add %[TH],%[CL]\n\t" "adc $0,%[CH]\n\t" - : [CH] "=&rm" (ch) + "shrd %[SH],%[CH],%[CL]\n\t" + + : [CH] "=&r" (ch) , [CL] "=rm" (cl) , [TH] "=&r" (th) , [TL] "=&r" (tl) @@ -294,10 +299,11 @@ , [AL] "g" (al) , [BH] "rm" (bh) , [BL] "[CL]" (bl) + , [SH] "i" (R::S2) : "eax","edx" ); - uint64 c = (uint64(ch) << 32) | cl; - return c >> R::S2; + return cl; + #elif defined(__arm__) unsigned res; unsigned th,tl; Modified: openmsx/trunk/src/utils/DivModBySame.hh =================================================================== --- openmsx/trunk/src/utils/DivModBySame.hh 2008-10-29 22:16:25 UTC (rev 8326) +++ openmsx/trunk/src/utils/DivModBySame.hh 2008-10-29 22:16:35 UTC (rev 8327) @@ -67,9 +67,12 @@ "add %[TH],%[CL]\n\t" "adc $0,%[CH]\n\t" + "mov %[SH],%[TH]\n\t" // TH == ecx + "shrd %%cl,%[CH],%[CL]\n\t" + : [CH] "=r" (ch) , [CL] "=r" (cl) - , [TH] "=&rm" (th) + , [TH] "=&c" (th) // ecx , [TL] "=&rm" (tl) : "[CH]" (ch) , "[CL]" (cl) @@ -77,10 +80,10 @@ , [AL] "m" (al) , [BH] "m" (bh) , [BL] "m" (bl) + , [SH] "m" (s) : "eax","edx" ); - uint64 c = (uint64(ch) << 32) | cl; - return c >> s; + return cl; #elif defined(__arm__) unsigned res; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2008-11-08 07:51:13
|
Revision: 8344 http://openmsx.svn.sourceforge.net/openmsx/?rev=8344&view=rev Author: m9710797 Date: 2008-11-08 07:51:05 +0000 (Sat, 08 Nov 2008) Log Message: ----------- use gcc's builtin 128-bit type on x64_64 Modified Paths: -------------- openmsx/trunk/src/utils/DivModBySame.cc openmsx/trunk/src/utils/uint128.cc openmsx/trunk/src/utils/uint128.hh Modified: openmsx/trunk/src/utils/DivModBySame.cc =================================================================== --- openmsx/trunk/src/utils/DivModBySame.cc 2008-11-06 17:40:18 UTC (rev 8343) +++ openmsx/trunk/src/utils/DivModBySame.cc 2008-11-08 07:51:05 UTC (rev 8344) @@ -48,7 +48,7 @@ --l; } if ((m_high >> 64) == 0) { - m = m_high.toUint64(); + m = toUint64(m_high); s = l; a = 0; } else { @@ -56,9 +56,9 @@ // "Integer Multiplication and Division on the HP Precision Architecture". // IEEE Transactions on Computers, Vol 37, No. 8, August 1988, page 980. s = log2(t); - uint128 m_low = (uint128(1) << (64 + s)) / t; - uint64 r = ((uint128(1) << (64 + s)) % t).toUint64(); - m = (m_low + ((r <= (t >> 1)) ? 0 : 1)).toUint64(); + uint128 m_low = (uint128(1) << (64 + s)) / t; + uint64 r = toUint64((uint128(1) << (64 + s)) % t); + m = toUint64(m_low + ((r <= (t >> 1)) ? 0 : 1)); a = m; } // reduce multiplier to smallest possible Modified: openmsx/trunk/src/utils/uint128.cc =================================================================== --- openmsx/trunk/src/utils/uint128.cc 2008-11-06 17:40:18 UTC (rev 8343) +++ openmsx/trunk/src/utils/uint128.cc 2008-11-08 07:51:05 UTC (rev 8344) @@ -1,5 +1,11 @@ // $Id:$ +#ifdef __x86_64 + +//nothing + +#else // __x86_64 + #include "uint128.hh" uint128& uint128::operator*=(const uint128& b) @@ -69,3 +75,4 @@ } } +#endif // __x86_64 Modified: openmsx/trunk/src/utils/uint128.hh =================================================================== --- openmsx/trunk/src/utils/uint128.hh 2008-11-06 17:40:18 UTC (rev 8343) +++ openmsx/trunk/src/utils/uint128.hh 2008-11-08 07:51:05 UTC (rev 8344) @@ -3,6 +3,17 @@ #ifndef UINT128_HH #define UINT128_HH +typedef unsigned long long uint64; + +#ifdef __x86_64 + +// On 64-bit CPUs gcc already provides a 128-bit type, +// use that type because it's most likely much more efficient. +typedef __uint128_t uint128; +inline uint64 toUint64(uint128 a) { return a; } + +#else // __x86_64 + /** Unsigned 128-bit integer type. * Very simple implementation, not optimized for speed. * @@ -12,8 +23,6 @@ class uint128 { public: - typedef unsigned long long uint64; - uint128() {} uint128(const uint128& a) : lo(a.lo), hi(a.hi) {} uint128(uint64 a) : lo(a), hi(0) {} @@ -127,19 +136,14 @@ return *this; } - uint64 toUint64() const - { - return lo; - } + uint128& operator*=(const uint128& b); - uint128& operator*=(const uint128& b); +private: + uint128(uint64 a, uint64 b) : lo(a), hi(b) {} uint128 div(const uint128& ds, uint128& remainder) const; bool bit(unsigned n) const; void setBit(unsigned n); -private: - uint128(uint64 a, uint64 b) : lo(a), hi(b) {} - uint64 lo; uint64 hi; @@ -147,6 +151,7 @@ friend bool operator==(const uint128&, const uint128&); friend bool operator||(const uint128&, const uint128&); friend bool operator&&(const uint128&, const uint128&); + friend uint64 toUint64(const uint128&); }; @@ -227,4 +232,11 @@ return a.hi || a.lo || b.hi || b.lo; } -#endif +inline uint64 toUint64(const uint128& a) +{ + return a.lo; +} + +#endif // __x86_64 + +#endif // UINT128_HH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2008-12-11 09:00:44
|
Revision: 8402 http://openmsx.svn.sourceforge.net/openmsx/?rev=8402&view=rev Author: m9710797 Date: 2008-12-11 09:00:39 +0000 (Thu, 11 Dec 2008) Log Message: ----------- rewrote asm routines (split in different sections) so that operand constraints can be satisfied when compiling on OSX with devel flavour Modified Paths: -------------- openmsx/trunk/src/utils/DivModByConst.hh openmsx/trunk/src/utils/DivModBySame.hh Modified: openmsx/trunk/src/utils/DivModByConst.hh =================================================================== --- openmsx/trunk/src/utils/DivModByConst.hh 2008-12-10 19:51:55 UTC (rev 8401) +++ openmsx/trunk/src/utils/DivModByConst.hh 2008-12-11 09:00:39 UTC (rev 8402) @@ -167,14 +167,14 @@ { typedef DBCReduce<M, S> R; #if defined(ASM_X86_32) || defined(__arm__) - unsigned ah = R::M2 >> 32; - unsigned al = unsigned(R::M2); - unsigned bh = dividend >> 32; - unsigned bl = unsigned(dividend); + const unsigned ah = R::M2 >> 32; + const unsigned al = unsigned(R::M2); + const unsigned bh = dividend >> 32; + const unsigned bl = unsigned(dividend); #endif #ifdef ASM_X86_32 unsigned th, tl, ch, cl; - asm volatile ( + asm ( "mov %[AH],%%eax\n\t" "mull %[BL]\n\t" "mov %%eax,%[TL]\n\t" @@ -196,19 +196,24 @@ "add %[TH],%[CL]\n\t" "adc $0,%[CH]\n\t" - "shrd %[SH],%[CH],%[CL]\n\t" - - : [CH] "=&r" (ch) + : [CH] "=&rm" (ch) + , [TH] "=&r" (th) , [CL] "=rm" (cl) - , [TH] "=&r" (th) - , [TL] "=&r" (tl) + , [TL] "=&rm" (tl) : [AH] "g" (ah) , [AL] "g" (al) , [BH] "rm" (bh) , [BL] "[CL]" (bl) - , [SH] "i" (R::S2) : "eax","edx" ); + asm ( + "shrd %[SH],%[CH],%[CL]\n\t" + + : [CL] "=rm" (cl) + : [CH] "r" (ch) + , "[CL]" (cl) + , [SH] "i" (R::S2) + ); return cl; #elif defined(__arm__) @@ -257,14 +262,14 @@ { typedef DBCReduce<M, S + N> R; #if defined(ASM_X86_32) || defined(__arm__) - unsigned ah = R::M2 >> 32; - unsigned al = unsigned(R::M2); - unsigned bh = dividend >> 32; - unsigned bl = dividend; + const unsigned ah = R::M2 >> 32; + const unsigned al = unsigned(R::M2); + const unsigned bh = dividend >> 32; + const unsigned bl = dividend; #endif #ifdef ASM_X86_32 unsigned th, tl, ch, cl; - asm volatile ( + asm ( "mov %[AH],%%eax\n\t" "mull %[BL]\n\t" "mov %%eax,%[TL]\n\t" @@ -289,19 +294,24 @@ "add %[TH],%[CL]\n\t" "adc $0,%[CH]\n\t" - "shrd %[SH],%[CH],%[CL]\n\t" - - : [CH] "=&r" (ch) + : [CH] "=&rm" (ch) + , [TH] "=&r" (th) , [CL] "=rm" (cl) - , [TH] "=&r" (th) - , [TL] "=&r" (tl) + , [TL] "=&rm" (tl) : [AH] "g" (ah) , [AL] "g" (al) , [BH] "rm" (bh) , [BL] "[CL]" (bl) - , [SH] "i" (R::S2) : "eax","edx" ); + asm ( + "shrd %[SH],%[CH],%[CL]\n\t" + + : [CL] "=rm" (cl) + : [CH] "r" (ch) + , "[CL]" (cl) + , [SH] "i" (R::S2) + ); return cl; #elif defined(__arm__) Modified: openmsx/trunk/src/utils/DivModBySame.hh =================================================================== --- openmsx/trunk/src/utils/DivModBySame.hh 2008-12-10 19:51:55 UTC (rev 8401) +++ openmsx/trunk/src/utils/DivModBySame.hh 2008-12-11 09:00:39 UTC (rev 8402) @@ -35,16 +35,20 @@ return t >> s; #elif defined (ASM_X86_32) + unsigned dummy; unsigned th, tl; - unsigned ah = dividend >> 32; - unsigned al = dividend; - unsigned bh = m >> 32; - unsigned bl = m; unsigned ch = a >> 32; unsigned cl = a; - asm volatile ( - "mov %[AH],%%eax\n\t" - "mull %[BL]\n\t" + const unsigned ah = dividend >> 32; + const unsigned al = dividend; + const unsigned bh = m >> 32; + const unsigned bl = m; + // Split in 3 asm sections to be able to satisfy operand + // constraints: between two sections gcc can reassign operands + // to different registers or memory locations. Apparently there + // are only 3 free registers available on OSX (devel flavour). + asm ( + "mull %[BL]\n\t" // eax = [AH] "mov %%eax,%[TL]\n\t" "mov %%edx,%[TH]\n\t" "mov %[AL],%%eax\n\t" @@ -55,8 +59,20 @@ "add %[CH],%[TL]\n\t" "adc $0,%[TH]\n\t" - "mov %[AH],%%eax\n\t" - "mull %[BH]\n\t" + : [TH] "=&rm" (th) + , [TL] "=&r" (tl) + , [CH] "=rm" (ch) + , [CL] "=rm" (cl) + , [EAX] "=&a" (dummy) + : "[CH]" (ch) + , "[CL]" (cl) + , "[EAX]" (ah) + , [AL] "m" (al) + , [BL] "m" (bl) + : "edx" + ); + asm ( + "mull %[BH]\n\t" // eax = [AH] "mov %%eax,%[CL]\n\t" "mov %%edx,%[CH]\n\t" "mov %[AL],%%eax\n\t" @@ -67,21 +83,25 @@ "add %[TH],%[CL]\n\t" "adc $0,%[CH]\n\t" - "mov %[SH],%[TH]\n\t" // TH == ecx - "shrd %%cl,%[CH],%[CL]\n\t" + : [CH] "=rm" (ch) + , [CL] "=r" (cl) + , [TH] "=&rm" (th) + , [TL] "=&rm" (tl) + , [EAX] "=&a" (dummy) + : "[TH]" (th) + , "[TL]" (tl) + , "[EAX]" (ah) + , [AL] "m" (al) + , [BH] "m" (bh) + : "edx" + ); + asm ( + "shrd %%cl,%[CH],%[CL]\n\t" // SH = ecx - : [CH] "=r" (ch) - , [CL] "=rm" (cl) - , [TH] "=&c" (th) // ecx - , [TL] "=&rm" (tl) - : "[CH]" (ch) + : [CL] "=rm" (cl) + : [CH] "r" (ch) , "[CL]" (cl) - , [AH] "m" (ah) - , [AL] "m" (al) - , [BH] "m" (bh) - , [BL] "m" (bl) - , [SH] "m" (s) - : "eax","edx" + , [SH] "c" (s) ); return cl; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 16:04:59
|
Revision: 10441 http://openmsx.svn.sourceforge.net/openmsx/?rev=10441&view=rev Author: mthuurne Date: 2009-09-01 16:04:50 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Added "Id" keyword. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzo.hh openmsx/trunk/src/utils/lzoconf.hh openmsx/trunk/src/utils/lzodefs.hh Property Changed: ---------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzo.hh openmsx/trunk/src/utils/lzoconf.hh openmsx/trunk/src/utils/lzodefs.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 16:00:52 UTC (rev 10440) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 16:04:50 UTC (rev 10441) @@ -1,3 +1,5 @@ +// $Id$ + /* minilzo.cc -- mini subset of the LZO real-time data compression library This file is part of the LZO real-time data compression library. @@ -2230,7 +2232,7 @@ "$Copyright: LZO (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Markus Franz Xaver Johannes Oberhumer\n" "<ma...@ob...>\n" "http://www.oberhumer.com $\n\n" - "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" + "$" "Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n" "$Built: " __DATE__ " " __TIME__ " $\n" "$Info: " LZO_INFO_STRING " $\n"; #endif Property changes on: openmsx/trunk/src/utils/lzo.cc ___________________________________________________________________ Added: svn:keywords + Id Modified: openmsx/trunk/src/utils/lzo.hh =================================================================== --- openmsx/trunk/src/utils/lzo.hh 2009-09-01 16:00:52 UTC (rev 10440) +++ openmsx/trunk/src/utils/lzo.hh 2009-09-01 16:04:50 UTC (rev 10441) @@ -1,3 +1,5 @@ +// $Id$ + /* minilzo.hh -- mini subset of the LZO real-time data compression library This file is part of the LZO real-time data compression library. Property changes on: openmsx/trunk/src/utils/lzo.hh ___________________________________________________________________ Added: svn:keywords + Id Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 16:00:52 UTC (rev 10440) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 16:04:50 UTC (rev 10441) @@ -1,3 +1,5 @@ +// $Id$ + /* lzoconf.hh -- configuration for the LZO real-time data compression library This file is part of the LZO real-time data compression library. Property changes on: openmsx/trunk/src/utils/lzoconf.hh ___________________________________________________________________ Added: svn:keywords + Id Modified: openmsx/trunk/src/utils/lzodefs.hh =================================================================== --- openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 16:00:52 UTC (rev 10440) +++ openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 16:04:50 UTC (rev 10441) @@ -1,3 +1,5 @@ +// $Id$ + /* lzodefs.hh -- architecture, OS and compiler specific defines This file is part of the LZO real-time data compression library. Property changes on: openmsx/trunk/src/utils/lzodefs.hh ___________________________________________________________________ Added: svn:keywords + Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-04 13:13:20
|
Revision: 10511 http://openmsx.svn.sourceforge.net/openmsx/?rev=10511&view=rev Author: mthuurne Date: 2009-09-04 11:58:34 +0000 (Fri, 04 Sep 2009) Log Message: ----------- Put functions in the openMSX namespace. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzo.hh openmsx/trunk/src/utils/lzoconf.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-04 11:55:47 UTC (rev 10510) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-04 11:58:34 UTC (rev 10511) @@ -121,6 +121,8 @@ // End of configuration. +namespace openmsx { + /* If you use the LZO library in a product, I would appreciate that you * keep this copyright string in the executable of your product. */ @@ -657,3 +659,5 @@ return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); } + +} // namespace openmsx Modified: openmsx/trunk/src/utils/lzo.hh =================================================================== --- openmsx/trunk/src/utils/lzo.hh 2009-09-04 11:55:47 UTC (rev 10510) +++ openmsx/trunk/src/utils/lzo.hh 2009-09-04 11:58:34 UTC (rev 10511) @@ -60,6 +60,8 @@ #define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) +namespace openmsx { + /* compression */ int lzo1x_1_compress(const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, @@ -69,4 +71,6 @@ int lzo1x_decompress(const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len); +} // namespace openmsx + #endif // LZO_HH Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-04 11:55:47 UTC (rev 10510) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-04 11:58:34 UTC (rev 10511) @@ -172,6 +172,8 @@ # define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep)) #endif +namespace openmsx { + /* lzo_init() should be the first function you call. * Check the return code ! * @@ -186,4 +188,6 @@ /* misc. */ int _lzo_config_check(void); +} // namespace openmsx + #endif // LZOCONF_HH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-06 23:22:37
|
Revision: 10530 http://openmsx.svn.sourceforge.net/openmsx/?rev=10530&view=rev Author: mthuurne Date: 2009-09-06 22:48:11 +0000 (Sun, 06 Sep 2009) Log Message: ----------- Resolved "lzo_xint": since we only compile on 32-bit or higher systems, it is always equal to "lzo_uint". Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzoconf.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-06 22:43:13 UTC (rev 10529) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-06 22:48:11 UTC (rev 10530) @@ -80,7 +80,7 @@ return (const lzo_bytep) __lzo_copyright; } -#define DMUL(a,b) ((lzo_xint) ((a) * (b))) +#define DMUL(a,b) ((lzo_uint) ((a) * (b))) #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5) #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f) @@ -103,7 +103,7 @@ #define D_HIGH ((D_MASK >> 1) + 1) #define DX2(p,s1,s2) \ - (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0]) + (((((lzo_uint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0]) #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0]) #define DM(v) ((lzo_uint) ((v) & D_MASK)) Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-06 22:43:13 UTC (rev 10529) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-06 22:48:11 UTC (rev 10530) @@ -122,13 +122,6 @@ # endif #endif -/* The larger type of lzo_uint and lzo_uint32. */ -#if (LZO_UINT_MAX >= LZO_UINT32_MAX) -# define lzo_xint lzo_uint -#else -# define lzo_xint lzo_uint32 -#endif - /* no typedef here because of const-pointer issues */ #define lzo_bytep unsigned char * #define lzo_charp char * @@ -139,7 +132,6 @@ #define lzo_int32p lzo_int32 * #define lzo_uintp lzo_uint * #define lzo_intp lzo_int * -#define lzo_xintp lzo_xint * #define lzo_voidpp lzo_voidp * #define lzo_bytepp lzo_bytep * /* deprecated - use `lzo_bytep' instead of `lzo_byte *' */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2012-06-06 20:33:09
|
Revision: 12592 http://openmsx.svn.sourceforge.net/openmsx/?rev=12592&view=rev Author: m9710797 Date: 2012-06-06 20:33:03 +0000 (Wed, 06 Jun 2012) Log Message: ----------- Added string_ref class (not yet used) This class is based on a proposal for std::string_ref, see comments in code for more details. The motivation for this class is optimizing code sequences like: void f(const std::string& str); // function that accepts a string parameter ... vector<char> buffer; // some buffer (could also e.g. be a mmapped file) ... // fill buffer (e.g. read a file) char* p = ...; // search something in the buffer f(string(p, 10)); // pass part of the buffer to f() The last line in this code does: - Create a temporary std::string object. This allocates heap memory and makes a copy of the actual string data (plus some extra string management overhead, e.g. for gcc initialize a reference count). - Pass this string to the function f(). f() takes the string by reference to const, meaning it only wants to observe the string (not change it). - After f() returned the temporary string object is destroyed, so the heap memory gets deallocated. But f() only observes the string. So instead of making a copy of the data and passing that, we could directly pass a reference to the original data. This is exactly what the string_ref class can do. string_ref has an interface that is very close to a read-only std::string (so it's often a drop-in replacement for const std::string). But unless std::string it doesn't own the string data it points to. So it's useful for e.g. parameter passing, but e.g. it can't (in general) be used to store a string as a class member. Modified Paths: -------------- openmsx/trunk/src/utils/node.mk Added Paths: ----------- openmsx/trunk/src/utils/string_ref.cc openmsx/trunk/src/utils/string_ref.hh Modified: openmsx/trunk/src/utils/node.mk =================================================================== --- openmsx/trunk/src/utils/node.mk 2012-06-06 20:32:44 UTC (rev 12591) +++ openmsx/trunk/src/utils/node.mk 2012-06-06 20:33:03 UTC (rev 12592) @@ -16,7 +16,8 @@ uint128 \ DivModBySame \ AltSpaceSuppressor sdlwin32 utf8_checked win32-dirent win32-arggen \ - lzo + lzo \ + string_ref \ HDR_ONLY:= \ my_auto_ptr \ Added: openmsx/trunk/src/utils/string_ref.cc =================================================================== --- openmsx/trunk/src/utils/string_ref.cc (rev 0) +++ openmsx/trunk/src/utils/string_ref.cc 2012-06-06 20:33:03 UTC (rev 12592) @@ -0,0 +1,178 @@ +// $Id$ + +#include "string_ref.hh" +#include <algorithm> +#include <iostream> + +using std::string; + +// Outgoing conversion operators + +string string_ref::str() const +{ + return siz ? string(dat, siz) + : string(); +} + + +// mutators + +void string_ref::remove_prefix(unsigned n) +{ + if (n <= siz) { + dat += n; + siz -= n; + } else { + clear(); + } +} + +void string_ref::remove_suffix(unsigned n) +{ + if (n <= siz) { + siz -= n; + } else { + clear(); + } +} + + +// string operations with the same semantics as std::string + +int string_ref::compare(string_ref rhs) const +{ + // Check prefix. + if (int r = memcmp(dat, rhs.dat, std::min(siz, rhs.siz))) { + return r; + } + // Prefixes match, check length. + return siz - rhs.siz; // Note: this overflows for very large strings. +} + + +string_ref string_ref::substr(unsigned pos, unsigned n) const +{ + if (pos >= siz) return string_ref(); + return string_ref(dat + pos, std::min(n, siz - pos)); +} + +unsigned string_ref::find(string_ref s) const +{ + // Simple string search algorithm O(size() * s.size()). An algorithm + // like Boyer–Moore has better time complexity and will run a lot + // faster on large strings. Though when the strings are relatively + // short (the typically case?) this very simple algorithm may run + // faster (because it has no setup-time). The implementation of + // std::string::find() in gcc uses a similar simple algorithm. + if (s.empty()) return 0; + if (s.size() <= siz) { + unsigned m = siz - s.size(); + for (unsigned pos = 0; pos <= m; ++pos) { + if ((dat[pos] == s[0]) && + std::equal(s.begin() + 1, s.end(), dat + pos + 1)) { + return pos; + } + } + } + return npos; +} + +unsigned string_ref::find(char c) const +{ + const_iterator it = std::find(begin(), end(), c); + return (it == end()) ? npos : it - begin(); +} + +//unsigned string_ref::rfind(string_ref s) const; +//unsigned string_ref::rfind(char c) const; +//unsigned string_ref::find_first_of(string_ref s) const; +//unsigned string_ref::find_first_of(char c) const; +//unsigned string_ref::find_first_not_of(string_ref s) const; +//unsigned string_ref::find_first_not_of(char c) const; +//unsigned string_ref::find_last_of(string_ref s) const; +//unsigned string_ref::find_last_of(char c) const; +//unsigned string_ref::find_last_not_of(string_ref s) const; +//unsigned string_ref::find_last_not_of(char c) const; + +// new string operations (not part of std::string) +bool string_ref::starts_with(string_ref x) const +{ + return (siz >= x.size()) && + (memcmp(dat, x.data(), x.size()) == 0); +} + +bool string_ref::ends_with(string_ref x) const +{ + return (siz >= x.size()) && + (memcmp(dat + siz - x.size(), x.data(), x.size()) == 0); +} + + +// Comparison operators +bool operator==(string_ref x, string_ref y) +{ + return (x.size() == y.size()) && + (memcmp(x.data(), y.data(), x.size()) == 0); +} + +bool operator< (string_ref x, string_ref y) +{ + return x.compare(y) < 0; +} + + +// numeric conversions +// TODO could be implemented more efficient (don't make a copy) +int stoi(string_ref str, unsigned* idx, int base) +{ + string s = str.str(); + const char* begin = s.c_str(); + char* end; + int result = strtol(begin, &end, base); + if (idx) *idx = end - begin; + return result; +} +long long stoll(string_ref str, unsigned* idx, int base) +{ + string s = str.str(); + const char* begin = s.c_str(); + char* end; + int result = strtoll(begin, &end, base); + if (idx) *idx = end - begin; + return result; +} + + +// concatenation +// TODO make s1 + s2 + s3 also efficient +string operator+(string_ref x, string_ref y) +{ + string result; + result.reserve(x.size() + y.size()); + result.append(x.data(), x.size()); + result.append(y.data(), y.size()); + return result; +} +std::string operator+(char x, string_ref y) +{ + string result; + result.reserve(1 + y.size()); + result.append(&x, 1); + result.append(y.data(), y.size()); + return result; +} +std::string operator+(string_ref x, char y) +{ + string result; + result.reserve(x.size() + 1); + result.append(x.data(), x.size()); + result.append(&y, 1); + return result; +} + + +std::ostream& operator<<(std::ostream& os, string_ref str) +{ + os.write(str.data(), str.size()); + return os; +} Added: openmsx/trunk/src/utils/string_ref.hh =================================================================== --- openmsx/trunk/src/utils/string_ref.hh (rev 0) +++ openmsx/trunk/src/utils/string_ref.hh 2012-06-06 20:33:03 UTC (rev 12592) @@ -0,0 +1,131 @@ +// $Id$ + +#ifndef STRING_REF_HH +#define STRING_REF_HH + +#include <string> +#include <iosfwd> +#include <cassert> +#include "string.h" + +/** This class implements a subset of the proposal for std::string_ref + * (proposed for the next c++ standard (c++1y)). + * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html#classstd_1_1basic__string__ref_1ab23a4885309a116e8e67349fe0950290 + * + * It has an interface that is close to std::string, but it does not own + * the memory for the string. Basically it's just a wrapper around: + * const char* + length. + */ +class string_ref +{ +public: + typedef const char* const_iterator; + + static const unsigned npos = unsigned(-1); + + // construct/copy/assign + string_ref() + : dat(NULL), siz(0) {} + string_ref(const string_ref& str) + : dat(str.dat), siz(str.siz) {} + string_ref(const char* str) + : dat(str), siz(str ? strlen(str) : 0) {} + string_ref(const char* str, unsigned len) + : dat(str), siz(len) { if (dat == NULL) assert(siz == 0); } + string_ref(const char* begin, const char* end) + : dat(begin), siz(end - begin) { if (dat == NULL) assert(siz == 0); } + string_ref(const std::string& str) + : dat(str.data()), siz(str.size()) {} + + string_ref& operator=(const string_ref& rhs) { + dat = rhs.data(); + siz = rhs.size(); + return *this; + } + + // iterators + const_iterator begin() const { return dat; } + const_iterator end() const { return dat + siz; } + //const_iterator rbegin() const; + //const_iterator rend() const; + + // capacity + unsigned size() const { return siz; } + bool empty() const { return siz == 0; } + //unsigned max_size() const; + //unsigned length() const; + + // element access + char operator[](unsigned i) const { + assert(i < siz); + return dat[i]; + } + //const char& at(unsigned i) const; + char front() const { return *dat; } + char back() const { return *(dat + siz - 1); } + const char* data() const { return dat; } + + // Outgoing conversion operators + //explicit operator std::string() const; // c++11 + std::string str() const; + + // mutators + void clear() { siz = 0; } // no need to change 'dat' + void remove_prefix(unsigned n); + void remove_suffix(unsigned n); + void pop_back() { remove_suffix(1); } + void pop_front() { remove_prefix(1); } + + // string operations with the same semantics as std::string + int compare(string_ref x) const; + string_ref substr(unsigned pos, unsigned n = npos) const; + //unsigned copy(char* buf) const; + unsigned find(string_ref s) const; + unsigned find(char c) const; + //unsigned rfind(string_ref s) const; + //unsigned rfind(char c) const; + //unsigned find_first_of(string_ref s) const; + //unsigned find_first_of(char c) const; + //unsigned find_first_not_of(string_ref s) const; + //unsigned find_first_not_of(char c) const; + //unsigned find_last_of(string_ref s) const; + //unsigned find_last_of(char c) const; + //unsigned find_last_not_of(string_ref s) const; + //unsigned find_last_not_of(char c) const; + + // new string operations (not part of std::string) + bool starts_with(string_ref x) const; + bool ends_with(string_ref x) const; + +private: + const char* dat; + unsigned siz; +}; + + +// Comparison operators +bool operator==(string_ref x, string_ref y); +bool operator< (string_ref x, string_ref y); +inline bool operator!=(string_ref x, string_ref y) { return !(x == y); } +inline bool operator> (string_ref x, string_ref y) { return (y < x); } +inline bool operator<=(string_ref x, string_ref y) { return !(y < x); } +inline bool operator>=(string_ref x, string_ref y) { return !(x < y); } + +// numeric conversions +int stoi (string_ref str, unsigned* idx = NULL, int base = 0); +//long stol (string_ref str, unsigned* idx = NULL, int base = 0); +//unsigned long stoul (string_ref str, unsigned* idx = NULL, int base = 0); +long long stoll (string_ref str, unsigned* idx = NULL, int base = 0); +//unsigned long long stoull(string_ref str, unsigned* idx = NULL, int base = 0); +//float stof (string_ref str, unsigned* idx = NULL); +//double stod (string_ref str, unsigned* idx = NULL); +//long double stold (string_ref str, unsigned* idx = NULL); + +// concatenation (this is not part of the std::string_ref proposal) +std::string operator+(string_ref x, string_ref y); +std::string operator+(char x, string_ref y); +std::string operator+(string_ref x, char y); + +std::ostream& operator<<(std::ostream& os, string_ref str); + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2012-06-14 20:04:30
|
Revision: 12612 http://openmsx.svn.sourceforge.net/openmsx/?rev=12612&view=rev Author: m9710797 Date: 2012-06-14 20:04:24 +0000 (Thu, 14 Jun 2012) Log Message: ----------- Added StringMap<T> class (not yet used) Hash table indexed on strings. Based on the StringMap code from LLVM. See comments in the code for more details. See follow up patches for the motivation for adding this class. I did change the actual hash function from 'Bernstein' to 'FNV', the latter gave slightly better results in my (limited) tests. Modified Paths: -------------- openmsx/trunk/src/utils/node.mk Added Paths: ----------- openmsx/trunk/src/utils/StringMap.cc openmsx/trunk/src/utils/StringMap.hh Added: openmsx/trunk/src/utils/StringMap.cc =================================================================== --- openmsx/trunk/src/utils/StringMap.cc (rev 0) +++ openmsx/trunk/src/utils/StringMap.cc 2012-06-14 20:04:24 UTC (rev 12612) @@ -0,0 +1,192 @@ +#include "StringMap.hh" + +// Hash function for strings +// Fowler / Noll / Vo (FNV-1a) Hash +// http://www.isthe.com/chongo/tech/comp/fnv/ +static inline unsigned hashString(string_ref str) +{ + unsigned hash = 2166136261; + for (unsigned i = 0; i < str.size(); ++i) { + hash ^= str[i]; + hash *= 16777619; + } + return hash; +} + + +StringMapImpl::StringMapImpl(unsigned itemSize_, unsigned initSize) + : itemSize(itemSize_) +{ + if (initSize) { + // If a size is specified, initialize the table with that many buckets. + init(initSize); + } else { + // Otherwise, initialize it with zero buckets to avoid the allocation. + theTable = NULL; + numBuckets = 0; + numItems = 0; + numTombstones = 0; + } +} + +void StringMapImpl::init(unsigned initSize) +{ + assert(((initSize & (initSize - 1)) == 0) && + "Init Size must be a power of 2 or zero!"); + numBuckets = initSize; + numItems = 0; + numTombstones = 0; + + theTable = static_cast<StringMapEntryBase**>(calloc( + numBuckets + 1, + sizeof(StringMapEntryBase**) + sizeof(unsigned))); + + // Allocate one extra bucket, set it to look filled so the iterators + // stop at end. + theTable[numBuckets] = reinterpret_cast<StringMapEntryBase*>(2); +} + +unsigned StringMapImpl::lookupBucketFor(string_ref name) +{ + if (numBuckets == 0) { // Hash table unallocated so far? + init(16); + } + unsigned fullHashValue = hashString(name); + unsigned bucketNo = fullHashValue & (numBuckets - 1); + unsigned* hashTable = getHashTable(); + + unsigned probeAmt = 1; + int firstTombstone = -1; + while (true) { + StringMapEntryBase* bucketItem = theTable[bucketNo]; + if (bucketItem == 0) { + // Empty bucket, this means the key isn't in the table + // yet. If we found a tombstone earlier, then reuse + // that instead of using this empty bucket. + if (firstTombstone != -1) { + hashTable[firstTombstone] = fullHashValue; + return firstTombstone; + } + hashTable[bucketNo] = fullHashValue; + return bucketNo; + } else if (bucketItem == getTombstoneVal()) { + // Skip tombstones, but remember the first one we see. + if (firstTombstone == -1) firstTombstone = bucketNo; + } else if (hashTable[bucketNo] == fullHashValue) { + // If the full hash value matches, check deeply for a + // match. The common case here is that we are only + // looking at the buckets (for item info being non-null + // and for the full hash value) not at the items. This + // is important for cache locality. + const char* itemStr = (char*)bucketItem + itemSize; + if (name == string_ref(itemStr, bucketItem->getKeyLength())) { + return bucketNo; + } + } + + // Use quadratic probing, it has fewer clumping artifacts than linear + // probing and has good cache behavior in the common case. + bucketNo = (bucketNo + probeAmt) & (numBuckets - 1); + ++probeAmt; + } +} + +int StringMapImpl::findKey(string_ref key) const +{ + if (numBuckets == 0) return -1; + + unsigned fullHashValue = hashString(key); + unsigned bucketNo = fullHashValue & (numBuckets - 1); + unsigned* hashTable = getHashTable(); + + unsigned probeAmt = 1; + while (true) { + StringMapEntryBase* bucketItem = theTable[bucketNo]; + if (bucketItem == 0) { + // Empty bucket, key isn't in the table yet. + return -1; + } else if (bucketItem == getTombstoneVal()) { + // Ignore tombstones. + } else if (hashTable[bucketNo] == fullHashValue) { + // Hash matches, compare full string. + const char* itemStr = (char*)bucketItem + itemSize; + if (key == string_ref(itemStr, bucketItem->getKeyLength())) { + return bucketNo; + } + } + // Quadratic probing. + bucketNo = (bucketNo + probeAmt) & (numBuckets - 1); + ++probeAmt; + } +} + +void StringMapImpl::removeKey(StringMapEntryBase* v) +{ + const char* vStr = reinterpret_cast<char*>(v) + itemSize; + StringMapEntryBase* v2 = removeKey(string_ref(vStr, v->getKeyLength())); + assert(v == v2 && "Didn't find key?"); (void)v2; +} + +StringMapEntryBase* StringMapImpl::removeKey(string_ref key) +{ + int bucket = findKey(key); + if (bucket == -1) return NULL; + + StringMapEntryBase* result = theTable[bucket]; + theTable[bucket] = getTombstoneVal(); + --numItems; + ++numTombstones; + assert(numItems + numTombstones <= numBuckets); + return result; +} + +void StringMapImpl::rehashTable() +{ + // If the hash table is now more than 3/4 full, or if fewer than 1/8 of + // the buckets are empty (meaning that many are filled with tombstones), + // grow/rehash the table. + unsigned newSize; + if ((numItems * 4) > (numBuckets * 3)) { + newSize = numBuckets * 2; // double size + } else if (numBuckets - (numItems + numTombstones) < (numBuckets / 8)) { + newSize = numBuckets; // same size, only clear tombstones + } else { + return; + } + + // Allocate one extra bucket (see init()). + StringMapEntryBase** newTableArray = static_cast<StringMapEntryBase**>( + calloc(newSize + 1, + sizeof(StringMapEntryBase*) + sizeof(unsigned))); + newTableArray[newSize] = reinterpret_cast<StringMapEntryBase*>(2); + unsigned* newHashArray = (unsigned*)(newTableArray + newSize + 1); + + // Rehash all the items into their new buckets. Luckily we already have + // the hash values available, so we don't have to rehash any strings. + unsigned* hashTable = getHashTable(); + for (unsigned i = 0; i != numBuckets; ++i) { + StringMapEntryBase* bucket = theTable[i]; + if (bucket && (bucket != getTombstoneVal())) { + unsigned fullHash = hashTable[i]; + unsigned newBucket = fullHash & (newSize - 1); + if (newTableArray[newBucket] == 0) { + // Fast case, bucket available. + newTableArray[newBucket] = bucket; + newHashArray [newBucket] = fullHash; + } else { + // Otherwise probe for a spot (quadratic). + unsigned probeSize = 1; + do { + newBucket = (newBucket + probeSize++) & (newSize - 1); + } while (newTableArray[newBucket]); + newTableArray[newBucket] = bucket; + newHashArray[newBucket] = fullHash; + } + } + } + + free(theTable); + theTable = newTableArray; + numBuckets = newSize; + numTombstones = 0; +} Added: openmsx/trunk/src/utils/StringMap.hh =================================================================== --- openmsx/trunk/src/utils/StringMap.hh (rev 0) +++ openmsx/trunk/src/utils/StringMap.hh 2012-06-14 20:04:24 UTC (rev 12612) @@ -0,0 +1,405 @@ +#ifndef STRINGMAP_HH +#define STRINGMAP_HH + +// This is based on the StringMap class in LLVM: +// http://llvm.org/docs/ProgrammersManual.html#dss_stringmap +// See also that page for a more detailed descrption. +// +// Very briefly: the class StringMap<T> offers a hashtable-based map. The keys +// are strings (or any byte-array with variable length) and the value can be +// any type. Both keys and values are stored in (=owned by) the map. +// +// The interface of the StringMap<T> class is very close to the STL +// std::map<std::string, T> class. Though one notable difference is the use of +// 'first'. An example: +// +// typedef std::map<std::string, int> MySTLmap; +// MySTLmap m1 = ...; +// MySTLmap::const_iterator it1 = m1.find("abc"); // *1* +// assert(it1->first == "abc"); +// int i1 = it1->second; +// +// typedef StringMap<int> MyHashmap; +// MyHashmap m2 = ...; +// MyHashmap::const_iterator it = m2.find("abc"); // *2 +// assert(it2->first() == "abc"); +// int i2 = it2->second; +// +// So basically you only have to replace 'first' with 'first()'. Note that on +// the line marked with *1* a temporary std::string object needs to be +// constructed and destructed. The corresponding line *2* has no such overhead. + + +#include "string_ref.hh" +#include <cassert> +#include <cstring> // memcpy +#include <cstdlib> // malloc, free + +template<typename T> class StringMapConstIterator; +template<typename T> class StringMapIterator; + +// Non-templatized base class of StringMapEntry<T>. +class StringMapEntryBase +{ +public: + explicit StringMapEntryBase(unsigned len) : strLen(len) {} + unsigned getKeyLength() const { return strLen; } +private: + unsigned strLen; +}; + + +/// Non-templatized base class of StringMap<T>. +class StringMapImpl +{ +public: + static StringMapEntryBase* getTombstoneVal() { + return reinterpret_cast<StringMapEntryBase*>(-1); + } + + unsigned getNumBuckets() const { return numBuckets; } + bool empty() const { return numItems == 0; } + unsigned size() const { return numItems; } + +protected: + explicit StringMapImpl(unsigned itemSize, unsigned initSize); + + // Look up the bucket that the specified string should end up in. If it + // already exists as a key in the map, the Item pointer for the + // specified bucket will be non-null. Otherwise, it will be null. In + // either case, the FullHashValue field of the bucket will be set to + // the hash value of the string. + unsigned lookupBucketFor(string_ref key); + + // Look up the bucket that contains the specified key. If it exists in + // the map, return the bucket number of the key. Otherwise return -1. + // This does not modify the map. + int findKey(string_ref key) const; + + // Remove the specified StringMapEntry from the table, but do not + // delete it. This aborts if the value isn't in the table. + void removeKey(StringMapEntryBase *V); + + // Remove the StringMapEntry for the specified key from the table, + // returning it. If the key is not in the table, this returns null. + StringMapEntryBase* removeKey(string_ref key); + + // Grow the table, redistributing values into the buckets with the + // appropriate mod-of-hashtable-size. + void rehashTable(); + +private: + void init(unsigned Size); + unsigned* getHashTable() const { + return reinterpret_cast<unsigned*>(theTable + numBuckets + 1); + } + +protected: + // Array of numBuckets pointers to entries, NULL-ptrs are holes. + // theTable[numBuckets] contains a sentinel value for easy iteration. + // Followed by an array of the actual hash values as unsigned integers. + StringMapEntryBase** theTable; + unsigned numBuckets; + unsigned numItems; + unsigned numTombstones; + +private: + const unsigned itemSize; +}; + + +// This is used to represent one value that is inserted into a StringMap. +// It contains the value itself and the key (string-length + string-data). +template<typename T> class StringMapEntry : public StringMapEntryBase +{ +public: + T second; + +public: + // Create a StringMapEntry for the specified key and value. + static StringMapEntry* create(string_ref key, const T& v) + { + // Allocate memory. + StringMapEntry* newItem = static_cast<StringMapEntry*>( + malloc(sizeof(StringMapEntry) + key.size())); + + // Construct the value (using placement new). + new (newItem) StringMapEntry(key.size(), v); + + // Copy the string data. + char* strBuffer = const_cast<char*>(newItem->getKeyData()); + memcpy(strBuffer, key.data(), key.size()); + + return newItem; + } + + // Destroy this StringMapEntry, releasing memory. + void destroy() { + this->~StringMapEntry(); + free(this); + } + + string_ref getKey() const { + return string_ref(getKeyData(), getKeyLength()); + } + string_ref first() const { return getKey(); } + + const T& getValue() const { return second; } + T& getValue() { return second; } + void setValue(const T& v) { second = v; } + + // Return the start of the string data that is the key for this value. + const char* getKeyData() const { + // The string data is stored immediately after this object. + return reinterpret_cast<const char*>(this + 1); + } + + // Given a value that is known to be embedded into a StringMapEntry, + // return the StringMapEntry itself. + static StringMapEntry& GetStringMapEntryFromValue(T& v) { + StringMapEntry* ePtr = 0; + char* ptr = reinterpret_cast<char*>(&v) - + (reinterpret_cast<char*>(&ePtr->second) - + reinterpret_cast<char*>(ePtr)); + return *reinterpret_cast<StringMapEntry*>(ptr); + } + static const StringMapEntry& GetStringMapEntryFromValue(const T &v) { + return GetStringMapEntryFromValue(const_cast<T&>(v)); + } + + // Given key data that is known to be embedded into a StringMapEntry, + // return the StringMapEntry itself. + static StringMapEntry& GetStringMapEntryFromKeyData(const char* keyData) { + char* ptr = const_cast<char*>(keyData) - sizeof(StringMapEntry<T>); + return *reinterpret_cast<StringMapEntry*>(ptr); + } + +private: + StringMapEntry(unsigned strLen, const T& v) + : StringMapEntryBase(strLen), second(v) {} + + ~StringMapEntry() {} +}; + + +// This is an unconventional map that is specialized for handling keys that are +// "strings", which are basically ranges of bytes. This does some funky memory +// allocation and hashing things to make it extremely efficient, storing the +// string data *after* the value in the map. +template<typename T> class StringMap : public StringMapImpl +{ +public: + typedef const char* key_type; + typedef T mapped_type; + typedef StringMapEntry<T> value_type; + typedef size_t size_type; + typedef StringMapConstIterator<T> const_iterator; + typedef StringMapIterator<T> iterator; + + explicit StringMap(unsigned initialSize = 0) + : StringMapImpl(sizeof(value_type), initialSize) {} + + ~StringMap() { + clear(); + free(theTable); + } + + iterator begin() { + return iterator(theTable, numBuckets != 0); + } + const_iterator begin() const { + return const_iterator(theTable, numBuckets != 0); + } + iterator end() { + return iterator(theTable + numBuckets); + } + const_iterator end() const { + return const_iterator(theTable + numBuckets); + } + + iterator find(string_ref key) { + int bucket = findKey(key); + if (bucket == -1) return end(); + return iterator(theTable + bucket); + } + const_iterator find(string_ref key) const { + int bucket = findKey(key); + if (bucket == -1) return end(); + return const_iterator(theTable + bucket); + } + + // Return the entry for the specified key, or a default constructed + // value if no such entry exists. + T lookup(string_ref key) const { + const_iterator it = find(key); + if (it != end()) return it->second; + return T(); + } + + T& operator[](string_ref key) { + return getOrCreateValue(key).second; + } + + size_type count(string_ref key) const { + return (find(key) == end()) ? 0 : 1; + } + + // Insert the specified key/value pair into the map. If the key already + // exists in the map, return false and ignore the request, otherwise + // insert it and return true. + bool insert(value_type* keyValue) + { + unsigned bucketNo = lookupBucketFor(keyValue->getKey()); + StringMapEntryBase*& bucket = theTable[bucketNo]; + if (bucket && (bucket != getTombstoneVal())) { + return false; // Already exists in map. + } + if (bucket == getTombstoneVal()) { + --numTombstones; + } + bucket = keyValue; + ++numItems; + assert(numItems + numTombstones <= numBuckets); + + rehashTable(); + return true; + } + + // Empties out the StringMap + void clear() + { + if (empty()) return; + + // Zap all values, resetting the keys back to non-present (not + // tombstone), which is safe because we're removing all + // elements. + for (unsigned i = 0; i != numBuckets; ++i) { + StringMapEntryBase*& bucket = theTable[i]; + if (bucket && (bucket != getTombstoneVal())) { + static_cast<value_type*>(bucket)->destroy(); + } + bucket = NULL; + } + + numItems = 0; + numTombstones = 0; + } + + // Look up the specified key in the table. If a value exists, return + // it. Otherwise, default construct a value, insert it, and return. + value_type& getOrCreateValue(string_ref key, const T& val = T()) + { + unsigned bucketNo = lookupBucketFor(key); + StringMapEntryBase*& bucket = theTable[bucketNo]; + if (bucket && (bucket != getTombstoneVal())) { + return *static_cast<value_type*>(bucket); + } + + value_type* newItem = value_type::create(key, val); + + if (bucket == getTombstoneVal()) --numTombstones; + ++numItems; + assert(numItems + numTombstones <= numBuckets); + + // Fill in the bucket for the hash table. The FullHashValue was already + // filled in by lookupBucketFor(). + bucket = newItem; + + rehashTable(); + return *newItem; + } + + // Remove the specified key/value pair from the map, but do not destroy + // it. This aborts if the key is not in the map. + void remove(value_type* keyValue) { + removeKey(keyValue); + } + + void erase(iterator i) { + value_type& v = *i; + remove(&v); + v.destroy(); + } + + bool erase(string_ref key) { + iterator i = find(key); + if (i == end()) return false; + erase(i); + return true; + } + +private: + // disable copy and assign + StringMap(const StringMap&); + StringMap& operator=(const StringMap&); +}; + + +template<typename T> class StringMapConstIterator +{ +public: + typedef StringMapEntry<T> value_type; + + explicit StringMapConstIterator( + StringMapEntryBase** bucket, bool advance = false) + : ptr(bucket) + { + if (advance) advancePastEmptyBuckets(); + } + + const value_type& operator*() const { + return *static_cast<value_type*>(*ptr); + } + const value_type* operator->() const { + return static_cast<value_type*>(*ptr); + } + + bool operator==(const StringMapConstIterator& rhs) const { + return ptr == rhs.ptr; + } + bool operator!=(const StringMapConstIterator& rhs) const { + return ptr != rhs.ptr; + } + + inline StringMapConstIterator& operator++() { // preincrement + ++ptr; + advancePastEmptyBuckets(); + return *this; + } + StringMapConstIterator operator++(int) { // postincrement + StringMapConstIterator tmp = *this; + ++*this; + return tmp; + } + +protected: + StringMapEntryBase** ptr; + +private: + void advancePastEmptyBuckets() { + while ((*ptr == 0) || (*ptr == StringMapImpl::getTombstoneVal())) { + ++ptr; + } + } +}; + +template<typename T> class StringMapIterator : public StringMapConstIterator<T> +{ +public: + typedef StringMapEntry<T> value_type; + + explicit StringMapIterator( + StringMapEntryBase** bucket, bool advance = false) + : StringMapConstIterator<T>(bucket, advance) + { + } + + value_type& operator*() const { + return *static_cast<value_type*>(*this->ptr); + } + value_type* operator->() const { + return static_cast<value_type*>(*this->ptr); + } +}; + +#endif Modified: openmsx/trunk/src/utils/node.mk =================================================================== --- openmsx/trunk/src/utils/node.mk 2012-06-14 20:04:00 UTC (rev 12611) +++ openmsx/trunk/src/utils/node.mk 2012-06-14 20:04:24 UTC (rev 12612) @@ -11,6 +11,7 @@ HostCPU \ Math \ MemoryOps \ + StringMap \ StringOp \ sha1 \ uint128 \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2012-11-26 17:55:24
|
Revision: 12995 http://openmsx.svn.sourceforge.net/openmsx/?rev=12995&view=rev Author: m9710797 Date: 2012-11-26 17:55:18 +0000 (Mon, 26 Nov 2012) Log Message: ----------- Added missing check for nullptr after malloc()/calloc() Bug found by visual studio's code analysis function. Modified Paths: -------------- openmsx/trunk/src/utils/StringMap.cc openmsx/trunk/src/utils/StringMap.hh Modified: openmsx/trunk/src/utils/StringMap.cc =================================================================== --- openmsx/trunk/src/utils/StringMap.cc 2012-11-26 17:54:11 UTC (rev 12994) +++ openmsx/trunk/src/utils/StringMap.cc 2012-11-26 17:55:18 UTC (rev 12995) @@ -40,6 +40,9 @@ theTable = static_cast<StringMapEntryBase**>(calloc( numBuckets + 1, sizeof(StringMapEntryBase**) + sizeof(unsigned))); + if (unlikely(theTable == nullptr)) { + throw std::bad_alloc(); + } // Allocate one extra bucket, set it to look filled so the iterators // stop at end. @@ -158,6 +161,9 @@ auto newTableArray = static_cast<StringMapEntryBase**>( calloc(newSize + 1, sizeof(StringMapEntryBase*) + sizeof(unsigned))); + if (unlikely(newTableArray == nullptr)) { + throw std::bad_alloc(); + } newTableArray[newSize] = reinterpret_cast<StringMapEntryBase*>(2); auto newHashArray = reinterpret_cast<unsigned*>(newTableArray + newSize + 1); Modified: openmsx/trunk/src/utils/StringMap.hh =================================================================== --- openmsx/trunk/src/utils/StringMap.hh 2012-11-26 17:54:11 UTC (rev 12994) +++ openmsx/trunk/src/utils/StringMap.hh 2012-11-26 17:55:18 UTC (rev 12995) @@ -31,9 +31,11 @@ #include "string_ref.hh" +#include "likely.hh" #include <cassert> #include <cstring> // memcpy #include <cstdlib> // malloc, free +#include <new> // bad_alloc template<typename T> class StringMapConstIterator; template<typename T> class StringMapIterator; @@ -122,6 +124,9 @@ // Allocate memory. auto newItem = static_cast<StringMapEntry*>( malloc(sizeof(StringMapEntry) + key.size())); + if (unlikely(newItem == nullptr)) { + throw std::bad_alloc(); + } // Construct the value (using placement new). new (newItem) StringMapEntry(key.size(), std::move(v)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2009-01-12 17:29:54
|
Revision: 8472 http://openmsx.svn.sourceforge.net/openmsx/?rev=8472&view=rev Author: m9710797 Date: 2009-01-12 17:29:34 +0000 (Mon, 12 Jan 2009) Log Message: ----------- match coding style with the rest of the openMSX code Modified Paths: -------------- openmsx/trunk/src/utils/my_auto_ptr.hh openmsx/trunk/src/utils/win32-dirent.cc openmsx/trunk/src/utils/win32-dirent.hh Modified: openmsx/trunk/src/utils/my_auto_ptr.hh =================================================================== --- openmsx/trunk/src/utils/my_auto_ptr.hh 2009-01-12 17:29:02 UTC (rev 8471) +++ openmsx/trunk/src/utils/my_auto_ptr.hh 2009-01-12 17:29:34 UTC (rev 8472) @@ -1,5 +1,8 @@ -#ifndef __MY_AUTO_PTR_HH__ -#define __MY_AUTO_PTR_HH__ +// $Id:$ + +#ifndef MY_AUTO_PTR_HH +#define MY_AUTO_PTR_HH + #include <algorithm> #include <iostream> #include <typeinfo> @@ -20,26 +23,33 @@ public: my_auto_ptr(T* t_ = 0) : t(t_) {} my_auto_ptr(my_auto_ptr& other) : t(other.t) { other.t = 0; } - ~my_auto_ptr() { - time_t curr = std::time(0); - if (t != NULL) PRT_DEBUG(std::ctime(&curr) << ": auto-destructing my_auto_ptr of type: " << typeid(t).name()); - delete t; - curr = std::time(0); - if (t != NULL) PRT_DEBUG(std::ctime(&curr) << "auto-destruction of my_auto_ptr of type " << typeid(t).name() << " done!"); + ~my_auto_ptr() { + if (t != NULL) { // don't bother printing for NULL ptrs + time_t curr = std::time(0); + PRT_DEBUG(std::ctime(&curr) << + ": auto-destructing my_auto_ptr of type: " << + typeid(t).name()); + delete t; + curr = std::time(0); + PRT_DEBUG(std::ctime(&curr) << + "auto-destruction of my_auto_ptr of type " << + typeid(t).name() << " done!"); + } } //~my_auto_ptr() { t = 0; } // a version without actually deleting void reset(T* t_ = 0) { my_auto_ptr<T>(t_).swap(*this); } T* get() const { return t; } T* release() { T* res = t; t = 0; return res; } - T& operator* () const { return *t; } T* operator->() const { return t; } - //my_auto_ptr& operator=(my_auto_ptr other) { swap(other); return *this; } - my_auto_ptr& operator=(my_auto_ptr& other) { reset(other.release()); return *this; } - template <typename T2> my_auto_ptr& operator=(my_auto_ptr<T2>& other) { reset(other.release()); return *this; } - template <typename T2> my_auto_ptr& operator=(std::auto_ptr<T2>& other) { reset(other.release()); return *this; } + my_auto_ptr& operator=(my_auto_ptr& other) + { reset(other.release()); return *this; } + template <typename T2> my_auto_ptr& operator=(my_auto_ptr<T2>& other) + { reset(other.release()); return *this; } + template <typename T2> my_auto_ptr& operator=(std::auto_ptr<T2>& other) + { reset(other.release()); return *this; } void swap(my_auto_ptr& other) { std::swap(t, other.t); } Modified: openmsx/trunk/src/utils/win32-dirent.cc =================================================================== --- openmsx/trunk/src/utils/win32-dirent.cc 2009-01-12 17:29:02 UTC (rev 8471) +++ openmsx/trunk/src/utils/win32-dirent.cc 2009-01-12 17:29:34 UTC (rev 8472) @@ -1,3 +1,5 @@ +// $Id:$ + /* Copyright (C) 2001, 2006 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or @@ -17,117 +19,102 @@ // NB: Taken from http://www.koders.com/c/fidB38A2E97F60B8A0C903631F8C60078DE8C6C8433.aspx // Also modified to use ANSI calls explicitly +// Slightly reformatted/simplified to fit openMSX coding style. #ifdef _MSC_VER +#include "win32-dirent.hh" #include <windows.h> -#include <stdio.h> -#include <string.h> +#include <cstring> +#include <cstdlib> -#include "win32-dirent.hh" - -DIR * -opendir (const char * name) +DIR* opendir(const char* name) { - DIR *dir; - HANDLE hnd; - char *file; - WIN32_FIND_DATAA find; + if (!name || !*name) return NULL; + size_t len = strlen(name); + char* file = static_cast<char*>(malloc(len + 3)); + strcpy(file, name); + if ((file[len - 1] != '/') && (file[len - 1] != '\\')) { + strcat(file, "/*"); + } else { + strcat(file, "*"); + } - if (!name || !*name) - return NULL; - file = (char*)malloc (strlen (name) + 3); - strcpy (file, name); - if (file[strlen (name) - 1] != '/' && file[strlen (name) - 1] != '\\') - strcat (file, "/*"); - else - strcat (file, "*"); + HANDLE hnd; + WIN32_FIND_DATAA find; + if ((hnd = FindFirstFileA(file, &find)) == INVALID_HANDLE_VALUE) { + free(file); + return NULL; + } - if ((hnd = FindFirstFileA (file, &find)) == INVALID_HANDLE_VALUE) - { - free (file); - return NULL; - } - - dir = (DIR*)malloc (sizeof (DIR)); - dir->mask = file; - dir->fd = (int) hnd; - dir->data = (char*)malloc (sizeof (WIN32_FIND_DATAA)); - dir->allocation = sizeof (WIN32_FIND_DATAA); - dir->size = dir->allocation; - dir->filepos = 0; - memcpy (dir->data, &find, sizeof (WIN32_FIND_DATAA)); - return dir; + DIR* dir = static_cast<DIR*>(malloc(sizeof(DIR))); + dir->mask = file; + dir->fd = int(hnd); + dir->data = malloc(sizeof(WIN32_FIND_DATAA)); + dir->filepos = 0; + memcpy(dir->data, &find, sizeof(WIN32_FIND_DATAA)); + return dir; } -struct dirent * -readdir (DIR * dir) +dirent* readdir(DIR* dir) { - static struct dirent entry; - WIN32_FIND_DATAA *find; + static dirent entry; + entry.d_ino = 0; + entry.d_type = 0; - entry.d_ino = 0; - entry.d_type = 0; - find = (WIN32_FIND_DATAA *) dir->data; + WIN32_FIND_DATAA* find = static_cast<WIN32_FIND_DATAA*>(dir->data); + if (dir->filepos) { + if (!FindNextFileA(static_cast<HANDLE>(dir->fd), find)) { + return NULL; + } + } - if (dir->filepos) - { - if (!FindNextFileA ((HANDLE) dir->fd, find)) - return NULL; - } - - entry.d_off = dir->filepos; - strncpy (entry.d_name, find->cFileName, sizeof (entry.d_name)); - entry.d_reclen = strlen (find->cFileName); - dir->filepos++; - return &entry; + entry.d_off = dir->filepos; + strncpy(entry.d_name, find->cFileName, sizeof(entry.d_name)); + entry.d_reclen = strlen(find->cFileName); + dir->filepos++; + return &entry; } -int -closedir (DIR * dir) +int closedir(DIR* dir) { - HANDLE hnd = (HANDLE) dir->fd; - free (dir->data); - free (dir->mask); - free (dir); - return FindClose (hnd) ? 0 : -1; + HANDLE hnd = static_cast<HANDLE>(dir->fd); + free(dir->data); + free(dir->mask); + free(dir); + return FindClose(hnd) ? 0 : -1; } -void -rewinddir (DIR * dir) +void rewinddir(DIR* dir) { - HANDLE hnd = (HANDLE) dir->fd; - WIN32_FIND_DATAA *find = (WIN32_FIND_DATAA *) dir->data; + HANDLE hnd = static_cast<HANDLE>(dir->fd); + WIN32_FIND_DATAA* find = static_cast<WIN32_FIND_DATAA*>(dir->data); - FindClose (hnd); - hnd = FindFirstFileA (dir->mask, find); - dir->fd = (int) hnd; - dir->filepos = 0; + FindClose(hnd); + hnd = FindFirstFileA(dir->mask, find); + dir->fd = int(hnd); + dir->filepos = 0; } -void -seekdir (DIR * dir, off_t offset) +void seekdir(DIR* dir, off_t offset) { - off_t n; - - rewinddir (dir); - for (n = 0; n < offset; n++) - { - if (FindNextFileA ((HANDLE) dir->fd, (WIN32_FIND_DATAA *) dir->data)) - dir->filepos++; - } + rewinddir(dir); + for (off_t n = 0; n < offset; ++n) { + if (FindNextFileA(static_cast<HANDLE>(dir->fd), + static_cast<WIN32_FIND_DATAA*>(dir->data))) { + dir->filepos++; + } + } } -off_t -telldir (DIR * dir) +off_t telldir(DIR* dir) { - return dir->filepos; + return dir->filepos; } -int -dirfd (DIR * dir) +int dirfd(DIR* dir) { - return dir->fd; + return dir->fd; } #endif Modified: openmsx/trunk/src/utils/win32-dirent.hh =================================================================== --- openmsx/trunk/src/utils/win32-dirent.hh 2009-01-12 17:29:02 UTC (rev 8471) +++ openmsx/trunk/src/utils/win32-dirent.hh 2009-01-12 17:29:34 UTC (rev 8472) @@ -1,7 +1,7 @@ -/* classes: h_files */ +// $Id:$ -#ifndef SCM_WIN32_DIRENT_H -#define SCM_WIN32_DIRENT_H +#ifndef WIN32_DIRENT_HH +#define WIN32_DIRENT_HH /* Copyright (C) 2001, 2006 Free Software Foundation, Inc. * @@ -25,6 +25,7 @@ into a buffer and return `struct dirent *' pointers into it. */ // NB: Taken from http://www.koders.com/c/fid5F00BC983E0F005E15E8E590E461D363F6146CEB.aspx +// Slightly reformatted/simplified to fit openMSX coding style. #ifdef _MSC_VER @@ -32,39 +33,35 @@ struct dirstream { - int fd; /* File descriptor. */ - char *data; /* Directory block. */ - size_t allocation; /* Space allocated for the block. */ - size_t size; /* Total valid data in the block. */ - size_t offset; /* Current offset into the block. */ - off_t filepos; /* Position of next entry to read. */ - char *mask; /* Initial file mask. */ + int fd; // File descriptor. + void* data; // Directory block. + off_t filepos; // Position of next entry to read. + char* mask; // Initial file mask. }; struct dirent { - long d_ino; - off_t d_off; - unsigned short int d_reclen; - unsigned char d_type; - char d_name[256]; + long d_ino; + off_t d_off; + unsigned short d_reclen; + unsigned char d_type; + char d_name[256]; }; -#define d_fileno d_ino /* Backwards compatibility. */ +#define d_fileno d_ino // Backwards compatibility. -/* This is the data type of directory stream objects. - The actual structure is opaque to users. */ - +// This is the data type of directory stream objects. +// The actual structure is opaque to users. typedef struct dirstream DIR; -DIR * opendir (const char * name); -struct dirent * readdir (DIR * dir); -int closedir (DIR * dir); -void rewinddir (DIR * dir); -void seekdir (DIR * dir, off_t offset); -off_t telldir (DIR * dir); -int dirfd (DIR * dir); +DIR* opendir(const char* name); +struct dirent* readdir(DIR* dir); +int closedir(DIR* dir); +void rewinddir(DIR* dir); +void seekdir(DIR* dir, off_t offset); +off_t telldir(DIR* dir); +int dirfd(DIR* dir); #endif -#endif /* SCM_WIN32_DIRENT_H */ +#endif // WIN32_DIRENT_HH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2009-01-18 18:41:29
|
Revision: 8480 http://openmsx.svn.sourceforge.net/openmsx/?rev=8480&view=rev Author: m9710797 Date: 2009-01-18 18:41:24 +0000 (Sun, 18 Jan 2009) Log Message: ----------- I broke VC++ build during an earlier cleanup, thanks to mfeingol for fixing it again Modified Paths: -------------- openmsx/trunk/src/utils/win32-dirent.cc openmsx/trunk/src/utils/win32-dirent.hh Modified: openmsx/trunk/src/utils/win32-dirent.cc =================================================================== --- openmsx/trunk/src/utils/win32-dirent.cc 2009-01-18 08:11:55 UTC (rev 8479) +++ openmsx/trunk/src/utils/win32-dirent.cc 2009-01-18 18:41:24 UTC (rev 8480) @@ -64,7 +64,7 @@ WIN32_FIND_DATAA* find = static_cast<WIN32_FIND_DATAA*>(dir->data); if (dir->filepos) { - if (!FindNextFileA(static_cast<HANDLE>(dir->fd), find)) { + if (!FindNextFileA(reinterpret_cast<HANDLE>(dir->fd), find)) { return NULL; } } @@ -78,7 +78,7 @@ int closedir(DIR* dir) { - HANDLE hnd = static_cast<HANDLE>(dir->fd); + HANDLE hnd = reinterpret_cast<HANDLE>(dir->fd); free(dir->data); free(dir->mask); free(dir); @@ -87,12 +87,12 @@ void rewinddir(DIR* dir) { - HANDLE hnd = static_cast<HANDLE>(dir->fd); + HANDLE hnd = reinterpret_cast<HANDLE>(dir->fd); WIN32_FIND_DATAA* find = static_cast<WIN32_FIND_DATAA*>(dir->data); FindClose(hnd); hnd = FindFirstFileA(dir->mask, find); - dir->fd = int(hnd); + dir->fd = INT_PTR(hnd); dir->filepos = 0; } @@ -100,7 +100,7 @@ { rewinddir(dir); for (off_t n = 0; n < offset; ++n) { - if (FindNextFileA(static_cast<HANDLE>(dir->fd), + if (FindNextFileA(reinterpret_cast<HANDLE>(dir->fd), static_cast<WIN32_FIND_DATAA*>(dir->data))) { dir->filepos++; } @@ -112,9 +112,12 @@ return dir->filepos; } -int dirfd(DIR* dir) +// For correctness on 64-bit Windows, this function would need to maintain an +// internal map of ints to HANDLEs, since HANDLEs are sizeof(void*). It's not +// used at the moment in the openMSX sources, so let's not bother for now. +/*int dirfd(DIR* dir) { return dir->fd; -} +}*/ #endif Modified: openmsx/trunk/src/utils/win32-dirent.hh =================================================================== --- openmsx/trunk/src/utils/win32-dirent.hh 2009-01-18 08:11:55 UTC (rev 8479) +++ openmsx/trunk/src/utils/win32-dirent.hh 2009-01-18 18:41:24 UTC (rev 8480) @@ -30,10 +30,11 @@ #ifdef _MSC_VER #include <sys/types.h> +#include <basetsd.h> // for INT_PTR struct dirstream { - int fd; // File descriptor. + INT_PTR fd; // File descriptor. void* data; // Directory block. off_t filepos; // Position of next entry to read. char* mask; // Initial file mask. @@ -60,7 +61,7 @@ void rewinddir(DIR* dir); void seekdir(DIR* dir, off_t offset); off_t telldir(DIR* dir); -int dirfd(DIR* dir); +//int dirfd(DIR* dir); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mfe...@us...> - 2009-02-01 22:38:58
|
Revision: 8542 http://openmsx.svn.sourceforge.net/openmsx/?rev=8542&view=rev Author: mfeingol Date: 2009-02-01 22:38:02 +0000 (Sun, 01 Feb 2009) Log Message: ----------- Change MinGW builds to use dirent-win32 instead of native MinGW dirent.h, thus obtaining proper UTF8 support from dirent calls Modified Paths: -------------- openmsx/trunk/src/utils/direntp.hh openmsx/trunk/src/utils/node.mk openmsx/trunk/src/utils/win32-dirent.cc openmsx/trunk/src/utils/win32-dirent.hh Modified: openmsx/trunk/src/utils/direntp.hh =================================================================== --- openmsx/trunk/src/utils/direntp.hh 2009-02-01 22:09:52 UTC (rev 8541) +++ openmsx/trunk/src/utils/direntp.hh 2009-02-01 22:38:02 UTC (rev 8542) @@ -3,9 +3,19 @@ #ifndef DIRENTP_HH #define DIRENTP_HH -#ifndef _MSC_VER +#ifndef _WIN32 #include <dirent.h> #else +// When building with MinGW, we use our own wrapper instead of the +// native dirent.h provided by the MinGW C runtime. We do this because +// we need an implementation of dirent that returns UTF8-encoded strings +// as chars. +// Unfortunately, MinGW's implementation of dirent provides either +// wchar_t-based versions that support UTF16 (when UNICODE is defined), +// or char-based versions containing what appear to be ANSI strings, +// certainly not UTF8. +// While this behavior is relatively consistent with Win32, it's not +// what we need here. Consequently, we use our wrapper instead. #include "win32-dirent.hh" #endif Modified: openmsx/trunk/src/utils/node.mk =================================================================== --- openmsx/trunk/src/utils/node.mk 2009-02-01 22:09:52 UTC (rev 8541) +++ openmsx/trunk/src/utils/node.mk 2009-02-01 22:38:02 UTC (rev 8542) @@ -15,7 +15,7 @@ sha1 \ uint128 \ DivModBySame \ - AltSpaceSuppressor sdlwin32 utf8_checked + AltSpaceSuppressor sdlwin32 utf8_checked win32-dirent HDR_ONLY:= \ my_auto_ptr \ Modified: openmsx/trunk/src/utils/win32-dirent.cc =================================================================== --- openmsx/trunk/src/utils/win32-dirent.cc 2009-02-01 22:09:52 UTC (rev 8541) +++ openmsx/trunk/src/utils/win32-dirent.cc 2009-02-01 22:38:02 UTC (rev 8542) @@ -21,7 +21,7 @@ // Also modified to use Unicode calls explicitly // Slightly reformatted/simplified to fit openMSX coding style. -#ifdef _MSC_VER +#ifdef _WIN32 #include "win32-dirent.hh" #include "utf8_checked.hh" @@ -87,7 +87,7 @@ int closedir(DIR* dir) { HANDLE hnd = reinterpret_cast<HANDLE>(dir->fd); - delete dir->data; + delete static_cast<WIN32_FIND_DATAW*>(dir->data); delete dir; return FindClose(hnd) ? 0 : -1; } Modified: openmsx/trunk/src/utils/win32-dirent.hh =================================================================== --- openmsx/trunk/src/utils/win32-dirent.hh 2009-02-01 22:09:52 UTC (rev 8541) +++ openmsx/trunk/src/utils/win32-dirent.hh 2009-02-01 22:38:02 UTC (rev 8542) @@ -27,7 +27,7 @@ // NB: Taken from http://www.koders.com/c/fid5F00BC983E0F005E15E8E590E461D363F6146CEB.aspx // Slightly reformatted/simplified to fit openMSX coding style. -#ifdef _MSC_VER +#ifdef _WIN32 #include <sys/types.h> #include <basetsd.h> // for INT_PTR This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2009-07-02 20:53:42
|
Revision: 10142 http://openmsx.svn.sourceforge.net/openmsx/?rev=10142&view=rev Author: m9710797 Date: 2009-07-02 19:01:57 +0000 (Thu, 02 Jul 2009) Log Message: ----------- don't inline OutputBuffer::insert() Generates slightly smaller code (about 20kB) and is hardly slower (if at all, I couldn't measure a difference). Modified Paths: -------------- openmsx/trunk/src/utils/MemBuffer.cc openmsx/trunk/src/utils/MemBuffer.hh Modified: openmsx/trunk/src/utils/MemBuffer.cc =================================================================== --- openmsx/trunk/src/utils/MemBuffer.cc 2009-07-02 19:01:40 UTC (rev 10141) +++ openmsx/trunk/src/utils/MemBuffer.cc 2009-07-02 19:01:57 UTC (rev 10142) @@ -1,6 +1,7 @@ // $Id$ #include "MemBuffer.hh" +#include "likely.hh" #include <algorithm> #include <cstdlib> @@ -16,17 +17,22 @@ free(begin); } -void OutputBuffer::insertGrow(const void* __restrict data, unsigned len) +void OutputBuffer::insert(const void* __restrict data, unsigned len) { - unsigned oldSize = end - begin; - unsigned newSize = std::max(oldSize + len, oldSize + oldSize / 2); - begin = reinterpret_cast<char*>(realloc(begin, newSize)); - end = begin + oldSize + len; - finish = begin + newSize; - memcpy(begin + oldSize, data, len); + char* newEnd = end + len; + if (likely(newEnd <= finish)) { + memcpy(end, data, len); + end = newEnd; + } else { + unsigned oldSize = end - begin; + unsigned newSize = std::max(oldSize + len, oldSize + oldSize / 2); + begin = reinterpret_cast<char*>(realloc(begin, newSize)); + end = begin + oldSize + len; + finish = begin + newSize; + memcpy(begin + oldSize, data, len); + } } - MemBuffer::MemBuffer(OutputBuffer& buffer) { data = buffer.begin; Modified: openmsx/trunk/src/utils/MemBuffer.hh =================================================================== --- openmsx/trunk/src/utils/MemBuffer.hh 2009-07-02 19:01:40 UTC (rev 10141) +++ openmsx/trunk/src/utils/MemBuffer.hh 2009-07-02 19:01:57 UTC (rev 10142) @@ -3,7 +3,6 @@ #ifndef MEMBUFFER_HH #define MEMBUFFER_HH -#include "likely.hh" #include <cstring> #include <cassert> @@ -38,16 +37,7 @@ /** Insert data at the end of this buffer. * This will automatically grow this buffer. */ - void insert(const void* __restrict data, unsigned len) - { - char* newEnd = end + len; - if (likely(newEnd <= finish)) { - memcpy(end, data, len); - end = newEnd; - } else { - insertGrow(data, len); - } - } + void insert(const void* __restrict data, unsigned len); /** Insert data at a given position. This will overwrite the old data. * It's not possible to grow the buffer via this method (so the buffer @@ -67,8 +57,6 @@ } private: - void insertGrow(const void* data, unsigned len); - char* begin; // begin of allocated memory char* end; // points right after the last used byte // so end - begin == size This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2009-07-03 04:35:03
|
Revision: 10143 http://openmsx.svn.sourceforge.net/openmsx/?rev=10143&view=rev Author: m9710797 Date: 2009-07-02 19:02:13 +0000 (Thu, 02 Jul 2009) Log Message: ----------- use __builtin_constant_p to simplify calls to OutputBuffer::insert() '__builtin_constant_p' is a gcc extension, it allows to test whether a certain expression is a compile-time constant or not. We use it to detect calls to OutputBuffer::insert() with the num parameter equal to 1, 2, 4, or 8. In such cases we call a specialized version of the routine, in all other cases we call the generic version. The benefit here does not come from the specialized code itself, but from the fact that the specialized function has one parameter less. This means the caller has to setup one parameter less and this saves a couple of bytes per call. Though there are a lot of callers and _by_far_ the majority has the num parameter equal to 1, 2, 4 or 8. The executable became about 35kB smaller with this patch. Modified Paths: -------------- openmsx/trunk/src/utils/MemBuffer.cc openmsx/trunk/src/utils/MemBuffer.hh Modified: openmsx/trunk/src/utils/MemBuffer.cc =================================================================== --- openmsx/trunk/src/utils/MemBuffer.cc 2009-07-02 19:01:57 UTC (rev 10142) +++ openmsx/trunk/src/utils/MemBuffer.cc 2009-07-02 19:02:13 UTC (rev 10143) @@ -17,22 +17,45 @@ free(begin); } -void OutputBuffer::insert(const void* __restrict data, unsigned len) +#ifdef __GNUC__ +template<unsigned LEN> void OutputBuffer::insertN(const void* __restrict data) { + char* newEnd = end + LEN; + if (likely(newEnd <= finish)) { + memcpy(end, data, LEN); + end = newEnd; + } else { + insertGrow(data, LEN); + } +} +// Force template instantiation +template void OutputBuffer::insertN<1>(const void* __restrict data); +template void OutputBuffer::insertN<2>(const void* __restrict data); +template void OutputBuffer::insertN<4>(const void* __restrict data); +template void OutputBuffer::insertN<8>(const void* __restrict data); +#endif + +void OutputBuffer::insertN(const void* __restrict data, unsigned len) +{ char* newEnd = end + len; if (likely(newEnd <= finish)) { memcpy(end, data, len); end = newEnd; } else { - unsigned oldSize = end - begin; - unsigned newSize = std::max(oldSize + len, oldSize + oldSize / 2); - begin = reinterpret_cast<char*>(realloc(begin, newSize)); - end = begin + oldSize + len; - finish = begin + newSize; - memcpy(begin + oldSize, data, len); + insertGrow(data, len); } } +void OutputBuffer::insertGrow(const void* __restrict data, unsigned len) +{ + unsigned oldSize = end - begin; + unsigned newSize = std::max(oldSize + len, oldSize + oldSize / 2); + begin = reinterpret_cast<char*>(realloc(begin, newSize)); + end = begin + oldSize + len; + finish = begin + newSize; + memcpy(begin + oldSize, data, len); +} + MemBuffer::MemBuffer(OutputBuffer& buffer) { data = buffer.begin; Modified: openmsx/trunk/src/utils/MemBuffer.hh =================================================================== --- openmsx/trunk/src/utils/MemBuffer.hh 2009-07-02 19:01:57 UTC (rev 10142) +++ openmsx/trunk/src/utils/MemBuffer.hh 2009-07-02 19:02:13 UTC (rev 10143) @@ -37,7 +37,27 @@ /** Insert data at the end of this buffer. * This will automatically grow this buffer. */ - void insert(const void* __restrict data, unsigned len); + void insert(const void* __restrict data, unsigned len) + { +#ifdef __GNUC__ + if (__builtin_constant_p(len)) { + if (len == 1) { + insertN<1>(data); return; + } else if (len == 2) { + insertN<2>(data); return; + } else if (len == 4) { + insertN<4>(data); return; + } else if (len == 8) { + insertN<8>(data); return; + } + } +#endif + insertN(data, len); + } +#ifdef __GNUC__ + template<unsigned N> void insertN(const void* __restrict data); +#endif + void insertN(const void* __restrict data, unsigned len); /** Insert data at a given position. This will overwrite the old data. * It's not possible to grow the buffer via this method (so the buffer @@ -57,6 +77,8 @@ } private: + void insertGrow(const void* __restrict data, unsigned len); + char* begin; // begin of allocated memory char* end; // points right after the last used byte // so end - begin == size This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <m97...@us...> - 2009-07-06 14:28:42
|
Revision: 10191 http://openmsx.svn.sourceforge.net/openmsx/?rev=10191&view=rev Author: m9710797 Date: 2009-07-06 14:28:32 +0000 (Mon, 06 Jul 2009) Log Message: ----------- added minilzo See http://www.oberhumer.com/opensource/lzo/ LZO is a very fast (de)compression routine. Though compression ratio is not as good as e.g. GZIP. The source code is small enough to be included in the openMSX source tree (and including the source code is also the recommended way according to the LZO documentation). Except for renaming .c -> .cc and .h -> .hh, the sources are unchanged compared to the original distribution. Code is not yet used in this commit. It will be in the next commit. Modified Paths: -------------- openmsx/trunk/src/utils/node.mk Added Paths: ----------- openmsx/trunk/src/utils/minilzo-2.03/ openmsx/trunk/src/utils/minilzo-2.03/COPYING openmsx/trunk/src/utils/minilzo-2.03/README.LZO openmsx/trunk/src/utils/minilzo-2.03/lzoconf.hh openmsx/trunk/src/utils/minilzo-2.03/lzodefs.hh openmsx/trunk/src/utils/minilzo-2.03/minilzo.cc openmsx/trunk/src/utils/minilzo-2.03/minilzo.hh openmsx/trunk/src/utils/minilzo-2.03/node.mk Added: openmsx/trunk/src/utils/minilzo-2.03/COPYING =================================================================== --- openmsx/trunk/src/utils/minilzo-2.03/COPYING (rev 0) +++ openmsx/trunk/src/utils/minilzo-2.03/COPYING 2009-07-06 14:28:32 UTC (rev 10191) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: openmsx/trunk/src/utils/minilzo-2.03/README.LZO =================================================================== --- openmsx/trunk/src/utils/minilzo-2.03/README.LZO (rev 0) +++ openmsx/trunk/src/utils/minilzo-2.03/README.LZO 2009-07-06 14:28:32 UTC (rev 10191) @@ -0,0 +1,123 @@ + + ============================================================================ + miniLZO -- mini subset of the LZO real-time data compression library + ============================================================================ + + Author : Markus Franz Xaver Johannes Oberhumer + <ma...@ob...> + http://www.oberhumer.com/opensource/lzo/ + Version : 2.03 + Date : 30 Apr 2008 + + I've created miniLZO for projects where it is inconvenient to + include (or require) the full LZO source code just because you + want to add a little bit of data compression to your application. + + miniLZO implements the LZO1X-1 compressor and both the standard and + safe LZO1X decompressor. Apart from fast compression it also useful + for situations where you want to use pre-compressed data files (which + must have been compressed with LZO1X-999). + + miniLZO consists of one C source file and three header files: + minilzo.c + minilzo.h, lzoconf.h, lzodefs.h + + To use miniLZO just copy these files into your source directory, add + minilzo.c to your Makefile and #include minilzo.h from your program. + Note: you also must distribute this file (`README.LZO') with your project. + + minilzo.o compiles to about 6 kB (using gcc or Visual C on a i386), and + the sources are about 30 kB when packed with zip - so there's no more + excuse that your application doesn't support data compression :-) + + For more information, documentation, example programs and other support + files (like Makefiles and build scripts) please download the full LZO + package from + http://www.oberhumer.com/opensource/lzo/ + + Have fun, + Markus + + + P.S. minilzo.c is generated automatically from the LZO sources and + therefore functionality is completely identical + + + Appendix A: building miniLZO + ---------------------------- + miniLZO is written such a way that it should compile and run + out-of-the-box on most machines. + + If you are running on a very unusual architecture and lzo_init() fails then + you should first recompile with `-DLZO_DEBUG' to see what causes the failure. + The most probable case is something like `sizeof(char *) != sizeof(long)'. + After identifying the problem you can compile by adding some defines + like `-DSIZEOF_CHAR_P=8' to your Makefile. + + The best solution is (of course) using Autoconf - if your project uses + Autoconf anyway just add `-DMINILZO_HAVE_CONFIG_H' to your compiler + flags when compiling minilzo.c. See the LZO distribution for an example + how to set up configure.in. + + + Appendix B: list of public functions available in miniLZO + --------------------------------------------------------- + Library initialization + lzo_init() + + Compression + lzo1x_1_compress() + + Decompression + lzo1x_decompress() + lzo1x_decompress_safe() + + Checksum functions + lzo_adler32() + + Version functions + lzo_version() + lzo_version_string() + lzo_version_date() + + Portable (but slow) string functions + lzo_memcmp() + lzo_memcpy() + lzo_memmove() + lzo_memset() + + + Appendix C: suggested macros for `configure.in' when using Autoconf + ------------------------------------------------------------------- + Checks for typedefs and structures + AC_CHECK_TYPE(ptrdiff_t,long) + AC_TYPE_SIZE_T + AC_CHECK_SIZEOF(short) + AC_CHECK_SIZEOF(int) + AC_CHECK_SIZEOF(long) + AC_CHECK_SIZEOF(long long) + AC_CHECK_SIZEOF(__int64) + AC_CHECK_SIZEOF(void *) + AC_CHECK_SIZEOF(size_t) + AC_CHECK_SIZEOF(ptrdiff_t) + + Checks for compiler characteristics + AC_C_CONST + + Checks for library functions + AC_CHECK_FUNCS(memcmp memcpy memmove memset) + + + Appendix D: Copyright + --------------------- + LZO and miniLZO are Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, + 2003, 2004, 2005, 2006, 2007, 2008 Markus Franz Xaver Johannes Oberhumer + + LZO and miniLZO are distributed under the terms of the GNU General + Public License (GPL). See the file COPYING. + + Special licenses for commercial and other applications which + are not willing to accept the GNU General Public License + are available by contacting the author. + + Added: openmsx/trunk/src/utils/minilzo-2.03/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/minilzo-2.03/lzoconf.hh (rev 0) +++ openmsx/trunk/src/utils/minilzo-2.03/lzoconf.hh 2009-07-06 14:28:32 UTC (rev 10191) @@ -0,0 +1,417 @@ +/* lzoconf.hh -- configuration for the LZO real-time data compression library + + This file is part of the LZO real-time data compression library. + + Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Markus F.X.J. Oberhumer + <ma...@ob...> + http://www.oberhumer.com/opensource/lzo/ + */ + + +#ifndef __LZOCONF_H_INCLUDED +#define __LZOCONF_H_INCLUDED + +#define LZO_VERSION 0x2030 +#define LZO_VERSION_STRING "2.03" +#define LZO_VERSION_DATE "Apr 30 2008" + +/* internal Autoconf configuration file - only used when building LZO */ +#if defined(LZO_HAVE_CONFIG_H) +# include <config.h> +#endif +#include <limits.h> +#include <stddef.h> + + +/*********************************************************************** +// LZO requires a conforming <limits.h> +************************************************************************/ + +#if !defined(CHAR_BIT) || (CHAR_BIT != 8) +# error "invalid CHAR_BIT" +#endif +#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) +# error "check your compiler installation" +#endif +#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) +# error "your limits.h macros are broken" +#endif + +/* get OS and architecture defines */ +#ifndef __LZODEFS_H_INCLUDED +#include "lzodefs.hh" +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + + +/*********************************************************************** +// some core defines +************************************************************************/ + +#if !defined(LZO_UINT32_C) +# if (UINT_MAX < LZO_0xffffffffL) +# define LZO_UINT32_C(c) c ## UL +# else +# define LZO_UINT32_C(c) ((c) + 0U) +# endif +#endif + +/* memory checkers */ +#if !defined(__LZO_CHECKER) +# if defined(__BOUNDS_CHECKING_ON) +# define __LZO_CHECKER 1 +# elif defined(__CHECKER__) +# define __LZO_CHECKER 1 +# elif defined(__INSURE__) +# define __LZO_CHECKER 1 +# elif defined(__PURIFY__) +# define __LZO_CHECKER 1 +# endif +#endif + + +/*********************************************************************** +// integral and pointer types +************************************************************************/ + +/* lzo_uint should match size_t */ +#if !defined(LZO_UINT_MAX) +# if defined(LZO_ABI_LLP64) /* WIN64 */ +# if defined(LZO_OS_WIN64) + typedef unsigned __int64 lzo_uint; + typedef __int64 lzo_int; +# else + typedef unsigned long long lzo_uint; + typedef long long lzo_int; +# endif +# define LZO_UINT_MAX 0xffffffffffffffffull +# define LZO_INT_MAX 9223372036854775807LL +# define LZO_INT_MIN (-1LL - LZO_INT_MAX) +# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ + typedef unsigned int lzo_uint; + typedef int lzo_int; +# define LZO_UINT_MAX UINT_MAX +# define LZO_INT_MAX INT_MAX +# define LZO_INT_MIN INT_MIN +# elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint; + typedef long lzo_int; +# define LZO_UINT_MAX ULONG_MAX +# define LZO_INT_MAX LONG_MAX +# define LZO_INT_MIN LONG_MIN +# else +# error "lzo_uint" +# endif +#endif + +/* Integral types with 32 bits or more. */ +#if !defined(LZO_UINT32_MAX) +# if (UINT_MAX >= LZO_0xffffffffL) + typedef unsigned int lzo_uint32; + typedef int lzo_int32; +# define LZO_UINT32_MAX UINT_MAX +# define LZO_INT32_MAX INT_MAX +# define LZO_INT32_MIN INT_MIN +# elif (ULONG_MAX >= LZO_0xffffffffL) + typedef unsigned long lzo_uint32; + typedef long lzo_int32; +# define LZO_UINT32_MAX ULONG_MAX +# define LZO_INT32_MAX LONG_MAX +# define LZO_INT32_MIN LONG_MIN +# else +# error "lzo_uint32" +# endif +#endif + +/* The larger type of lzo_uint and lzo_uint32. */ +#if (LZO_UINT_MAX >= LZO_UINT32_MAX) +# define lzo_xint lzo_uint +#else +# define lzo_xint lzo_uint32 +#endif + +/* Memory model that allows to access memory at offsets of lzo_uint. */ +#if !defined(__LZO_MMODEL) +# if (LZO_UINT_MAX <= UINT_MAX) +# define __LZO_MMODEL +# elif defined(LZO_HAVE_MM_HUGE_PTR) +# define __LZO_MMODEL_HUGE 1 +# define __LZO_MMODEL __huge +# else +# define __LZO_MMODEL +# endif +#endif + +/* no typedef here because of const-pointer issues */ +#define lzo_bytep unsigned char __LZO_MMODEL * +#define lzo_charp char __LZO_MMODEL * +#define lzo_voidp void __LZO_MMODEL * +#define lzo_shortp short __LZO_MMODEL * +#define lzo_ushortp unsigned short __LZO_MMODEL * +#define lzo_uint32p lzo_uint32 __LZO_MMODEL * +#define lzo_int32p lzo_int32 __LZO_MMODEL * +#define lzo_uintp lzo_uint __LZO_MMODEL * +#define lzo_intp lzo_int __LZO_MMODEL * +#define lzo_xintp lzo_xint __LZO_MMODEL * +#define lzo_voidpp lzo_voidp __LZO_MMODEL * +#define lzo_bytepp lzo_bytep __LZO_MMODEL * +/* deprecated - use `lzo_bytep' instead of `lzo_byte *' */ +#define lzo_byte unsigned char __LZO_MMODEL + +typedef int lzo_bool; + + +/*********************************************************************** +// function types +************************************************************************/ + +/* name mangling */ +#if !defined(__LZO_EXTERN_C) +# ifdef __cplusplus +# define __LZO_EXTERN_C extern "C" +# else +# define __LZO_EXTERN_C extern +# endif +#endif + +/* calling convention */ +#if !defined(__LZO_CDECL) +# define __LZO_CDECL __lzo_cdecl +#endif + +/* DLL export information */ +#if !defined(__LZO_EXPORT1) +# define __LZO_EXPORT1 +#endif +#if !defined(__LZO_EXPORT2) +# define __LZO_EXPORT2 +#endif + +/* __cdecl calling convention for public C and assembly functions */ +#if !defined(LZO_PUBLIC) +# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL +#endif +#if !defined(LZO_EXTERN) +# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) +#endif +#if !defined(LZO_PRIVATE) +# define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL +#endif + +/* function types */ +typedef int +(__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem ); + +typedef int +(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem, + const lzo_bytep dict, lzo_uint dict_len ); + +typedef int +(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len, + lzo_bytep dst, lzo_uintp dst_len, + lzo_voidp wrkmem, + const lzo_bytep dict, lzo_uint dict_len ); + + +/* Callback interface. Currently only the progress indicator ("nprogress") + * is used, but this may change in a future release. */ + +struct lzo_callback_t; +typedef struct lzo_callback_t lzo_callback_t; +#define lzo_callback_p lzo_callback_t __LZO_MMODEL * + +/* malloc & free function types */ +typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) + (lzo_callback_p self, lzo_uint items, lzo_uint size); +typedef void (__LZO_CDECL *lzo_free_func_t) + (lzo_callback_p self, lzo_voidp ptr); + +/* a progress indicator callback function */ +typedef void (__LZO_CDECL *lzo_progress_func_t) + (lzo_callback_p, lzo_uint, lzo_uint, int); + +struct lzo_callback_t +{ + /* custom allocators (set to 0 to disable) */ + lzo_alloc_func_t nalloc; /* [not used right now] */ + lzo_free_func_t nfree; /* [not used right now] */ + + /* a progress indicator callback function (set to 0 to disable) */ + lzo_progress_func_t nprogress; + + /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress + * callbacks points back to this struct, so you are free to store + * some extra info in the following variables. */ + lzo_voidp user1; + lzo_xint user2; + lzo_xint user3; +}; + + +/*********************************************************************** +// error codes and prototypes +************************************************************************/ + +/* Error codes for the compression/decompression functions. Negative + * values are errors, positive values will be used for special but + * normal events. + */ +#define LZO_E_OK 0 +#define LZO_E_ERROR (-1) +#define LZO_E_OUT_OF_MEMORY (-2) /* [not used right now] */ +#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ +#define LZO_E_INPUT_OVERRUN (-4) +#define LZO_E_OUTPUT_OVERRUN (-5) +#define LZO_E_LOOKBEHIND_OVERRUN (-6) +#define LZO_E_EOF_NOT_FOUND (-7) +#define LZO_E_INPUT_NOT_CONSUMED (-8) +#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ + + +#ifndef lzo_sizeof_dict_t +# define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep)) +#endif + +/* lzo_init() should be the first function you call. + * Check the return code ! + * + * lzo_init() is a macro to allow checking that the library and the + * compiler's view of various types are consistent. + */ +#define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ + (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ + (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ + (int)sizeof(lzo_callback_t)) +LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); + +/* version functions (useful for shared libraries) */ +LZO_EXTERN(unsigned) lzo_version(void); +LZO_EXTERN(const char *) lzo_version_string(void); +LZO_EXTERN(const char *) lzo_version_date(void); +LZO_EXTERN(const lzo_charp) _lzo_version_string(void); +LZO_EXTERN(const lzo_charp) _lzo_version_date(void); + +/* string functions */ +LZO_EXTERN(int) +lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); +LZO_EXTERN(lzo_voidp) +lzo_memset(lzo_voidp _s, int _c, lzo_uint _len); + +/* checksum functions */ +LZO_EXTERN(lzo_uint32) +lzo_adler32(lzo_uint32 _adler, const lzo_bytep _buf, lzo_uint _len); +LZO_EXTERN(lzo_uint32) +lzo_crc32(lzo_uint32 _c, const lzo_bytep _buf, lzo_uint _len); +LZO_EXTERN(const lzo_uint32p) +lzo_get_crc32_table(void); + +/* misc. */ +LZO_EXTERN(int) _lzo_config_check(void); +typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; +typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; +typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t; + +/* align a char pointer on a boundary that is a multiple of `size' */ +LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size); +#define LZO_PTR_ALIGN_UP(_ptr,_size) \ + ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) + + +/*********************************************************************** +// deprecated macros - only for backward compatibility with LZO v1.xx +************************************************************************/ + +#if defined(LZO_CFG_COMPAT) + +#define __LZOCONF_H 1 + +#if defined(LZO_ARCH_I086) +# define __LZO_i386 1 +#elif defined(LZO_ARCH_I386) +# define __LZO_i386 1 +#endif + +#if defined(LZO_OS_DOS16) +# define __LZO_DOS 1 +# define __LZO_DOS16 1 +#elif defined(LZO_OS_DOS32) +# define __LZO_DOS 1 +#elif defined(LZO_OS_WIN16) +# define __LZO_WIN 1 +# define __LZO_WIN16 1 +#elif defined(LZO_OS_WIN32) +# define __LZO_WIN 1 +#endif + +#define __LZO_CMODEL +#define __LZO_DMODEL +#define __LZO_ENTRY __LZO_CDECL +#define LZO_EXTERN_CDECL LZO_EXTERN +#define LZO_ALIGN LZO_PTR_ALIGN_UP + +#define lzo_compress_asm_t lzo_compress_t +#define lzo_decompress_asm_t lzo_decompress_t + +#endif /* LZO_CFG_COMPAT */ + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* already included */ + + +/* vim:set ts=4 et: */ Added: openmsx/trunk/src/utils/minilzo-2.03/lzodefs.hh =================================================================== --- openmsx/trunk/src/utils/minilzo-2.03/lzodefs.hh (rev 0) +++ openmsx/trunk/src/utils/minilzo-2.03/lzodefs.hh 2009-07-06 14:28:32 UTC (rev 10191) @@ -0,0 +1,1807 @@ +/* lzodefs.hh -- architecture, OS and compiler specific defines + + This file is part of the LZO real-time data compression library. + + Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer + Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer + All Rights Reserved. + + The LZO library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of + the License, or (at your option) any later version. + + The LZO library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with the LZO library; see the file COPYING. + If not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Markus F.X.J. Oberhumer + <ma...@ob...> + http://www.oberhumer.com/opensource/lzo/ + */ + + +#ifndef __LZODEFS_H_INCLUDED +#define __LZODEFS_H_INCLUDED 1 + +#if defined(__CYGWIN32__) && !defined(__CYGWIN__) +# define __CYGWIN__ __CYGWIN32__ +#endif +#if defined(__IBMCPP__) && !defined(__IBMC__) +# define __IBMC__ __IBMCPP__ +#endif +#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) +# define __INTEL_COMPILER __ICL +#endif +#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) +# define _ALL_SOURCE 1 +#endif +#if defined(__mips__) && defined(__R5900__) +# if !defined(__LONG_MAX__) +# define __LONG_MAX__ 9223372036854775807L +# endif +#endif +#if defined(__INTEL_COMPILER) && defined(__linux__) +# pragma warning(disable: 193) +#endif +#if defined(__KEIL__) && defined(__C166__) +# pragma warning disable = 322 +#elif 0 && defined(__C251__) +# pragma warning disable = 322 +#endif +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) +# if (_MSC_VER >= 1300) +# pragma warning(disable: 4668) +# endif +#endif +#if 0 && defined(__WATCOMC__) +# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) +# pragma warning 203 9 +# endif +#endif +#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) +# pragma option -h +#endif +#if 0 +#define LZO_0xffffL 0xfffful +#define LZO_0xffffffffL 0xfffffffful +#else +#define LZO_0xffffL 65535ul +#define LZO_0xffffffffL 4294967295ul +#endif +#if (LZO_0xffffL == LZO_0xffffffffL) +# error "your preprocessor is broken 1" +#endif +#if (16ul * 16384ul != 262144ul) +# error "your preprocessor is broken 2" +#endif +#if 0 +#if (32767 >= 4294967295ul) +# error "your preprocessor is broken 3" +#endif +#if (65535u >= 4294967295ul) +# error "your preprocessor is broken 4" +#endif +#endif +#if (UINT_MAX == LZO_0xffffL) +#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) +# if !defined(MSDOS) +# define MSDOS 1 +# endif +# if !defined(_MSDOS) +# define _MSDOS 1 +# endif +#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) +# if (__VERSION == 520) && (MB_LEN_MAX == 1) +# if !defined(__AZTEC_C__) +# define __AZTEC_C__ __VERSION +# endif +# if !defined(__DOS__) +# define __DOS__ 1 +# endif +# endif +#endif +#endif +#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) +# define ptrdiff_t long +# define _PTRDIFF_T_DEFINED +#endif +#if (UINT_MAX == LZO_0xffffL) +# undef __LZO_RENAME_A +# undef __LZO_RENAME_B +# if defined(__AZTEC_C__) && defined(__DOS__) +# define __LZO_RENAME_A 1 +# elif defined(_MSC_VER) && defined(MSDOS) +# if (_MSC_VER < 600) +# define __LZO_RENAME_A 1 +# elif (_MSC_VER < 700) +# define __LZO_RENAME_B 1 +# endif +# elif defined(__TSC__) && defined(__OS2__) +# define __LZO_RENAME_A 1 +# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) +# define __LZO_RENAME_A 1 +# elif defined(__PACIFIC__) && defined(DOS) +# if !defined(__far) +# define __far far +# endif +# if !defined(__near) +# define __near near +# endif +# endif +# if defined(__LZO_RENAME_A) +# if !defined(__cdecl) +# define __cdecl cdecl +# endif +# if !defined(__far) +# define __far far +# endif +# if !defined(__huge) +# define __huge huge +# endif +# if !defined(__near) +# define __near near +# endif +# if !defined(__pascal) +# define __pascal pascal +# endif +# if !defined(__huge) +# define __huge huge +# endif +# elif defined(__LZO_RENAME_B) +# if !defined(__cdecl) +# define __cdecl _cdecl +# endif +# if !defined(__far) +# define __far _far +# endif +# if !defined(__huge) +# define __huge _huge +# endif +# if !defined(__near) +# define __near _near +# endif +# if !defined(__pascal) +# define __pascal _pascal +# endif +# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) +# if !defined(__cdecl) +# define __cdecl cdecl +# endif +# if !defined(__pascal) +# define __pascal pascal +# endif +# endif +# undef __LZO_RENAME_A +# undef __LZO_RENAME_B +#endif +#if (UINT_MAX == LZO_0xffffL) +#if defined(__AZTEC_C__) && defined(__DOS__) +# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 +#elif defined(_MSC_VER) && defined(MSDOS) +# if (_MSC_VER < 600) +# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 +# endif +# if (_MSC_VER < 700) +# define LZO_BROKEN_INTEGRAL_PROMOTION 1 +# define LZO_BROKEN_SIZEOF 1 +# endif +#elif defined(__PACIFIC__) && defined(DOS) +# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 +#elif defined(__TURBOC__) && defined(__MSDOS__) +# if (__TURBOC__ < 0x0150) +# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 +# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 +# define LZO_BROKEN_INTEGRAL_PROMOTION 1 +# endif +# if (__TURBOC__ < 0x0200) +# define LZO_BROKEN_SIZEOF 1 +# endif +# if (__TURBOC__ < 0x0400) && defined(__cplusplus) +# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 +# endif +#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) +# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 +# define LZO_BROKEN_SIZEOF 1 +#endif +#endif +#if defined(__WATCOMC__) && (__WATCOMC__ < 900) +# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 +#endif +#if defined(_CRAY) && defined(_CRAY1) +# define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 +#endif +#define LZO_PP_STRINGIZE(x) #x +#define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) +#define LZO_PP_CONCAT2(a,b) a ## b +#define LZO_PP_CONCAT3(a,b,c) a ## b ## c +#define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d +#define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) +#define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) +#define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) +#define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) +#if 1 +#define LZO_CPP_STRINGIZE(x) #x +#define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) +#define LZO_CPP_CONCAT2(a,b) a ## b +#define LZO_CPP_CONCAT3(a,b,c) a ## b ## c +#define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d +#define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e +#define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) +#define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) +#define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) +#define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) +#endif +#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) +#if 1 && defined(__cplusplus) +# if !defined(__STDC_CONSTANT_MACROS) +# define __STDC_CONSTANT_MACROS 1 +# endif +# if !defined(__STDC_LIMIT_MACROS) +# define __STDC_LIMIT_MACROS 1 +# endif +#endif +#if defined(__cplusplus) +# define LZO_EXTERN_C extern "C" +#else +# define LZO_EXTERN_C extern +#endif +#if !defined(__LZO_OS_OVERRIDE) +#if defined(LZO_OS_FREESTANDING) +# define LZO_INFO_OS "freestanding" +#elif defined(LZO_OS_EMBEDDED) +# define LZO_INFO_OS "embedded" +#elif 1 && defined(__IAR_SYSTEMS_ICC__) +# define LZO_OS_EMBEDDED 1 +# define LZO_INFO_OS "embedded" +#elif defined(__CYGWIN__) && defined(__GNUC__) +# define LZO_OS_CYGWIN 1 +# define LZO_INFO_OS "cygwin" +#elif defined(__EMX__) && defined(__GNUC__) +# define LZO_OS_EMX 1 +# define LZO_INFO_OS "emx" +#elif defined(__BEOS__) +# define LZO_OS_BEOS 1 +# define LZO_INFO_OS "beos" +#elif defined(__Lynx__) +# define LZO_OS_LYNXOS 1 +# define LZO_INFO_OS "lynxos" +#elif defined(__OS400__) +# define LZO_OS_OS400 1 +# define LZO_INFO_OS "os400" +#elif defined(__QNX__) +# define LZO_OS_QNX 1 +# define LZO_INFO_OS "qnx" +#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) +# define LZO_OS_DOS32 1 +# define LZO_INFO_OS "dos32" +#elif defined(__BORLANDC__) && defined(__DPMI16__) +# define LZO_OS_DOS16 1 +# define LZO_INFO_OS "dos16" +#elif defined(__ZTC__) && defined(DOS386) +# define LZO_OS_DOS32 1 +# define LZO_INFO_OS "dos32" +#elif defined(__OS2__) || defined(__OS2V2__) +# if (UINT_MAX == LZO_0xffffL) +# define LZO_OS_OS216 1 +# define LZO_INFO_OS "os216" +# elif (UINT_MAX == LZO_0xffffffffL) +# define LZO_OS_OS2 1 +# define LZO_INFO_OS "os2" +# else +# error "check your limits.h header" +# endif +#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) +# define LZO_OS_WIN64 1 +# define LZO_INFO_OS "win64" +#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) +# define LZO_OS_WIN32 1 +# define LZO_INFO_OS "win32" +#elif defined(__MWERKS__) && defined(__INTEL__) +# define LZO_OS_WIN32 1 +# define LZO_INFO_OS "win32" +#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) +# if (UINT_MAX == LZO_0xffffL) +# define LZO_OS_WIN16 1 +# define LZO_INFO_OS "win16" +# elif (UINT_MAX == LZO_0xffffffffL) +# define LZO_OS_WIN32 1 +# define LZO_INFO_OS "win32" +# else +# error "check your limits.h header" +# endif +#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) +# if (UINT_MAX == LZO_0xffffL) +# define LZO_OS_DOS16 1 +# define LZO_INFO_OS "dos16" +# elif (UINT_MAX == LZO_0xffffffffL) +# define LZO_OS_DOS32 1 +# define LZO_INFO_OS "dos32" +# else +# error "check your limits.h header" +# endif +#elif defined(__WATCOMC__) +# if defined(__NT__) && (UINT_MAX == LZO_0xffffL) +# define LZO_OS_DOS16 1 +# define LZO_INFO_OS "dos16" +# elif defined(__NT__) && (__WATCOMC__ < 1100) +# define LZO_OS_WIN32 1 +# define LZO_INFO_OS "win32" +# elif defined(__linux__) || defined(__LINUX__) +# define LZO_OS_POSIX 1 +# define LZO_INFO_OS "posix" +# else +# error "please specify a target using the -bt compiler option" +# endif +#elif defined(__palmos__) +# define LZO_OS_PALMOS 1 +# define LZO_INFO_OS "palmos" +#elif defined(__TOS__) || defined(__atarist__) +# define LZO_OS_TOS 1 +# define LZO_INFO_OS "tos" +#elif defined(macintosh) && !defined(__ppc__) +# define LZO_OS_MACCLASSIC 1 +# define LZO_INFO_OS "macclassic" +#elif defined(__VMS) +# define LZO_OS_VMS 1 +# define LZO_INFO_OS "vms" +#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) +# define LZO_OS_CONSOLE 1 +# define LZO_OS_CONSOLE_PS2 1 +# define LZO_INFO_OS "console" +# define LZO_INFO_OS_CONSOLE "ps2" +#elif (defined(__mips__) && defined(__psp__)) +# define LZO_OS_CONSOLE 1 +# define LZO_OS_CONSOLE_PSP 1 +# define LZO_INFO_OS "console" +# define LZO_INFO_OS_CONSOLE "psp" +#else +# define LZO_OS_POSIX 1 +# define LZO_INFO_OS "posix" +#endif +#if (LZO_OS_POSIX) +# if defined(_AIX) || defined(__AIX__) || defined(__aix__) +# define LZO_OS_POSIX_AIX 1 +# define LZO_INFO_OS_POSIX "aix" +# elif defined(__FreeBSD__) +# define LZO_OS_POSIX_FREEBSD 1 +# define LZO_INFO_OS_POSIX "freebsd" +# elif defined(__hpux__) || defined(__hpux) +# define LZO_OS_POSIX_HPUX 1 +# define LZO_INFO_OS_POSIX "hpux" +# elif defined(__INTERIX) +# define LZO_OS_POSIX_INTERIX 1 +# define LZO_INFO_OS_POSIX "interix" +# elif defined(__IRIX__) || defined(__irix__) +# define LZO_OS_POSIX_IRIX 1 +# define LZO_INFO_OS_POSIX "irix" +# elif defined(__linux__) || defined(__linux) || defined(__LINUX__) +# define LZO_OS_POSIX_LINUX 1 +# define LZO_INFO_OS_POSIX "linux" +# elif defined(__APPLE__) || defined(__MACOS__) +# define LZO_OS_POSIX_MACOSX 1 +# define LZO_INFO_OS_POSIX "macosx" +# elif defined(__minix__) || defined(__minix) +# define LZO_OS_POSIX_MINIX 1 +# define LZO_INFO_OS_POSIX "minix" +# elif defined(__NetBSD__) +# define LZO_OS_POSIX_NETBSD 1 +# define LZO_INFO_OS_POSIX "netbsd" +# elif defined(__OpenBSD__) +# define LZO_OS_POSIX_OPENBSD 1 +# define LZO_INFO_OS_POSIX "openbsd" +# elif defined(__osf__) +# define LZO_OS_POSIX_OSF 1 +# define LZO_INFO_OS_POSIX "osf" +# elif defined(__solaris__) || defined(__sun) +# if defined(__SVR4) || defined(__svr4__) +# define LZO_OS_POSIX_SOLARIS 1 +# define LZO_INFO_OS_POSIX "solaris" +# else +# define LZO_OS_POSIX_SUNOS 1 +# define LZO_INFO_OS_POSIX "sunos" +# endif +# elif defined(__ultrix__) || defined(__ultrix) +# define LZO_OS_POSIX_ULTRIX 1 +# define LZO_INFO_OS_POSIX "ultrix" +# elif defined(_UNICOS) +# define LZO_OS_POSIX_UNICOS 1 +# define LZO_INFO_OS_POSIX "unicos" +# else +# define LZO_OS_POSIX_UNKNOWN 1 +# define LZO_INFO_OS_POSIX "unknown" +# endif +#endif +#endif +#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) +# if (UINT_MAX != LZO_0xffffL) +# error "this should not happen" +# endif +# if (ULONG_MAX != LZO_0xffffffffL) +# error "this should not happen" +# endif +#endif +#if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) +# if (UINT_MAX != LZO_0xffffffffL) +# error "this should not happen" +# endif +# if (ULONG_MAX != LZO_0xffffffffL) +# error "this should not happen" +# endif +#endif +#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) +# define LZO_CC_CILLY 1 +# define LZO_INFO_CC "Cilly" +# if defined(__CILLY__) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) +# else +# define LZO_INFO_CCVER "unknown" +# endif +#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) +# define LZO_CC_SDCC 1 +# define LZO_INFO_CC "sdcc" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) +#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) +# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) +# define LZO_INFO_CC "Pathscale C" +# define LZO_INFO_CCVER __PATHSCALE__ +#elif defined(__INTEL_COMPILER) +# define LZO_CC_INTELC 1 +# define LZO_INFO_CC "Intel C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) +# if defined(_WIN32) || defined(_WIN64) +# define LZO_CC_SYNTAX_MSC 1 +# else +# define LZO_CC_SYNTAX_GNUC 1 +# endif +#elif defined(__POCC__) && defined(_WIN32) +# define LZO_CC_PELLESC 1 +# define LZO_INFO_CC "Pelles C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) +#elif defined(__llvm__) && defined(__GNUC__) && defined(__VERSION__) +# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +# define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# else +# define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# endif +# define LZO_INFO_CC "llvm-gcc" +# define LZO_INFO_CCVER __VERSION__ +#elif defined(__GNUC__) && defined(__VERSION__) +# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) +# elif defined(__GNUC_MINOR__) +# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) +# else +# define LZO_CC_GNUC (__GNUC__ * 0x10000L) +# endif +# define LZO_INFO_CC "gcc" +# define LZO_INFO_CCVER __VERSION__ +#elif defined(__ACK__) && defined(_ACK) +# define LZO_CC_ACK 1 +# define LZO_INFO_CC "Amsterdam Compiler Kit C" +# define LZO_INFO_CCVER "unknown" +#elif defined(__AZTEC_C__) +# define LZO_CC_AZTECC 1 +# define LZO_INFO_CC "Aztec C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) +#elif defined(__BORLANDC__) +# define LZO_CC_BORLANDC 1 +# define LZO_INFO_CC "Borland C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) +#elif defined(_CRAYC) && defined(_RELEASE) +# define LZO_CC_CRAYC 1 +# define LZO_INFO_CC "Cray C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) +#elif defined(__DMC__) && defined(__SC__) +# define LZO_CC_DMC 1 +# define LZO_INFO_CC "Digital Mars C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) +#elif defined(__DECC) +# define LZO_CC_DECC 1 +# define LZO_INFO_CC "DEC C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) +#elif defined(__HIGHC__) +# define LZO_CC_HIGHC 1 +# define LZO_INFO_CC "MetaWare High C" +# define LZO_INFO_CCVER "unknown" +#elif defined(__IAR_SYSTEMS_ICC__) +# define LZO_CC_IARC 1 +# define LZO_INFO_CC "IAR C" +# if defined(__VER__) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) +# else +# define LZO_INFO_CCVER "unknown" +# endif +#elif defined(__IBMC__) +# define LZO_CC_IBMC 1 +# define LZO_INFO_CC "IBM C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) +#elif defined(__KEIL__) && defined(__C166__) +# define LZO_CC_KEILC 1 +# define LZO_INFO_CC "Keil C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) +#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) +# define LZO_CC_LCCWIN32 1 +# define LZO_INFO_CC "lcc-win32" +# define LZO_INFO_CCVER "unknown" +#elif defined(__LCC__) +# define LZO_CC_LCC 1 +# define LZO_INFO_CC "lcc" +# if defined(__LCC_VERSION__) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) +# else +# define LZO_INFO_CCVER "unknown" +# endif +#elif defined(_MSC_VER) +# define LZO_CC_MSC 1 +# define LZO_INFO_CC "Microsoft C" +# if defined(_MSC_FULL_VER) +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) +# else +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) +# endif +#elif defined(__MWERKS__) +# define LZO_CC_MWERKS 1 +# define LZO_INFO_CC "Metrowerks C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) +#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) +# define LZO_CC_NDPC 1 +# define LZO_INFO_CC "Microway NDP C" +# define LZO_INFO_CCVER "unknown" +#elif defined(__PACIFIC__) +# define LZO_CC_PACIFICC 1 +# define LZO_INFO_CC "Pacific C" +# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) +#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) +# define LZO_CC_PGI 1 +# define LZO_INFO_CC "Portland Group PGI C" +# define LZO_INFO_CCVER "unknown" +#elif defined(... [truncated message content] |
From: <mth...@us...> - 2009-09-01 16:28:29
|
Revision: 10444 http://openmsx.svn.sourceforge.net/openmsx/?rev=10444&view=rev Author: mthuurne Date: 2009-09-01 16:28:15 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Removed all preprocessor checks related to "config.h" inclusion, which will never happen. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzo.hh openmsx/trunk/src/utils/lzoconf.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 16:22:20 UTC (rev 10443) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 16:28:15 UTC (rev 10444) @@ -45,9 +45,6 @@ * http://www.oberhumer.com/opensource/lzo/ */ -#ifdef MINILZO_HAVE_CONFIG_H -# include <config.h> -#endif #include <limits.h> #include <stddef.h> #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS) @@ -1820,17 +1817,12 @@ #endif -#undef LZO_HAVE_CONFIG_H #include "lzo.hh" #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2030) # error "version mismatch in miniLZO source files" #endif -#ifdef MINILZO_HAVE_CONFIG_H -# define LZO_HAVE_CONFIG_H -#endif - #ifndef __LZO_CONF_H #define __LZO_CONF_H Modified: openmsx/trunk/src/utils/lzo.hh =================================================================== --- openmsx/trunk/src/utils/lzo.hh 2009-09-01 16:22:20 UTC (rev 10443) +++ openmsx/trunk/src/utils/lzo.hh 2009-09-01 16:28:15 UTC (rev 10444) @@ -55,7 +55,6 @@ # error "you cannot use both LZO and miniLZO" #endif -#undef LZO_HAVE_CONFIG_H #include "lzoconf.hh" #if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 16:22:20 UTC (rev 10443) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 16:28:15 UTC (rev 10444) @@ -47,10 +47,6 @@ #define LZO_VERSION_STRING "2.03" #define LZO_VERSION_DATE "Apr 30 2008" -/* internal Autoconf configuration file - only used when building LZO */ -#if defined(LZO_HAVE_CONFIG_H) -# include <config.h> -#endif #include <limits.h> #include <stddef.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 17:28:29
|
Revision: 10452 http://openmsx.svn.sourceforge.net/openmsx/?rev=10452&view=rev Author: mthuurne Date: 2009-09-01 17:28:21 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Use the same names for double-include guards as elsewhere in openMSX. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzo.hh openmsx/trunk/src/utils/lzoconf.hh openmsx/trunk/src/utils/lzodefs.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:26:28 UTC (rev 10451) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:28:21 UTC (rev 10452) @@ -56,7 +56,7 @@ // Start of configuration. -#if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) +#if (LZO_VERSION < 0x02000) # error "version mismatch" #endif Modified: openmsx/trunk/src/utils/lzo.hh =================================================================== --- openmsx/trunk/src/utils/lzo.hh 2009-09-01 17:26:28 UTC (rev 10451) +++ openmsx/trunk/src/utils/lzo.hh 2009-09-01 17:28:21 UTC (rev 10452) @@ -46,8 +46,8 @@ */ -#ifndef __MINILZO_H -#define __MINILZO_H +#ifndef LZO_HH +#define LZO_HH #define MINILZO_VERSION 0x2030 @@ -103,5 +103,4 @@ } /* extern "C" */ #endif -#endif /* already included */ - +#endif // LZO_HH Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 17:26:28 UTC (rev 10451) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 17:28:21 UTC (rev 10452) @@ -40,8 +40,8 @@ */ -#ifndef __LZOCONF_H_INCLUDED -#define __LZOCONF_H_INCLUDED +#ifndef LZOCONF_HH +#define LZOCONF_HH #define LZO_VERSION 0x2030 #define LZO_VERSION_STRING "2.03" @@ -66,9 +66,7 @@ #endif /* get OS and architecture defines */ -#ifndef __LZODEFS_H_INCLUDED #include "lzodefs.hh" -#endif #ifdef __cplusplus @@ -371,7 +369,4 @@ } /* extern "C" */ #endif -#endif /* already included */ - - -/* vim:set ts=4 et: */ +#endif // LZOCONF_HH Modified: openmsx/trunk/src/utils/lzodefs.hh =================================================================== --- openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 17:26:28 UTC (rev 10451) +++ openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 17:28:21 UTC (rev 10452) @@ -40,8 +40,8 @@ */ -#ifndef __LZODEFS_H_INCLUDED -#define __LZODEFS_H_INCLUDED 1 +#ifndef LZODEFS_HH +#define LZODEFS_HH #if defined(__CYGWIN32__) && !defined(__CYGWIN__) # define __CYGWIN__ __CYGWIN32__ @@ -1804,6 +1804,4 @@ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER -#endif /* already included */ - -/* vim:set ts=4 et: */ +#endif // LZODEFS_HH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 17:48:17
|
Revision: 10457 http://openmsx.svn.sourceforge.net/openmsx/?rev=10457&view=rev Author: mthuurne Date: 2009-09-01 17:48:10 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Resolved macros related to bounds checking, which is always off. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzoconf.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:43:41 UTC (rev 10456) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:48:10 UTC (rev 10457) @@ -124,13 +124,6 @@ # endif # include <assert.h> -#if 0 && defined(__BOUNDS_CHECKING_ON) -# include <unchecked.h> -#else -# define BOUNDS_CHECKING_OFF_DURING(stmt) stmt -# define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) -#endif - #if !defined(__lzo_inline) # define __lzo_inline #endif @@ -684,11 +677,11 @@ (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset) #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ - (BOUNDS_CHECKING_OFF_IN_EXPR(( \ + ( \ m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \ PTR_LT(m_pos,in) || \ (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) <= 0 || \ - m_off > max_offset ))) + m_off > max_offset ) #else Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 17:43:41 UTC (rev 10456) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 17:48:10 UTC (rev 10457) @@ -86,20 +86,7 @@ # endif #endif -/* memory checkers */ -#if !defined(__LZO_CHECKER) -# if defined(__BOUNDS_CHECKING_ON) -# define __LZO_CHECKER 1 -# elif defined(__CHECKER__) -# define __LZO_CHECKER 1 -# elif defined(__INSURE__) -# define __LZO_CHECKER 1 -# elif defined(__PURIFY__) -# define __LZO_CHECKER 1 -# endif -#endif - /*********************************************************************** // integral and pointer types ************************************************************************/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 17:56:36
|
Revision: 10458 http://openmsx.svn.sourceforge.net/openmsx/?rev=10458&view=rev Author: mthuurne Date: 2009-09-01 17:56:29 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Removed hardcoded 0 and 1 in preprocessor checks. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzodefs.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:48:10 UTC (rev 10457) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:56:29 UTC (rev 10458) @@ -91,7 +91,7 @@ #if !defined(lzo_uintptr_t) # if defined(__LZO_MMODEL_HUGE) # define lzo_uintptr_t unsigned long -# elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) +# elif defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) # define __LZO_UINTPTR_T_IS_POINTER 1 typedef char* lzo_uintptr_t; # define lzo_uintptr_t lzo_uintptr_t @@ -134,11 +134,7 @@ # define __lzo_noinline #endif -#if 1 # define LZO_BYTE(x) ((unsigned char) (x)) -#else -# define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) -#endif #define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) @@ -152,16 +148,11 @@ #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) #if !defined(DMUL) -#if 0 - -# define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) -#else # define DMUL(a,b) ((lzo_xint) ((a) * (b))) #endif -#endif -#if 1 && !defined(LZO_CFG_NO_UNALIGNED) -#if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386) +#if !defined(LZO_CFG_NO_UNALIGNED) +#if (LZO_ARCH_AMD64 || LZO_ARCH_I386) # if (LZO_SIZEOF_SHORT == 2) # define LZO_UNALIGNED_OK_2 # endif @@ -271,9 +262,6 @@ // End of pointer alignment definitions. #define LZO_DICT_USE_PTR -#if 0 && (LZO_ARCH_I086) -# undef LZO_DICT_USE_PTR -#endif #if defined(LZO_DICT_USE_PTR) # define lzo_dict_t const lzo_bytep @@ -735,11 +723,9 @@ GINDEX(m_pos,m_off,dict,dindex,in); if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) goto literal; -#if 1 if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto try_match; DINDEX2(dindex,ip); -#endif GINDEX(m_pos,m_off,dict,dindex,in); if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) goto literal; @@ -748,7 +734,7 @@ goto literal; try_match: -#if 1 && defined(LZO_UNALIGNED_OK_2) +#if defined(LZO_UNALIGNED_OK_2) if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip) #else if (m_pos[0] != ip[0] || m_pos[1] != ip[1]) @@ -759,44 +745,8 @@ { if __lzo_likely(m_pos[2] == ip[2]) { -#if 0 - if (m_off <= M2_MAX_OFFSET) goto match; - if (lit <= 3) - goto match; - if (lit == 3) - { - assert(op - 2 > out); op[-2] |= LZO_BYTE(3); - *op++ = *ii++; *op++ = *ii++; *op++ = *ii++; - goto code_match; - } - if (m_pos[3] == ip[3]) -#endif - goto match; } - else - { -#if 0 -#if 0 - if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3) -#else - if (m_off <= M1_MAX_OFFSET && lit == 3) -#endif - { - register lzo_uint t; - - t = lit; - assert(op - 2 > out); op[-2] |= LZO_BYTE(t); - do *op++ = *ii++; while (--t > 0); - assert(ii == ip); - m_off -= 1; - *op++ = LZO_BYTE(M1_MARKER | ((m_off & 3) << 2)); - *op++ = LZO_BYTE(m_off >> 2); - ip += 2; - goto match_done; - } -#endif - } } literal: @@ -932,9 +882,6 @@ *op++ = LZO_BYTE(m_off >> 6); } -#if 0 -match_done: -#endif ii = ip; if __lzo_unlikely(ip >= ip_end) break; @@ -1452,12 +1399,8 @@ match_next: assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); -#if 0 - do *op++ = *ip++; while (--t > 0); -#else *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } -#endif t = *ip++; } while (TEST_IP && TEST_OP); } Modified: openmsx/trunk/src/utils/lzodefs.hh =================================================================== --- openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 17:48:10 UTC (rev 10457) +++ openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 17:56:29 UTC (rev 10458) @@ -52,7 +52,7 @@ #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) # define __INTEL_COMPILER __ICL #endif -#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) +#if defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) # define _ALL_SOURCE 1 #endif #if defined(__mips__) && defined(__R5900__) @@ -65,43 +65,23 @@ #endif #if defined(__KEIL__) && defined(__C166__) # pragma warning disable = 322 -#elif 0 && defined(__C251__) -# pragma warning disable = 322 #endif #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) # if (_MSC_VER >= 1300) # pragma warning(disable: 4668) # endif #endif -#if 0 && defined(__WATCOMC__) -# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) -# pragma warning 203 9 -# endif -#endif #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) # pragma option -h #endif -#if 0 -#define LZO_0xffffL 0xfffful -#define LZO_0xffffffffL 0xfffffffful -#else #define LZO_0xffffL 65535ul #define LZO_0xffffffffL 4294967295ul -#endif #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif #if (16ul * 16384ul != 262144ul) # error "your preprocessor is broken 2" #endif -#if 0 -#if (32767 >= 4294967295ul) -# error "your preprocessor is broken 3" -#endif -#if (65535u >= 4294967295ul) -# error "your preprocessor is broken 4" -#endif -#endif #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) @@ -110,15 +90,6 @@ # if !defined(_MSDOS) # define _MSDOS 1 # endif -#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) -# if (__VERSION == 520) && (MB_LEN_MAX == 1) -# if !defined(__AZTEC_C__) -# define __AZTEC_C__ __VERSION -# endif -# if !defined(__DOS__) -# define __DOS__ 1 -# endif -# endif #endif #endif #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) @@ -240,7 +211,6 @@ #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -#if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) #define LZO_CPP_CONCAT2(a,b) a ## b @@ -251,9 +221,8 @@ #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -#endif #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -#if 1 && defined(__cplusplus) +#if defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 # endif @@ -271,7 +240,7 @@ # define LZO_INFO_OS "freestanding" #elif defined(LZO_OS_EMBEDDED) # define LZO_INFO_OS "embedded" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) +#elif defined(__IAR_SYSTEMS_ICC__) # define LZO_OS_EMBEDDED 1 # define LZO_INFO_OS "embedded" #elif defined(__CYGWIN__) && defined(__GNUC__) @@ -457,10 +426,6 @@ # else # define LZO_INFO_CCVER "unknown" # endif -#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) -# define LZO_CC_SDCC 1 -# define LZO_INFO_CC "sdcc" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) # define LZO_INFO_CC "Pathscale C" @@ -631,9 +596,6 @@ # define LZO_INFO_CC "unknown" # define LZO_INFO_CCVER "unknown" #endif -#if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) -# error "LZO_CC_MSC: _MSC_FULL_VER is not defined" -#endif #if !defined(__LZO_ARCH_OVERRIDE) && !defined(LZO_ARCH_GENERIC) && defined(_CRAY) # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) @@ -779,25 +741,25 @@ # define LZO_INFO_ARCH "unknown" #endif #endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) +#if (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) # error "FIXME - missing define for CPU architecture" #endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) +#if (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) # error "FIXME - missing WIN32 define for CPU architecture" #endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) +#if (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) # error "FIXME - missing WIN64 define for CPU architecture" #endif #if (LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && defined(BLX286)) +#elif (LZO_OS_DOS16 && defined(BLX286)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) +#elif (LZO_OS_DOS16 && defined(DOSX286)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) +#elif (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #endif @@ -1122,7 +1084,7 @@ #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) -#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define LZO_SIZEOF_LONG_LONG 8 #endif #endif @@ -1192,9 +1154,6 @@ # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #elif (LZO_ARCH_SPU) -# if 0 -# define __LZO_WORDSIZE 16 -# endif # define LZO_SIZEOF_VOID_P 4 #else # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG @@ -1241,23 +1200,23 @@ # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_M68K || LZO_ARCH_S390) # define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) +#elif defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) # if (__LITTLE_ENDIAN__ == 1) # define LZO_ABI_LITTLE_ENDIAN 1 # else # define LZO_ABI_BIG_ENDIAN 1 # endif -#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +#elif defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) # define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +#elif defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) # define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) +#elif (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) # define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) +#elif (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) # define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) +#elif (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) # define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) +#elif (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #endif #endif @@ -1323,7 +1282,7 @@ #elif (LZO_CC_MWERKS) && defined(__MSL__) # define LZO_LIBC_MSL __MSL__ # define LZO_INFO_LIBC "msl" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) +#elif defined(__IAR_SYSTEMS_ICC__) # define LZO_LIBC_ISOC90 1 # define LZO_INFO_LIBC "isoc90" #else @@ -1426,7 +1385,7 @@ # define __lzo_forceinline #endif #if !defined(__lzo_noinline) -#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) +#if (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) # define __lzo_noinline __attribute__((__noinline__,__used__)) #elif (LZO_CC_GNUC >= 0x030200ul) # define __lzo_noinline __attribute__((__noinline__)) @@ -1573,13 +1532,7 @@ # endif #endif #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -# if 0 -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -# elif 0 && (LZO_CC_GNUC) -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -# else # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -# endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 17:58:41
|
Revision: 10459 http://openmsx.svn.sourceforge.net/openmsx/?rev=10459&view=rev Author: mthuurne Date: 2009-09-01 17:58:35 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Removed pragmas: the LZO code should be compiled using the same settings as openMSX itself. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzodefs.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:56:29 UTC (rev 10458) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:58:35 UTC (rev 10459) @@ -60,23 +60,6 @@ # error "version mismatch" #endif -#if (LZO_CC_BORLANDC && LZO_ARCH_I086) -# pragma option -h -#endif - -#if (LZO_CC_MSC && (_MSC_VER >= 1000)) -# pragma warning(disable: 4127 4701) -#endif -#if (LZO_CC_MSC && (_MSC_VER >= 1300)) -# pragma warning(disable: 4820) -# pragma warning(disable: 4514 4710 4711) -#endif - -#if (LZO_CC_SUNPROC) -# pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED) -# pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP) -#endif - #if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR) # error "this should not happen - check defines for __huge" #endif Modified: openmsx/trunk/src/utils/lzodefs.hh =================================================================== --- openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 17:56:29 UTC (rev 10458) +++ openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 17:58:35 UTC (rev 10459) @@ -60,20 +60,6 @@ # define __LONG_MAX__ 9223372036854775807L # endif #endif -#if defined(__INTEL_COMPILER) && defined(__linux__) -# pragma warning(disable: 193) -#endif -#if defined(__KEIL__) && defined(__C166__) -# pragma warning disable = 322 -#endif -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -# if (_MSC_VER >= 1300) -# pragma warning(disable: 4668) -# endif -#endif -#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) -# pragma option -h -#endif #define LZO_0xffffL 65535ul #define LZO_0xffffffffL 4294967295ul #if (LZO_0xffffL == LZO_0xffffffffL) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 18:01:10
|
Revision: 10460 http://openmsx.svn.sourceforge.net/openmsx/?rev=10460&view=rev Author: mthuurne Date: 2009-09-01 18:01:03 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Removed version consistency checks. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzo.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 17:58:35 UTC (rev 10459) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 18:01:03 UTC (rev 10460) @@ -50,16 +50,8 @@ #include "lzo.hh" -#if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2030) -# error "version mismatch in miniLZO source files" -#endif - // Start of configuration. -#if (LZO_VERSION < 0x02000) -# error "version mismatch" -#endif - #if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR) # error "this should not happen - check defines for __huge" #endif Modified: openmsx/trunk/src/utils/lzo.hh =================================================================== --- openmsx/trunk/src/utils/lzo.hh 2009-09-01 17:58:35 UTC (rev 10459) +++ openmsx/trunk/src/utils/lzo.hh 2009-09-01 18:01:03 UTC (rev 10460) @@ -49,19 +49,13 @@ #ifndef LZO_HH #define LZO_HH -#define MINILZO_VERSION 0x2030 - #ifdef __LZOCONF_H # error "you cannot use both LZO and miniLZO" #endif #include "lzoconf.hh" -#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) -# error "version mismatch in header files" -#endif - #ifdef __cplusplus extern "C" { #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 18:16:14
|
Revision: 10461 http://openmsx.svn.sourceforge.net/openmsx/?rev=10461&view=rev Author: mthuurne Date: 2009-09-01 18:16:07 +0000 (Tue, 01 Sep 2009) Log Message: ----------- We are not building a library, so use C++ calling convention everywhere. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzo.hh openmsx/trunk/src/utils/lzoconf.hh openmsx/trunk/src/utils/lzodefs.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 18:01:03 UTC (rev 10460) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 18:16:07 UTC (rev 10461) @@ -155,16 +155,12 @@ #define MEMCPY_DS(dest,src,len) \ do *dest++ = *src++; while (--len > 0) -__LZO_EXTERN_C int __lzo_init_done; -__LZO_EXTERN_C const char __lzo_copyright[]; +extern int __lzo_init_done; +extern const char __lzo_copyright[]; LZO_EXTERN(const lzo_bytep) lzo_copyright(void); // Start of pointer alignment definitions. -#ifdef __cplusplus -extern "C" { -#endif - #if !defined(lzo_uintptr_t) # if defined(__LZO_MMODEL_HUGE) # define lzo_uintptr_t unsigned long @@ -230,10 +226,6 @@ } lzo_full_align_t; -#ifdef __cplusplus -} -#endif - // End of pointer alignment definitions. #define LZO_DICT_USE_PTR @@ -453,10 +445,6 @@ // Start of dictionary macros. -#ifdef __cplusplus -extern "C" { -#endif - #if !defined(D_BITS) && defined(DBITS) # define D_BITS DBITS #endif @@ -660,10 +648,6 @@ #endif -#ifdef __cplusplus -} -#endif - // End of dictionary macros. // End of LZO1X. Modified: openmsx/trunk/src/utils/lzo.hh =================================================================== --- openmsx/trunk/src/utils/lzo.hh 2009-09-01 18:01:03 UTC (rev 10460) +++ openmsx/trunk/src/utils/lzo.hh 2009-09-01 18:16:07 UTC (rev 10461) @@ -56,15 +56,6 @@ #include "lzoconf.hh" -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - /* Memory required for the wrkmem parameter. * When the required size is 0, you can also pass a NULL pointer. */ @@ -86,9 +77,4 @@ lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem /* NOT USED */ ); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - #endif // LZO_HH Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 18:01:03 UTC (rev 10460) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 18:16:07 UTC (rev 10461) @@ -69,11 +69,6 @@ #include "lzodefs.hh" -#ifdef __cplusplus -extern "C" { -#endif - - /*********************************************************************** // some core defines ************************************************************************/ @@ -182,39 +177,10 @@ // function types ************************************************************************/ -/* name mangling */ -#if !defined(__LZO_EXTERN_C) -# ifdef __cplusplus -# define __LZO_EXTERN_C extern "C" -# else -# define __LZO_EXTERN_C extern -# endif -#endif +# define __LZO_CDECL +# define LZO_PUBLIC(_rettype) _rettype __LZO_CDECL +# define LZO_EXTERN(_rettype) extern LZO_PUBLIC(_rettype) -/* calling convention */ -#if !defined(__LZO_CDECL) -# define __LZO_CDECL __lzo_cdecl -#endif - -/* DLL export information */ -#if !defined(__LZO_EXPORT1) -# define __LZO_EXPORT1 -#endif -#if !defined(__LZO_EXPORT2) -# define __LZO_EXPORT2 -#endif - -/* __cdecl calling convention for public C and assembly functions */ -#if !defined(LZO_PUBLIC) -# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL -#endif -#if !defined(LZO_EXTERN) -# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) -#endif -#if !defined(LZO_PRIVATE) -# define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL -#endif - /* function types */ typedef int (__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, @@ -351,9 +317,4 @@ #define LZO_PTR_ALIGN_UP(_ptr,_size) \ ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) - -#ifdef __cplusplus -} /* extern "C" */ -#endif - #endif // LZOCONF_HH Modified: openmsx/trunk/src/utils/lzodefs.hh =================================================================== --- openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 18:01:03 UTC (rev 10460) +++ openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 18:16:07 UTC (rev 10461) @@ -216,11 +216,6 @@ # define __STDC_LIMIT_MACROS 1 # endif #endif -#if defined(__cplusplus) -# define LZO_EXTERN_C extern "C" -#else -# define LZO_EXTERN_C extern -#endif #if !defined(__LZO_OS_OVERRIDE) #if defined(LZO_OS_FREESTANDING) # define LZO_INFO_OS "freestanding" @@ -833,9 +828,6 @@ # error "this should not happen" # endif #endif -#ifdef __cplusplus -extern "C" { -#endif #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) @@ -856,10 +848,7 @@ #else # error "FIXME - implement LZO_MM_AHSHIFT" #endif -#ifdef __cplusplus -} #endif -#endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) # error "FIXME - C166 __MODEL__" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 22:57:38
|
Revision: 10466 http://openmsx.svn.sourceforge.net/openmsx/?rev=10466&view=rev Author: mthuurne Date: 2009-09-01 22:57:27 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Removed support for non-flat memory models. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzoconf.hh openmsx/trunk/src/utils/lzodefs.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 20:21:07 UTC (rev 10465) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 22:57:27 UTC (rev 10466) @@ -52,21 +52,8 @@ // Start of configuration. -#if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR) -# error "this should not happen - check defines for __huge" -#endif - -#if (LZO_ARCH_I086) -# define ACC_MM_AHSHIFT LZO_MM_AHSHIFT -# define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) -# define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) -# define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) -#endif - #if !defined(lzo_uintptr_t) -# if defined(__LZO_MMODEL_HUGE) -# define lzo_uintptr_t unsigned long -# elif defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) +# if defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) # define __LZO_UINTPTR_T_IS_POINTER 1 typedef char* lzo_uintptr_t; # define lzo_uintptr_t lzo_uintptr_t @@ -86,12 +73,10 @@ #include <string.h> -#if !defined(__LZO_MMODEL_HUGE) # define lzo_memcmp(a,b,c) memcmp(a,b,c) # define lzo_memcpy(a,b,c) memcpy(a,b,c) # define lzo_memmove(a,b,c) memmove(a,b,c) # define lzo_memset(a,b,c) memset(a,b,c) -#endif #undef NDEBUG # if !defined(LZO_DEBUG) @@ -162,32 +147,18 @@ // Start of pointer alignment definitions. #if !defined(lzo_uintptr_t) -# if defined(__LZO_MMODEL_HUGE) -# define lzo_uintptr_t unsigned long -# else # define lzo_uintptr_t acc_uintptr_t # ifdef __ACC_INTPTR_T_IS_POINTER # define __LZO_UINTPTR_T_IS_POINTER 1 # endif -# endif #endif -#if (LZO_ARCH_I086) -#define PTR(a) ((lzo_bytep) (a)) -#define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) -#define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) -#elif (LZO_MM_PVP) -#define PTR(a) ((lzo_bytep) (a)) -#define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) -#define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) -#else #define PTR(a) ((lzo_uintptr_t) (a)) #define PTR_LINEAR(a) PTR(a) #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) -#endif #define PTR_LT(a,b) (PTR(a) < PTR(b)) #define PTR_GE(a,b) (PTR(a) >= PTR(b)) @@ -232,10 +203,10 @@ #if defined(LZO_DICT_USE_PTR) # define lzo_dict_t const lzo_bytep -# define lzo_dict_p lzo_dict_t __LZO_MMODEL * +# define lzo_dict_p lzo_dict_t * #else # define lzo_dict_t lzo_uint -# define lzo_dict_p lzo_dict_t __LZO_MMODEL * +# define lzo_dict_p lzo_dict_t * #endif // End of configuration. @@ -248,11 +219,7 @@ LZO_PUBLIC(const lzo_bytep) lzo_copyright(void) { -#if (LZO_OS_DOS16 && LZO_CC_TURBOC) - return (lzo_voidp) __lzo_copyright; -#else return (const lzo_bytep) __lzo_copyright; -#endif } LZO_PUBLIC(unsigned) Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 20:21:07 UTC (rev 10465) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 22:57:27 UTC (rev 10466) @@ -142,33 +142,21 @@ # define lzo_xint lzo_uint32 #endif -/* Memory model that allows to access memory at offsets of lzo_uint. */ -#if !defined(__LZO_MMODEL) -# if (LZO_UINT_MAX <= UINT_MAX) -# define __LZO_MMODEL -# elif defined(LZO_HAVE_MM_HUGE_PTR) -# define __LZO_MMODEL_HUGE 1 -# define __LZO_MMODEL __huge -# else -# define __LZO_MMODEL -# endif -#endif - /* no typedef here because of const-pointer issues */ -#define lzo_bytep unsigned char __LZO_MMODEL * -#define lzo_charp char __LZO_MMODEL * -#define lzo_voidp void __LZO_MMODEL * -#define lzo_shortp short __LZO_MMODEL * -#define lzo_ushortp unsigned short __LZO_MMODEL * -#define lzo_uint32p lzo_uint32 __LZO_MMODEL * -#define lzo_int32p lzo_int32 __LZO_MMODEL * -#define lzo_uintp lzo_uint __LZO_MMODEL * -#define lzo_intp lzo_int __LZO_MMODEL * -#define lzo_xintp lzo_xint __LZO_MMODEL * -#define lzo_voidpp lzo_voidp __LZO_MMODEL * -#define lzo_bytepp lzo_bytep __LZO_MMODEL * +#define lzo_bytep unsigned char * +#define lzo_charp char * +#define lzo_voidp void * +#define lzo_shortp short * +#define lzo_ushortp unsigned short * +#define lzo_uint32p lzo_uint32 * +#define lzo_int32p lzo_int32 * +#define lzo_uintp lzo_uint * +#define lzo_intp lzo_int * +#define lzo_xintp lzo_xint * +#define lzo_voidpp lzo_voidp * +#define lzo_bytepp lzo_bytep * /* deprecated - use `lzo_bytep' instead of `lzo_byte *' */ -#define lzo_byte unsigned char __LZO_MMODEL +#define lzo_byte unsigned char typedef int lzo_bool; @@ -215,7 +203,7 @@ struct lzo_callback_t; typedef struct lzo_callback_t lzo_callback_t; -#define lzo_callback_p lzo_callback_t __LZO_MMODEL * +#define lzo_callback_p lzo_callback_t * /* malloc & free function types */ typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) Modified: openmsx/trunk/src/utils/lzodefs.hh =================================================================== --- openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 20:21:07 UTC (rev 10465) +++ openmsx/trunk/src/utils/lzodefs.hh 2009-09-01 22:57:27 UTC (rev 10466) @@ -68,119 +68,6 @@ #if (16ul * 16384ul != 262144ul) # error "your preprocessor is broken 2" #endif -#if (UINT_MAX == LZO_0xffffL) -#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) -# if !defined(MSDOS) -# define MSDOS 1 -# endif -# if !defined(_MSDOS) -# define _MSDOS 1 -# endif -#endif -#endif -#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) -# define ptrdiff_t long -# define _PTRDIFF_T_DEFINED -#endif -#if (UINT_MAX == LZO_0xffffL) -# undef __LZO_RENAME_A -# undef __LZO_RENAME_B -# if defined(__AZTEC_C__) && defined(__DOS__) -# define __LZO_RENAME_A 1 -# elif defined(_MSC_VER) && defined(MSDOS) -# if (_MSC_VER < 600) -# define __LZO_RENAME_A 1 -# elif (_MSC_VER < 700) -# define __LZO_RENAME_B 1 -# endif -# elif defined(__TSC__) && defined(__OS2__) -# define __LZO_RENAME_A 1 -# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) -# define __LZO_RENAME_A 1 -# elif defined(__PACIFIC__) && defined(DOS) -# if !defined(__far) -# define __far far -# endif -# if !defined(__near) -# define __near near -# endif -# endif -# if defined(__LZO_RENAME_A) -# if !defined(__cdecl) -# define __cdecl cdecl -# endif -# if !defined(__far) -# define __far far -# endif -# if !defined(__huge) -# define __huge huge -# endif -# if !defined(__near) -# define __near near -# endif -# if !defined(__pascal) -# define __pascal pascal -# endif -# if !defined(__huge) -# define __huge huge -# endif -# elif defined(__LZO_RENAME_B) -# if !defined(__cdecl) -# define __cdecl _cdecl -# endif -# if !defined(__far) -# define __far _far -# endif -# if !defined(__huge) -# define __huge _huge -# endif -# if !defined(__near) -# define __near _near -# endif -# if !defined(__pascal) -# define __pascal _pascal -# endif -# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) -# if !defined(__cdecl) -# define __cdecl cdecl -# endif -# if !defined(__pascal) -# define __pascal pascal -# endif -# endif -# undef __LZO_RENAME_A -# undef __LZO_RENAME_B -#endif -#if (UINT_MAX == LZO_0xffffL) -#if defined(__AZTEC_C__) && defined(__DOS__) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -#elif defined(_MSC_VER) && defined(MSDOS) -# if (_MSC_VER < 600) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -# endif -# if (_MSC_VER < 700) -# define LZO_BROKEN_INTEGRAL_PROMOTION 1 -# define LZO_BROKEN_SIZEOF 1 -# endif -#elif defined(__PACIFIC__) && defined(DOS) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -#elif defined(__TURBOC__) && defined(__MSDOS__) -# if (__TURBOC__ < 0x0150) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -# define LZO_BROKEN_INTEGRAL_PROMOTION 1 -# endif -# if (__TURBOC__ < 0x0200) -# define LZO_BROKEN_SIZEOF 1 -# endif -# if (__TURBOC__ < 0x0400) && defined(__cplusplus) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# endif -#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# define LZO_BROKEN_SIZEOF 1 -#endif -#endif #if defined(__WATCOMC__) && (__WATCOMC__ < 900) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #endif @@ -245,22 +132,12 @@ #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" -#elif defined(__BORLANDC__) && defined(__DPMI16__) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" #elif defined(__ZTC__) && defined(DOS386) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__OS2__) || defined(__OS2V2__) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_OS216 1 -# define LZO_INFO_OS "os216" -# elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_OS2 1 # define LZO_INFO_OS "os2" -# else -# error "check your limits.h header" -# endif #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) # define LZO_OS_WIN64 1 # define LZO_INFO_OS "win64" @@ -271,30 +148,13 @@ # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_WIN16 1 -# define LZO_INFO_OS "win16" -# elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" -# else -# error "check your limits.h header" -# endif #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -# elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" -# else -# error "check your limits.h header" -# endif #elif defined(__WATCOMC__) -# if defined(__NT__) && (UINT_MAX == LZO_0xffffL) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -# elif defined(__NT__) && (__WATCOMC__ < 1100) +# if defined(__NT__) && (__WATCOMC__ < 1100) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # elif defined(__linux__) || defined(__LINUX__) @@ -383,14 +243,6 @@ # endif #endif #endif -#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -# if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (UINT_MAX != LZO_0xffffffffL) # error "this should not happen" @@ -581,18 +433,12 @@ # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) # define LZO_ARCH_CRAY_MPP 1 -# elif defined(_CRAY1) -# define LZO_ARCH_CRAY_PVP 1 # endif # endif #endif #if !defined(__LZO_ARCH_OVERRIDE) #if defined(LZO_ARCH_GENERIC) # define LZO_INFO_ARCH "generic" -#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -# define LZO_ARCH_I086 1 -# define LZO_ARCH_IA16 1 -# define LZO_INFO_ARCH "i086" #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" @@ -619,15 +465,9 @@ #elif defined(__arm__) || defined(_M_ARM) # define LZO_ARCH_ARM 1 # define LZO_INFO_ARCH "arm" -#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) -# define LZO_ARCH_AVR 1 -# define LZO_INFO_ARCH "avr" #elif defined(__bfin__) # define LZO_ARCH_BLACKFIN 1 # define LZO_INFO_ARCH "blackfin" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) -# define LZO_ARCH_C166 1 -# define LZO_INFO_ARCH "c166" #elif defined(__cris__) # define LZO_ARCH_CRIS 1 # define LZO_INFO_ARCH "cris" @@ -655,36 +495,15 @@ #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) # define LZO_ARCH_IA64 1 # define LZO_INFO_ARCH "ia64" -#elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) -# define LZO_ARCH_M16C 1 -# define LZO_INFO_ARCH "m16c" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) -# define LZO_ARCH_M16C 1 -# define LZO_INFO_ARCH "m16c" #elif defined(__m32r__) # define LZO_ARCH_M32R 1 # define LZO_INFO_ARCH "m32r" #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) # define LZO_ARCH_M68K 1 # define LZO_INFO_ARCH "m68k" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) -# define LZO_ARCH_MCS251 1 -# define LZO_INFO_ARCH "mcs251" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) -# define LZO_ARCH_MCS51 1 -# define LZO_INFO_ARCH "mcs51" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) -# define LZO_ARCH_MCS51 1 -# define LZO_INFO_ARCH "mcs51" #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) # define LZO_ARCH_MIPS 1 # define LZO_INFO_ARCH "mips" -#elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) -# define LZO_ARCH_MSP430 1 -# define LZO_INFO_ARCH "msp430" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) -# define LZO_ARCH_MSP430 1 -# define LZO_INFO_ARCH "msp430" #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) # define LZO_ARCH_POWERPC 1 # define LZO_INFO_ARCH "powerpc" @@ -700,23 +519,6 @@ #elif defined(__SPU__) # define LZO_ARCH_SPU 1 # define LZO_INFO_ARCH "spu" -#elif (UINT_MAX == LZO_0xffffL) && defined(__z80) -# define LZO_ARCH_Z80 1 -# define LZO_INFO_ARCH "z80" -#elif (LZO_ARCH_CRAY_PVP) -# if defined(_CRAYSV1) -# define LZO_ARCH_CRAY_SV1 1 -# define LZO_INFO_ARCH "cray_sv1" -# elif (_ADDR64) -# define LZO_ARCH_CRAY_T90 1 -# define LZO_INFO_ARCH "cray_t90" -# elif (_ADDR32) -# define LZO_ARCH_CRAY_YMP 1 -# define LZO_INFO_ARCH "cray_ymp" -# else -# define LZO_ARCH_CRAY_XMP 1 -# define LZO_INFO_ARCH "cray_xmp" -# endif #else # define LZO_ARCH_UNKNOWN 1 # define LZO_INFO_ARCH "unknown" @@ -731,199 +533,17 @@ #if (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) # error "FIXME - missing WIN64 define for CPU architecture" #endif -#if (LZO_OS_OS216 || LZO_OS_WIN16) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif (LZO_OS_DOS16 && defined(BLX286)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif (LZO_OS_DOS16 && defined(DOSX286)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#endif #if defined(LZO_ARCH_ARM_THUMB) && !defined(LZO_ARCH_ARM) # error "this should not happen" #endif -#if defined(LZO_ARCH_I086PM) && !defined(LZO_ARCH_I086) -# error "this should not happen" -#endif -#if (LZO_ARCH_I086) -# if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif #if (LZO_ARCH_I386) -# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) +# if (UINT_MAX != LZO_0xffffffffL) # error "this should not happen" # endif -# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) -# error "this should not happen" -# endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif -#if !defined(__LZO_MM_OVERRIDE) -#if (LZO_ARCH_I086) -#if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -#endif -#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) -# define LZO_MM_TINY 1 -#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) -# define LZO_MM_HUGE 1 -#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) -# define LZO_MM_SMALL 1 -#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) -# define LZO_MM_MEDIUM 1 -#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) -# define LZO_MM_COMPACT 1 -#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) -# define LZO_MM_LARGE 1 -#elif (LZO_CC_AZTECC) -# if defined(_LARGE_CODE) && defined(_LARGE_DATA) -# define LZO_MM_LARGE 1 -# elif defined(_LARGE_CODE) -# define LZO_MM_MEDIUM 1 -# elif defined(_LARGE_DATA) -# define LZO_MM_COMPACT 1 -# else -# define LZO_MM_SMALL 1 -# endif -#elif (LZO_CC_ZORTECHC && defined(__VCM__)) -# define LZO_MM_LARGE 1 -#else -# error "unknown memory model" -#endif -#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -#define LZO_HAVE_MM_HUGE_PTR 1 -#define LZO_HAVE_MM_HUGE_ARRAY 1 -#if (LZO_MM_TINY) -# undef LZO_HAVE_MM_HUGE_ARRAY -#endif -#if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) -# undef LZO_HAVE_MM_HUGE_PTR -# undef LZO_HAVE_MM_HUGE_ARRAY -#elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -# undef LZO_HAVE_MM_HUGE_ARRAY -#elif (LZO_CC_MSC && defined(_QC)) -# undef LZO_HAVE_MM_HUGE_ARRAY -# if (_MSC_VER < 600) -# undef LZO_HAVE_MM_HUGE_PTR -# endif -#elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) -# undef LZO_HAVE_MM_HUGE_ARRAY -#endif -#if (LZO_ARCH_I086PM) && !defined(LZO_HAVE_MM_HUGE_PTR) -# if (LZO_OS_DOS16) -# error "this should not happen" -# elif (LZO_CC_ZORTECHC) -# else -# error "this should not happen" -# endif -#endif -#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) -# define LZO_MM_AHSHIFT 12 -#elif (LZO_CC_WATCOMC) - extern unsigned char _HShift; -# define LZO_MM_AHSHIFT ((unsigned) _HShift) -#else -# error "FIXME - implement LZO_MM_AHSHIFT" -#endif -#endif -#elif (LZO_ARCH_C166) -#if !defined(__MODEL__) -# error "FIXME - C166 __MODEL__" -#elif ((__MODEL__) == 0) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 1) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - C166 __MODEL__" -#endif -#elif (LZO_ARCH_MCS251) -#if !defined(__MODEL__) -# error "FIXME - MCS251 __MODEL__" -#elif ((__MODEL__) == 0) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - MCS251 __MODEL__" -#endif -#elif (LZO_ARCH_MCS51) -#if !defined(__MODEL__) -# error "FIXME - MCS51 __MODEL__" -#elif ((__MODEL__) == 1) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - MCS51 __MODEL__" -#endif -#elif (LZO_ARCH_CRAY_PVP) -# define LZO_MM_PVP 1 -#else -# define LZO_MM_FLAT 1 -#endif -#if (LZO_MM_COMPACT) -# define LZO_INFO_MM "compact" -#elif (LZO_MM_FLAT) -# define LZO_INFO_MM "flat" -#elif (LZO_MM_HUGE) -# define LZO_INFO_MM "huge" -#elif (LZO_MM_LARGE) -# define LZO_INFO_MM "large" -#elif (LZO_MM_MEDIUM) -# define LZO_INFO_MM "medium" -#elif (LZO_MM_PVP) -# define LZO_INFO_MM "pvp" -#elif (LZO_MM_SMALL) -# define LZO_INFO_MM "small" -#elif (LZO_MM_TINY) -# define LZO_INFO_MM "tiny" -#else -# error "unknown memory model" -#endif -#endif #if defined(SIZEOF_SHORT) # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) #endif @@ -956,9 +576,7 @@ #endif #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) #if !defined(LZO_SIZEOF_SHORT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_SHORT 8 -# elif (USHRT_MAX == LZO_0xffffL) +# if (USHRT_MAX == LZO_0xffffL) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,7) == 1) # define LZO_SIZEOF_SHORT 1 @@ -975,9 +593,7 @@ # endif #endif #if !defined(LZO_SIZEOF_INT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_INT 8 -# elif (UINT_MAX == LZO_0xffffL) +# if (UINT_MAX == LZO_0xffffL) # define LZO_SIZEOF_INT 2 # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_INT 4 @@ -1027,8 +643,7 @@ #endif #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -#if (LZO_ARCH_I086 && LZO_CC_DMC) -#elif (LZO_CC_CILLY) && defined(__GNUC__) +#if (LZO_CC_CILLY) && defined(__GNUC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_SIZEOF_LONG_LONG 8 @@ -1073,21 +688,7 @@ # undef LZO_SIZEOF_LONG_LONG #endif #if !defined(LZO_SIZEOF_VOID_P) -#if (LZO_ARCH_I086) -# define __LZO_WORDSIZE 2 -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -# define LZO_SIZEOF_VOID_P 2 -# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -# define LZO_SIZEOF_VOID_P 4 -# else -# error "LZO_MM" -# endif -#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) -# define __LZO_WORDSIZE 1 -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_H8300) +#if (LZO_ARCH_H8300) # if defined(__NORMAL_MODE__) # define __LZO_WORDSIZE 4 # define LZO_SIZEOF_VOID_P 2 @@ -1102,13 +703,6 @@ # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT # endif -#elif (LZO_ARCH_M16C) -# define __LZO_WORDSIZE 2 -# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) -# define LZO_SIZEOF_VOID_P 4 -# else -# define LZO_SIZEOF_VOID_P 2 -# endif #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define __LZO_WORDSIZE 8 # define LZO_SIZEOF_VOID_P 4 @@ -1142,36 +736,18 @@ # endif #endif #if !defined(LZO_SIZEOF_SIZE_T) -#if (LZO_ARCH_I086 || LZO_ARCH_M16C) -# define LZO_SIZEOF_SIZE_T 2 -#else # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P #endif -#endif #if !defined(LZO_SIZEOF_PTRDIFF_T) -#if (LZO_ARCH_I086) -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P -# elif (LZO_MM_COMPACT || LZO_MM_LARGE) -# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) -# define LZO_SIZEOF_PTRDIFF_T 4 -# else -# define LZO_SIZEOF_PTRDIFF_T 2 -# endif -# else -# error "LZO_MM" -# endif -#else # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T #endif -#endif #if defined(LZO_ABI_NEUTRAL_ENDIAN) # undef LZO_ABI_BIG_ENDIAN # undef LZO_ABI_LITTLE_ENDIAN #elif !defined(LZO_ABI_BIG_ENDIAN) && !defined(LZO_ABI_LITTLE_ENDIAN) #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) # define LZO_ABI_BIG_ENDIAN 1 -#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) +#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I386) # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_M68K || LZO_ARCH_S390) # define LZO_ABI_BIG_ENDIAN 1 @@ -1533,7 +1109,7 @@ # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} # endif #endif -#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) +#if (LZO_ARCH_I386) && (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define __lzo_cdecl __cdecl @@ -1688,14 +1264,6 @@ # define __LZO_ASM_CLOBBER "cc", "memory" #endif #endif -#if defined(__LZO_INFOSTR_MM) -#elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) -# define __LZO_INFOSTR_MM "" -#elif defined(LZO_INFO_MM) -# define __LZO_INFOSTR_MM "." LZO_INFO_MM -#else -# define __LZO_INFOSTR_MM "" -#endif #if defined(__LZO_INFOSTR_PM) #elif defined(LZO_INFO_ABI_PM) # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM @@ -1729,7 +1297,7 @@ # define __LZO_INFOSTR_CCVER "" #endif #define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ + LZO_INFO_ARCH __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER #endif // LZODEFS_HH This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mth...@us...> - 2009-09-01 23:06:33
|
Revision: 10468 http://openmsx.svn.sourceforge.net/openmsx/?rev=10468&view=rev Author: mthuurne Date: 2009-09-01 23:06:26 +0000 (Tue, 01 Sep 2009) Log Message: ----------- Removed callback interface, since it is not used. Modified Paths: -------------- openmsx/trunk/src/utils/lzo.cc openmsx/trunk/src/utils/lzoconf.hh Modified: openmsx/trunk/src/utils/lzo.cc =================================================================== --- openmsx/trunk/src/utils/lzo.cc 2009-09-01 23:01:26 UTC (rev 10467) +++ openmsx/trunk/src/utils/lzo.cc 2009-09-01 23:06:26 UTC (rev 10468) @@ -320,7 +320,7 @@ LZO_PUBLIC(int) __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, - int s6, int s7, int s8, int s9) + int s6, int s7, int s8) { int r; @@ -336,8 +336,7 @@ (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && (s7 == -1 || s7 == (int) sizeof(char *)) && - (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) && - (s9 == -1 || s9 == (int) sizeof(lzo_callback_t)); + (s8 == -1 || s8 == (int) sizeof(lzo_voidp)); if (!r) return LZO_E_ERROR; Modified: openmsx/trunk/src/utils/lzoconf.hh =================================================================== --- openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 23:01:26 UTC (rev 10467) +++ openmsx/trunk/src/utils/lzoconf.hh 2009-09-01 23:06:26 UTC (rev 10468) @@ -198,41 +198,6 @@ const lzo_bytep dict, lzo_uint dict_len ); -/* Callback interface. Currently only the progress indicator ("nprogress") - * is used, but this may change in a future release. */ - -struct lzo_callback_t; -typedef struct lzo_callback_t lzo_callback_t; -#define lzo_callback_p lzo_callback_t * - -/* malloc & free function types */ -typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) - (lzo_callback_p self, lzo_uint items, lzo_uint size); -typedef void (__LZO_CDECL *lzo_free_func_t) - (lzo_callback_p self, lzo_voidp ptr); - -/* a progress indicator callback function */ -typedef void (__LZO_CDECL *lzo_progress_func_t) - (lzo_callback_p, lzo_uint, lzo_uint, int); - -struct lzo_callback_t -{ - /* custom allocators (set to 0 to disable) */ - lzo_alloc_func_t nalloc; /* [not used right now] */ - lzo_free_func_t nfree; /* [not used right now] */ - - /* a progress indicator callback function (set to 0 to disable) */ - lzo_progress_func_t nprogress; - - /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress - * callbacks points back to this struct, so you are free to store - * some extra info in the following variables. */ - lzo_voidp user1; - lzo_xint user2; - lzo_xint user3; -}; - - /*********************************************************************** // error codes and prototypes ************************************************************************/ @@ -265,9 +230,8 @@ */ #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_callback_t)) -LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); + (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp)) +LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int); /* version functions (useful for shared libraries) */ LZO_EXTERN(unsigned) lzo_version(void); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |