basetsd.h revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
Abstract:
Type definitions for the basic sized types.
Author:
Revision History:
--*/
#ifndef _BASETSD_H_
#define _BASETSD_H_
#if _MSC_VER > 1000
#pragma once
#endif
#ifdef __cplusplus
extern "C" {
#endif
//
// The following types are guaranteed to be signed and 32 bits wide.
//
//
// The following types are guaranteed to be unsigned and 32 bits wide.
//
#if !defined(_W64)
#else
#define _W64
#endif
#endif
//
// The INT_PTR is guaranteed to be the same size as a pointer. Its
// size with change with pointer size (32/64). It should be used
// anywhere that a pointer is cast to an integer type. UINT_PTR is
// the unsigned variation.
//
// __int3264 is intrinsic to 64b MIDL but not to old MIDL or to C compiler.
//
#if ( 501 < __midl )
#else // midl64
// old midl and C++ compiler
#if defined(_WIN64)
#else
#endif
#endif // midl64
//
// HALF_PTR is half the size of a pointer it intended for use with
// within structures which contain a pointer and two small fields.
// UHALF_PTR is the unsigned variation.
//
#ifdef _WIN64
typedef __int64 SHANDLE_PTR;
typedef unsigned __int64 HANDLE_PTR;
typedef unsigned int UHALF_PTR, *PUHALF_PTR;
#if !defined(__midl)
unsigned long
const void *h
)
{
return((unsigned long) (ULONG_PTR) h );
}
long
const void *h
)
{
return((long) (LONG_PTR) h );
}
void *
const unsigned long h
)
{
return((void *) (UINT_PTR) h );
}
void *
const long h
)
{
return((void *) (INT_PTR) h );
}
unsigned long
const void *p
)
{
return((unsigned long) (ULONG_PTR) p );
}
unsigned int
const void *p
)
{
return((unsigned int) (UINT_PTR) p );
}
unsigned short
const void *p
)
{
return((unsigned short) (unsigned long) (ULONG_PTR) p );
}
long
const void *p
)
{
return((long) (LONG_PTR) p );
}
int
const void *p
)
{
return((int) (INT_PTR) p );
}
short
const void *p
)
{
return((short) (long) (LONG_PTR) p );
}
void *
const int i
)
// Caution: IntToPtr() sign-extends the int value.
{
return( (void *)(INT_PTR)i );
}
void *
const unsigned int ui
)
// Caution: UIntToPtr() zero-extends the unsigned int value.
{
}
void *
const long l
)
// Caution: LongToPtr() sign-extends the long value.
{
return( (void *)(LONG_PTR)l );
}
void *
const unsigned long ul
)
// Caution: ULongToPtr() zero-extends the unsigned long value.
{
}
#endif // !_midl
#else // !_WIN64
#define ADDRESS_TAG_BIT 0x80000000UL
typedef unsigned short UHALF_PTR, *PUHALF_PTR;
typedef _W64 long SHANDLE_PTR;
typedef _W64 unsigned long HANDLE_PTR;
#define PtrToUshort( p ) ((unsigned short)(ULONG_PTR)(p) )
#define PtrToShort( p ) ((short)(LONG_PTR)(p) )
#endif // !_WIN64
#define HandleToUlong(h) HandleToULong(h)
#define MAXUINT_PTR (~((UINT_PTR)0))
#define MININT_PTR (~MAXINT_PTR)
#define MAXULONG_PTR (~((ULONG_PTR)0))
#define MINLONG_PTR (~MAXLONG_PTR)
#define MAXUHALF_PTR ((UHALF_PTR)~0)
#define MINHALF_PTR (~MAXHALF_PTR)
//
// SIZE_T used for counts or ranges which need to span the range of
// of a pointer. SSIZE_T is the signed variation.
//
//
// Add Windows flavor DWORD_PTR types
//
//
// The following types are guaranteed to be signed and 64 bits wide.
//
//
// The following types are guaranteed to be unsigned and 64 bits wide.
//
//
// Thread affinity.
//
typedef KAFFINITY *PKAFFINITY;
#ifdef __cplusplus
}
#endif
#endif // _BASETSD_H_