1 // AsmJit - Complete JIT Assembler for C++ Language.
3 // Copyright (c) 2008-2010, Petr Kobalicek <kobalicek.petr@gmail.com>
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 // OTHER DEALINGS IN THE SOFTWARE.
27 #ifndef _ASMJIT_UTIL_P_H
28 #define _ASMJIT_UTIL_P_H
38 //! @addtogroup AsmJit_Util
41 // ============================================================================
43 // ============================================================================
47 // --------------------------------------------------------------------------
48 // [AsmJit::floatAsInt32, int32AsFloat]
49 // --------------------------------------------------------------------------
53 //! @brief used to cast from float to 32-bit integer and vica versa.
56 //! @brief 32-bit signed integer value.
58 //! @brief 32-bit SP-FP value.
64 //! @brief used to cast from double to 64-bit integer and vica versa.
67 //! @brief 64-bit signed integer value.
69 //! @brief 64-bit DP-FP value.
73 //! @brief Binary cast from 32-bit integer to SP-FP value (@c float).
74 static inline float int32AsFloat(int32_t i) ASMJIT_NOTHROW
81 //! @brief Binary cast SP-FP value (@c float) to 32-bit integer.
82 static inline int32_t floatAsInt32(float f) ASMJIT_NOTHROW
89 //! @brief Binary cast from 64-bit integer to DP-FP value (@c double).
90 static inline double int64AsDouble(int64_t i) ASMJIT_NOTHROW
97 //! @brief Binary cast from DP-FP value (@c double) to 64-bit integer.
98 static inline int64_t doubleAsInt64(double f) ASMJIT_NOTHROW
105 // --------------------------------------------------------------------------
107 // --------------------------------------------------------------------------
109 ASMJIT_HIDDEN char* mycpy(char* dst, const char* src, sysuint_t len = (sysuint_t)-1) ASMJIT_NOTHROW;
110 ASMJIT_HIDDEN char* myfill(char* dst, const int c, sysuint_t len) ASMJIT_NOTHROW;
111 ASMJIT_HIDDEN char* myhex(char* dst, const uint8_t* src, sysuint_t len) ASMJIT_NOTHROW;
112 ASMJIT_HIDDEN char* myutoa(char* dst, sysuint_t i, sysuint_t base = 10) ASMJIT_NOTHROW;
113 ASMJIT_HIDDEN char* myitoa(char* dst, sysint_t i, sysuint_t base = 10) ASMJIT_NOTHROW;
115 // --------------------------------------------------------------------------
117 // --------------------------------------------------------------------------
119 static inline void memset32(uint32_t* p, uint32_t c, sysuint_t len) ASMJIT_NOTHROW
122 for (i = 0; i < len; i++) p[i] = c;
128 } // AsmJit namespace
130 #endif // _ASMJIT_UTIL_P_H