Logo Search packages:      
Sourcecode: virtualbox-ose version File versions

kTypes.h

Go to the documentation of this file.
/* $Id: kTypes.h 17 2009-01-24 02:03:50Z bird $ */
/** @file
 *
 * kTypes - Typedefs And Related Constants And Macros.
 *
 * Copyright (c) 2007-2009 knut st. osmundsen <bird-src-spam@anduin.net>
 *
 *
 * This file is part of kStuff.
 *
 * kStuff is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * kStuff is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with kStuff; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef ___k_kTypes_h___
#define ___k_kTypes_h___

#include <k/kDefs.h>

/** @defgroup grp_kTypes    kTypes - Typedefs And Related Constants And Macros
 * @{
 */

/** @typedef KI64
 * 64-bit signed integer. */
/** @typedef KU64
 * 64-bit unsigned integer. */
/** @def KI64_C
 * 64-bit signed integer constant.
 * @param c         The constant value. */
/** @def KU64_C
 * 64-bit unsigned integer constant.
 * @param c         The constant value. */
/** @def KI64_PRI
 * 64-bit signed integer printf format. */
/** @def KU64_PRI
 * 64-bit unsigned integer printf format. */
/** @def KX64_PRI
 * 64-bit signed and unsigned integer hexadecimal printf format. */

/** @typedef KI32
 * 32-bit signed integer. */
/** @typedef KU32
 * 32-bit unsigned integer. */
/** @def KI32_C
 * 32-bit signed integer constant.
 * @param c         The constant value. */
/** @def KU32_C
 * 32-bit unsigned integer constant.
 * @param c         The constant value. */
/** @def KI32_PRI
 * 32-bit signed integer printf format. */
/** @def KU32_PRI
 * 32-bit unsigned integer printf format. */
/** @def KX32_PRI
 * 32-bit signed and unsigned integer hexadecimal printf format. */

/** @typedef KI16
 * 16-bit signed integer. */
/** @typedef KU16
 * 16-bit unsigned integer. */
/** @def KI16_C
 * 16-bit signed integer constant.
 * @param c         The value. */
/** @def KU16_C
 * 16-bit unsigned integer constant.
 * @param c         The value. */
/** @def KI16_PRI
 * 16-bit signed integer printf format. */
/** @def KU16_PRI
 * 16-bit unsigned integer printf format. */
/** @def KX16_PRI
 * 16-bit signed and unsigned integer hexadecimal printf format. */

/** @typedef KI8
 * 8-bit signed integer. */
/** @typedef KU8
 * 8-bit unsigned integer. */
/** @def KI8_C
 * 8-bit signed integer constant.
 * @param c         The constant value. */
/** @def KU8_C
 * 8-bit unsigned integer constant.
 * @param c         The constant value. */
/** @def KI8_PRI
 * 8-bit signed integer printf format. */
/** @def KU8_PRI
 * 8-bit unsigned integer printf format. */
/** @def KX8_PRI
 * 8-bit signed and unsigned integer hexadecimal printf format. */

/** @typedef KSIZE
 * Memory size type; unsigned integer. */
/** @typedef KSSIZE
 * Memory size type; signed integer. */
/** @def KSIZE_C
 * Memory size constant.
 * @param c         The constant value. */
/** @def KSSIZE_C
 * Memory size constant.
 * @param c         The constant value. */
/** @def KSIZE_MAX
 * Memory size max constant.*/
/** @def KSSIZE_MAX
 * Memory size max constant.*/
/** @def KSSIZE_MIN
 * Memory size min constant.*/
/** @def KSIZE_PRI
 * Memory size printf format. */
/** @def KSSIZE_PRI
 * Memory size printf format. */

/** @typedef KIPTR
 * Signed integer type capable of containing a pointer value.  */
/** @typedef KUPTR
 * Unsigned integer type capable of containing a pointer value.  */
/** @def KIPTR_C
 * Signed pointer constant.
 * @param c         The constant value. */
/** @def KUPTR_C
 * Unsigned pointer constant.
 * @param c         The constant value. */
/** @def KIPTR_MAX
 * Signed pointer max constant.*/
/** @def KIPTR_MIN
 * Signed pointer min constant.*/
/** @def KUPTR_MAX
 * Unsigned pointer max constant.*/
/** @def KIPTR_PRI
 * Signed pointer printf format. */
/** @def KUPTR_PRI
 * Unsigned pointer printf format. */


#if K_ARCH_BITS == 32
  /* ASSUMES int == long == 32-bit, short == 16-bit, char == 8-bit. */
# ifdef _MSC_VER
typedef signed __int64          KI64;
typedef unsigned __int64        KU64;
#define KI64_PRI                "I64d"
#define KU64_PRI                "I64u"
#define KX64_PRI                "I64x"
# else
typedef signed long long int    KI64;
typedef unsigned long long int  KU64;
#define KI64_PRI                "lld"
#define KU64_PRI                "llu"
#define KX64_PRI                "llx"
# endif
typedef signed int              KI32;
typedef unsigned int            KU32;
typedef signed short int        KI16;
typedef unsigned short int      KU16;
typedef signed char             KI8;
typedef unsigned char           KU8;
#define KI64_C(c)               (c ## LL)
#define KU64_C(c)               (c ## ULL)
#define KI32_C(c)               (c)
#define KU32_C(c)               (c)
#define KI16_C(c)               (c)
#define KU16_C(c)               (c)
#define KI8_C(c)                (c)
#define KU8_C(c)                (c)

#define KI32_PRI                "d"
#define KU32_PRI                "u"
#define KX32_PRI                "x"
#define KI16_PRI                "d"
#define KU16_PRI                "u"
#define KX16_PRI                "x"
#define KI8_PRI                 "d"
#define KU8_PRI                 "u"
#define KX8_PRI                 "x"

typedef KI32                    KSSIZE;
#define KSSIZE(c)               KI32_C(c)
#define KSSIZE_MAX              KI32_MAX
#define KSSIZE_MIN              KI32_MIN
#define KSSIZE_PRI              KX32_PRI

typedef KU32                    KSIZE;
#define KSIZE_C(c)              KU32_C(c)
#define KSIZE_MAX               KU32_MAX
#define KSIZE_PRI               KX32_PRI
#define KIPTR_C(c)              KI32_C(c)

typedef KI32                    KIPTR;
#define KIPTR_MAX               KI32_MAX
#define KIPTR_MIN               KI32_MIN
#define KIPTR_PRI               KX32_PRI

typedef KU32                    KUPTR;
#define KUPTR_C(c)              KU32_C(c)
#define KUPTR_MAX               KU32_MAX
#define KUPTR_PRI               KX32_PRI


#elif K_ARCH_BITS == 64

# if K_OS == K_OS_WINDOWS
#  if _MSC_VER
typedef signed __int64          KI64;
typedef unsigned __int64        KU64;
#   define KI64_PRI             "I64d"
#   define KU64_PRI             "I64u"
#   define KX64_PRI             "I64x"
#  else
typedef signed long long int    KI64;
typedef unsigned long long int  KU64;
#   define KI64_PRI              "lld"
#   define KU64_PRI              "llu"
#   define KX64_PRI              "llx"
#  endif
#  define KI64_C(c)             (c ## LL)
#  define KU64_C(c)             (c ## ULL)
# else
typedef signed long int         KI64;
typedef unsigned long int       KU64;
#  define KI64_C(c)             (c ## L)
#  define KU64_C(c)             (c ## UL)
#  define KI64_PRI              "ld"
#  define KU64_PRI              "lu"
#  define KX64_PRI              "lx"
# endif
typedef signed int              KI32;
typedef unsigned int            KU32;
typedef signed short            KI16;
typedef unsigned short          KU16;
typedef signed char             KI8;
typedef unsigned char           KU8;
#define KI32_C(c)               (c)
#define KU32_C(c)               (c)
#define KI16_C(c)               (c)
#define KU16_C(c)               (c)
#define KI8_C(c)                (c)
#define KU8_C(c)                (c)

#define KI32_PRI                "d"
#define KU32_PRI                "u"
#define KX32_PRI                "x"
#define KI16_PRI                "d"
#define KU16_PRI                "u"
#define KX16_PRI                "x"
#define KI8_PRI                 "d"
#define KU8_PRI                 "u"
#define KX8_PRI                 "x"

typedef KI64                    KSSIZE;
#define KSSIZE(c)               KI64_C(c)
#define KSSIZE_MAX              KI64_MAX
#define KSSIZE_MIN              KI64_MIN
#define KSSIZE_PRI              KX64_PRI

typedef KU64                    KSIZE;
#define KSIZE_C(c)              KU64_C(c)
#define KSIZE_MAX               KU64_MAX
#define KSIZE_PRI               KX64_PRI

typedef KI64                    KIPTR;
#define KIPTR_C(c)              KI64_C(c)
#define KIPTR_MAX               KI64_MAX
#define KIPTR_MIN               KI64_MIN
#define KIPTR_PRI               KX64_PRI

typedef KU64                    KUPTR;
#define KUPTR_C(c)              KU64_C(c)
#define KUPTR_MAX               KU64_MAX
#define KUPTR_PRI               KX64_PRI

#else
# error "Port Me"
#endif


/** Min KI8 value. */
00288 #define KI8_MIN                 (KI8_C(-0x7f) - 1)
/** Min KI16 value. */
00290 #define KI16_MIN                (KI16_C(-0x7fff) - 1)
/** Min KI32 value. */
00292 #define KI32_MIN                (KI32_C(-0x7fffffff) - 1)
/** Min KI64 value. */
00294 #define KI64_MIN                (KI64_C(-0x7fffffffffffffff) - 1)
/** Max KI8 value. */
00296 #define KI8_MAX                 KI8_C(0x7f)
/** Max KI16 value. */
00298 #define KI16_MAX                KI16_C(0x7fff)
/** Max KI32 value. */
00300 #define KI32_MAX                KI32_C(0x7fffffff)
/** Max KI64 value. */
00302 #define KI64_MAX                KI64_C(0x7fffffffffffffff)
/** Max KU8 value. */
00304 #define KU8_MAX                 KU8_C(0xff)
/** Max KU16 value. */
00306 #define KU16_MAX                KU16_C(0xffff)
/** Max KU32 value. */
00308 #define KU32_MAX                KU32_C(0xffffffff)
/** Max KU64 value. */
00310 #define KU64_MAX                KU64_C(0xffffffffffffffff)

/** File offset. */
00313 typedef KI64                    KFOFF;
/** Pointer a file offset. */
00315 typedef KFOFF                  *PFOFF;
/** Pointer a const file offset. */
00317 typedef KFOFF                  *PCFOFF;
/** The min value for the KFOFF type. */
00319 #define KFOFF_MIN               KI64_MIN
/** The max value for the KFOFF type. */
00321 #define KFOFF_MAX               KI64_MAX
/** File offset contstant.
 * @param c         The constant value. */
00324 #define KFOFF_C(c)              KI64_C(c)
/** File offset printf format. */
00326 #define KFOFF_PRI               KI64_PRI


/**
 * Memory Protection.
 */
00332 typedef enum KPROT
{
    /** The usual invalid 0. */
00335     KPROT_INVALID = 0,
    /** No access (page not present). */
00337     KPROT_NOACCESS,
    /** Read only. */
00339     KPROT_READONLY,
    /** Read & write. */
00341     KPROT_READWRITE,
    /** Read & copy on write. */
00343     KPROT_WRITECOPY,
    /** Execute only. */
00345     KPROT_EXECUTE,
    /** Execute & read. */
00347     KPROT_EXECUTE_READ,
    /** Execute, read & write. */
00349     KPROT_EXECUTE_READWRITE,
    /** Execute, read & copy on write. */
00351     KPROT_EXECUTE_WRITECOPY,
    /** The usual end value. (exclusive) */
00353     KPROT_END,
    /** Blow the type up to 32-bits. */
00355     KPROT_32BIT_HACK = 0x7fffffff
} KPROT;
/** Pointer to a memory protection enum. */
00358 typedef KPROT                  *PKPROT;
/** Pointer to a const memory protection enum. */
00360 typedef KPROT const            *PCKPROT;

/** Boolean.
 * This can be used as a tri-state type, but then you *must* do == checks. */
00364 typedef KI8                     KBOOL;
/** Pointer to a boolean value. */
00366 typedef KBOOL                  *PKBOOL;
/** Pointer to a const boolean value. */
00368 typedef KBOOL const            *PCKBOOL;
/** Maxium value the KBOOL type can hold (officially). */
00370 #define KBOOL_MIN               KI8_C(-1)
/** Maxium value the KBOOL type can hold (officially). */
00372 #define KBOOL_MAX               KI8_C(1)
/** The KBOOL printf format. */
00374 #define KBOOL_PRI               KU8_PRI
/** Boolean true constant. */
00376 #define K_TRUE                  KI8_C(1)
/** Boolean false constant. */
00378 #define K_FALSE                 KI8_C(0)
/** Boolean unknown constant (the third state). */
00380 #define K_UNKNOWN               KI8_C(-1)


/**
 * Integer union.
 */
00386 typedef union KUINT
{
00388     KFOFF           iBig;               /**< The biggest member. */
00389     KBOOL           fBool;              /**< Boolean. */
00390     KU8             b;                  /**< unsigned 8-bit. */
00391     KU8             u8;                 /**< unsigned 8-bit. */
00392     KI8             i8;                 /**< signed 8-bit.  */
00393     KU16            u16;                /**< unsigned 16-bit. */
00394     KI16            i16;                /**< signed 16-bit. */
00395     KU32            u32;                /**< unsigned 32-bit. */
00396     KI32            i32;                /**< signed 32-bit. */
00397     KU64            u64;                /**< unsigned 64-bit. */
00398     KI64            i64;                /**< signed 64-bit. */
00399     KSIZE           cbUnsign;           /**< unsigned size. */
00400     KSSIZE          cbSign;             /**< signed size. */
00401     KFOFF           offFile;            /**< file offset. */
00402     KUPTR           uPtr;               /**< unsigned pointer. */
00403     KIPTR           iPtr;               /**< signed pointer. */
00404     void           *pv;                 /**< void pointer. */
00405     char            ch;                 /**< char. */
00406     unsigned char   uch;                /**< unsigned char. */
00407     signed char     chSigned;           /**< signed char. */
00408     unsigned short  uShort;             /**< Unsigned short. */
00409     signed short    iShort;             /**< Signed short. */
00410     unsigned int    uInt;               /**< Unsigned int. */
00411     signed int      iInt;               /**< Signed int. */
00412     unsigned long   uLong;              /**< Unsigned long. */
00413     signed long     iLong;              /**< Signed long. */
} KUINT;


/**
 * Integer pointer union.
 */
00420 typedef union KPUINT
{
00422     KFOFF          *piBig;              /**< The biggest member. */
00423     KBOOL          *pfBool;             /**< Boolean. */
00424     KU8            *pb;                 /**< unsigned 8-bit. */
00425     KU8            *pu8;                /**< unsigned 8-bit. */
00426     KI8            *pi8;                /**< signed 8-bit. */
00427     KU16           *pu16;               /**< unsigned 16-bit. */
00428     KI16           *pi16;               /**< signed 16-bit. */
00429     KU32           *pu32;               /**< unsigned 32-bit. */
00430     KI32           *pi32;               /**< signed 32-bit. */
00431     KU64           *pu64;               /**< unsigned 64-bit. */
00432     KI64           *pi64;               /**< signed 64-bit. */
00433     KSIZE          *pcbUnsign;          /**< unsigned size. */
00434     KSSIZE         *pcbSign;            /**< signed size. */
00435     KFOFF          *poffFile;           /**< file offset. */
00436     KUPTR          *puPtr;              /**< unsigned pointer. */
00437     KIPTR          *piPtr;              /**< signed pointer. */
00438     void          **ppv;                /**< void pointer pointer. */
00439     void           *pv;                 /**< void pointer. */
00440     char           *pch;                /**< char. */
00441     char           *psz;                /**< zero terminated string. */
00442     unsigned char  *puch;               /**< unsigned char. */
00443     signed char    *pchSigned;          /**< signed char. */
00444     unsigned short *puShort;            /**< Unsigned short. */
00445     signed short   *piShort;            /**< Signed short. */
00446     unsigned int   *puInt;              /**< Unsigned int. */
00447     signed int     *piInt;              /**< Signed int. */
00448     unsigned long  *puLong;             /**< Unsigned long. */
00449     signed long    *piLong;             /**< Signed long. */
} KPUINT;

/**
 * Integer const pointer union.
 */
00455 typedef union KPCUINT
{
00457     KFOFF  const   *piBig;              /**< The biggest member. */
00458     KBOOL  const   *pfBool;             /**< Boolean. */
00459     KU8    const   *pb;                 /**< byte.  */
00460     KU8    const   *pu8;                /**< unsigned 8-bit.  */
00461     KI8    const   *pi8;                /**< signed 8-bit.  */
00462     KU16   const   *pu16;               /**< unsigned 16-bit. */
00463     KI16   const   *pi16;               /**< signed 16-bit. */
00464     KU32   const   *pu32;               /**< unsigned 32-bit. */
00465     KI32   const   *pi32;               /**< signed 32-bit. */
00466     KU64   const   *pu64;               /**< unsigned 64-bit. */
00467     KI64   const   *pi64;               /**< signed 64-bit. */
00468     KSIZE  const   *pcbUnsign;          /**< unsigned size. */
00469     KSSIZE const   *pcbSign;            /**< signed size. */
00470     KFOFF  const   *poffFile;           /**< file offset. */
00471     KUPTR  const   *puPtr;              /**< unsigned pointer. */
00472     KIPTR  const   *piPtr;              /**< signed pointer. */
00473     void   const  **ppv;                /**< void pointer pointer. */
00474     void   const   *pv;                 /**< void pointer. */
00475     char   const   *pch;                /**< char. */
00476     char   const   *psz;                /**< zero terminated string. */
00477     unsigned char  const *puch;         /**< unsigned char. */
00478     signed char    const *pchSigned;    /**< signed char. */
00479     unsigned short const *puShort;      /**< Unsigned short. */
00480     signed short   const *piShort;      /**< Signed short. */
00481     unsigned int   const *puInt;        /**< Unsigned int. */
00482     signed int     const *piInt;        /**< Signed int. */
00483     unsigned long  const *puLong;       /**< Unsigned long. */
00484     signed long    const *piLong;       /**< Signed long. */
} KPCUINT;


/** @name   Forward Declarations / Handle Types.
 * @{ */

/** Pointer to a file provider instance. */
00492 typedef struct KRDR *PKRDR;
/** Pointer to a file provider instance pointer. */
00494 typedef struct KRDR **PPKRDR;

/** Pointer to a loader segment. */
00497 typedef struct KLDRSEG *PKLDRSEG;
/** Pointer to a loader segment. */
00499 typedef const struct KLDRSEG *PCKLDRSEG;

/** @} */

/** @} */

#endif


Generated by  Doxygen 1.6.0   Back to index