-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore_ptr_api.h
14 lines (10 loc) · 981 Bytes
/
core_ptr_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#ifndef SW_CORE_PTR_API_H_
#define SW_CORE_PTR_API_H_
#include "core_preface.h"
typedef SwU64 SwPtrUInt;
typedef const void* SwPtrAddr;
SW_PUBL_API_IMPL inline SwBool swPtrEqual(SwPtrAddr ptr1, SwPtrAddr ptr2) { return (SwPtrUInt)ptr1 == (SwPtrUInt)ptr2; }
SW_PUBL_API_IMPL inline SwBool swPtrInAddrRangeIncl(SwPtrAddr ptr, SwPtrAddr addrLoIncl, SwPtrAddr addrHiIncl) { SW_DASSERT(addrLoIncl <= addrHiIncl); return ((SwPtrUInt)ptr - (SwPtrUInt)addrLoIncl) <= ((SwPtrUInt)addrHiIncl - (SwPtrUInt)addrLoIncl); }
SW_PUBL_API_IMPL inline SwBool swPtrInAddrRangeExcl(SwPtrAddr ptr, SwPtrAddr addrLoIncl, SwPtrAddr addrHiExcl) { SW_DASSERT(addrLoIncl <= addrHiExcl); return ((SwPtrUInt)ptr - (SwPtrUInt)addrLoIncl) < ((SwPtrUInt)addrHiExcl - (SwPtrUInt)addrLoIncl); }
SW_PUBL_API_IMPL inline SwBool swPtrInSizedMem(SwPtrAddr ptr, SwUsz byteSize, SwPtrAddr memBegin) { return swPtrInAddrRangeExcl(ptr, memBegin, (const SwU8*)memBegin + byteSize); }
#endif // SW_CORE_PTR_API_H_