Changeset 3528 for trunk/kDbg/kDbgBase.h


Ignore:
Timestamp:
Aug 20, 2007, 4:43:13 AM (18 years ago)
Author:
bird
Message:

Some refactoring and OS abstraction by instroducing kDbgHlp.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/kDbg/kDbgBase.h

    • Property svn:eol-style set to native
    r3526 r3528  
    11/* $Id$ */
    22/** @file
    3  *
    43 * kDbg - The Debug Info Reader, Base Definitions and Typedefs.
    5  *
     4 */
     5
     6/*
    67 * Copyright (c) 2006-2007 knut st. osmundsen <bird@anduin.net>
    78 *
     
    7879
    7980
     81/** @def KDBG_CALL
     82 * The calling convention used by the kDbg functions. */
     83#if defined(_MSC_VER) || defined(__OS2__)
     84# define KDBG_CALL  __cdecl
     85#else
     86# define KDBG_CALL
     87#endif
     88
     89#ifdef __DOXYGEN__
     90/** @def KDBG_BUILDING
     91 * Define KDBG_BUILDING to indicate that kDbg is being built.
     92 */
     93# define KDBG_BUILDING
     94/** @def KDBG_RESIDES_IN_DLL
     95 * Define KDBG_RESIDES_IN_DLL to indicate that kDbg resides in a DLL.
     96 */
     97# define KDBG_RESIDES_IN_DLL
     98#endif
     99
     100/** @def KDBG_DECL
     101 * Macro for defining public functions. */
     102#if defined(KDBG_RESIDES_IN_DLL) \
     103 && (defined(_MSC_VER) || defined(__OS2__))
     104# ifdef KDBG_BUILDING
     105#  define KDBG_DECL(type) __declspec(dllexport) type
     106# else
     107#  define KDBG_DECL(type) __declspec(dllimport) type
     108# endif
     109#else
     110# define KDBG_DECL(type) type
     111#endif
     112
     113/** @def KDBG_INLINE
     114 * Macro for defining an inline function. */
     115#ifdef __cplusplus
     116# if defined(__GNUC__)
     117#  define KDBG_INLINE(type) static inline type
     118# else
     119#  define KDBG_INLINE(type) inline type
     120# endif
     121#else
     122# if defined(__GNUC__)
     123#  define KDBG_INLINE(type) static __inline__ type
     124# elif defined(_MSC_VER)
     125#  define KDBG_INLINE(type) _inline type
     126# else
     127#  error "Port me"
     128# endif
     129#endif
     130
     131
     132/** The kDbg address type. */
     133typedef uint64_t KDBGADDR;
     134/** Pointer to a kLdr address. */
     135typedef KDBGADDR *PKDBGADDR;
     136/** Pointer to a const kLdr address. */
     137typedef const KDBGADDR *PCKDBGADDR;
     138
     139/** NIL address. */
     140#define NIL_KDBGADDR    (~(uint64_t)0)
     141
     142/** @def PRI_KDBGADDR
     143 * printf format type. */
     144#ifdef _MSC_VER
     145# define PRI_KDBGADDR    "I64x"
     146#else
     147# define PRI_KDBGADDR    "llx"
     148#endif
     149
     150
    80151/** Get the minimum of two values. */
    81152#define KDBG_MIN(a, b)              ((a) <= (b) ? (a) : (b))
     
    89160#define KDBG_ALIGN_P(pv, align)     ( (void *)( ((uintptr_t)(pv) + ((align) - 1)) & ~(uintptr_t)((align) - 1) ) )
    90161/** Align a size_t value. */
    91 #define KDBG_ALIGN_ADDR(val, align) ( ((val) + ((align) - 1)) & ~(KLDRADDR)((align) - 1) )
     162#define KDBG_ALIGN_ADDR(val, align) ( ((val) + ((align) - 1)) & ~(KDBGADDR)((align) - 1) )
    92163/** Number of elements in an array. */
    93164#define KDBG_ELEMENTS(a)            ( sizeof(a) / sizeof((a)[0]) )
     165/** @def KDBG_VALID_PTR
     166 * Checks if the specified pointer is a valid address or not. */
     167#define KDBG_VALID_PTR(ptr)         ( (uintptr_t)(ptr) + 0x1000U >= 0x2000U )
    94168
    95169
Note: See TracChangeset for help on using the changeset viewer.