public/sourcepawn/sp_typeutil.h
author David Anderson <dvander@alliedmods.net>
Fri Feb 16 03:47:10 2007 +0000 (2007-02-16)
changeset 501 e209a7296936
parent 379 b3c99c22ba80
child 1231 17badaf66ce4
permissions -rw-r--r--
removed this potential feature, not useful enough
     1 /**
     2  * vim: set ts=4 :
     3  * ================================================================
     4  * SourcePawn, Copyright (C) 2004-2007 AlliedModders LLC. 
     5  * All rights reserved.
     6  * ================================================================
     7  *
     8  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be 
     9  * used or modified under the Terms and Conditions of its License Agreement, 
    10  * which is found in public/licenses/LICENSE.txt.  As of this notice, derivative 
    11  * works must be licensed under the GNU General Public License (version 2 or 
    12  * greater).  A copy of the GPL is included under public/licenses/GPL.txt.
    13  * 
    14  * To view the latest information, see: http://www.sourcemod.net/license.php
    15  *
    16  * Version: $Id$
    17  */
    18 
    19 #ifndef _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
    20 #define _INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
    21 
    22 /**
    23  * @file sp_typeutil.h
    24  * @brief Defines type utility functions.
    25  */
    26 
    27 #include "sp_vm_types.h"
    28 
    29 /**
    30  * @brief Reinterpret-casts a float to a cell (requires -fno-strict-aliasing for GCC).
    31  *
    32  * @param val		Float value.
    33  * @return			Cell typed version.
    34  */
    35 inline cell_t sp_ftoc(float val)
    36 {
    37 	return *(cell_t *)&val;
    38 }
    39 
    40 /**
    41  * @brief Reinterpret-casts a cell to a float (requires -fno-strict-aliasing for GCC).
    42  *
    43  * @param val		Cell-packed float value.
    44  * @return			Float typed version.
    45  */
    46 inline float sp_ctof(cell_t val)
    47 {
    48 	return *(float *)&val;
    49 }
    50 
    51 #endif //_INCLUDE_SOURCEPAWN_VM_TYPEUTIL_H_
    52