// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//  »Project«   Talina Gaming System (TgS) (∂)
//  »File«      TgS Common - Base - API.inl
//  »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
//  »Version«   4.0
// ------------------------------------------------------------------------------------------------------------------------------ //
//  Copyright: © 2002-2010, Andrew Aye.  All Rights Reserved.
//  This software is free for non-commercial use. Redistribution and use in source and binary forms, with or without modification,
//  are permitted provided that the following conditions are met: 
//    Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. 
//    Redistributions in binary form must reproduce this copyright notice, this list of conditions and the following
//      disclaimers in the documentation and other materials provided with the distribution. 
//  Neither the names of the copyright owner nor the names of its contributors may be used to endorse or promote products derived
//  from this software without specific prior written permission. 
//  The intellectual property rights of the algorithms used reside with Andrew Aye.  You may not use this software, in whole or
//  in part, in support of any commercial product without the express written consent of the author.
//  There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
#if !defined(_TGS_COMMON_BASE_API_INL_)
#define _TGS_COMMON_BASE_API_INL_
#pragma once


// START TGS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

TgINLINE TgUINTPTR tgCM_FLR_ALGN_PW2_UPTR( C_TgUINTPTR uiA, C_TgUINTPTR uiAlignment )
{
#if defined(_WIN64)
    return (tgCM_FLR_ALGN_PW2_U64( uiA, uiAlignment ));
#else
    return (tgCM_FLR_ALGN_PW2_U32( uiA, uiAlignment ));
#endif
}


TgINLINE TgUINTPTR tgCM_CEL_ALGN_PW2_UPTR( C_TgUINTPTR uiA, C_TgUINTPTR uiAlignment )
{
#if defined(_WIN64)
    return (tgCM_CEL_ALGN_PW2_U64( uiA, uiAlignment ));
#else
    return (tgCM_CEL_ALGN_PW2_U32( uiA, uiAlignment ));
#endif
}


TgINLINE TgFLOAT32 tgCM_RND_F32()
{
    return (tgCM_RND_MT_U32() / 4294967296.0F);
}


TgINLINE TgFLOAT64 tgCM_RND_F64()
{
    C_TgUINT32                              uiA = tgCM_RND_MT_U32() >> 5;
    C_TgUINT32                              uiB = tgCM_RND_MT_U32() >> 6;

    return ( uiA * 67108864.0 + uiB ) * (1.0/9007199254740992.0);
}


// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

#define INT_SIGNED 0

#define PCU_TYPE PCU_TgUINT08
#define TYPE TgUINT08
#define F(A) A##_U08
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef TYPE
#undef PCU_TYPE

#define PCU_TYPE PCU_TgUINT16
#define TYPE TgUINT16
#define F(A) A##_U16
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef TYPE
#undef PCU_TYPE

#define PCU_TYPE PCU_TgUINT32
#define TYPE TgUINT32
#define F(A) A##_U32
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef TYPE
#undef PCU_TYPE

#define PCU_TYPE PCU_TgUINT64
#define TYPE TgUINT64
#define F(A) A##_U64
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef TYPE
#undef PCU_TYPE

#undef INT_SIGNED

// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

#define INT_SIGNED 1

#define PCU_TYPE PCU_TgSINT08
#define UTYPE TgUINT08
#define TYPE TgSINT08
#define FU(A) A##_U08
#define F(A) A##_S08
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef FU
#undef TYPE
#undef UTYPE
#undef PCU_TYPE

#define PCU_TYPE PCU_TgSINT16
#define UTYPE TgUINT16
#define TYPE TgSINT16
#define FU(A) A##_U16
#define F(A) A##_S16
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef FU
#undef TYPE
#undef UTYPE
#undef PCU_TYPE

#define PCU_TYPE PCU_TgSINT32
#define UTYPE TgUINT32
#define TYPE TgSINT32
#define FU(A) A##_U32
#define F(A) A##_S32
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef FU
#undef TYPE
#undef UTYPE
#undef PCU_TYPE

#define PCU_TYPE PCU_TgSINT64
#define UTYPE TgUINT64
#define TYPE TgSINT64
#define FU(A) A##_U64
#define F(A) A##_S64
#include "TgS COMMON/TgS Common - Base - API [I].i_inc"
#undef F
#undef FU
#undef TYPE
#undef UTYPE
#undef PCU_TYPE

#undef INT_SIGNED

// -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. //

#define PCU_TYPE PCU_TgFLOAT32
#define TYPE TgFLOAT32
#define F(A) A##_F32
#define MKL(A) A##F
#include "TgS COMMON/TgS Common - Base - API [F].i_inc"
#undef MKL
#undef F
#undef TYPE
#undef PCU_TYPE

#define PCU_TYPE PCU_TgFLOAT64
#define TYPE TgFLOAT64
#define F(A) A##_F64
#define MKL(A) A
#include "TgS COMMON/TgS Common - Base - API [F].i_inc"
#undef MKL
#undef F
#undef TYPE
#undef PCU_TYPE

#endif //  END  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////