VirtualBox

Changeset 19177 in vbox


Ignore:
Timestamp:
Apr 24, 2009 6:29:25 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46489
Message:

iprt/cdefs.h: Added RT_VALID_ALIGNED_PTR and renamed VALID_PTR to RT_VALID_PTR (old name remains valid).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cdefs.h

    r19167 r19177  
    15361536/** @def VALID_PTR
    15371537 * Pointer validation macro.
    1538  * @param   ptr
     1538 * @param   ptr         The pointer.
    15391539 */
    15401540#if defined(RT_ARCH_AMD64)
    15411541# ifdef IN_RING3
    15421542#  if defined(RT_OS_DARWIN) /* first 4GB is reserved for legacy kernel. */
    1543 #   define VALID_PTR(ptr)   (   (uintptr_t)(ptr) >= _4G \
    1544                              && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
     1543#   define RT_VALID_PTR(ptr)    (   (uintptr_t)(ptr) >= _4G \
     1544                                 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
    15451545#  elif defined(RT_OS_SOLARIS) /* The kernel only used the top 2TB, but keep it simple. */
    1546 #   define VALID_PTR(ptr)   (   (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
    1547                              && (   ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
    1548                                  || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
     1546#   define RT_VALID_PTR(ptr)    (   (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
     1547                                 && (   ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
     1548                                     || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
    15491549#  else
    1550 #   define VALID_PTR(ptr)   (   (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
    1551                              && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
     1550#   define RT_VALID_PTR(ptr)    (   (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
     1551                                 && !((uintptr_t)(ptr) & 0xffff800000000000ULL) )
    15521552#  endif
    15531553# else /* !IN_RING3 */
    1554 #  define VALID_PTR(ptr)    (   (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
    1555                              && (   ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
    1556                                  || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
     1554#  define RT_VALID_PTR(ptr)     (   (uintptr_t)(ptr) + 0x1000U >= 0x2000U \
     1555                                 && (   ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0xffff800000000000ULL \
     1556                                     || ((uintptr_t)(ptr) & 0xffff800000000000ULL) == 0) )
    15571557# endif /* !IN_RING3 */
    15581558#elif defined(RT_ARCH_X86)
    1559 # define VALID_PTR(ptr)     ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
     1559# define RT_VALID_PTR(ptr)      ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
    15601560#else
    15611561# error "Architecture identifier missing / not implemented."
    15621562#endif
     1563
     1564/** Old name for RT_VALID_PTR.  */
     1565#define VALID_PTR(ptr)      RT_VALID_PTR(ptr)
     1566
     1567/** @def RT_VALID_ALIGNED_PTR
     1568 * Pointer validation macro that also checks the alignment.
     1569 * @param   ptr         The pointer.
     1570 * @param   align       The alignment, must be a power of two.
     1571 */
     1572#define RT_VALID_ALIGNED_PTR(ptr, align)   \
     1573    (   !((uintptr_t)(ptr) & (uintptr_t)((align) - 1)) \
     1574     && VALID_PTR(ptr) )
    15631575
    15641576
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette