Misc cleanups.

committer: mfx <mfx> 1088804669 +0000
This commit is contained in:
Markus F.X.J. Oberhumer
2004-07-02 21:44:29 +00:00
parent f412b5e0cd
commit 61594f7873
8 changed files with 47 additions and 33 deletions
+17 -2
View File
@@ -65,9 +65,24 @@ upx_bytep pfind_le32(const void *b, int blen, unsigned what);
#endif
inline ptrdiff_t ptr_diff(const void *p1, const void *p2)
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530))
#elif (ACC_CC_DMC && (__DMC__ < 0x830))
#elif (ACC_CC_MSC && (_MSC_VER < 1310))
#else
template <class T>
inline int ptr_diff(const T *p1, const T *p2)
{
return (const char*) p1 - (const char*) p2;
COMPILE_TIME_ASSERT(sizeof(T) == 1)
ptrdiff_t d = (const char*) p1 - (const char*) p2;
assert((int)d == d);
return (int) d;
}
#endif
inline int ptr_diff(const void *p1, const void *p2)
{
ptrdiff_t d = (const char*) p1 - (const char*) p2;
assert((int)d == d);
return (int) d;
}