1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Create the "uptr" typedef (the same as uintptr_t when available) and use it

to cast pointers before comparison.

FossilOrigin-Name: 2484cc0c3ffc8834a155f89af1581bd07d453a90
This commit is contained in:
drh
2016-03-22 14:37:59 +00:00
parent 0b98207c5b
commit 3bfa7e82b6
4 changed files with 31 additions and 25 deletions

View File

@@ -181,21 +181,6 @@
# define SQLITE_PTR_TO_INT(X) ((int)(X))
#endif
/*
** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
** something between S (inclusive) and E (exclusive).
**
** In other words, S is a buffer and E is a pointer to the first byte after
** the end of buffer S. This macro returns true if P points to something
** contained within the buffer S.
*/
#if defined(HAVE_STDINT_H)
# define SQLITE_WITHIN(P,S,E) \
((uintptr_t)(P)>=(uintptr_t)(S) && (uintptr_t)(P)<(uintptr_t)(E))
#else
# define SQLITE_WITHIN(P,S,E) ((P)>=(S) && (P)<(E))
#endif
/*
** A macro to hint to the compiler that a function should not be
** inlined.
@@ -717,6 +702,27 @@ typedef INT16_TYPE LogEst;
# endif
#endif
/* The uptr type is an unsigned integer large enough to hold a pointer
*/
#if defined(HAVE_STDINT_H)
typedef uintptr_t uptr;
#elif SQLITE_PTRSIZE==4
typedef u32 uptr;
#else
typedef u64 uptr;
#endif
/*
** The SQLITE_WITHIN(P,S,E) macro checks to see if pointer P points to
** something between S (inclusive) and E (exclusive).
**
** In other words, S is a buffer and E is a pointer to the first byte after
** the end of buffer S. This macro returns true if P points to something
** contained within the buffer S.
*/
#define SQLITE_WITHIN(P,S,E) (((uptr)(P)>=(uptr)(S))&&((uptr)(P)<(uptr)(E)))
/*
** Macros to determine whether the machine is big or little endian,
** and whether or not that determination is run-time or compile-time.