00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
#ifndef _POBJECT_H
00379
#define _POBJECT_H
00380
00381
#ifdef P_USE_PRAGMA
00382
#pragma interface
00383
#endif
00384
00385
#ifdef _WIN32
00386
#include "msos/ptlib/contain.h"
00387
#else
00388
#include "unix/ptlib/contain.h"
00389
#endif
00390
00391
#if defined(P_VXWORKS)
00392
#include <private/stdiop.h>
00393
#endif
00394
00395
#include <stdio.h>
00396
#include <stdarg.h>
00397
#include <stdlib.h>
00398
00399
#ifdef _WIN32
00400
#include <malloc.h>
00401
#endif
00402
00403
#include <string.h>
00404
00405
#ifdef __USE_STL__
00406
#include <string>
00407
#include <iomanip>
00408
#include <iostream>
00409
#if (__GNUC__ >= 3)
00410
#include <sstream>
00411
00412
#else
00413
#include <strstream>
00414
#endif
00415
00416
#else
00417
#if (__GNUC__ >= 3)
00418
#include <iostream>
00419
#ifndef __MWERKS__
00420
#include <iomanip>
00421
#endif
00422
#else
00423
#include <iostream.h>
00424
#ifdef __GNUC__
00425
#include <strstream.h>
00426
#else
00427
#include <strstrea.h>
00428
#endif
00429
#ifndef __MWERKS__
00430
#include <iomanip.h>
00431
#endif
00432
#endif
00433
#endif
00434
00435
#ifdef _WIN32_WCE
00436
#include <stdlibx.h>
00437
#endif
00438
00439
#if (__GNUC__ < 3)
00440 typedef long _Ios_Fmtflags;
00441
#endif
00442
00443
#if _MSC_VER<1300
00444 #define _BADOFF -1
00445
#endif
00446
00448
00449
00450
00451
#ifndef P_USE_INLINES
00452
#ifdef _DEBUG
00453
#define P_USE_INLINES 0
00454
#else
00455 #define P_USE_INLINES 0
00456
#endif
00457
#endif
00458
00459
#if P_USE_INLINES
00460
#define PINLINE inline
00461
#else
00462 #define PINLINE
00463
#endif
00464
00465
00467
00468
00470 enum PStandardAssertMessage {
00471
PLogicError,
00472
POutOfMemory,
00473
PNullPointerReference,
00474
PInvalidCast,
00475
PInvalidArrayIndex,
00476
PInvalidArrayElement,
00477
PStackEmpty,
00478
PUnimplementedFunction,
00479
PInvalidParameter,
00480
POperatingSystemError,
00481
PChannelNotOpen,
00482
PUnsupportedFeature,
00483
PInvalidWindow,
00484
PMaxStandardAssertMessage
00485 };
00486
00487 #define __CLASS__ NULL
00488
00495 #define PAssert(b, m) if(b);else PAssertFunc(__FILE__, __LINE__, __CLASS__, (m))
00496
00504 #define PAssert2(b, c, m) if(b);else PAssertFunc(__FILE__, __LINE__, (c), (m))
00505
00512 #define PAssertOS(b) \
00513
if(b);else PAssertFunc(__FILE__, __LINE__, __CLASS__, POperatingSystemError)
00514
00524 #define PAssertNULL(p) ((&(p)&&(p)!=NULL)?(p):(PAssertFunc(__FILE__, \
00525
__LINE__, __CLASS__, PNullPointerReference), (p)))
00526
00533 #define PAssertAlways(m) PAssertFunc(__FILE__, __LINE__, __CLASS__, (m))
00534
00541 #define PAssertAlways2(c, m) PAssertFunc(__FILE__, __LINE__, (c), (m))
00542
00543
00544
void PAssertFunc(
const char * file,
int line,
const char * className, PStandardAssertMessage msg);
00545
void PAssertFunc(
const char * file,
int line,
const char * className,
const char * msg);
00546
void PAssertFunc(
const char * full_msg);
00547
00548
00553 ostream &
PGetErrorStream();
00554
00558
void PSetErrorStream(ostream * strm );
00559
00574 #define PError (PGetErrorStream())
00575
00576
00577
00579
00580
00581
#ifndef PTRACING
00582
#ifndef _DEBUG
00583 #define PTRACING 0
00584
#else
00585
#define PTRACING 1
00586
#endif
00587
#endif
00588
00593 class PTrace
00594 {
00595
public:
00597 enum Options {
00603
Blocks = 1,
00605
DateAndTime = 2,
00607
Timestamp = 4,
00609
Thread = 8,
00611
TraceLevel = 16,
00613
FileAndLine = 32,
00615
ThreadAddress = 64,
00617
AppendToFile = 128,
00621
GMTTime = 256,
00624
SystemLogStream = 32768
00625 };
00626
00634
static void Initialise(
00635
unsigned level,
00636
const char * filename = NULL,
00637
unsigned options = Timestamp | Thread | Blocks
00638 );
00639
00646
static void SetOptions(
unsigned options );
00647
00655
static void ClearOptions(
unsigned options );
00656
00661
static unsigned GetOptions();
00662
00668
static void SetLevel(
unsigned level );
00669
00675
static unsigned GetLevel();
00676
00681
static BOOL CanTrace(
unsigned level );
00682
00687
static void SetStream(ostream * out );
00688
00704
static ostream & Begin(
00705
unsigned level,
00706
const char * fileName,
00707
int lineNum
00708 );
00709
00726
static ostream & End(ostream & strm );
00727
00728
00734 class Block {
00735
public:
00737
Block(
00738
const char * fileName,
00739
int lineNum,
00740
const char * traceName
00742 );
00744
~Block();
00745
private:
00746
const char * file;
00747
int line;
00748
const char * name;
00749 };
00750 };
00751
00752
#if !PTRACING
00753
00754 #define PTRACE_PARAM(param)
00755 #define PTRACE_BLOCK(n)
00756 #define PTRACE_LINE()
00757 #define PTRACE(level, arg)
00758 #define PTRACE_IF(level, cond, args)
00759
00760
#else
00761
00762
00763
00764
#define PTRACE_PARAM(param) param
00765
00772
#define PTRACE_BLOCK(name) PTrace::Block __trace_block_instance(__FILE__, __LINE__, name)
00773
00777
#define PTRACE_LINE() \
00778
if (!PTrace::CanTrace(1)) ; else \
00779
PTrace::Begin(1, __FILE__, __LINE__) << __FILE__ << '(' << __LINE__ << ')' << PTrace::End
00780
00786
#define PTRACE(level, args) \
00787
if (!PTrace::CanTrace(level)) ; else \
00788
PTrace::Begin(level, __FILE__, __LINE__) << args << PTrace::End
00789
00797
#define PTRACE_IF(level, cond, args) \
00798
if (!(PTrace::CanTrace(level) && (cond))) ; else \
00799
PTrace::Begin(level, __FILE__, __LINE__) << args << PTrace::End
00800
00801
#endif
00802
00803
#if PMEMORY_CHECK
00804
00811
class PMemoryHeap {
00812
protected:
00814 PMemoryHeap();
00815
00816
public:
00817
00818 ~PMemoryHeap();
00819
00826
static void * Allocate(
00827 size_t nSize,
00828
const char * file,
00829
int line,
00830
const char * className
00831 );
00838
static void * Allocate(
00839 size_t count,
00840 size_t iSize,
00841
const char * file,
00842
int line
00843 );
00844
00852
static void * Reallocate(
00853
void * ptr,
00854 size_t nSize,
00855
const char * file,
00856
int line
00857 );
00858
00864
static void Deallocate(
00865
void * ptr,
00866
const char * className
00867 );
00868
00871
enum Validation {
00872 Ok, Bad, Trashed
00873 };
00881
static Validation Validate(
00882
void * ptr,
00883
const char * className,
00884 ostream * error
00885 );
00886
00891
static BOOL ValidateHeap(
00892 ostream * error = NULL
00893 );
00894
00900
static BOOL SetIgnoreAllocations(
00901 BOOL ignore
00902 );
00903
00907
static void DumpStatistics();
00911
static void DumpStatistics(ostream & strm );
00912
00913
00914
00915
00916
00917
00918
static DWORD GetAllocationRequest();
00919
00927
static void DumpObjectsSince(
00928 DWORD objectNumber
00929 );
00930
00936
static void DumpObjectsSince(
00937 DWORD objectNumber,
00938 ostream & strm
00939 );
00940
00946
static void SetAllocationBreakpoint(
00947 DWORD point
00948 );
00949
00950
protected:
00951
void * InternalAllocate(
00952 size_t nSize,
00953
const char * file,
00954
int line,
00955
const char * className
00956 );
00957 Validation InternalValidate(
00958
void * ptr,
00959
const char * className,
00960 ostream * error
00961 );
00962
void InternalDumpStatistics(ostream & strm);
00963
void InternalDumpObjectsSince(DWORD objectNumber, ostream & strm);
00964
00965
class Wrapper {
00966
public:
00967 Wrapper();
00968 ~Wrapper();
00969 PMemoryHeap * operator->()
const {
return instance; }
00970
private:
00971 PMemoryHeap * instance;
00972 };
00973
friend class Wrapper;
00974
00975
enum Flags {
00976 NoLeakPrint = 1
00977 };
00978
00979
#pragma pack(1)
00980
struct Header {
00981
enum {
00982
00983 NumGuardBytes = 16 - (
sizeof(Header *) +
00984
sizeof(Header *) +
00985
sizeof(
const char *) +
00986
sizeof(
const char *) +
00987
sizeof(size_t) +
00988
sizeof(DWORD) +
00989
sizeof(WORD) +
00990
sizeof(BYTE))%8
00991 };
00992
00993 Header * prev;
00994 Header * next;
00995
const char * className;
00996
const char * fileName;
00997 size_t size;
00998 DWORD request;
00999 WORD line;
01000 BYTE flags;
01001
char guard[NumGuardBytes];
01002
01003
static char GuardBytes[NumGuardBytes];
01004 };
01005
#pragma pack()
01006
01007 BOOL isDestroyed;
01008
01009 Header * listHead;
01010 Header * listTail;
01011
01012
static DWORD allocationBreakpoint;
01013 DWORD allocationRequest;
01014 DWORD firstRealObject;
01015 BYTE flags;
01016
01017
char allocFillChar;
01018
char freeFillChar;
01019
01020 DWORD currentMemoryUsage;
01021 DWORD peakMemoryUsage;
01022 DWORD currentObjects;
01023 DWORD peakObjects;
01024 DWORD totalObjects;
01025
01026 ostream * leakDumpStream;
01027
01028
#if defined(_WIN32)
01029
CRITICAL_SECTION mutex;
01030
#elif defined(P_PTHREADS)
01031
pthread_mutex_t mutex;
01032
#elif defined(P_VXWORKS)
01033
void * mutex;
01034
#endif
01035
};
01036
01037
01042
inline void *
runtime_malloc(size_t bytes ) {
return malloc(bytes); }
01043
01048
inline void runtime_free(
void * ptr ) { free(ptr); }
01049
01050
01057
#define malloc(s) PMemoryHeap::Allocate(s, __FILE__, __LINE__, NULL)
01058
01065
#define calloc(n,s) PMemoryHeap::Allocate(n, s, __FILE__, __LINE__)
01066
01073
#define realloc(p,s) PMemoryHeap::Reallocate(p, s, __FILE__, __LINE__)
01074
01075
01082
#define free(p) PMemoryHeap::Deallocate(p, NULL)
01083
01084
01091
#define cfree(p) PMemoryHeap::Deallocate(p, NULL)
01092
01093
01108
#define PNEW new (__FILE__, __LINE__)
01109
01110
#if !defined(_MSC_VER) || _MSC_VER<1200
01111
#define PSPECIAL_DELETE_FUNCTION
01112
#else
01113
#define PSPECIAL_DELETE_FUNCTION \
01114
void operator delete(void * ptr, const char *, int) \
01115
{ PMemoryHeap::Deallocate(ptr, Class()); } \
01116
void operator delete[](void * ptr, const char *, int) \
01117
{ PMemoryHeap::Deallocate(ptr, Class()); }
01118
#endif
01119
01120
#define PNEW_AND_DELETE_FUNCTIONS \
01121
void * operator new(size_t nSize, const char * file, int line) \
01122
{ return PMemoryHeap::Allocate(nSize, file, line, Class()); } \
01123
void * operator new(size_t nSize) \
01124
{ return PMemoryHeap::Allocate(nSize, NULL, 0, Class()); } \
01125
void operator delete(void * ptr) \
01126
{ PMemoryHeap::Deallocate(ptr, Class()); } \
01127
void * operator new[](size_t nSize, const char * file, int line) \
01128
{ return PMemoryHeap::Allocate(nSize, file, line, Class()); } \
01129
void * operator new[](size_t nSize) \
01130
{ return PMemoryHeap::Allocate(nSize, NULL, 0, Class()); } \
01131
void operator delete[](void * ptr) \
01132
{ PMemoryHeap::Deallocate(ptr, Class()); } \
01133
PSPECIAL_DELETE_FUNCTION
01134
01135
01136
inline void *
operator new(size_t nSize,
const char * file,
int line)
01137 {
return PMemoryHeap::Allocate(nSize, file, line, NULL); }
01138
01139
inline void *
operator new[](size_t nSize,
const char * file,
int line)
01140 {
return PMemoryHeap::Allocate(nSize, file, line, NULL); }
01141
01142
#ifndef __GNUC__
01143
void *
operator new(size_t nSize);
01144
void *
operator new[](size_t nSize);
01145
01146
void operator delete(
void * ptr);
01147
void operator delete[](
void * ptr);
01148
01149
#if defined(_MSC_VER) && _MSC_VER>=1200
01150
inline void operator delete(
void * ptr,
const char *,
int)
01151 { PMemoryHeap::Deallocate(ptr, NULL); }
01152
01153
inline void operator delete[](
void * ptr,
const char *,
int)
01154 { PMemoryHeap::Deallocate(ptr, NULL); }
01155
#endif
01156
#endif
01157
01158
01159
#else // PMEMORY_CHECK
01160
01161 #define PNEW new
01162
01163
#if defined(__GNUC__) || (defined(_WIN32_WCE) && defined(_X86_))
01164
01165
#define PNEW_AND_DELETE_FUNCTIONS
01166
01167
#else
01168
01169 #define PNEW_AND_DELETE_FUNCTIONS \
01170
void * operator new(size_t nSize) \
01171
{ return malloc(nSize); } \
01172
void operator delete(void * ptr) \
01173
{ free(ptr); } \
01174
void * operator new[](size_t nSize) \
01175
{ return malloc(nSize); } \
01176
void operator delete[](void * ptr) \
01177
{ free(ptr); }
01178
01179
void *
operator new(size_t nSize);
01180
void *
operator new[](size_t nSize);
01181
01182
void operator delete(
void * ptr);
01183
void operator delete[](
void * ptr);
01184
01185
#endif
01186
01187 #define runtime_malloc(s) malloc(s)
01188 #define runtime_free(p) free(p)
01189
01190
#endif // PMEMORY_CHECK
01191
01192
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
#if P_HAS_TYPEINFO
01223
01224 #define PIsDescendant(ptr, cls) (dynamic_cast<const cls *>(ptr) != NULL)
01225 #define PIsDescendantStr(ptr, str) ((ptr)->InternalIsDescendant(str))
01226
01227
#include <typeinfo>
01228
01229
#ifndef PCLASSNAME
01230
#error "Must define PCLASSNAME"
01231
#endif
01232
01233 #define PBASECLASSINFO(cls, par) \
01234
public: \
01235
static inline const char * Class() \
01236
{ return PCLASSNAME(cls); } \
01237
virtual BOOL InternalIsDescendant(const char * clsName) const \
01238
{ return strcmp(clsName, PCLASSNAME(cls)) == 0 || par::InternalIsDescendant(clsName); } \
01239
01240
#else // P_HAS_TYPEINFO
01241
01242
#define PIsDescendant(ptr, cls) ((ptr)->InternalIsDescendant(cls::Class()))
01243
#define PIsDescendantStr(ptr, str) ((ptr)->InternalIsDescendant(str))
01244
01245
#define PBASECLASSINFO(cls, par) \
01246
public: \
01247
static const char * Class() \
01248
{ return #cls; } \
01249
virtual BOOL InternalIsDescendant(const char * clsName) const \
01250
{ return strcmp(clsName, cls::Class()) == 0 || par::InternalIsDescendant(clsName); } \
01251
01252
#endif // P_HAS_TYPEINFO
01253
01254
01255 #define PCLASSINFO(cls, par) \
01256
PBASECLASSINFO(cls, par) \
01257
virtual const char * GetClass(unsigned ancestor = 0) const \
01258
{ return ancestor > 0 ? par::GetClass(ancestor-1) : cls::Class(); } \
01259
virtual Comparison CompareObjectMemoryDirect(const PObject & obj) const \
01260
{ return (Comparison)memcmp(this, &obj, sizeof(cls)); } \
01261
01262
01270 #define PDECLARE_CLASS(cls, par) class cls : public par { PCLASSINFO(cls, par)
01271
#ifdef DOC_PLUS_PLUS
01272
} Match previous opening brace in doc++
01273
#endif
01274
01276
01277
01282 class PObject {
01283
01284
protected:
01288 PObject() { }
01289
01290
public:
01291
01292
01293
01294 virtual ~PObject() { }
01295
01308 static inline const char *
Class() {
return PCLASSNAME(
PObject); }
01309
01322 virtual const char *
GetClass(
unsigned = 0)
const {
return Class(); }
01323
01324 BOOL
IsClass(
const char * cls)
const
01325
{
return strcmp(cls, GetClass()) == 0; }
01326
01336 virtual BOOL
InternalIsDescendant(
01337
const char * clsName
01338 )
const
01339
{
return IsClass(clsName); }
01340
01342
01348 enum Comparison {
01349
LessThan = -1,
01350
EqualTo = 0,
01351
GreaterThan = 1
01352 };
01353
01365
virtual Comparison Compare(
01366
const PObject & obj
01367 )
const;
01368
01380
virtual Comparison CompareObjectMemoryDirect(
01381
const PObject & obj
01382 )
const;
01383
01389 bool operator==(
01390
const PObject & obj
01391 )
const {
return Compare(obj) ==
EqualTo; }
01392
01398 bool operator!=(
01399
const PObject & obj
01400 )
const {
return Compare(obj) !=
EqualTo; }
01401
01407 bool operator<(
01408
const PObject & obj
01409 )
const {
return Compare(obj) ==
LessThan; }
01410
01416 bool operator>(
01417
const PObject & obj
01418 )
const {
return Compare(obj) ==
GreaterThan; }
01419
01425 bool operator<=(
01426
const PObject & obj
01427 )
const {
return Compare(obj) !=
GreaterThan; }
01428
01434 bool operator>=(
01435
const PObject & obj
01436 )
const {
return Compare(obj) !=
LessThan; }
01438
01447
virtual void PrintOn(
01448 ostream &strm
01449 )
const;
01450
01457
virtual void ReadFrom(
01458 istream &strm
01459 );
01460
01461
01467 inline friend ostream &
operator<<(
01468 ostream &strm,
01469
const PObject & obj
01470 ) { obj.
PrintOn(strm);
return strm; }
01471
01477 inline friend istream &
operator>>(
01478 istream &strm,
01479
PObject & obj
01480 ) { obj.
ReadFrom(strm);
return strm; }
01481
01482
01497
virtual PObject *
Clone() const;
01498
01510 virtual PINDEX HashFunction() const;
01512 };
01513
01515
01516
01517
01518
01519
01520
01521
01522 #define PANSI_CHAR 1
01523 #define PLITTLE_ENDIAN 2
01524 #define PBIG_ENDIAN 3
01525
01526
01527 #if 0
01528 class PStandardType
01529
01530
01531
01532
01533
01534
01535 {
01536
public:
01537 PStandardType(
01538 type newVal
01539 ) { data = newVal; }
01540
01541
01542
01543
01544 operator type() {
return data; }
01545
01546
01547
01548
01549
01550
01551
friend ostream & operator<<(ostream & strm,
const PStandardType & val)
01552 {
return strm << (type)val; }
01553
01554
01555
01556
01557
01558
01559
friend istream & operator>>(istream & strm, PStandardType & val)
01560 { type data; strm >> data; val = PStandardType(data);
return strm; }
01561
01562
01563
01564
01565
01566
01567
01568
private:
01569 type data;
01570 };
01571
#endif
01572
01573
01574 #define PI_SAME(name, type) \
01575
struct name { \
01576
name() { } \
01577
name(type value) { data = value; } \
01578
name(const name & value) { data = value.data; } \
01579
name & operator =(type value) { data = value; return *this; } \
01580
name & operator =(const name & value) { data = value.data; return *this; } \
01581
operator type() const { return data; } \
01582
friend ostream & operator<<(ostream & s, const name & v) { return s << v.data; } \
01583
friend istream & operator>>(istream & s, name & v) { return s >> v.data; } \
01584
private: type data; \
01585
}
01586
01587 #define PI_LOOP(src, dst) \
01588
BYTE *s = ((BYTE *)&src)+sizeof(src); BYTE *d = (BYTE *)&dst; \
01589
while (s != (BYTE *)&src) *d++ = *--s;
01590
01591 #define PI_DIFF(name, type) \
01592
struct name { \
01593
name() { } \
01594
name(type value) { operator=(value); } \
01595
name(const name & value) { data = value.data; } \
01596
name & operator =(type value) { PI_LOOP(value, data); return *this; } \
01597
name & operator =(const name & value) { data = value.data; return *this; } \
01598
operator type() const { type value; PI_LOOP(data, value); return value; } \
01599
friend ostream & operator<<(ostream & s, const name & value) { return s << (type)value; } \
01600
friend istream & operator>>(istream & s, name & v) { type val; s >> val; v = val; return s; } \
01601
private: type data; \
01602
}
01603
01604
#ifndef PCHAR8
01605 #define PCHAR8 PANSI_CHAR
01606
#endif
01607
01608
#if PCHAR8==PANSI_CHAR
01609
PI_SAME(PChar8,
char);
01610
#endif
01611
01612
PI_SAME(PInt8,
signed char);
01613
01614
PI_SAME(PUInt8,
unsigned char);
01615
01616
#if PBYTE_ORDER==PLITTLE_ENDIAN
01617
PI_SAME(PInt16l, PInt16);
01618
#elif PBYTE_ORDER==PBIG_ENDIAN
01619
PI_DIFF(PInt16l, PInt16);
01620
#endif
01621
01622
#if PBYTE_ORDER==PLITTLE_ENDIAN
01623
PI_DIFF(PInt16b, PInt16);
01624
#elif PBYTE_ORDER==PBIG_ENDIAN
01625
PI_SAME(PInt16b, PInt16);
01626
#endif
01627
01628
#if PBYTE_ORDER==PLITTLE_ENDIAN
01629
PI_SAME(PUInt16l, WORD);
01630
#elif PBYTE_ORDER==PBIG_ENDIAN
01631
PI_DIFF(PUInt16l, WORD);
01632
#endif
01633
01634
#if PBYTE_ORDER==PLITTLE_ENDIAN
01635
PI_DIFF(PUInt16b, WORD);
01636
#elif PBYTE_ORDER==PBIG_ENDIAN
01637
PI_SAME(PUInt16b, WORD);
01638
#endif
01639
01640
#if PBYTE_ORDER==PLITTLE_ENDIAN
01641
PI_SAME(PInt32l, PInt32);
01642
#elif PBYTE_ORDER==PBIG_ENDIAN
01643
PI_DIFF(PInt32l, PInt32);
01644
#endif
01645
01646
#if PBYTE_ORDER==PLITTLE_ENDIAN
01647
PI_DIFF(PInt32b, PInt32);
01648
#elif PBYTE_ORDER==PBIG_ENDIAN
01649
PI_SAME(PInt32b, PInt32);
01650
#endif
01651
01652
#if PBYTE_ORDER==PLITTLE_ENDIAN
01653
PI_SAME(PUInt32l, DWORD);
01654
#elif PBYTE_ORDER==PBIG_ENDIAN
01655
PI_DIFF(PUInt32l, DWORD);
01656
#endif
01657
01658
#if PBYTE_ORDER==PLITTLE_ENDIAN
01659
PI_DIFF(PUInt32b, DWORD);
01660
#elif PBYTE_ORDER==PBIG_ENDIAN
01661
PI_SAME(PUInt32b, DWORD);
01662
#endif
01663
01664
#if PBYTE_ORDER==PLITTLE_ENDIAN
01665
PI_SAME(PInt64l, PInt64);
01666
#elif PBYTE_ORDER==PBIG_ENDIAN
01667
PI_DIFF(PInt64l, PInt64);
01668
#endif
01669
01670
#if PBYTE_ORDER==PLITTLE_ENDIAN
01671
PI_DIFF(PInt64b, PInt64);
01672
#elif PBYTE_ORDER==PBIG_ENDIAN
01673
PI_SAME(PInt64b, PInt64);
01674
#endif
01675
01676
#if PBYTE_ORDER==PLITTLE_ENDIAN
01677
PI_SAME(PUInt64l, PUInt64);
01678
#elif PBYTE_ORDER==PBIG_ENDIAN
01679
PI_DIFF(PUInt64l, PUInt64);
01680
#endif
01681
01682
#if PBYTE_ORDER==PLITTLE_ENDIAN
01683
PI_DIFF(PUInt64b, PUInt64);
01684
#elif PBYTE_ORDER==PBIG_ENDIAN
01685
PI_SAME(PUInt64b, PUInt64);
01686
#endif
01687
01688
#if PBYTE_ORDER==PLITTLE_ENDIAN
01689
PI_SAME(PFloat32l,
float);
01690
#elif PBYTE_ORDER==PBIG_ENDIAN
01691
PI_DIFF(PFloat32l,
float);
01692
#endif
01693
01694
#if PBYTE_ORDER==PLITTLE_ENDIAN
01695
PI_DIFF(PFloat32b,
float);
01696
#elif PBYTE_ORDER==PBIG_ENDIAN
01697
PI_SAME(PFloat32b,
float);
01698
#endif
01699
01700
#if PBYTE_ORDER==PLITTLE_ENDIAN
01701
PI_SAME(PFloat64l,
double);
01702
#elif PBYTE_ORDER==PBIG_ENDIAN
01703
PI_DIFF(PFloat64l,
double);
01704
#endif
01705
01706
#if PBYTE_ORDER==PLITTLE_ENDIAN
01707
PI_DIFF(PFloat64b,
double);
01708
#elif PBYTE_ORDER==PBIG_ENDIAN
01709
PI_SAME(PFloat64b,
double);
01710
#endif
01711
01712
#ifndef NO_LONG_DOUBLE // stupid OSX compiler
01713
#if PBYTE_ORDER==PLITTLE_ENDIAN
01714
PI_SAME(PFloat80l,
long double);
01715
#elif PBYTE_ORDER==PBIG_ENDIAN
01716
PI_DIFF(PFloat80l,
long double);
01717
#endif
01718
01719
#if PBYTE_ORDER==PLITTLE_ENDIAN
01720
PI_DIFF(PFloat80b,
long double);
01721
#elif PBYTE_ORDER==PBIG_ENDIAN
01722
PI_SAME(PFloat80b,
long double);
01723
#endif
01724
#endif
01725
01726
#undef PI_LOOP
01727
#undef PI_SAME
01728
#undef PI_DIFF
01729
01730
01732
01733
01734
01735
01736
01737
01738 #define PARRAYSIZE(array) ((PINDEX)(sizeof(array)/sizeof(array[0])))
01739
01740
01741
01742
01743
01744
01745 #define PMIN(v1, v2) ((v1) < (v2) ? (v1) : (v2))
01746
01747
01748
01749
01750
01751
01752 #define PMAX(v1, v2) ((v1) > (v2) ? (v1) : (v2))
01753
01754
01755
01756
01757
01758
01759 #define PABS(v) ((v) < 0 ? -(v) : (v))
01760
01761
#endif // _POBJECT_H
01762
01763