github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/jit-intrinsic.c (about)

     1  /*
     2   * jit-intrinsic.c - Support routines for JIT intrinsics.
     3   *
     4   * Copyright (C) 2004  Southern Storm Software, Pty Ltd.
     5   *
     6   * This file is part of the libjit library.
     7   *
     8   * The libjit library is free software: you can redistribute it and/or
     9   * modify it under the terms of the GNU Lesser General Public License
    10   * as published by the Free Software Foundation, either version 2.1 of
    11   * the License, or (at your option) any later version.
    12   *
    13   * The libjit library is distributed in the hope that it will be useful,
    14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    16   * Lesser General Public License for more details.
    17   *
    18   * You should have received a copy of the GNU Lesser General Public
    19   * License along with the libjit library.  If not, see
    20   * <http://www.gnu.org/licenses/>.
    21   */
    22  
    23  #include "jit-internal.h"
    24  #if defined(HAVE_TGMATH_H) && !defined(JIT_NFLOAT_IS_DOUBLE)
    25  	#include <tgmath.h>
    26  #elif defined(HAVE_MATH_H)
    27  	#include <math.h>
    28  #endif
    29  #ifdef JIT_WIN32_PLATFORM
    30  #include <float.h>
    31  #if !defined(isnan)
    32  #define isnan(value)	_isnan((value))
    33  #endif
    34  #if !defined(isfinite)
    35  #define isfinite(value)	_finite((value))
    36  #endif
    37  #ifndef HAVE_ISNAN
    38  #define HAVE_ISNAN 1
    39  #endif
    40  #undef	HAVE_ISNANF
    41  #undef	HAVE_ISNANL
    42  #else
    43  #ifdef HAVE_IEEEFP_H
    44  #include <ieeefp.h>
    45  #endif
    46  #endif
    47  
    48  /*@
    49  
    50  @cindex jit-intrinsic.h
    51  
    52  Intrinsics are functions that are provided to ease code generation
    53  on platforms that may not be able to perform all operations natively.
    54  
    55  For example, on a CPU without a floating-point unit, the back end code
    56  generator will output a call to an intrinsic function when a floating-point
    57  operation is performed.  CPU's with a floating-point unit would use
    58  a native instruction instead.
    59  
    60  Some platforms may already have appropriate intrinsics (e.g. the ARM
    61  floating-point emulation routines).  The back end code generator may choose
    62  to use either the system-supplied intrinsics or the ones supplied by
    63  this library.  We supply all of them in our library just in case a
    64  particular platform lacks an appropriate intrinsic.
    65  
    66  Some intrinsics have no equivalent in existing system libraries;
    67  particularly those that deal with overflow checking.
    68  
    69  Functions that perform overflow checking or which divide integer operands
    70  return a built-in exception code to indicate the type of exception
    71  to be thrown (the caller is responsible for throwing the actual
    72  exception).  @xref{Exceptions}, for a list of built-in exception codes.
    73  
    74  The following functions are defined in @code{<jit/jit-intrinsic.h>}:
    75  
    76  @*/
    77  
    78  /*
    79   * Special values that indicate "not a number" for floating-point types.
    80   * Visual C++ won't let us compute NaN's at compile time, so we have to
    81   * work around it with a run-time hack.
    82   */
    83  #if defined(_MSC_VER) && defined(_M_IX86)
    84  static unsigned int const float32_nan = 0x7FC00000;
    85  static unsigned __int64 const float64_nan = 0x7FF8000000000000LL;
    86  #define	jit_float32_nan	(*((jit_float32 *)&float32_nan))
    87  #define	jit_float64_nan	(*((jit_float64 *)&float64_nan))
    88  #define	jit_nfloat_nan	((jit_nfloat)(*((jit_float64 *)&float64_nan)))
    89  #else
    90  #define	jit_float32_nan	((jit_float32)(0.0 / 0.0))
    91  #define	jit_float64_nan	((jit_float64)(0.0 / 0.0))
    92  #define	jit_nfloat_nan	((jit_nfloat)(0.0 / 0.0))
    93  #endif
    94  
    95  /*@
    96   * @deftypefun jit_int jit_int_add (jit_int @var{value1}, jit_int @var{value2})
    97   * @deftypefunx jit_int jit_int_sub (jit_int @var{value1}, jit_int @var{value2})
    98   * @deftypefunx jit_int jit_int_mul (jit_int @var{value1}, jit_int @var{value2})
    99   * @deftypefunx jit_int jit_int_neg (jit_int @var{value1})
   100   * @deftypefunx jit_int jit_int_and (jit_int @var{value1}, jit_int @var{value2})
   101   * @deftypefunx jit_int jit_int_or (jit_int @var{value1}, jit_int @var{value2})
   102   * @deftypefunx jit_int jit_int_xor (jit_int @var{value1}, jit_int @var{value2})
   103   * @deftypefunx jit_int jit_int_not (jit_int @var{value1})
   104   * @deftypefunx jit_int jit_int_not (jit_int @var{value1})
   105   * @deftypefunx jit_int jit_int_shl (jit_int @var{value1}, jit_uint @var{value2})
   106   * @deftypefunx jit_int jit_int_shr (jit_int @var{value1}, jit_uint @var{value2})
   107   * Perform an arithmetic operation on signed 32-bit integers.
   108   * @end deftypefun
   109   *
   110   * @deftypefun jit_int jit_int_add_ovf (jit_int *@var{result}, jit_int @var{value1}, jit_int @var{value2})
   111   * @deftypefunx jit_int jit_int_sub_ovf (jit_int *@var{result}, jit_int @var{value1}, jit_int @var{value2})
   112   * @deftypefunx jit_int jit_int_mul_ovf (jit_int *@var{result}, jit_int @var{value1}, jit_int @var{value2})
   113   * Perform an arithmetic operation on two signed 32-bit integers,
   114   * with overflow checking.  Returns @code{JIT_RESULT_OK}
   115   * or @code{JIT_RESULT_OVERFLOW}.
   116   * @end deftypefun
   117   *
   118   * @deftypefun jit_int jit_int_div_ovf (jit_int *@var{result}, jit_int @var{value1}, jit_int @var{value2})
   119   * @deftypefunx jit_int jit_int_rem_ovf (jit_int *@var{result}, jit_int @var{value1}, jit_int @var{value2})
   120   * Perform a division or remainder operation on two signed 32-bit integers.
   121   * Returns @code{JIT_RESULT_OK}, @code{JIT_RESULT_DIVISION_BY_ZERO},
   122   * or @code{JIT_RESULT_ARITHMETIC}.
   123   * @end deftypefun
   124   *
   125   * @deftypefun jit_int jit_int_eq (jit_int @var{value1}, jit_int @var{value2})
   126   * @deftypefunx jit_int jit_int_ne (jit_int @var{value1}, jit_int @var{value2})
   127   * @deftypefunx jit_int jit_int_lt (jit_int @var{value1}, jit_int @var{value2})
   128   * @deftypefunx jit_int jit_int_le (jit_int @var{value1}, jit_int @var{value2})
   129   * @deftypefunx jit_int jit_int_gt (jit_int @var{value1}, jit_int @var{value2})
   130   * @deftypefunx jit_int jit_int_ge (jit_int @var{value1}, jit_int @var{value2})
   131   * Compare two signed 32-bit integers, returning 0 or 1 based
   132   * on their relationship.
   133   * @end deftypefun
   134   *
   135   * @deftypefun jit_int jit_int_cmp (jit_int @var{value1}, jit_int @var{value2})
   136   * Compare two signed 32-bit integers and return -1, 0, or 1 based
   137   * on their relationship.
   138   * @end deftypefun
   139   *
   140   * @deftypefun jit_int jit_int_abs (jit_int @var{value1})
   141   * @deftypefunx jit_int jit_int_min (jit_int @var{value1}, jit_int @var{value2})
   142   * @deftypefunx jit_int jit_int_max (jit_int @var{value1}, jit_int @var{value2})
   143   * @deftypefunx jit_int jit_int_sign (jit_int @var{value1})
   144   * Calculate the absolute value, minimum, maximum, or sign for
   145   * signed 32-bit integer values.
   146   * @end deftypefun
   147  @*/
   148  jit_int jit_int_add(jit_int value1, jit_int value2)
   149  {
   150  	return value1 + value2;
   151  }
   152  
   153  jit_int jit_int_sub(jit_int value1, jit_int value2)
   154  {
   155  	return value1 - value2;
   156  }
   157  
   158  jit_int jit_int_mul(jit_int value1, jit_int value2)
   159  {
   160  	return value1 * value2;
   161  }
   162  
   163  jit_int jit_int_div(jit_int *result, jit_int value1, jit_int value2)
   164  {
   165  	if(value2 == 0)
   166  	{
   167  		*result = 0;
   168  		return JIT_RESULT_DIVISION_BY_ZERO;
   169  	}
   170  	else if(value2 == (jit_int)(-1) && value1 == jit_min_int)
   171  	{
   172  		*result = 0;
   173  		return JIT_RESULT_ARITHMETIC;
   174  	}
   175  	else
   176  	{
   177  		*result = value1 / value2;
   178  		return JIT_RESULT_OK;
   179  	}
   180  }
   181  
   182  jit_int jit_int_rem(jit_int *result, jit_int value1, jit_int value2)
   183  {
   184  	if(value2 == 0)
   185  	{
   186  		*result = 0;
   187  		return JIT_RESULT_DIVISION_BY_ZERO;
   188  	}
   189  	else if(value2 == (jit_int)(-1) && value1 == jit_min_int)
   190  	{
   191  		*result = 0;
   192  		return JIT_RESULT_ARITHMETIC;
   193  	}
   194  	else
   195  	{
   196  		*result = value1 % value2;
   197  		return JIT_RESULT_OK;
   198  	}
   199  }
   200  
   201  jit_int jit_int_add_ovf(jit_int *result, jit_int value1, jit_int value2)
   202  {
   203  	if(value1 >= 0 && value2 >= 0)
   204  	{
   205  		return ((*result = value1 + value2) >= value1);
   206  	}
   207  	else if(value1 < 0 && value2 < 0)
   208  	{
   209  		return ((*result = value1 + value2) < value1);
   210  	}
   211  	else
   212  	{
   213  		*result = value1 + value2;
   214  		return 1;
   215  	}
   216  }
   217  
   218  jit_int jit_int_sub_ovf(jit_int *result, jit_int value1, jit_int value2)
   219  {
   220  	if(value1 >= 0 && value2 >= 0)
   221  	{
   222  		*result = value1 - value2;
   223  		return 1;
   224  	}
   225  	else if(value1 < 0 && value2 < 0)
   226  	{
   227  		*result = value1 - value2;
   228  		return 1;
   229  	}
   230  	else if(value1 < 0)
   231  	{
   232  		return ((*result = value1 - value2) <= value1);
   233  	}
   234  	else
   235  	{
   236  		return ((*result = value1 - value2) >= value1);
   237  	}
   238  }
   239  
   240  jit_int jit_int_mul_ovf(jit_int *result, jit_int value1, jit_int value2)
   241  {
   242  	jit_long temp = ((jit_long)value1) * ((jit_long)value2);
   243  	*result = (jit_int)temp;
   244  	return (temp >= (jit_long)jit_min_int && temp <= (jit_long)jit_max_int);
   245  }
   246  
   247  jit_int jit_int_neg(jit_int value1)
   248  {
   249  	return -value1;
   250  }
   251  
   252  jit_int jit_int_and(jit_int value1, jit_int value2)
   253  {
   254  	return value1 & value2;
   255  }
   256  
   257  jit_int jit_int_or(jit_int value1, jit_int value2)
   258  {
   259  	return value1 | value2;
   260  }
   261  
   262  jit_int jit_int_xor(jit_int value1, jit_int value2)
   263  {
   264  	return value1 ^ value2;
   265  }
   266  
   267  jit_int jit_int_not(jit_int value1)
   268  {
   269  	return ~value1;
   270  }
   271  
   272  jit_int jit_int_shl(jit_int value1, jit_uint value2)
   273  {
   274  	return value1 << (value2 & 0x1F);
   275  }
   276  
   277  jit_int jit_int_shr(jit_int value1, jit_uint value2)
   278  {
   279  	return value1 >> (value2 & 0x1F);
   280  }
   281  
   282  jit_int jit_int_eq(jit_int value1, jit_int value2)
   283  {
   284  	return (value1 == value2);
   285  }
   286  
   287  jit_int jit_int_ne(jit_int value1, jit_int value2)
   288  {
   289  	return (value1 != value2);
   290  }
   291  
   292  jit_int jit_int_lt(jit_int value1, jit_int value2)
   293  {
   294  	return (value1 < value2);
   295  }
   296  
   297  jit_int jit_int_le(jit_int value1, jit_int value2)
   298  {
   299  	return (value1 <= value2);
   300  }
   301  
   302  jit_int jit_int_gt(jit_int value1, jit_int value2)
   303  {
   304  	return (value1 > value2);
   305  }
   306  
   307  jit_int jit_int_ge(jit_int value1, jit_int value2)
   308  {
   309  	return (value1 >= value2);
   310  }
   311  
   312  jit_int jit_int_cmp(jit_int value1, jit_int value2)
   313  {
   314  	if(value1 < value2)
   315  	{
   316  		return -1;
   317  	}
   318  	else if(value1 > value2)
   319  	{
   320  		return 1;
   321  	}
   322  	else
   323  	{
   324  		return 0;
   325  	}
   326  }
   327  
   328  jit_int jit_int_abs(jit_int value1)
   329  {
   330  	return ((value1 >= 0) ? value1 : -value1);
   331  }
   332  
   333  jit_int jit_int_min(jit_int value1, jit_int value2)
   334  {
   335  	return ((value1 <= value2) ? value1 : value2);
   336  }
   337  
   338  jit_int jit_int_max(jit_int value1, jit_int value2)
   339  {
   340  	return ((value1 >= value2) ? value1 : value2);
   341  }
   342  
   343  jit_int jit_int_sign(jit_int value1)
   344  {
   345  	if(value1 < 0)
   346  	{
   347  		return -1;
   348  	}
   349  	else if(value1 > 0)
   350  	{
   351  		return 1;
   352  	}
   353  	else
   354  	{
   355  		return 0;
   356  	}
   357  }
   358  
   359  /*@
   360   * @deftypefun jit_uint jit_uint_add (jit_uint @var{value1}, jit_uint @var{value2})
   361   * @deftypefunx jit_uint jit_uint_sub (jit_uint @var{value1}, jit_uint @var{value2})
   362   * @deftypefunx jit_uint jit_uint_mul (jit_uint @var{value1}, jit_uint @var{value2})
   363   * @deftypefunx jit_uint jit_uint_neg (jit_uint @var{value1})
   364   * @deftypefunx jit_uint jit_uint_and (jit_uint @var{value1}, jit_uint @var{value2})
   365   * @deftypefunx jit_uint jit_uint_or (jit_uint @var{value1}, jit_uint @var{value2})
   366   * @deftypefunx jit_uint jit_uint_xor (jit_uint @var{value1}, jit_uint @var{value2})
   367   * @deftypefunx jit_uint jit_uint_not (jit_uint @var{value1})
   368   * @deftypefunx jit_uint jit_uint_not (jit_uint @var{value1})
   369   * @deftypefunx jit_uint jit_uint_shl (jit_uint @var{value1}, jit_uint @var{value2})
   370   * @deftypefunx jit_uint jit_uint_shr (jit_uint @var{value1}, jit_uint @var{value2})
   371   * Perform an arithmetic operation on unsigned 32-bit integers.
   372   * @end deftypefun
   373   *
   374   * @deftypefun jit_int jit_uint_add_ovf (jit_uint *@var{result}, jit_uint @var{value1}, jit_uint @var{value2})
   375   * @deftypefunx jit_int jit_uint_sub_ovf (jit_uint *@var{result}, jit_uint @var{value1}, jit_uint @var{value2})
   376   * @deftypefunx jit_int jit_uint_mul_ovf (jit_uint *@var{result}, jit_uint @var{value1}, jit_uint @var{value2})
   377   * Perform an arithmetic operation on two unsigned 32-bit integers,
   378   * with overflow checking.  Returns @code{JIT_RESULT_OK}
   379   * or @code{JIT_RESULT_OVERFLOW}.
   380   * @end deftypefun
   381   *
   382   * @deftypefun jit_int jit_uint_div_ovf (jit_uint *@var{result}, jit_uint @var{value1}, jit_uint @var{value2})
   383   * @deftypefunx jit_int jit_uint_rem_ovf (jit_uint *@var{result}, jit_uint @var{value1}, jit_uint @var{value2})
   384   * Perform a division or remainder operation on two unsigned 32-bit integers.
   385   * Returns @code{JIT_RESULT_OK} or @code{JIT_RESULT_DIVISION_BY_ZERO}
   386   * (@code{JIT_RESULT_ARITHMETIC} is not possible with unsigned integers).
   387   * @end deftypefun
   388   *
   389   * @deftypefun jit_int jit_uint_eq (jit_uint @var{value1}, jit_uint @var{value2})
   390   * @deftypefunx jit_int jit_uint_ne (jit_uint @var{value1}, jit_uint @var{value2})
   391   * @deftypefunx jit_int jit_uint_lt (jit_uint @var{value1}, jit_uint @var{value2})
   392   * @deftypefunx jit_int jit_uint_le (jit_uint @var{value1}, jit_uint @var{value2})
   393   * @deftypefunx jit_int jit_uint_gt (jit_uint @var{value1}, jit_uint @var{value2})
   394   * @deftypefunx jit_int jit_uint_ge (jit_uint @var{value1}, jit_uint @var{value2})
   395   * Compare two unsigned 32-bit integers, returning 0 or 1 based
   396   * on their relationship.
   397   * @end deftypefun
   398   *
   399   * @deftypefun jit_int jit_uint_cmp (jit_uint @var{value1}, jit_uint @var{value2})
   400   * Compare two unsigned 32-bit integers and return -1, 0, or 1 based
   401   * on their relationship.
   402   * @end deftypefun
   403   *
   404   * @deftypefun jit_uint jit_uint_min (jit_uint @var{value1}, jit_uint @var{value2})
   405   * @deftypefunx jit_uint jit_uint_max (jit_uint @var{value1}, jit_uint @var{value2})
   406   * Calculate the minimum or maximum for unsigned 32-bit integer values.
   407   * @end deftypefun
   408  @*/
   409  jit_uint jit_uint_add(jit_uint value1, jit_uint value2)
   410  {
   411  	return value1 + value2;
   412  }
   413  
   414  jit_uint jit_uint_sub(jit_uint value1, jit_uint value2)
   415  {
   416  	return value1 - value2;
   417  }
   418  
   419  jit_uint jit_uint_mul(jit_uint value1, jit_uint value2)
   420  {
   421  	return value1 * value2;
   422  }
   423  
   424  jit_int jit_uint_div(jit_uint *result, jit_uint value1, jit_uint value2)
   425  {
   426  	if(value2 == 0)
   427  	{
   428  		*result = 0;
   429  		return JIT_RESULT_DIVISION_BY_ZERO;
   430  	}
   431  	else
   432  	{
   433  		*result = value1 / value2;
   434  		return JIT_RESULT_OK;
   435  	}
   436  }
   437  
   438  jit_int jit_uint_rem(jit_uint *result, jit_uint value1, jit_uint value2)
   439  {
   440  	if(value2 == 0)
   441  	{
   442  		*result = 0;
   443  		return JIT_RESULT_DIVISION_BY_ZERO;
   444  	}
   445  	else
   446  	{
   447  		*result = value1 % value2;
   448  		return JIT_RESULT_OK;
   449  	}
   450  }
   451  
   452  jit_int jit_uint_add_ovf(jit_uint *result, jit_uint value1, jit_uint value2)
   453  {
   454  	return ((*result = value1 + value2) >= value1);
   455  }
   456  
   457  jit_int jit_uint_sub_ovf(jit_uint *result, jit_uint value1, jit_uint value2)
   458  {
   459  	return ((*result = value1 - value2) <= value1);
   460  }
   461  
   462  jit_int jit_uint_mul_ovf(jit_uint *result, jit_uint value1, jit_uint value2)
   463  {
   464  	jit_ulong temp = ((jit_ulong)value1) * ((jit_ulong)value2);
   465  	*result = (jit_uint)temp;
   466  	return (temp <= (jit_ulong)jit_max_uint);
   467  }
   468  
   469  jit_uint jit_uint_neg(jit_uint value1)
   470  {
   471  	return (jit_uint)(-((jit_int)value1));
   472  }
   473  
   474  jit_uint jit_uint_and(jit_uint value1, jit_uint value2)
   475  {
   476  	return value1 & value2;
   477  }
   478  
   479  jit_uint jit_uint_or(jit_uint value1, jit_uint value2)
   480  {
   481  	return value1 | value2;
   482  }
   483  
   484  jit_uint jit_uint_xor(jit_uint value1, jit_uint value2)
   485  {
   486  	return value1 ^ value2;
   487  }
   488  
   489  jit_uint jit_uint_not(jit_uint value1)
   490  {
   491  	return ~value1;
   492  }
   493  
   494  jit_uint jit_uint_shl(jit_uint value1, jit_uint value2)
   495  {
   496  	return value1 << (value2 & 0x1F);
   497  }
   498  
   499  jit_uint jit_uint_shr(jit_uint value1, jit_uint value2)
   500  {
   501  	return value1 >> (value2 & 0x1F);
   502  }
   503  
   504  jit_int jit_uint_eq(jit_uint value1, jit_uint value2)
   505  {
   506  	return (value1 == value2);
   507  }
   508  
   509  jit_int jit_uint_ne(jit_uint value1, jit_uint value2)
   510  {
   511  	return (value1 != value2);
   512  }
   513  
   514  jit_int jit_uint_lt(jit_uint value1, jit_uint value2)
   515  {
   516  	return (value1 < value2);
   517  }
   518  
   519  jit_int jit_uint_le(jit_uint value1, jit_uint value2)
   520  {
   521  	return (value1 <= value2);
   522  }
   523  
   524  jit_int jit_uint_gt(jit_uint value1, jit_uint value2)
   525  {
   526  	return (value1 > value2);
   527  }
   528  
   529  jit_int jit_uint_ge(jit_uint value1, jit_uint value2)
   530  {
   531  	return (value1 >= value2);
   532  }
   533  
   534  jit_int jit_uint_cmp(jit_uint value1, jit_uint value2)
   535  {
   536  	if(value1 < value2)
   537  	{
   538  		return -1;
   539  	}
   540  	else if(value1 > value2)
   541  	{
   542  		return 1;
   543  	}
   544  	else
   545  	{
   546  		return 0;
   547  	}
   548  }
   549  
   550  jit_uint jit_uint_min(jit_uint value1, jit_uint value2)
   551  {
   552  	return ((value1 <= value2) ? value1 : value2);
   553  }
   554  
   555  jit_uint jit_uint_max(jit_uint value1, jit_uint value2)
   556  {
   557  	return ((value1 >= value2) ? value1 : value2);
   558  }
   559  
   560  /*@
   561   * @deftypefun jit_long jit_long_add (jit_long @var{value1}, jit_long @var{value2})
   562   * @deftypefunx jit_long jit_long_sub (jit_long @var{value1}, jit_long @var{value2})
   563   * @deftypefunx jit_long jit_long_mul (jit_long @var{value1}, jit_long @var{value2})
   564   * @deftypefunx jit_long jit_long_neg (jit_long @var{value1})
   565   * @deftypefunx jit_long jit_long_and (jit_long @var{value1}, jit_long @var{value2})
   566   * @deftypefunx jit_long jit_long_or (jit_long @var{value1}, jit_long @var{value2})
   567   * @deftypefunx jit_long jit_long_xor (jit_long @var{value1}, jit_long @var{value2})
   568   * @deftypefunx jit_long jit_long_not (jit_long @var{value1})
   569   * @deftypefunx jit_long jit_long_not (jit_long @var{value1})
   570   * @deftypefunx jit_long jit_long_shl (jit_long @var{value1}, jit_uint @var{value2})
   571   * @deftypefunx jit_long jit_long_shr (jit_long @var{value1}, jit_uint @var{value2})
   572   * Perform an arithmetic operation on signed 64-bit integers.
   573   * @end deftypefun
   574   *
   575   * @deftypefun jit_int jit_long_add_ovf (jit_long *@var{result}, jit_long @var{value1}, jit_long @var{value2})
   576   * @deftypefunx jit_int jit_long_sub_ovf (jit_long *@var{result}, jit_long @var{value1}, jit_long @var{value2})
   577   * @deftypefunx jit_int jit_long_mul_ovf (jit_long *@var{result}, jit_long @var{value1}, jit_long @var{value2})
   578   * Perform an arithmetic operation on two signed 64-bit integers,
   579   * with overflow checking.  Returns @code{JIT_RESULT_OK}
   580   * or @code{JIT_RESULT_OVERFLOW}.
   581   * @end deftypefun
   582   *
   583   * @deftypefun jit_int jit_long_div_ovf (jit_long *@var{result}, jit_long @var{value1}, jit_long @var{value2})
   584   * @deftypefunx jit_int jit_long_rem_ovf (jit_long *@var{result}, jit_long @var{value1}, jit_long @var{value2})
   585   * Perform a division or remainder operation on two signed 64-bit integers.
   586   * Returns @code{JIT_RESULT_OK}, @code{JIT_RESULT_DIVISION_BY_ZERO},
   587   * or @code{JIT_RESULT_ARITHMETIC}.
   588   * @end deftypefun
   589   *
   590   * @deftypefun jit_int jit_long_eq (jit_long @var{value1}, jit_long @var{value2})
   591   * @deftypefunx jit_int jit_long_ne (jit_long @var{value1}, jit_long @var{value2})
   592   * @deftypefunx jit_int jit_long_lt (jit_long @var{value1}, jit_long @var{value2})
   593   * @deftypefunx jit_int jit_long_le (jit_long @var{value1}, jit_long @var{value2})
   594   * @deftypefunx jit_int jit_long_gt (jit_long @var{value1}, jit_long @var{value2})
   595   * @deftypefunx jit_int jit_long_ge (jit_long @var{value1}, jit_long @var{value2})
   596   * Compare two signed 64-bit integers, returning 0 or 1 based
   597   * on their relationship.
   598   * @end deftypefun
   599   *
   600   * @deftypefun jit_int jit_long_cmp (jit_long @var{value1}, jit_long @var{value2})
   601   * Compare two signed 64-bit integers and return -1, 0, or 1 based
   602   * on their relationship.
   603   * @end deftypefun
   604   *
   605   * @deftypefun jit_long jit_long_abs (jit_long @var{value1})
   606   * @deftypefunx jit_long jit_long_min (jit_long @var{value1}, jit_long @var{value2})
   607   * @deftypefunx jit_long jit_long_max (jit_long @var{value1}, jit_long @var{value2})
   608   * @deftypefunx jit_int jit_long_sign (jit_long @var{value1})
   609   * Calculate the absolute value, minimum, maximum, or sign for
   610   * signed 64-bit integer values.
   611   * @end deftypefun
   612  @*/
   613  jit_long jit_long_add(jit_long value1, jit_long value2)
   614  {
   615  	return value1 + value2;
   616  }
   617  
   618  jit_long jit_long_sub(jit_long value1, jit_long value2)
   619  {
   620  	return value1 - value2;
   621  }
   622  
   623  jit_long jit_long_mul(jit_long value1, jit_long value2)
   624  {
   625  	return value1 * value2;
   626  }
   627  
   628  jit_int jit_long_div(jit_long *result, jit_long value1, jit_long value2)
   629  {
   630  	if(value2 == 0)
   631  	{
   632  		*result = 0;
   633  		return JIT_RESULT_DIVISION_BY_ZERO;
   634  	}
   635  	else if(value2 == (jit_long)(-1) && value1 == jit_min_long)
   636  	{
   637  		*result = 0;
   638  		return JIT_RESULT_ARITHMETIC;
   639  	}
   640  	else
   641  	{
   642  		*result = value1 / value2;
   643  		return JIT_RESULT_OK;
   644  	}
   645  }
   646  
   647  jit_int jit_long_rem(jit_long *result, jit_long value1, jit_long value2)
   648  {
   649  	if(value2 == 0)
   650  	{
   651  		*result = 0;
   652  		return JIT_RESULT_DIVISION_BY_ZERO;
   653  	}
   654  	else if(value2 == (jit_long)(-1) && value1 == jit_min_long)
   655  	{
   656  		*result = 0;
   657  		return JIT_RESULT_ARITHMETIC;
   658  	}
   659  	else
   660  	{
   661  		*result = value1 % value2;
   662  		return JIT_RESULT_OK;
   663  	}
   664  }
   665  
   666  jit_int jit_long_add_ovf(jit_long *result, jit_long value1, jit_long value2)
   667  {
   668  	if(value1 >= 0 && value2 >= 0)
   669  	{
   670  		return ((*result = value1 + value2) >= value1);
   671  	}
   672  	else if(value1 < 0 && value2 < 0)
   673  	{
   674  		return ((*result = value1 + value2) < value1);
   675  	}
   676  	else
   677  	{
   678  		*result = value1 + value2;
   679  		return 1;
   680  	}
   681  }
   682  
   683  jit_int jit_long_sub_ovf(jit_long *result, jit_long value1, jit_long value2)
   684  {
   685  	if(value1 >= 0 && value2 >= 0)
   686  	{
   687  		*result = value1 - value2;
   688  		return 1;
   689  	}
   690  	else if(value1 < 0 && value2 < 0)
   691  	{
   692  		*result = value1 - value2;
   693  		return 1;
   694  	}
   695  	else if(value1 < 0)
   696  	{
   697  		return ((*result = value1 - value2) <= value1);
   698  	}
   699  	else
   700  	{
   701  		return ((*result = value1 - value2) >= value1);
   702  	}
   703  }
   704  
   705  jit_int jit_long_mul_ovf(jit_long *result, jit_long value1, jit_long value2)
   706  {
   707  	jit_ulong temp;
   708  	if(value1 >= 0 && value2 >= 0)
   709  	{
   710  		/* Both values are positive */
   711  		if(!jit_ulong_mul_ovf(&temp, (jit_ulong)value1, (jit_ulong)value2))
   712  		{
   713  			*result = jit_max_long;
   714  			return 0;
   715  		}
   716  		if(temp > ((jit_ulong)jit_max_long))
   717  		{
   718  			*result = jit_max_long;
   719  			return 0;
   720  		}
   721  		*result = (jit_long)temp;
   722  		return 1;
   723  	}
   724  	else if(value1 >= 0)
   725  	{
   726  		/* The first value is positive */
   727  		if(!jit_ulong_mul_ovf(&temp, (jit_ulong)value1, (jit_ulong)-value2))
   728  		{
   729  			*result = jit_min_long;
   730  			return 0;
   731  		}
   732  		if(temp > (((jit_ulong)jit_max_long) + 1))
   733  		{
   734  			*result = jit_min_long;
   735  			return 0;
   736  		}
   737  		*result = -((jit_long)temp);
   738  		return 1;
   739  	}
   740  	else if(value2 >= 0)
   741  	{
   742  		/* The second value is positive */
   743  		if(!jit_ulong_mul_ovf(&temp, (jit_ulong)-value1, (jit_ulong)value2))
   744  		{
   745  			*result = jit_min_long;
   746  			return 0;
   747  		}
   748  		if(temp > (((jit_ulong)jit_max_long) + 1))
   749  		{
   750  			*result = jit_min_long;
   751  			return 0;
   752  		}
   753  		*result = -((jit_long)temp);
   754  		return 1;
   755  	}
   756  	else
   757  	{
   758  		/* Both values are negative */
   759  		if(!jit_ulong_mul_ovf(&temp, (jit_ulong)-value1, (jit_ulong)-value2))
   760  		{
   761  			*result = jit_max_long;
   762  			return 0;
   763  		}
   764  		if(temp > ((jit_ulong)jit_max_long))
   765  		{
   766  			*result = jit_max_long;
   767  			return 0;
   768  		}
   769  		*result = (jit_long)temp;
   770  		return 1;
   771  	}
   772  }
   773  
   774  jit_long jit_long_neg(jit_long value1)
   775  {
   776  	return -value1;
   777  }
   778  
   779  jit_long jit_long_and(jit_long value1, jit_long value2)
   780  {
   781  	return value1 & value2;
   782  }
   783  
   784  jit_long jit_long_or(jit_long value1, jit_long value2)
   785  {
   786  	return value1 | value2;
   787  }
   788  
   789  jit_long jit_long_xor(jit_long value1, jit_long value2)
   790  {
   791  	return value1 ^ value2;
   792  }
   793  
   794  jit_long jit_long_not(jit_long value1)
   795  {
   796  	return ~value1;
   797  }
   798  
   799  jit_long jit_long_shl(jit_long value1, jit_uint value2)
   800  {
   801  	return value1 << (value2 & 0x3F);
   802  }
   803  
   804  jit_long jit_long_shr(jit_long value1, jit_uint value2)
   805  {
   806  	return value1 >> (value2 & 0x3F);
   807  }
   808  
   809  jit_int jit_long_eq(jit_long value1, jit_long value2)
   810  {
   811  	return (value1 == value2);
   812  }
   813  
   814  jit_int jit_long_ne(jit_long value1, jit_long value2)
   815  {
   816  	return (value1 != value2);
   817  }
   818  
   819  jit_int jit_long_lt(jit_long value1, jit_long value2)
   820  {
   821  	return (value1 < value2);
   822  }
   823  
   824  jit_int jit_long_le(jit_long value1, jit_long value2)
   825  {
   826  	return (value1 <= value2);
   827  }
   828  
   829  jit_int jit_long_gt(jit_long value1, jit_long value2)
   830  {
   831  	return (value1 > value2);
   832  }
   833  
   834  jit_int jit_long_ge(jit_long value1, jit_long value2)
   835  {
   836  	return (value1 >= value2);
   837  }
   838  
   839  jit_int jit_long_cmp(jit_long value1, jit_long value2)
   840  {
   841  	if(value1 < value2)
   842  	{
   843  		return -1;
   844  	}
   845  	else if(value1 > value2)
   846  	{
   847  		return 1;
   848  	}
   849  	else
   850  	{
   851  		return 0;
   852  	}
   853  }
   854  
   855  jit_long jit_long_abs(jit_long value1)
   856  {
   857  	return ((value1 >= 0) ? value1 : -value1);
   858  }
   859  
   860  jit_long jit_long_min(jit_long value1, jit_long value2)
   861  {
   862  	return ((value1 <= value2) ? value1 : value2);
   863  }
   864  
   865  jit_long jit_long_max(jit_long value1, jit_long value2)
   866  {
   867  	return ((value1 >= value2) ? value1 : value2);
   868  }
   869  
   870  jit_int jit_long_sign(jit_long value1)
   871  {
   872  	if(value1 < 0)
   873  	{
   874  		return -1;
   875  	}
   876  	else if(value1 > 0)
   877  	{
   878  		return 1;
   879  	}
   880  	else
   881  	{
   882  		return 0;
   883  	}
   884  }
   885  
   886  /*@
   887   * @deftypefun jit_ulong jit_ulong_add (jit_ulong @var{value1}, jit_ulong @var{value2})
   888   * @deftypefunx jit_ulong jit_ulong_sub (jit_ulong @var{value1}, jit_ulong @var{value2})
   889   * @deftypefunx jit_ulong jit_ulong_mul (jit_ulong @var{value1}, jit_ulong @var{value2})
   890   * @deftypefunx jit_ulong jit_ulong_neg (jit_ulong @var{value1})
   891   * @deftypefunx jit_ulong jit_ulong_and (jit_ulong @var{value1}, jit_ulong @var{value2})
   892   * @deftypefunx jit_ulong jit_ulong_or (jit_ulong @var{value1}, jit_ulong @var{value2})
   893   * @deftypefunx jit_ulong jit_ulong_xor (jit_ulong @var{value1}, jit_ulong @var{value2})
   894   * @deftypefunx jit_ulong jit_ulong_not (jit_ulong @var{value1})
   895   * @deftypefunx jit_ulong jit_ulong_not (jit_ulong @var{value1})
   896   * @deftypefunx jit_ulong jit_ulong_shl (jit_ulong @var{value1}, jit_uint @var{value2})
   897   * @deftypefunx jit_ulong jit_ulong_shr (jit_ulong @var{value1}, jit_uint @var{value2})
   898   * Perform an arithmetic operation on unsigned 64-bit integers.
   899   * @end deftypefun
   900   *
   901   * @deftypefun jit_int jit_ulong_add_ovf (jit_ulong *@var{result}, jit_ulong @var{value1}, jit_ulong @var{value2})
   902   * @deftypefunx jit_int jit_ulong_sub_ovf (jit_ulong *@var{result}, jit_ulong @var{value1}, jit_ulong @var{value2})
   903   * @deftypefunx jit_int jit_ulong_mul_ovf (jit_ulong *@var{result}, jit_ulong @var{value1}, jit_ulong @var{value2})
   904   * Perform an arithmetic operation on two unsigned 64-bit integers,
   905   * with overflow checking.  Returns @code{JIT_RESULT_OK}
   906   * or @code{JIT_RESULT_OVERFLOW}.
   907   * @end deftypefun
   908   *
   909   * @deftypefun jit_int jit_ulong_div_ovf (jit_ulong *@var{result}, jit_ulong @var{value1}, jit_ulong @var{value2})
   910   * @deftypefunx jit_int jit_ulong_rem_ovf (jit_ulong *@var{result}, jit_ulong @var{value1}, jit_ulong @var{value2})
   911   * Perform a division or remainder operation on two unsigned 64-bit integers.
   912   * Returns @code{JIT_RESULT_OK} or @code{JIT_RESULT_DIVISION_BY_ZERO}
   913   * (@code{JIT_RESULT_ARITHMETIC} is not possible with unsigned integers).
   914   * @end deftypefun
   915   *
   916   * @deftypefun jit_int jit_ulong_eq (jit_ulong @var{value1}, jit_ulong @var{value2})
   917   * @deftypefunx jit_int jit_ulong_ne (jit_ulong @var{value1}, jit_ulong @var{value2})
   918   * @deftypefunx jit_int jit_ulong_lt (jit_ulong @var{value1}, jit_ulong @var{value2})
   919   * @deftypefunx jit_int jit_ulong_le (jit_ulong @var{value1}, jit_ulong @var{value2})
   920   * @deftypefunx jit_int jit_ulong_gt (jit_ulong @var{value1}, jit_ulong @var{value2})
   921   * @deftypefunx jit_int jit_ulong_ge (jit_ulong @var{value1}, jit_ulong @var{value2})
   922   * Compare two unsigned 64-bit integers, returning 0 or 1 based
   923   * on their relationship.
   924   * @end deftypefun
   925   *
   926   * @deftypefun jit_int jit_ulong_cmp (jit_ulong @var{value1}, jit_ulong @var{value2})
   927   * Compare two unsigned 64-bit integers and return -1, 0, or 1 based
   928   * on their relationship.
   929   * @end deftypefun
   930   *
   931   * @deftypefun jit_ulong jit_ulong_min (jit_ulong @var{value1}, jit_ulong @var{value2})
   932   * @deftypefunx jit_ulong jit_ulong_max (jit_ulong @var{value1}, jit_ulong @var{value2})
   933   * Calculate the minimum or maximum for unsigned 64-bit integer values.
   934   * @end deftypefun
   935  @*/
   936  jit_ulong jit_ulong_add(jit_ulong value1, jit_ulong value2)
   937  {
   938  	return value1 + value2;
   939  }
   940  
   941  jit_ulong jit_ulong_sub(jit_ulong value1, jit_ulong value2)
   942  {
   943  	return value1 - value2;
   944  }
   945  
   946  jit_ulong jit_ulong_mul(jit_ulong value1, jit_ulong value2)
   947  {
   948  	return value1 * value2;
   949  }
   950  
   951  jit_int jit_ulong_div(jit_ulong *result, jit_ulong value1, jit_ulong value2)
   952  {
   953  	if(value2 == 0)
   954  	{
   955  		*result = 0;
   956  		return JIT_RESULT_DIVISION_BY_ZERO;
   957  	}
   958  	else
   959  	{
   960  		*result = value1 / value2;
   961  		return JIT_RESULT_OK;
   962  	}
   963  }
   964  
   965  jit_int jit_ulong_rem(jit_ulong *result, jit_ulong value1, jit_ulong value2)
   966  {
   967  	if(value2 == 0)
   968  	{
   969  		*result = 0;
   970  		return JIT_RESULT_DIVISION_BY_ZERO;
   971  	}
   972  	else
   973  	{
   974  		*result = value1 % value2;
   975  		return JIT_RESULT_OK;
   976  	}
   977  }
   978  
   979  jit_int jit_ulong_add_ovf(jit_ulong *result, jit_ulong value1, jit_ulong value2)
   980  {
   981  	return ((*result = value1 + value2) >= value1);
   982  }
   983  
   984  jit_int jit_ulong_sub_ovf(jit_ulong *result, jit_ulong value1, jit_ulong value2)
   985  {
   986  	return ((*result = value1 - value2) <= value1);
   987  }
   988  
   989  jit_int jit_ulong_mul_ovf(jit_ulong *result, jit_ulong value1, jit_ulong value2)
   990  {
   991  	jit_uint high1, low1, high2, low2, orig;
   992  	jit_ulong temp;
   993  	jit_uint result1, result2, result3, result4;
   994  	high1 = (jit_uint)(value1 >> 32);
   995  	low1  = (jit_uint)value1;
   996  	high2 = (jit_uint)(value2 >> 32);
   997  	low2  = (jit_uint)value2;
   998  	temp = ((jit_ulong)low1) * ((jit_ulong)low2);
   999  	result1 = (jit_uint)temp;
  1000  	result2 = (jit_uint)(temp >> 32);
  1001  	temp = ((jit_ulong)low1) * ((jit_ulong)high2);
  1002  	orig = result2;
  1003  	result2 += (jit_uint)temp;
  1004  	if(result2 < orig)
  1005  		result3 = (((jit_uint)(temp >> 32)) + 1);
  1006  	else
  1007  		result3 = ((jit_uint)(temp >> 32));
  1008  	temp = ((jit_ulong)high1) * ((jit_ulong)low2);
  1009  	orig = result2;
  1010  	result2 += (jit_uint)temp;
  1011  	if(result2 < orig)
  1012  	{
  1013  		orig = result3;
  1014  		result3 += (((jit_uint)(temp >> 32)) + 1);
  1015  		if(result3 < orig)
  1016  			result4 = 1;
  1017  		else
  1018  			result4 = 0;
  1019  	}
  1020  	else
  1021  	{
  1022  		orig = result3;
  1023  		result3 += ((jit_uint)(temp >> 32));
  1024  		if(result3 < orig)
  1025  			result4 = 1;
  1026  		else
  1027  			result4 = 0;
  1028  	}
  1029  	temp = ((jit_ulong)high1) * ((jit_ulong)high2);
  1030  	orig = result3;
  1031  	result3 += (jit_uint)temp;
  1032  	if(result3 < orig)
  1033  		result4 += ((jit_uint)(temp >> 32)) + 1;
  1034  	else
  1035  		result4 += ((jit_uint)(temp >> 32));
  1036  	if(result3 != 0 || result4 != 0)
  1037  	{
  1038  		*result = jit_max_ulong;
  1039  		return 0;
  1040  	}
  1041  	*result = (((jit_ulong)result2) << 32) | ((jit_ulong)result1);
  1042  	return 1;
  1043  }
  1044  
  1045  jit_ulong jit_ulong_neg(jit_ulong value1)
  1046  {
  1047  	return (jit_ulong)(-((jit_long)value1));
  1048  }
  1049  
  1050  jit_ulong jit_ulong_and(jit_ulong value1, jit_ulong value2)
  1051  {
  1052  	return value1 & value2;
  1053  }
  1054  
  1055  jit_ulong jit_ulong_or(jit_ulong value1, jit_ulong value2)
  1056  {
  1057  	return value1 | value2;
  1058  }
  1059  
  1060  jit_ulong jit_ulong_xor(jit_ulong value1, jit_ulong value2)
  1061  {
  1062  	return value1 ^ value2;
  1063  }
  1064  
  1065  jit_ulong jit_ulong_not(jit_ulong value1)
  1066  {
  1067  	return ~value1;
  1068  }
  1069  
  1070  jit_ulong jit_ulong_shl(jit_ulong value1, jit_uint value2)
  1071  {
  1072  	return value1 << (value2 & 0x3F);
  1073  }
  1074  
  1075  jit_ulong jit_ulong_shr(jit_ulong value1, jit_uint value2)
  1076  {
  1077  	return value1 >> (value2 & 0x3F);
  1078  }
  1079  
  1080  jit_int jit_ulong_eq(jit_ulong value1, jit_ulong value2)
  1081  {
  1082  	return (value1 == value2);
  1083  }
  1084  
  1085  jit_int jit_ulong_ne(jit_ulong value1, jit_ulong value2)
  1086  {
  1087  	return (value1 != value2);
  1088  }
  1089  
  1090  jit_int jit_ulong_lt(jit_ulong value1, jit_ulong value2)
  1091  {
  1092  	return (value1 < value2);
  1093  }
  1094  
  1095  jit_int jit_ulong_le(jit_ulong value1, jit_ulong value2)
  1096  {
  1097  	return (value1 <= value2);
  1098  }
  1099  
  1100  jit_int jit_ulong_gt(jit_ulong value1, jit_ulong value2)
  1101  {
  1102  	return (value1 > value2);
  1103  }
  1104  
  1105  jit_int jit_ulong_ge(jit_ulong value1, jit_ulong value2)
  1106  {
  1107  	return (value1 >= value2);
  1108  }
  1109  
  1110  jit_int jit_ulong_cmp(jit_ulong value1, jit_ulong value2)
  1111  {
  1112  	if(value1 < value2)
  1113  	{
  1114  		return -1;
  1115  	}
  1116  	else if(value1 > value2)
  1117  	{
  1118  		return 1;
  1119  	}
  1120  	else
  1121  	{
  1122  		return 0;
  1123  	}
  1124  }
  1125  
  1126  jit_ulong jit_ulong_min(jit_ulong value1, jit_ulong value2)
  1127  {
  1128  	return ((value1 <= value2) ? value1 : value2);
  1129  }
  1130  
  1131  jit_ulong jit_ulong_max(jit_ulong value1, jit_ulong value2)
  1132  {
  1133  	return ((value1 >= value2) ? value1 : value2);
  1134  }
  1135  
  1136  /*@
  1137   * @deftypefun jit_float32 jit_float32_add (jit_float32 @var{value1}, jit_float32 @var{value2})
  1138   * @deftypefunx jit_float32 jit_float32_sub (jit_float32 @var{value1}, jit_float32 @var{value2})
  1139   * @deftypefunx jit_float32 jit_float32_mul (jit_float32 @var{value1}, jit_float32 @var{value2})
  1140   * @deftypefunx jit_float32 jit_float32_div (jit_float32 @var{value1}, jit_float32 @var{value2})
  1141   * @deftypefunx jit_float32 jit_float32_rem (jit_float32 @var{value1}, jit_float32 @var{value2})
  1142   * @deftypefunx jit_float32 jit_float32_ieee_rem (jit_float32 @var{value1}, jit_float32 @var{value2})
  1143   * @deftypefunx jit_float32 jit_float32_neg (jit_float32 @var{value1})
  1144   * Perform an arithmetic operation on 32-bit floating-point values.
  1145   * @end deftypefun
  1146   *
  1147   * @deftypefun jit_int jit_float32_eq (jit_float32 @var{value1}, jit_float32 @var{value2})
  1148   * @deftypefunx jit_int jit_float32_ne (jit_float32 @var{value1}, jit_float32 @var{value2})
  1149   * @deftypefunx jit_int jit_float32_lt (jit_float32 @var{value1}, jit_float32 @var{value2})
  1150   * @deftypefunx jit_int jit_float32_le (jit_float32 @var{value1}, jit_float32 @var{value2})
  1151   * @deftypefunx jit_int jit_float32_gt (jit_float32 @var{value1}, jit_float32 @var{value2})
  1152   * @deftypefunx jit_int jit_float32_ge (jit_float32 @var{value1}, jit_float32 @var{value2})
  1153   * Compare two 32-bit floating-point values, returning 0 or 1 based
  1154   * on their relationship.
  1155   * @end deftypefun
  1156   *
  1157   * @deftypefun jit_int jit_float32_cmpl (jit_float32 @var{value1}, jit_float32 @var{value2})
  1158   * Compare two 32-bit floating-point values and return -1, 0, or 1 based
  1159   * on their relationship.  If either value is "not a number",
  1160   * then -1 is returned.
  1161   * @end deftypefun
  1162   *
  1163   * @deftypefun jit_int jit_float32_cmpg (jit_float32 @var{value1}, jit_float32 @var{value2})
  1164   * Compare two 32-bit floating-point values and return -1, 0, or 1 based
  1165   * on their relationship.  If either value is "not a number",
  1166   * then 1 is returned.
  1167   * @end deftypefun
  1168   *
  1169   * @deftypefun jit_float32 jit_float32_abs (jit_float32 @var{value1})
  1170   * @deftypefunx jit_float32 jit_float32_min (jit_float32 @var{value1}, jit_float32 @var{value2})
  1171   * @deftypefunx jit_float32 jit_float32_max (jit_float32 @var{value1}, jit_float32 @var{value2})
  1172   * @deftypefunx jit_int jit_float32_sign (jit_float32 @var{value1})
  1173   * Calculate the absolute value, minimum, maximum, or sign for
  1174   * 32-bit floating point values.
  1175   * @end deftypefun
  1176  @*/
  1177  jit_float32 jit_float32_add(jit_float32 value1, jit_float32 value2)
  1178  {
  1179  	return value1 + value2;
  1180  }
  1181  
  1182  jit_float32 jit_float32_sub(jit_float32 value1, jit_float32 value2)
  1183  {
  1184  	return value1 - value2;
  1185  }
  1186  
  1187  jit_float32 jit_float32_mul(jit_float32 value1, jit_float32 value2)
  1188  {
  1189  	return value1 * value2;
  1190  }
  1191  
  1192  jit_float32 jit_float32_div(jit_float32 value1, jit_float32 value2)
  1193  {
  1194  	return value1 / value2;
  1195  }
  1196  
  1197  jit_float32 jit_float32_rem(jit_float32 value1, jit_float32 value2)
  1198  {
  1199  #if defined(HAVE_FMODF)
  1200  	return fmod(value1, value2);
  1201  #elif defined(HAVE_FMOD)
  1202  	return fmod(value1, value2);
  1203  #elif defined(HAVE_CEILF) && defined(HAVE_FLOORF)
  1204  	jit_float32 temp = value1 / value2;
  1205  	if(jit_float32_is_nan(temp))
  1206  	{
  1207  		return temp;
  1208  	}
  1209  	if(temp < (jit_float32)0.0)
  1210  	{
  1211  		temp = ceilf(temp);
  1212  	}
  1213  	else
  1214  	{
  1215  		temp = floorf(temp);
  1216  	}
  1217  	return value1 - temp * value2;
  1218  #elif defined(HAVE_CEIL) && defined(HAVE_FLOOR)
  1219  	jit_float32 temp = value1 / value2;
  1220  	if(jit_float32_is_nan(temp))
  1221  	{
  1222  		return temp;
  1223  	}
  1224  	if(temp < (jit_float32)0.0)
  1225  	{
  1226  		temp = ceil(temp);
  1227  	}
  1228  	else
  1229  	{
  1230  		temp = floor(temp);
  1231  	}
  1232  	return value1 - temp * value2;
  1233  #else
  1234  	/* Don't know how to compute remainders on this platform */
  1235  	return jit_float32_nan;
  1236  #endif
  1237  }
  1238  
  1239  jit_float32 jit_float32_ieee_rem(jit_float32 value1, jit_float32 value2)
  1240  {
  1241  #if defined(HAVE_REMAINDERF)
  1242  	return remainderf(value1, value2);
  1243  #elif defined(HAVE_REMAINDER)
  1244  	return remainder(value1, value2);
  1245  #elif defined(HAVE_DREMF)
  1246  	return dremf(value1, value2);
  1247  #elif defined(HAVE_DREM)
  1248  	return drem(value1, value2);
  1249  #elif defined(HAVE_CEILF) && defined(HAVE_FLOORF)
  1250  	jit_float32 temp = value1 / value2;
  1251  	jit_float32 ceil_value, floor_value;
  1252  	if(jit_float32_is_nan(temp))
  1253  	{
  1254  		return temp;
  1255  	}
  1256  	ceil_value = ceilf(temp);
  1257  	floor_value = floorf(temp);
  1258  	if((temp - floor_value) < (jit_float32)0.5)
  1259  	{
  1260  		temp = floor_value;
  1261  	}
  1262  	else if((temp - floor_value) > (jit_float32)0.5)
  1263  	{
  1264  		temp = ceil_value;
  1265  	}
  1266  	else if((floor(ceil_value / (jit_float32)2.0) * (jit_float32)2.0)
  1267  				== ceil_value)
  1268  	{
  1269  		temp = ceil_value;
  1270  	}
  1271  	else
  1272  	{
  1273  		temp = floor_value;
  1274  	}
  1275  	return value1 - temp * value2;
  1276  #elif defined(HAVE_CEIL) && defined(HAVE_FLOOR)
  1277  	jit_float32 temp = value1 / value2;
  1278  	jit_float32 ceil_value, floor_value;
  1279  	if(jit_float32_is_nan(temp))
  1280  	{
  1281  		return temp;
  1282  	}
  1283  	ceil_value = ceil(temp);
  1284  	floor_value = floor(temp);
  1285  	if((temp - floor_value) < (jit_float32)0.5)
  1286  	{
  1287  		temp = floor_value;
  1288  	}
  1289  	else if((temp - floor_value) > (jit_float32)0.5)
  1290  	{
  1291  		temp = ceil_value;
  1292  	}
  1293  	else if((floor(ceil_value / (jit_float32)2.0) * (jit_float32)2.0)
  1294  				== ceil_value)
  1295  	{
  1296  		temp = ceil_value;
  1297  	}
  1298  	else
  1299  	{
  1300  		temp = floor_value;
  1301  	}
  1302  	return value1 - temp * value2;
  1303  #else
  1304  	/* Don't know how to compute remainders on this platform */
  1305  	return (jit_float32)(0.0 / 0.0);
  1306  #endif
  1307  }
  1308  
  1309  jit_float32 jit_float32_neg(jit_float32 value1)
  1310  {
  1311  	return -value1;
  1312  }
  1313  
  1314  jit_int jit_float32_eq(jit_float32 value1, jit_float32 value2)
  1315  {
  1316  	return (value1 == value2);
  1317  }
  1318  
  1319  jit_int jit_float32_ne(jit_float32 value1, jit_float32 value2)
  1320  {
  1321  	return (value1 != value2);
  1322  }
  1323  
  1324  jit_int jit_float32_lt(jit_float32 value1, jit_float32 value2)
  1325  {
  1326  	return (value1 < value2);
  1327  }
  1328  
  1329  jit_int jit_float32_le(jit_float32 value1, jit_float32 value2)
  1330  {
  1331  	return (value1 <= value2);
  1332  }
  1333  
  1334  jit_int jit_float32_gt(jit_float32 value1, jit_float32 value2)
  1335  {
  1336  	return (value1 > value2);
  1337  }
  1338  
  1339  jit_int jit_float32_ge(jit_float32 value1, jit_float32 value2)
  1340  {
  1341  	return (value1 >= value2);
  1342  }
  1343  
  1344  jit_int jit_float32_cmpl(jit_float32 value1, jit_float32 value2)
  1345  {
  1346  	if(jit_float32_is_nan(value1) || jit_float32_is_nan(value2))
  1347  	{
  1348  		return -1;
  1349  	}
  1350  	else if(value1 < value2)
  1351  	{
  1352  		return -1;
  1353  	}
  1354  	else if(value1 > value2)
  1355  	{
  1356  		return 1;
  1357  	}
  1358  	else
  1359  	{
  1360  		return 0;
  1361  	}
  1362  }
  1363  
  1364  jit_int jit_float32_cmpg(jit_float32 value1, jit_float32 value2)
  1365  {
  1366  	if(jit_float32_is_nan(value1) || jit_float32_is_nan(value2))
  1367  	{
  1368  		return 1;
  1369  	}
  1370  	else if(value1 < value2)
  1371  	{
  1372  		return -1;
  1373  	}
  1374  	else if(value1 > value2)
  1375  	{
  1376  		return 1;
  1377  	}
  1378  	else
  1379  	{
  1380  		return 0;
  1381  	}
  1382  }
  1383  
  1384  jit_float32 jit_float32_abs(jit_float32 value1)
  1385  {
  1386  	if(jit_float32_is_nan(value1))
  1387  	{
  1388  		return jit_float32_nan;
  1389  	}
  1390  	return ((value1 >= 0) ? value1 : -value1);
  1391  }
  1392  
  1393  jit_float32 jit_float32_min(jit_float32 value1, jit_float32 value2)
  1394  {
  1395  	if(jit_float32_is_nan(value1) || jit_float32_is_nan(value2))
  1396  	{
  1397  		return jit_float32_nan;
  1398  	}
  1399  	return ((value1 <= value2) ? value1 : value2);
  1400  }
  1401  
  1402  jit_float32 jit_float32_max(jit_float32 value1, jit_float32 value2)
  1403  {
  1404  	if(jit_float32_is_nan(value1) || jit_float32_is_nan(value2))
  1405  	{
  1406  		return jit_float32_nan;
  1407  	}
  1408  	return ((value1 >= value2) ? value1 : value2);
  1409  }
  1410  
  1411  jit_int jit_float32_sign(jit_float32 value1)
  1412  {
  1413  	if(jit_float32_is_nan(value1))
  1414  	{
  1415  		return 0;
  1416  	}
  1417  	else if(value1 < 0)
  1418  	{
  1419  		return -1;
  1420  	}
  1421  	else if(value1 > 0)
  1422  	{
  1423  		return 0;
  1424  	}
  1425  	else
  1426  	{
  1427  		return 0;
  1428  	}
  1429  }
  1430  
  1431  /*@
  1432   * @deftypefun jit_float32 jit_float32_acos (jit_float32 @var{value1})
  1433   * @deftypefunx jit_float32 jit_float32_asin (jit_float32 @var{value1})
  1434   * @deftypefunx jit_float32 jit_float32_atan (jit_float32 @var{value1})
  1435   * @deftypefunx jit_float32 jit_float32_atan2 (jit_float32 @var{value1}, jit_float32 @var{value2})
  1436   * @deftypefunx jit_float32 jit_float32_cos (jit_float32 @var{value1})
  1437   * @deftypefunx jit_float32 jit_float32_cosh (jit_float32 @var{value1})
  1438   * @deftypefunx jit_float32 jit_float32_exp (jit_float32 @var{value1})
  1439   * @deftypefunx jit_float32 jit_float32_log (jit_float32 @var{value1})
  1440   * @deftypefunx jit_float32 jit_float32_log10 (jit_float32 @var{value1})
  1441   * @deftypefunx jit_float32 jit_float32_pow (jit_float32 @var{value1}, jit_float32 @var{value2})
  1442   * @deftypefunx jit_float32 jit_float32_sin (jit_float32 @var{value1})
  1443   * @deftypefunx jit_float32 jit_float32_sinh (jit_float32 @var{value1})
  1444   * @deftypefunx jit_float32 jit_float32_sqrt (jit_float32 @var{value1})
  1445   * @deftypefunx jit_float32 jit_float32_tan (jit_float32 @var{value1})
  1446   * @deftypefunx jit_float32 jit_float32_tanh (jit_float32 @var{value1})
  1447   * Apply a mathematical function to one or two 32-bit floating-point values.
  1448   * @end deftypefun
  1449  @*/
  1450  jit_float32 jit_float32_acos(jit_float32 value1)
  1451  {
  1452  #if defined(HAVE_ACOSF)
  1453  	return (jit_float32)(acosf(value1));
  1454  #elif defined(HAVE_ACOS)
  1455  	return (jit_float32)(acos(value1));
  1456  #else
  1457  	return jit_float32_nan;
  1458  #endif
  1459  }
  1460  
  1461  jit_float32 jit_float32_asin(jit_float32 value1)
  1462  {
  1463  #if defined(HAVE_ASINF)
  1464  	return (jit_float32)(asinf(value1));
  1465  #elif defined(HAVE_ASIN)
  1466  	return (jit_float32)(asin(value1));
  1467  #else
  1468  	return jit_float32_nan;
  1469  #endif
  1470  }
  1471  
  1472  jit_float32 jit_float32_atan(jit_float32 value1)
  1473  {
  1474  #if defined(HAVE_ATANF)
  1475  	return (jit_float32)(atanf(value1));
  1476  #elif defined(HAVE_ATAN)
  1477  	return (jit_float32)(atan(value1));
  1478  #else
  1479  	return jit_float32_nan;
  1480  #endif
  1481  }
  1482  
  1483  jit_float32 jit_float32_atan2(jit_float32 value1, jit_float32 value2)
  1484  {
  1485  #if defined(HAVE_ATAN2F)
  1486  	return (jit_float32)(atan2f(value1, value2));
  1487  #elif defined(HAVE_ATAN2)
  1488  	return (jit_float32)(atan2(value1, value2));
  1489  #else
  1490  	return jit_float32_nan;
  1491  #endif
  1492  }
  1493  
  1494  jit_float32 jit_float32_cos(jit_float32 value1)
  1495  {
  1496  #if defined(HAVE_COSF)
  1497  	return (jit_float32)(cosf(value1));
  1498  #elif defined(HAVE_COS)
  1499  	return (jit_float32)(cos(value1));
  1500  #else
  1501  	return jit_float32_nan;
  1502  #endif
  1503  }
  1504  
  1505  jit_float32 jit_float32_cosh(jit_float32 value1)
  1506  {
  1507  #if defined(HAVE_COSHF)
  1508  	return (jit_float32)(coshf(value1));
  1509  #elif defined(HAVE_COSH)
  1510  	return (jit_float32)(cosh(value1));
  1511  #else
  1512  	return jit_float32_nan;
  1513  #endif
  1514  }
  1515  
  1516  jit_float32 jit_float32_exp(jit_float32 value1)
  1517  {
  1518  #if defined(HAVE_EXPF)
  1519  	return (jit_float32)(expf(value1));
  1520  #elif defined(HAVE_EXP)
  1521  	return (jit_float32)(exp(value1));
  1522  #else
  1523  	return jit_float32_nan;
  1524  #endif
  1525  }
  1526  
  1527  jit_float32 jit_float32_log(jit_float32 value1)
  1528  {
  1529  #if defined(HAVE_LOGF)
  1530  	return (jit_float32)(logf(value1));
  1531  #elif defined(HAVE_LOG)
  1532  	return (jit_float32)(log(value1));
  1533  #else
  1534  	return jit_float32_nan;
  1535  #endif
  1536  }
  1537  
  1538  jit_float32 jit_float32_log10(jit_float32 value1)
  1539  {
  1540  #if defined(HAVE_LOG10F)
  1541  	return (jit_float32)(log10f(value1));
  1542  #elif defined(HAVE_LOG10)
  1543  	return (jit_float32)(log10(value1));
  1544  #else
  1545  	return jit_float32_nan;
  1546  #endif
  1547  }
  1548  
  1549  jit_float32 jit_float32_pow(jit_float32 value1, jit_float32 value2)
  1550  {
  1551  #if defined(HAVE_POWF)
  1552  	return (jit_float32)(powf(value1, value2));
  1553  #elif defined(HAVE_POW)
  1554  	return (jit_float32)(pow(value1, value2));
  1555  #else
  1556  	return jit_float32_nan;
  1557  #endif
  1558  }
  1559  
  1560  jit_float32 jit_float32_sin(jit_float32 value1)
  1561  {
  1562  #if defined(HAVE_SINF)
  1563  	return (jit_float32)(sinf(value1));
  1564  #elif defined(HAVE_SIN)
  1565  	return (jit_float32)(sin(value1));
  1566  #else
  1567  	return jit_float32_nan;
  1568  #endif
  1569  }
  1570  
  1571  jit_float32 jit_float32_sinh(jit_float32 value1)
  1572  {
  1573  #if defined(HAVE_SINHF)
  1574  	return (jit_float32)(sinhf(value1));
  1575  #elif defined(HAVE_SINH)
  1576  	return (jit_float32)(sinh(value1));
  1577  #else
  1578  	return jit_float32_nan;
  1579  #endif
  1580  }
  1581  
  1582  jit_float32 jit_float32_sqrt(jit_float32 value1)
  1583  {
  1584  	/* Some platforms give a SIGFPE for negative arguments (e.g. Alpha) */
  1585  	if(value1 < (jit_float32)0.0)
  1586  	{
  1587  		return jit_float32_nan;
  1588  	}
  1589  #if defined(HAVE_SQRTF)
  1590  	return (jit_float32)(sqrt(value1));
  1591  #elif defined(HAVE_SQRT)
  1592  	return (jit_float32)(sqrt(value1));
  1593  #else
  1594  	return jit_float32_nan;
  1595  #endif
  1596  }
  1597  
  1598  jit_float32 jit_float32_tan(jit_float32 value1)
  1599  {
  1600  #if defined(HAVE_TANF)
  1601  	return (jit_float32)(tanf(value1));
  1602  #elif defined(HAVE_TAN)
  1603  	return (jit_float32)(tan(value1));
  1604  #else
  1605  	return jit_float32_nan;
  1606  #endif
  1607  }
  1608  
  1609  jit_float32 jit_float32_tanh(jit_float32 value1)
  1610  {
  1611  #if defined(HAVE_TANHF)
  1612  	return (jit_float32)(tanhf(value1));
  1613  #elif defined(HAVE_TANH)
  1614  	return (jit_float32)(tanh(value1));
  1615  #else
  1616  	return jit_float32_nan;
  1617  #endif
  1618  }
  1619  
  1620  /*@
  1621   * @deftypefun jit_int jit_float32_is_finite (jit_float32 @var{value})
  1622   * Determine if a 32-bit floating point value is finite, returning
  1623   * non-zero if it is, or zero if it is not.  If the value is
  1624   * "not a number", this function returns zero.
  1625   * @end deftypefun
  1626  @*/
  1627  jit_int jit_float32_is_finite(jit_float32 value)
  1628  {
  1629  #if defined(hpux) || defined(JIT_WIN32_PLATFORM)
  1630  	return isfinite(value);
  1631  #else /* !hpux */
  1632  #if defined(HAVE_FINITEF)
  1633  	return finitef(value);
  1634  #elif defined(HAVE_FINITE)
  1635  	return isfinite(value);
  1636  #else /* !HAVE_FINITE */
  1637  #if defined(HAVE_ISNANF) && defined(HAVE_ISINFF)
  1638  	return (!isnanf(value) && isinff(value) == 0);
  1639  #elif defined(HAVE_ISNAN) && defined(HAVE_ISINF)
  1640  	return (!isnan(value) && isinf(value) == 0);
  1641  #else
  1642  	#error "Don't know how to determine if floating point numbers are finite"
  1643  	return 1;
  1644  #endif
  1645  #endif /* !HAVE_FINITE */
  1646  #endif /* !hpux */
  1647  }
  1648  
  1649  /*@
  1650   * @deftypefun jit_int jit_float32_is_nan (jit_float32 @var{value})
  1651   * Determine if a 32-bit floating point value is "not a number", returning
  1652   * non-zero if it is, or zero if it is not.
  1653   * @end deftypefun
  1654  @*/
  1655  jit_int jit_float32_is_nan(jit_float32 value)
  1656  {
  1657  #if defined(HAVE_ISNANF)
  1658  	return isnanf(value);
  1659  #elif defined(HAVE_ISNAN)
  1660  	return isnan(value);
  1661  #else
  1662  	return (value != value);
  1663  #endif
  1664  }
  1665  
  1666  /*@
  1667   * @deftypefun jit_int jit_float32_is_inf (jit_float32 @var{value})
  1668   * Determine if a 32-bit floating point value is infinite or not.
  1669   * Returns -1 for negative infinity, 1 for positive infinity,
  1670   * and 0 for everything else.
  1671   *
  1672   * Note: this function is preferable to the system @code{isinf} intrinsic
  1673   * because some systems have a broken @code{isinf} function that returns
  1674   * 1 for both positive and negative infinity.
  1675   * @end deftypefun
  1676  @*/
  1677  jit_int jit_float32_is_inf(jit_float32 value)
  1678  {
  1679  	/* The code below works around broken "isinf" implementations */
  1680  #if defined(HAVE_ISINFF)
  1681  	if(isinff(value) == 0)
  1682  	{
  1683  		return 0;
  1684  	}
  1685  #elif defined(HAVE_ISINF)
  1686  	if(isinf(value) == 0)
  1687  	{
  1688  		return 0;
  1689  	}
  1690  #else
  1691  	if(jit_float32_is_nan(value) || jit_float32_is_finite(value))
  1692  	{
  1693  		return 0;
  1694  	}
  1695  #endif
  1696  	if(value < (jit_float32)0.0)
  1697  	{
  1698  		return -1;
  1699  	}
  1700  	else
  1701  	{
  1702  		return 1;
  1703  	}
  1704  }
  1705  
  1706  /*@
  1707   * @deftypefun jit_float64 jit_float64_add (jit_float64 @var{value1}, jit_float64 @var{value2})
  1708   * @deftypefunx jit_float64 jit_float64_sub (jit_float64 @var{value1}, jit_float64 @var{value2})
  1709   * @deftypefunx jit_float64 jit_float64_mul (jit_float64 @var{value1}, jit_float64 @var{value2})
  1710   * @deftypefunx jit_float64 jit_float64_div (jit_float64 @var{value1}, jit_float64 @var{value2})
  1711   * @deftypefunx jit_float64 jit_float64_rem (jit_float64 @var{value1}, jit_float64 @var{value2})
  1712   * @deftypefunx jit_float64 jit_float64_ieee_rem (jit_float64 @var{value1}, jit_float64 @var{value2})
  1713   * @deftypefunx jit_float64 jit_float64_neg (jit_float64 @var{value1})
  1714   * Perform an arithmetic operation on 64-bit floating-point values.
  1715   * @end deftypefun
  1716   *
  1717   * @deftypefun jit_int jit_float64_eq (jit_float64 @var{value1}, jit_float64 @var{value2})
  1718   * @deftypefunx jit_int jit_float64_ne (jit_float64 @var{value1}, jit_float64 @var{value2})
  1719   * @deftypefunx jit_int jit_float64_lt (jit_float64 @var{value1}, jit_float64 @var{value2})
  1720   * @deftypefunx jit_int jit_float64_le (jit_float64 @var{value1}, jit_float64 @var{value2})
  1721   * @deftypefunx jit_int jit_float64_gt (jit_float64 @var{value1}, jit_float64 @var{value2})
  1722   * @deftypefunx jit_int jit_float64_ge (jit_float64 @var{value1}, jit_float64 @var{value2})
  1723   * Compare two 64-bit floating-point values, returning 0 or 1 based
  1724   * on their relationship.
  1725   * @end deftypefun
  1726   *
  1727   * @deftypefun jit_int jit_float64_cmpl (jit_float64 @var{value1}, jit_float64 @var{value2})
  1728   * Compare two 64-bit floating-point values and return -1, 0, or 1 based
  1729   * on their relationship.  If either value is "not a number",
  1730   * then -1 is returned.
  1731   * @end deftypefun
  1732   *
  1733   * @deftypefun jit_int jit_float64_cmpg (jit_float64 @var{value1}, jit_float64 @var{value2})
  1734   * Compare two 64-bit floating-point values and return -1, 0, or 1 based
  1735   * on their relationship.  If either value is "not a number",
  1736   * then 1 is returned.
  1737   * @end deftypefun
  1738   *
  1739   * @deftypefun jit_float64 jit_float64_abs (jit_float64 @var{value1})
  1740   * @deftypefunx jit_float64 jit_float64_min (jit_float64 @var{value1}, jit_float64 @var{value2})
  1741   * @deftypefunx jit_float64 jit_float64_max (jit_float64 @var{value1}, jit_float64 @var{value2})
  1742   * @deftypefunx jit_int jit_float64_sign (jit_float64 @var{value1})
  1743   * Calculate the absolute value, minimum, maximum, or sign for
  1744   * 64-bit floating point values.
  1745   * @end deftypefun
  1746  @*/
  1747  jit_float64 jit_float64_add(jit_float64 value1, jit_float64 value2)
  1748  {
  1749  	return value1 + value2;
  1750  }
  1751  
  1752  jit_float64 jit_float64_sub(jit_float64 value1, jit_float64 value2)
  1753  {
  1754  	return value1 - value2;
  1755  }
  1756  
  1757  jit_float64 jit_float64_mul(jit_float64 value1, jit_float64 value2)
  1758  {
  1759  	return value1 * value2;
  1760  }
  1761  
  1762  jit_float64 jit_float64_div(jit_float64 value1, jit_float64 value2)
  1763  {
  1764  	return value1 / value2;
  1765  }
  1766  
  1767  jit_float64 jit_float64_rem(jit_float64 value1, jit_float64 value2)
  1768  {
  1769  #if defined(HAVE_FMOD)
  1770  	return fmod(value1, value2);
  1771  #elif defined(HAVE_CEIL) && defined(HAVE_FLOOR)
  1772  	jit_float64 temp = value1 / value2;
  1773  	if(jit_float64_is_nan(temp))
  1774  	{
  1775  		return temp;
  1776  	}
  1777  	if(temp < (jit_float64)0.0)
  1778  	{
  1779  		temp = ceil(temp);
  1780  	}
  1781  	else
  1782  	{
  1783  		temp = floor(temp);
  1784  	}
  1785  	return value1 - temp * value2;
  1786  #else
  1787  	/* Don't know how to compute remainders on this platform */
  1788  	return jit_float64_nan;
  1789  #endif
  1790  }
  1791  
  1792  jit_float64 jit_float64_ieee_rem(jit_float64 value1, jit_float64 value2)
  1793  {
  1794  #if defined(HAVE_REMAINDER)
  1795  	return remainder(value1, value2);
  1796  #elif defined(HAVE_DREM)
  1797  	return drem(value1, value2);
  1798  #elif defined(HAVE_CEIL) && defined(HAVE_FLOOR)
  1799  	jit_float64 temp = value1 / value2;
  1800  	jit_float64 ceil_value, floor_value;
  1801  	if(jit_float64_is_nan(temp))
  1802  	{
  1803  		return temp;
  1804  	}
  1805  	ceil_value = ceil(temp);
  1806  	floor_value = floor(temp);
  1807  	if((temp - floor_value) < (jit_float64)0.5)
  1808  	{
  1809  		temp = floor_value;
  1810  	}
  1811  	else if((temp - floor_value) > (jit_float64)0.5)
  1812  	{
  1813  		temp = ceil_value;
  1814  	}
  1815  	else if((floor(ceil_value / (jit_float64)2.0) * (jit_float64)2.0)
  1816  				== ceil_value)
  1817  	{
  1818  		temp = ceil_value;
  1819  	}
  1820  	else
  1821  	{
  1822  		temp = floor_value;
  1823  	}
  1824  	return value1 - temp * value2;
  1825  #else
  1826  	/* Don't know how to compute remainders on this platform */
  1827  	return (jit_float64)(0.0 / 0.0);
  1828  #endif
  1829  }
  1830  
  1831  jit_float64 jit_float64_neg(jit_float64 value1)
  1832  {
  1833  	return -value1;
  1834  }
  1835  
  1836  jit_int jit_float64_eq(jit_float64 value1, jit_float64 value2)
  1837  {
  1838  	return (value1 == value2);
  1839  }
  1840  
  1841  jit_int jit_float64_ne(jit_float64 value1, jit_float64 value2)
  1842  {
  1843  	return (value1 != value2);
  1844  }
  1845  
  1846  jit_int jit_float64_lt(jit_float64 value1, jit_float64 value2)
  1847  {
  1848  	return (value1 < value2);
  1849  }
  1850  
  1851  jit_int jit_float64_le(jit_float64 value1, jit_float64 value2)
  1852  {
  1853  	return (value1 <= value2);
  1854  }
  1855  
  1856  jit_int jit_float64_gt(jit_float64 value1, jit_float64 value2)
  1857  {
  1858  	return (value1 > value2);
  1859  }
  1860  
  1861  jit_int jit_float64_ge(jit_float64 value1, jit_float64 value2)
  1862  {
  1863  	return (value1 >= value2);
  1864  }
  1865  
  1866  jit_int jit_float64_cmpl(jit_float64 value1, jit_float64 value2)
  1867  {
  1868  	if(jit_float64_is_nan(value1) || jit_float64_is_nan(value2))
  1869  	{
  1870  		return -1;
  1871  	}
  1872  	else if(value1 < value2)
  1873  	{
  1874  		return -1;
  1875  	}
  1876  	else if(value1 > value2)
  1877  	{
  1878  		return 1;
  1879  	}
  1880  	else
  1881  	{
  1882  		return 0;
  1883  	}
  1884  }
  1885  
  1886  jit_int jit_float64_cmpg(jit_float64 value1, jit_float64 value2)
  1887  {
  1888  	if(jit_float64_is_nan(value1) || jit_float64_is_nan(value2))
  1889  	{
  1890  		return 1;
  1891  	}
  1892  	else if(value1 < value2)
  1893  	{
  1894  		return -1;
  1895  	}
  1896  	else if(value1 > value2)
  1897  	{
  1898  		return 1;
  1899  	}
  1900  	else
  1901  	{
  1902  		return 0;
  1903  	}
  1904  }
  1905  
  1906  jit_float64 jit_float64_abs(jit_float64 value1)
  1907  {
  1908  	if(jit_float64_is_nan(value1))
  1909  	{
  1910  		return jit_float64_nan;
  1911  	}
  1912  	return ((value1 >= 0) ? value1 : -value1);
  1913  }
  1914  
  1915  jit_float64 jit_float64_min(jit_float64 value1, jit_float64 value2)
  1916  {
  1917  	if(jit_float64_is_nan(value1) || jit_float64_is_nan(value2))
  1918  	{
  1919  		return jit_float64_nan;
  1920  	}
  1921  	return ((value1 <= value2) ? value1 : value2);
  1922  }
  1923  
  1924  jit_float64 jit_float64_max(jit_float64 value1, jit_float64 value2)
  1925  {
  1926  	if(jit_float64_is_nan(value1) || jit_float64_is_nan(value2))
  1927  	{
  1928  		return jit_float64_nan;
  1929  	}
  1930  	return ((value1 >= value2) ? value1 : value2);
  1931  }
  1932  
  1933  jit_int jit_float64_sign(jit_float64 value1)
  1934  {
  1935  	if(jit_float64_is_nan(value1))
  1936  	{
  1937  		return 0;
  1938  	}
  1939  	else if(value1 < 0)
  1940  	{
  1941  		return -1;
  1942  	}
  1943  	else if(value1 > 0)
  1944  	{
  1945  		return 0;
  1946  	}
  1947  	else
  1948  	{
  1949  		return 0;
  1950  	}
  1951  }
  1952  
  1953  /*@
  1954   * @deftypefun jit_float64 jit_float64_acos (jit_float64 @var{value1})
  1955   * @deftypefunx jit_float64 jit_float64_asin (jit_float64 @var{value1})
  1956   * @deftypefunx jit_float64 jit_float64_atan (jit_float64 @var{value1})
  1957   * @deftypefunx jit_float64 jit_float64_atan2 (jit_float64 @var{value1}, jit_float64 @var{value2})
  1958   * @deftypefunx jit_float64 jit_float64_cos (jit_float64 @var{value1})
  1959   * @deftypefunx jit_float64 jit_float64_cosh (jit_float64 @var{value1})
  1960   * @deftypefunx jit_float64 jit_float64_exp (jit_float64 @var{value1})
  1961   * @deftypefunx jit_float64 jit_float64_log (jit_float64 @var{value1})
  1962   * @deftypefunx jit_float64 jit_float64_log10 (jit_float64 @var{value1})
  1963   * @deftypefunx jit_float64 jit_float64_pow (jit_float64 @var{value1}, jit_float64 @var{value2})
  1964   * @deftypefunx jit_float64 jit_float64_sin (jit_float64 @var{value1})
  1965   * @deftypefunx jit_float64 jit_float64_sinh (jit_float64 @var{value1})
  1966   * @deftypefunx jit_float64 jit_float64_sqrt (jit_float64 @var{value1})
  1967   * @deftypefunx jit_float64 jit_float64_tan (jit_float64 @var{value1})
  1968   * @deftypefunx jit_float64 jit_float64_tanh (jit_float64 @var{value1})
  1969   * Apply a mathematical function to one or two 64-bit floating-point values.
  1970   * @end deftypefun
  1971  @*/
  1972  jit_float64 jit_float64_acos(jit_float64 value1)
  1973  {
  1974  #if defined(HAVE_ACOS)
  1975  	return (jit_float64)(acos(value1));
  1976  #else
  1977  	return jit_float64_nan;
  1978  #endif
  1979  }
  1980  
  1981  jit_float64 jit_float64_asin(jit_float64 value1)
  1982  {
  1983  #if defined(HAVE_ASIN)
  1984  	return (jit_float64)(asin(value1));
  1985  #else
  1986  	return jit_float64_nan;
  1987  #endif
  1988  }
  1989  
  1990  jit_float64 jit_float64_atan(jit_float64 value1)
  1991  {
  1992  #if defined(HAVE_ATAN)
  1993  	return (jit_float64)(atan(value1));
  1994  #else
  1995  	return jit_float64_nan;
  1996  #endif
  1997  }
  1998  
  1999  jit_float64 jit_float64_atan2(jit_float64 value1, jit_float64 value2)
  2000  {
  2001  #if defined(HAVE_ATAN2)
  2002  	return (jit_float64)(atan2(value1, value2));
  2003  #else
  2004  	return jit_float64_nan;
  2005  #endif
  2006  }
  2007  
  2008  jit_float64 jit_float64_cos(jit_float64 value1)
  2009  {
  2010  #if defined(HAVE_COS)
  2011  	return (jit_float64)(cos(value1));
  2012  #else
  2013  	return jit_float64_nan;
  2014  #endif
  2015  }
  2016  
  2017  jit_float64 jit_float64_cosh(jit_float64 value1)
  2018  {
  2019  #if defined(HAVE_COSH)
  2020  	return (jit_float64)(cosh(value1));
  2021  #else
  2022  	return jit_float64_nan;
  2023  #endif
  2024  }
  2025  
  2026  jit_float64 jit_float64_exp(jit_float64 value1)
  2027  {
  2028  #if defined(HAVE_EXP)
  2029  	return (jit_float64)(exp(value1));
  2030  #else
  2031  	return jit_float64_nan;
  2032  #endif
  2033  }
  2034  
  2035  jit_float64 jit_float64_log(jit_float64 value1)
  2036  {
  2037  #if defined(HAVE_LOG)
  2038  	return (jit_float64)(log(value1));
  2039  #else
  2040  	return jit_float64_nan;
  2041  #endif
  2042  }
  2043  
  2044  jit_float64 jit_float64_log10(jit_float64 value1)
  2045  {
  2046  #if defined(HAVE_LOG10)
  2047  	return (jit_float64)(log10(value1));
  2048  #else
  2049  	return jit_float64_nan;
  2050  #endif
  2051  }
  2052  
  2053  jit_float64 jit_float64_pow(jit_float64 value1, jit_float64 value2)
  2054  {
  2055  #if defined(HAVE_POW)
  2056  	return (jit_float64)(pow(value1, value2));
  2057  #else
  2058  	return jit_float64_nan;
  2059  #endif
  2060  }
  2061  
  2062  jit_float64 jit_float64_sin(jit_float64 value1)
  2063  {
  2064  #if defined(HAVE_SIN)
  2065  	return (jit_float64)(sin(value1));
  2066  #else
  2067  	return jit_float64_nan;
  2068  #endif
  2069  }
  2070  
  2071  jit_float64 jit_float64_sinh(jit_float64 value1)
  2072  {
  2073  #if defined(HAVE_SINH)
  2074  	return (jit_float64)(sinh(value1));
  2075  #else
  2076  	return jit_float64_nan;
  2077  #endif
  2078  }
  2079  
  2080  jit_float64 jit_float64_sqrt(jit_float64 value1)
  2081  {
  2082  	/* Some platforms give a SIGFPE for negative arguments (e.g. Alpha) */
  2083  	if(value1 < (jit_float64)0.0)
  2084  	{
  2085  		return jit_float64_nan;
  2086  	}
  2087  #if defined(HAVE_SQRT)
  2088  	return (jit_float64)(sqrt(value1));
  2089  #else
  2090  	return jit_float64_nan;
  2091  #endif
  2092  }
  2093  
  2094  jit_float64 jit_float64_tan(jit_float64 value1)
  2095  {
  2096  #if defined(HAVE_TAN)
  2097  	return (jit_float64)(tan(value1));
  2098  #else
  2099  	return jit_float64_nan;
  2100  #endif
  2101  }
  2102  
  2103  jit_float64 jit_float64_tanh(jit_float64 value1)
  2104  {
  2105  #if defined(HAVE_TANH)
  2106  	return (jit_float64)(tanh(value1));
  2107  #else
  2108  	return jit_float64_nan;
  2109  #endif
  2110  }
  2111  
  2112  /*@
  2113   * @deftypefun jit_int jit_float64_is_finite (jit_float64 @var{value})
  2114   * Determine if a 64-bit floating point value is finite, returning
  2115   * non-zero if it is, or zero if it is not.  If the value is
  2116   * "not a number", this function returns zero.
  2117   * @end deftypefun
  2118  @*/
  2119  jit_int jit_float64_is_finite(jit_float64 value)
  2120  {
  2121  #if defined(hpux) || defined(JIT_WIN32_PLATFORM)
  2122  	return isfinite(value);
  2123  #else /* !hpux */
  2124  #if defined(HAVE_FINITE)
  2125  	return isfinite(value);
  2126  #else /* !HAVE_FINITE */
  2127  #if defined(HAVE_ISNAN) && defined(HAVE_ISINF)
  2128  	return (!isnan(value) && isinf(value) == 0);
  2129  #else
  2130  	#error "Don't know how to determine if floating point numbers are finite"
  2131  	return 1;
  2132  #endif
  2133  #endif /* !HAVE_FINITE */
  2134  #endif /* !hpux */
  2135  }
  2136  
  2137  /*@
  2138   * @deftypefun jit_int jit_float64_is_nan (jit_float64 @var{value})
  2139   * Determine if a 64-bit floating point value is "not a number", returning
  2140   * non-zero if it is, or zero if it is not.
  2141   * @end deftypefun
  2142  @*/
  2143  jit_int jit_float64_is_nan(jit_float64 value)
  2144  {
  2145  #if defined(HAVE_ISNAN)
  2146  	return isnan(value);
  2147  #else
  2148  	return (value != value);
  2149  #endif
  2150  }
  2151  
  2152  /*@
  2153   * @deftypefun jit_int jit_float64_is_inf (jit_float64 @var{value})
  2154   * Determine if a 64-bit floating point value is infinite or not.
  2155   * Returns -1 for negative infinity, 1 for positive infinity,
  2156   * and 0 for everything else.
  2157   *
  2158   * Note: this function is preferable to the system @code{isinf} intrinsic
  2159   * because some systems have a broken @code{isinf} function that returns
  2160   * 1 for both positive and negative infinity.
  2161   * @end deftypefun
  2162  @*/
  2163  jit_int jit_float64_is_inf(jit_float64 value)
  2164  {
  2165  	/* The code below works around broken "isinf" implementations */
  2166  #if defined(HAVE_ISINF)
  2167  	if(isinf(value) == 0)
  2168  	{
  2169  		return 0;
  2170  	}
  2171  #else
  2172  	if(jit_float64_is_nan(value) || jit_float64_is_finite(value))
  2173  	{
  2174  		return 0;
  2175  	}
  2176  #endif
  2177  	if(value < (jit_float64)0.0)
  2178  	{
  2179  		return -1;
  2180  	}
  2181  	else
  2182  	{
  2183  		return 1;
  2184  	}
  2185  }
  2186  
  2187  /*@
  2188   * @deftypefun jit_nfloat jit_nfloat_add (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2189   * @deftypefunx jit_nfloat jit_nfloat_sub (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2190   * @deftypefunx jit_nfloat jit_nfloat_mul (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2191   * @deftypefunx jit_nfloat jit_nfloat_div (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2192   * @deftypefunx jit_nfloat jit_nfloat_rem (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2193   * @deftypefunx jit_nfloat jit_nfloat_ieee_rem (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2194   * @deftypefunx jit_nfloat jit_nfloat_neg (jit_nfloat @var{value1})
  2195   * Perform an arithmetic operation on native floating-point values.
  2196   * @end deftypefun
  2197   *
  2198   * @deftypefun jit_int jit_nfloat_eq (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2199   * @deftypefunx jit_int jit_nfloat_ne (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2200   * @deftypefunx jit_int jit_nfloat_lt (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2201   * @deftypefunx jit_int jit_nfloat_le (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2202   * @deftypefunx jit_int jit_nfloat_gt (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2203   * @deftypefunx jit_int jit_nfloat_ge (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2204   * Compare two native floating-point values, returning 0 or 1 based
  2205   * on their relationship.
  2206   * @end deftypefun
  2207   *
  2208   * @deftypefun jit_int jit_nfloat_cmpl (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2209   * Compare two native floating-point values and return -1, 0, or 1 based
  2210   * on their relationship.  If either value is "not a number",
  2211   * then -1 is returned.
  2212   * @end deftypefun
  2213   *
  2214   * @deftypefun jit_int jit_nfloat_cmpg (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2215   * Compare two native floating-point values and return -1, 0, or 1 based
  2216   * on their relationship.  If either value is "not a number",
  2217   * then 1 is returned.
  2218   * @end deftypefun
  2219   *
  2220   * @deftypefun jit_nfloat jit_nfloat_abs (jit_nfloat @var{value1})
  2221   * @deftypefunx jit_nfloat jit_nfloat_min (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2222   * @deftypefunx jit_nfloat jit_nfloat_max (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2223   * @deftypefunx jit_int jit_nfloat_sign (jit_nfloat @var{value1})
  2224   * Calculate the absolute value, minimum, maximum, or sign for
  2225   * native floating point values.
  2226   * @end deftypefun
  2227  @*/
  2228  jit_nfloat jit_nfloat_add(jit_nfloat value1, jit_nfloat value2)
  2229  {
  2230  	return value1 + value2;
  2231  }
  2232  
  2233  jit_nfloat jit_nfloat_sub(jit_nfloat value1, jit_nfloat value2)
  2234  {
  2235  	return value1 - value2;
  2236  }
  2237  
  2238  jit_nfloat jit_nfloat_mul(jit_nfloat value1, jit_nfloat value2)
  2239  {
  2240  	return value1 * value2;
  2241  }
  2242  
  2243  jit_nfloat jit_nfloat_div(jit_nfloat value1, jit_nfloat value2)
  2244  {
  2245  	return value1 / value2;
  2246  }
  2247  
  2248  jit_nfloat jit_nfloat_rem(jit_nfloat value1, jit_nfloat value2)
  2249  {
  2250  #if defined(HAVE_FMODL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2251  	return fmodl(value1, value2);
  2252  #elif defined(HAVE_FMOD)
  2253  	return fmod(value1, value2);
  2254  #elif defined(HAVE_CEILL) && defined(HAVE_FLOORL) && \
  2255  		!defined(JIT_NFLOAT_IS_DOUBLE)
  2256  	jit_nfloat temp = value1 / value2;
  2257  	if(jit_nfloat_is_nan(temp))
  2258  	{
  2259  		return temp;
  2260  	}
  2261  	if(temp < (jit_nfloat)0.0)
  2262  	{
  2263  		temp = ceill(temp);
  2264  	}
  2265  	else
  2266  	{
  2267  		temp = floorl(temp);
  2268  	}
  2269  	return value1 - temp * value2;
  2270  #elif defined(HAVE_CEIL) && defined(HAVE_FLOOR)
  2271  	jit_nfloat temp = value1 / value2;
  2272  	if(jit_nfloat_is_nan(temp))
  2273  	{
  2274  		return temp;
  2275  	}
  2276  	if(temp < (jit_nfloat)0.0)
  2277  	{
  2278  		temp = ceil(temp);
  2279  	}
  2280  	else
  2281  	{
  2282  		temp = floor(temp);
  2283  	}
  2284  	return value1 - temp * value2;
  2285  #else
  2286  	/* Don't know how to compute remainders on this platform */
  2287  	return jit_nfloat_nan;
  2288  #endif
  2289  }
  2290  
  2291  jit_nfloat jit_nfloat_ieee_rem(jit_nfloat value1, jit_nfloat value2)
  2292  {
  2293  #if defined(HAVE_REMAINDERL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2294  	return remainderl(value1, value2);
  2295  #elif defined(HAVE_REMAINDER)
  2296  	return remainder(value1, value2);
  2297  #elif defined(HAVE_DREML) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2298  	return dreml(value1, value2);
  2299  #elif defined(HAVE_DREM)
  2300  	return drem(value1, value2);
  2301  #elif defined(HAVE_CEILL) && defined(HAVE_FLOORL) && \
  2302  		!defined(JIT_NFLOAT_IS_DOUBLE)
  2303  	jit_nfloat temp = value1 / value2;
  2304  	jit_nfloat ceil_value, floor_value;
  2305  	if(jit_nfloat_is_nan(temp))
  2306  	{
  2307  		return temp;
  2308  	}
  2309  	ceil_value = ceill(temp);
  2310  	floor_value = floorl(temp);
  2311  	if((temp - floor_value) < (jit_nfloat)0.5)
  2312  	{
  2313  		temp = floor_value;
  2314  	}
  2315  	else if((temp - floor_value) > (jit_nfloat)0.5)
  2316  	{
  2317  		temp = ceil_value;
  2318  	}
  2319  	else if((floor(ceil_value / (jit_nfloat)2.0) * (jit_nfloat)2.0)
  2320  				== ceil_value)
  2321  	{
  2322  		temp = ceil_value;
  2323  	}
  2324  	else
  2325  	{
  2326  		temp = floor_value;
  2327  	}
  2328  	return value1 - temp * value2;
  2329  #elif defined(HAVE_CEIL) && defined(HAVE_FLOOR)
  2330  	jit_nfloat temp = value1 / value2;
  2331  	jit_nfloat ceil_value, floor_value;
  2332  	if(jit_nfloat_is_nan(temp))
  2333  	{
  2334  		return temp;
  2335  	}
  2336  	ceil_value = ceil(temp);
  2337  	floor_value = floor(temp);
  2338  	if((temp - floor_value) < (jit_nfloat)0.5)
  2339  	{
  2340  		temp = floor_value;
  2341  	}
  2342  	else if((temp - floor_value) > (jit_nfloat)0.5)
  2343  	{
  2344  		temp = ceil_value;
  2345  	}
  2346  	else if((floor(ceil_value / (jit_nfloat)2.0) * (jit_nfloat)2.0)
  2347  				== ceil_value)
  2348  	{
  2349  		temp = ceil_value;
  2350  	}
  2351  	else
  2352  	{
  2353  		temp = floor_value;
  2354  	}
  2355  	return value1 - temp * value2;
  2356  #else
  2357  	/* Don't know how to compute remainders on this platform */
  2358  	return (jit_nfloat)(0.0 / 0.0);
  2359  #endif
  2360  }
  2361  
  2362  jit_nfloat jit_nfloat_neg(jit_nfloat value1)
  2363  {
  2364  	return -value1;
  2365  }
  2366  
  2367  jit_int jit_nfloat_eq(jit_nfloat value1, jit_nfloat value2)
  2368  {
  2369  	return (value1 == value2);
  2370  }
  2371  
  2372  jit_int jit_nfloat_ne(jit_nfloat value1, jit_nfloat value2)
  2373  {
  2374  	return (value1 != value2);
  2375  }
  2376  
  2377  jit_int jit_nfloat_lt(jit_nfloat value1, jit_nfloat value2)
  2378  {
  2379  	return (value1 < value2);
  2380  }
  2381  
  2382  jit_int jit_nfloat_le(jit_nfloat value1, jit_nfloat value2)
  2383  {
  2384  	return (value1 <= value2);
  2385  }
  2386  
  2387  jit_int jit_nfloat_gt(jit_nfloat value1, jit_nfloat value2)
  2388  {
  2389  	return (value1 > value2);
  2390  }
  2391  
  2392  jit_int jit_nfloat_ge(jit_nfloat value1, jit_nfloat value2)
  2393  {
  2394  	return (value1 >= value2);
  2395  }
  2396  
  2397  jit_int jit_nfloat_cmpl(jit_nfloat value1, jit_nfloat value2)
  2398  {
  2399  	if(jit_nfloat_is_nan(value1) || jit_nfloat_is_nan(value2))
  2400  	{
  2401  		return -1;
  2402  	}
  2403  	else if(value1 < value2)
  2404  	{
  2405  		return -1;
  2406  	}
  2407  	else if(value1 > value2)
  2408  	{
  2409  		return 1;
  2410  	}
  2411  	else
  2412  	{
  2413  		return 0;
  2414  	}
  2415  }
  2416  
  2417  jit_int jit_nfloat_cmpg(jit_nfloat value1, jit_nfloat value2)
  2418  {
  2419  	if(jit_nfloat_is_nan(value1) || jit_nfloat_is_nan(value2))
  2420  	{
  2421  		return 1;
  2422  	}
  2423  	else if(value1 < value2)
  2424  	{
  2425  		return -1;
  2426  	}
  2427  	else if(value1 > value2)
  2428  	{
  2429  		return 1;
  2430  	}
  2431  	else
  2432  	{
  2433  		return 0;
  2434  	}
  2435  }
  2436  
  2437  jit_nfloat jit_nfloat_abs(jit_nfloat value1)
  2438  {
  2439  	if(jit_nfloat_is_nan(value1))
  2440  	{
  2441  		return jit_nfloat_nan;
  2442  	}
  2443  	return ((value1 >= 0) ? value1 : -value1);
  2444  }
  2445  
  2446  jit_nfloat jit_nfloat_min(jit_nfloat value1, jit_nfloat value2)
  2447  {
  2448  	if(jit_nfloat_is_nan(value1) || jit_nfloat_is_nan(value2))
  2449  	{
  2450  		return jit_nfloat_nan;
  2451  	}
  2452  	return ((value1 <= value2) ? value1 : value2);
  2453  }
  2454  
  2455  jit_nfloat jit_nfloat_max(jit_nfloat value1, jit_nfloat value2)
  2456  {
  2457  	if(jit_nfloat_is_nan(value1) || jit_nfloat_is_nan(value2))
  2458  	{
  2459  		return jit_nfloat_nan;
  2460  	}
  2461  	return ((value1 >= value2) ? value1 : value2);
  2462  }
  2463  
  2464  jit_int jit_nfloat_sign(jit_nfloat value1)
  2465  {
  2466  	if(jit_nfloat_is_nan(value1))
  2467  	{
  2468  		return 0;
  2469  	}
  2470  	else if(value1 < 0)
  2471  	{
  2472  		return -1;
  2473  	}
  2474  	else if(value1 > 0)
  2475  	{
  2476  		return 0;
  2477  	}
  2478  	else
  2479  	{
  2480  		return 0;
  2481  	}
  2482  }
  2483  
  2484  /*@
  2485   * @deftypefun jit_nfloat jit_nfloat_acos (jit_nfloat @var{value1})
  2486   * @deftypefunx jit_nfloat jit_nfloat_asin (jit_nfloat @var{value1})
  2487   * @deftypefunx jit_nfloat jit_nfloat_atan (jit_nfloat @var{value1})
  2488   * @deftypefunx jit_nfloat jit_nfloat_atan2 (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2489   * @deftypefunx jit_nfloat jit_nfloat_cos (jit_nfloat @var{value1})
  2490   * @deftypefunx jit_nfloat jit_nfloat_cosh (jit_nfloat @var{value1})
  2491   * @deftypefunx jit_nfloat jit_nfloat_exp (jit_nfloat @var{value1})
  2492   * @deftypefunx jit_nfloat jit_nfloat_log (jit_nfloat @var{value1})
  2493   * @deftypefunx jit_nfloat jit_nfloat_log10 (jit_nfloat @var{value1})
  2494   * @deftypefunx jit_nfloat jit_nfloat_pow (jit_nfloat @var{value1}, jit_nfloat @var{value2})
  2495   * @deftypefunx jit_nfloat jit_nfloat_sin (jit_nfloat @var{value1})
  2496   * @deftypefunx jit_nfloat jit_nfloat_sinh (jit_nfloat @var{value1})
  2497   * @deftypefunx jit_nfloat jit_nfloat_sqrt (jit_nfloat @var{value1})
  2498   * @deftypefunx jit_nfloat jit_nfloat_tan (jit_nfloat @var{value1})
  2499   * @deftypefunx jit_nfloat jit_nfloat_tanh (jit_nfloat @var{value1})
  2500   * Apply a mathematical function to one or two native floating-point values.
  2501   * @end deftypefun
  2502  @*/
  2503  jit_nfloat jit_nfloat_acos(jit_nfloat value1)
  2504  {
  2505  #if defined(HAVE_ACOSL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2506  	return (jit_nfloat)(acosl(value1));
  2507  #elif defined(HAVE_ACOS)
  2508  	return (jit_nfloat)(acos(value1));
  2509  #else
  2510  	return jit_nfloat_nan;
  2511  #endif
  2512  }
  2513  
  2514  jit_nfloat jit_nfloat_asin(jit_nfloat value1)
  2515  {
  2516  #if defined(HAVE_ASINL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2517  	return (jit_nfloat)(asinl(value1));
  2518  #elif defined(HAVE_ASIN)
  2519  	return (jit_nfloat)(asin(value1));
  2520  #else
  2521  	return jit_nfloat_nan;
  2522  #endif
  2523  }
  2524  
  2525  jit_nfloat jit_nfloat_atan(jit_nfloat value1)
  2526  {
  2527  #if defined(HAVE_ATANL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2528  	return (jit_nfloat)(atanl(value1));
  2529  #elif defined(HAVE_ATAN)
  2530  	return (jit_nfloat)(atan(value1));
  2531  #else
  2532  	return jit_nfloat_nan;
  2533  #endif
  2534  }
  2535  
  2536  jit_nfloat jit_nfloat_atan2(jit_nfloat value1, jit_nfloat value2)
  2537  {
  2538  #if defined(HAVE_ATAN2L) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2539  	return (jit_nfloat)(atan2l(value1, value2));
  2540  #elif defined(HAVE_ATAN2)
  2541  	return (jit_nfloat)(atan2(value1, value2));
  2542  #else
  2543  	return jit_nfloat_nan;
  2544  #endif
  2545  }
  2546  
  2547  jit_nfloat jit_nfloat_cos(jit_nfloat value1)
  2548  {
  2549  #if defined(HAVE_COSL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2550  	return (jit_nfloat)(cosl(value1));
  2551  #elif defined(HAVE_COS)
  2552  	return (jit_nfloat)(cos(value1));
  2553  #else
  2554  	return jit_nfloat_nan;
  2555  #endif
  2556  }
  2557  
  2558  jit_nfloat jit_nfloat_cosh(jit_nfloat value1)
  2559  {
  2560  #if defined(HAVE_COSHL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2561  	return (jit_nfloat)(coshl(value1));
  2562  #elif defined(HAVE_COSH)
  2563  	return (jit_nfloat)(cosh(value1));
  2564  #else
  2565  	return jit_nfloat_nan;
  2566  #endif
  2567  }
  2568  
  2569  jit_nfloat jit_nfloat_exp(jit_nfloat value1)
  2570  {
  2571  #if defined(HAVE_EXPL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2572  	return (jit_nfloat)(expl(value1));
  2573  #elif defined(HAVE_EXP)
  2574  	return (jit_nfloat)(exp(value1));
  2575  #else
  2576  	return jit_nfloat_nan;
  2577  #endif
  2578  }
  2579  
  2580  jit_nfloat jit_nfloat_log(jit_nfloat value1)
  2581  {
  2582  #if defined(HAVE_LOGL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2583  	return (jit_nfloat)(logl(value1));
  2584  #elif defined(HAVE_LOG)
  2585  	return (jit_nfloat)(log(value1));
  2586  #else
  2587  	return jit_nfloat_nan;
  2588  #endif
  2589  }
  2590  
  2591  jit_nfloat jit_nfloat_log10(jit_nfloat value1)
  2592  {
  2593  #if defined(HAVE_LOG10L) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2594  	return (jit_nfloat)(log10l(value1));
  2595  #elif defined(HAVE_LOG10)
  2596  	return (jit_nfloat)(log10(value1));
  2597  #else
  2598  	return jit_nfloat_nan;
  2599  #endif
  2600  }
  2601  
  2602  jit_nfloat jit_nfloat_pow(jit_nfloat value1, jit_nfloat value2)
  2603  {
  2604  #if defined(HAVE_POWL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2605  	return (jit_nfloat)(powl(value1, value2));
  2606  #elif defined(HAVE_POW)
  2607  	return (jit_nfloat)(pow(value1, value2));
  2608  #else
  2609  	return jit_nfloat_nan;
  2610  #endif
  2611  }
  2612  
  2613  jit_nfloat jit_nfloat_sin(jit_nfloat value1)
  2614  {
  2615  #if defined(HAVE_SINL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2616  	return (jit_nfloat)(sinl(value1));
  2617  #elif defined(HAVE_SIN)
  2618  	return (jit_nfloat)(sin(value1));
  2619  #else
  2620  	return jit_nfloat_nan;
  2621  #endif
  2622  }
  2623  
  2624  jit_nfloat jit_nfloat_sinh(jit_nfloat value1)
  2625  {
  2626  #if defined(HAVE_SINHL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2627  	return (jit_nfloat)(sinhl(value1));
  2628  #elif defined(HAVE_SINH)
  2629  	return (jit_nfloat)(sinh(value1));
  2630  #else
  2631  	return jit_nfloat_nan;
  2632  #endif
  2633  }
  2634  
  2635  jit_nfloat jit_nfloat_sqrt(jit_nfloat value1)
  2636  {
  2637  	/* Some platforms give a SIGFPE for negative arguments (e.g. Alpha) */
  2638  	if(value1 < (jit_nfloat)0.0)
  2639  	{
  2640  		return jit_nfloat_nan;
  2641  	}
  2642  #if defined(HAVE_SQRTL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2643  	return (jit_nfloat)(sqrtl(value1));
  2644  #elif defined(HAVE_SQRT)
  2645  	return (jit_nfloat)(sqrt(value1));
  2646  #else
  2647  	return jit_nfloat_nan;
  2648  #endif
  2649  }
  2650  
  2651  jit_nfloat jit_nfloat_tan(jit_nfloat value1)
  2652  {
  2653  #if defined(HAVE_TANL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2654  	return (jit_nfloat)(tanl(value1));
  2655  #elif defined(HAVE_TAN)
  2656  	return (jit_nfloat)(tan(value1));
  2657  #else
  2658  	return jit_nfloat_nan;
  2659  #endif
  2660  }
  2661  
  2662  jit_nfloat jit_nfloat_tanh(jit_nfloat value1)
  2663  {
  2664  #if defined(HAVE_TANHL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2665  	return (jit_nfloat)(tanhl(value1));
  2666  #elif defined(HAVE_TANH)
  2667  	return (jit_nfloat)(tanh(value1));
  2668  #else
  2669  	return jit_nfloat_nan;
  2670  #endif
  2671  }
  2672  
  2673  /*@
  2674   * @deftypefun jit_int jit_nfloat_is_finite (jit_nfloat @var{value})
  2675   * Determine if a native floating point value is finite, returning
  2676   * non-zero if it is, or zero if it is not.  If the value is
  2677   * "not a number", this function returns zero.
  2678   * @end deftypefun
  2679  @*/
  2680  jit_int jit_nfloat_is_finite(jit_nfloat value)
  2681  {
  2682  #if defined(hpux) || defined(JIT_WIN32_PLATFORM)
  2683  	return isfinite(value);
  2684  #else /* !hpux */
  2685  #if defined(HAVE_FINITEL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2686  	return finitel(value);
  2687  #elif defined(HAVE_FINITE)
  2688  	return isfinite(value);
  2689  #else /* !HAVE_FINITE */
  2690  #if defined(HAVE_ISNANL) && defined(HAVE_ISINFL) && \
  2691  		!defined(JIT_NFLOAT_IS_DOUBLE)
  2692  	return (!isnanl(value) && isinfl(value) == 0);
  2693  #elif defined(HAVE_ISNAN) && defined(HAVE_ISINF)
  2694  	return (!isnan(value) && isinf(value) == 0);
  2695  #else
  2696  	#error "Don't know how to determine if floating point numbers are finite"
  2697  	return 1;
  2698  #endif
  2699  #endif /* !HAVE_FINITE */
  2700  #endif /* !hpux */
  2701  }
  2702  
  2703  /*@
  2704   * @deftypefun jit_int jit_nfloat_is_nan (jit_nfloat @var{value})
  2705   * Determine if a native floating point value is "not a number", returning
  2706   * non-zero if it is, or zero if it is not.
  2707   * @end deftypefun
  2708  @*/
  2709  jit_int jit_nfloat_is_nan(jit_nfloat value)
  2710  {
  2711  #if defined(HAVE_ISNANL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2712  	return isnanl(value);
  2713  #elif defined(HAVE_ISNAN)
  2714  	return isnan(value);
  2715  #else
  2716  	return (value != value);
  2717  #endif
  2718  }
  2719  
  2720  /*@
  2721   * @deftypefun jit_int jit_nfloat_is_inf (jit_nfloat @var{value})
  2722   * Determine if a native floating point value is infinite or not.
  2723   * Returns -1 for negative infinity, 1 for positive infinity,
  2724   * and 0 for everything else.
  2725   *
  2726   * Note: this function is preferable to the system @code{isinf} intrinsic
  2727   * because some systems have a broken @code{isinf} function that returns
  2728   * 1 for both positive and negative infinity.
  2729   * @end deftypefun
  2730  @*/
  2731  jit_int jit_nfloat_is_inf(jit_nfloat value)
  2732  {
  2733  	/* The code below works around broken "isinf" implementations */
  2734  #if defined(HAVE_ISINFL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2735  	if(isinfl(value) == 0)
  2736  	{
  2737  		return 0;
  2738  	}
  2739  #elif defined(HAVE_ISINF)
  2740  	if(isinf(value) == 0)
  2741  	{
  2742  		return 0;
  2743  	}
  2744  #else
  2745  	if(jit_nfloat_is_nan(value) || jit_nfloat_is_finite(value))
  2746  	{
  2747  		return 0;
  2748  	}
  2749  #endif
  2750  	if(value < (jit_nfloat)0.0)
  2751  	{
  2752  		return -1;
  2753  	}
  2754  	else
  2755  	{
  2756  		return 1;
  2757  	}
  2758  }
  2759  
  2760  /*@
  2761   * Floatingpoint rounding operations.defined by ieee754
  2762   * @deftypefun jit_float32 jit_float32_rint (jit_float32 @var{value1})
  2763   * @deftypefunx jit_float64 jit_float64_rint (jit_float64 @var{value1})
  2764   * @deftypefunx jit_nfloat jit_nfloat_rint (jit_nfloat @var{value1})
  2765   * Round @var{value1} to the nearest integer.  Half-way cases
  2766   * are rounded to an even number.
  2767   * @end deftypefun
  2768   * @deftypefun jit_float32 jit_float32_ceil (jit_float32 @var{value1})
  2769   * @deftypefunx jit_float64 jit_float64_ceil (jit_float64 @var{value1})
  2770   * @deftypefunx jit_nfloat jit_nfloat_ceil (jit_nfloat @var{value1})
  2771   * Round @var{value1} up towards positive infinity.
  2772   * @end deftypefun
  2773   * @deftypefun jit_float32 jit_float32_floor (jit_float32 @var{value1})
  2774   * @deftypefunx jit_float64 jit_float64_floor (jit_float64 @var{value1})
  2775   * @deftypefunx jit_nfloat jit_nfloat_floor (jit_nfloat @var{value1})
  2776   * Round @var{value1} down towards negative infinity.
  2777   * @end deftypefun
  2778   * @deftypefun jit_float32 jit_float32_trunc (jit_float32 @var{value1})
  2779   * @deftypefunx jit_float64 jit_float64_trunc (jit_float64 @var{value1})
  2780   * @deftypefunx jit_nfloat jit_nfloat_trunc (jit_nfloat @var{value1})
  2781   * Round @var{value1} towards zero.
  2782   * @end deftypefun
  2783  @*/
  2784  
  2785  /*
  2786   * NOTE: rint rounds the value according to the current rounding mode.
  2787   * The default rounding mode is round to nearest with half way cases
  2788   * rounded to the even number. So there is no need to set the rounding
  2789   * mode here.
  2790   */
  2791  jit_float32 jit_float32_rint(jit_float32 value1)
  2792  {
  2793  #ifdef HAVE_RINTF
  2794  	return (jit_float32)rintf(value1);
  2795  #elif defined(HAVE_RINT)
  2796  	return (jit_float32)(rint(value1));
  2797  #else
  2798  	jit_float32 above, below;
  2799  	if(!jit_float32_is_finite(value1))
  2800  	{
  2801  		return value1;
  2802  	}
  2803  	above = jit_float32_ceil(value1);
  2804  	below = jit_float32_floor(value1);
  2805  	if((above - value1) < (jit_float32)0.5)
  2806  	{
  2807  		return above;
  2808  	}
  2809  	else if((value1 - below) < (jit_float32)0.5)
  2810  	{
  2811  		return below;
  2812  	}
  2813  	else if(jit_float32_ieee_rem(above, (jit_float32)2.0) == (jit_float32)0.0)
  2814  	{
  2815  		return above;
  2816  	}
  2817  	else
  2818  	{
  2819  		return below;
  2820  	}
  2821  #endif
  2822  }
  2823  
  2824  jit_float64 jit_float64_rint(jit_float64 value1)
  2825  {
  2826  #ifdef HAVE_RINT
  2827  	return (jit_float64)rint(value1);
  2828  #else
  2829  	jit_float64 above, below;
  2830  	if(!jit_float64_is_finite(value1))
  2831  	{
  2832  		return value1;
  2833  	}
  2834  	above = jit_float64_ceil(value1);
  2835  	below = jit_float64_floor(value1);
  2836  	if((above - value1) < (jit_float64)0.5)
  2837  	{
  2838  		return above;
  2839  	}
  2840  	else if((value1 - below) < (jit_float64)0.5)
  2841  	{
  2842  		return below;
  2843  	}
  2844  	else if(jit_float64_ieee_rem(above, (jit_float64)2.0) == (jit_float64)0.0)
  2845  	{
  2846  		return above;
  2847  	}
  2848  	else
  2849  	{
  2850  		return below;
  2851  	}
  2852  #endif
  2853  }
  2854  
  2855  jit_nfloat jit_nfloat_rint(jit_nfloat value1)
  2856  {
  2857  #if defined(HAVE_RINTL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2858  	return (jit_nfloat)(rintl(value1));
  2859  #elif defined(HAVE_RINT) && defined(JIT_NFLOAT_IS_DOUBLE)
  2860  	return (jit_nfloat)(rint(value1));
  2861  #else
  2862  	jit_nfloat above, below;
  2863  	if(!jit_nfloat_is_finite(value1))
  2864  	{
  2865  		return value1;
  2866  	}
  2867  	above = jit_nfloat_ceil(value1);
  2868  	below = jit_nfloat_floor(value1);
  2869  	if((above - value1) < (jit_nfloat)0.5)
  2870  	{
  2871  		return above;
  2872  	}
  2873  	else if((value1 - below) < (jit_nfloat)0.5)
  2874  	{
  2875  		return below;
  2876  	}
  2877  	else if(jit_nfloat_ieee_rem(above, (jit_nfloat)2.0) == (jit_nfloat)0.0)
  2878  	{
  2879  		return above;
  2880  	}
  2881  	else
  2882  	{
  2883  		return below;
  2884  	}
  2885  #endif
  2886  }
  2887  
  2888  jit_float32 jit_float32_ceil(jit_float32 value1)
  2889  {
  2890  #if defined(HAVE_CEILF)
  2891  	return (jit_float32)(ceilf(value1));
  2892  #elif defined(HAVE_CEIL)
  2893  	return (jit_float32)(ceil(value1));
  2894  #else
  2895  	return jit_float32_nan;
  2896  #endif
  2897  }
  2898  
  2899  jit_float64 jit_float64_ceil(jit_float64 value1)
  2900  {
  2901  #if defined(HAVE_CEIL)
  2902  	return (jit_float64)(ceil(value1));
  2903  #else
  2904  	return jit_float64_nan;
  2905  #endif
  2906  }
  2907  
  2908  jit_nfloat jit_nfloat_ceil(jit_nfloat value1)
  2909  {
  2910  #if defined(HAVE_CEILL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2911  	return (jit_nfloat)(ceill(value1));
  2912  #elif defined(HAVE_CEIL) && defined(JIT_NFLOAT_IS_DOUBLE)
  2913  	return (jit_nfloat)(ceil(value1));
  2914  #else
  2915  	return jit_nfloat_nan;
  2916  #endif
  2917  }
  2918  
  2919  jit_float32 jit_float32_floor(jit_float32 value1)
  2920  {
  2921  #if defined(HAVE_FLOORF)
  2922  	return (jit_float32)(floorf(value1));
  2923  #elif defined(HAVE_FLOOR)
  2924  	return (jit_float32)(floor(value1));
  2925  #else
  2926  	return jit_float32_nan;
  2927  #endif
  2928  }
  2929  
  2930  jit_float64 jit_float64_floor(jit_float64 value1)
  2931  {
  2932  #if defined(HAVE_FLOOR)
  2933  	return (jit_float64)(floor(value1));
  2934  #else
  2935  	return jit_float64_nan;
  2936  #endif
  2937  }
  2938  
  2939  jit_nfloat jit_nfloat_floor(jit_nfloat value1)
  2940  {
  2941  #if defined(HAVE_FLOORL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2942  	return (jit_nfloat)(floorl(value1));
  2943  #elif defined(HAVE_FLOOR) && defined(JIT_NFLOAT_IS_DOUBLE)
  2944  	return (jit_nfloat)(floor(value1));
  2945  #else
  2946  	return jit_nfloat_nan;
  2947  #endif
  2948  }
  2949  
  2950  jit_float32 jit_float32_trunc(jit_float32 value1)
  2951  {
  2952  #if defined(HAVE_TRUNCF)
  2953  	return (jit_float32)(truncf(value1));
  2954  #elif defined(HAVE_TRUNC)
  2955  	return (jit_float32)(trunc(value1));
  2956  #else
  2957  	if(value1 > 0)
  2958  	{
  2959  		return jit_float32_floor(value1);
  2960  	}
  2961  	else
  2962  	{
  2963  		return jit_float32_ceil(value1);
  2964  	}
  2965  #endif
  2966  }
  2967  
  2968  jit_float64 jit_float64_trunc(jit_float64 value1)
  2969  {
  2970  #if defined(HAVE_TRUNC)
  2971  	return (jit_float64)(trunc(value1));
  2972  #else
  2973  	if(value1 > 0)
  2974  	{
  2975  		return jit_float64_floor(value1);
  2976  	}
  2977  	else
  2978  	{
  2979  		return jit_float64_ceil(value1);
  2980  	}
  2981  #endif
  2982  }
  2983  
  2984  jit_nfloat jit_nfloat_trunc(jit_nfloat value1)
  2985  {
  2986  #if defined(HAVE_TRUNCL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  2987  	return (jit_nfloat)(truncl(value1));
  2988  #elif defined(HAVE_TRUNC) && defined(JIT_NFLOAT_IS_DOUBLE)
  2989  	return (jit_nfloat)(trunc(value1));
  2990  #else
  2991  	if(value1 > 0)
  2992  	{
  2993  		return jit_nfloat_floor(value1);
  2994  	}
  2995  	else
  2996  	{
  2997  		return jit_nfloat_ceil(value1);
  2998  	}
  2999  #endif
  3000  }
  3001  
  3002  /*@
  3003   * Floatingpoint rounding operations.not covered by ieee754
  3004   * @deftypefun jit_float32 jit_float32_round (jit_float32 @var{value1})
  3005   * @deftypefunx jit_float64 jit_float64_round (jit_float64 @var{value1})
  3006   * @deftypefunx jit_nfloat jit_nfloat_round (jit_nfloat @var{value1})
  3007   * Round @var{value1} to the nearest integer.  Half-way cases
  3008   * are rounded away from zero.
  3009   * @end deftypefun
  3010  @*/
  3011  jit_float32 jit_float32_round(jit_float32 value1)
  3012  {
  3013  #ifdef HAVE_ROUNDF
  3014  	return (jit_float32)roundf(value1);
  3015  #else
  3016  	jit_float32 above, below;
  3017  	if(!jit_float32_is_finite(value1))
  3018  	{
  3019  		return value1;
  3020  	}
  3021  	above = jit_float32_ceil(value1);
  3022  	below = jit_float32_floor(value1);
  3023  	if((above - value1) < (jit_float32)0.5)
  3024  	{
  3025  		return above;
  3026  	}
  3027  	else if((value1 - below) < (jit_float32)0.5)
  3028  	{
  3029  		return below;
  3030  	}
  3031  	else if(above >= (jit_float32)0.0)
  3032  	{
  3033  		return above;
  3034  	}
  3035  	else
  3036  	{
  3037  		return below;
  3038  	}
  3039  #endif
  3040  }
  3041  
  3042  jit_float64 jit_float64_round(jit_float64 value1)
  3043  {
  3044  #ifdef HAVE_ROUND
  3045  	return (jit_float64)round(value1);
  3046  #else
  3047  	jit_float64 above, below;
  3048  	if(!jit_float64_is_finite(value1))
  3049  	{
  3050  		return value1;
  3051  	}
  3052  	above = jit_float64_ceil(value1);
  3053  	below = jit_float64_floor(value1);
  3054  	if((above - value1) < (jit_float64)0.5)
  3055  	{
  3056  		return above;
  3057  	}
  3058  	else if((value1 - below) < (jit_float64)0.5)
  3059  	{
  3060  		return below;
  3061  	}
  3062  	else if(above >= (jit_float64)0.0)
  3063  	{
  3064  		return above;
  3065  	}
  3066  	else
  3067  	{
  3068  		return below;
  3069  	}
  3070  #endif
  3071  }
  3072  
  3073  jit_nfloat jit_nfloat_round(jit_nfloat value1)
  3074  {
  3075  #if defined(HAVE_ROUNDL) && !defined(JIT_NFLOAT_IS_DOUBLE)
  3076  	return (jit_nfloat)(roundl(value1));
  3077  #elif defined(HAVE_ROUND) && defined(JIT_NFLOAT_IS_DOUBLE)
  3078  	return (jit_nfloat)(round(value1));
  3079  #else
  3080  	jit_nfloat above, below;
  3081  	if(!jit_nfloat_is_finite(value1))
  3082  	{
  3083  		return value1;
  3084  	}
  3085  	above = jit_nfloat_ceil(value1);
  3086  	below = jit_nfloat_floor(value1);
  3087  	if((above - value1) < (jit_nfloat)0.5)
  3088  	{
  3089  		return above;
  3090  	}
  3091  	else if((value1 - below) < (jit_nfloat)0.5)
  3092  	{
  3093  		return below;
  3094  	}
  3095  	else if(above >= (jit_nfloat)0.0)
  3096  	{
  3097  		return above;
  3098  	}
  3099  	else
  3100  	{
  3101  		return below;
  3102  	}
  3103  #endif
  3104  }
  3105  
  3106  /*@
  3107   * @deftypefun jit_int jit_int_to_sbyte (jit_int @var{value})
  3108   * @deftypefunx jit_int jit_int_to_ubyte (jit_int @var{value})
  3109   * @deftypefunx jit_int jit_int_to_short (jit_int @var{value})
  3110   * @deftypefunx jit_int jit_int_to_ushort (jit_int @var{value})
  3111   * @deftypefunx jit_int jit_int_to_int (jit_int @var{value})
  3112   * @deftypefunx jit_uint jit_int_to_uint (jit_int @var{value})
  3113   * @deftypefunx jit_long jit_int_to_long (jit_int @var{value})
  3114   * @deftypefunx jit_ulong jit_int_to_ulong (jit_int @var{value})
  3115   * @deftypefunx jit_int jit_uint_to_int (jit_uint @var{value})
  3116   * @deftypefunx jit_uint jit_uint_to_uint (jit_uint @var{value})
  3117   * @deftypefunx jit_long jit_uint_to_long (jit_uint @var{value})
  3118   * @deftypefunx jit_ulong jit_uint_to_ulong (jit_uint @var{value})
  3119   * @deftypefunx jit_int jit_long_to_int (jit_long @var{value})
  3120   * @deftypefunx jit_uint jit_long_to_uint (jit_long @var{value})
  3121   * @deftypefunx jit_long jit_long_to_long (jit_long @var{value})
  3122   * @deftypefunx jit_ulong jit_long_to_ulong (jit_long @var{value})
  3123   * @deftypefunx jit_int jit_ulong_to_int (jit_ulong @var{value})
  3124   * @deftypefunx jit_uint jit_ulong_to_uint (jit_ulong @var{value})
  3125   * @deftypefunx jit_long jit_ulong_to_long (jit_ulong @var{value})
  3126   * @deftypefunx jit_ulong jit_ulong_to_ulong (jit_ulong @var{value})
  3127   * Convert between integer types.
  3128   * @end deftypefun
  3129  @*/
  3130  jit_int jit_int_to_sbyte(jit_int value)
  3131  {
  3132  	return (jit_int)(jit_sbyte)value;
  3133  }
  3134  
  3135  jit_int jit_int_to_ubyte(jit_int value)
  3136  {
  3137  	return (jit_int)(jit_ubyte)value;
  3138  }
  3139  
  3140  jit_int jit_int_to_short(jit_int value)
  3141  {
  3142  	return (jit_int)(jit_short)value;
  3143  }
  3144  
  3145  jit_int jit_int_to_ushort(jit_int value)
  3146  {
  3147  	return (jit_int)(jit_ushort)value;
  3148  }
  3149  
  3150  jit_int jit_int_to_int(jit_int value)
  3151  {
  3152  	return value;
  3153  }
  3154  
  3155  jit_uint jit_int_to_uint(jit_int value)
  3156  {
  3157  	return (jit_uint)value;
  3158  }
  3159  
  3160  jit_long jit_int_to_long(jit_int value)
  3161  {
  3162  	return (jit_long)value;
  3163  }
  3164  
  3165  jit_ulong jit_int_to_ulong(jit_int value)
  3166  {
  3167  	return (jit_ulong)(jit_long)value;
  3168  }
  3169  
  3170  jit_int jit_uint_to_int(jit_uint value)
  3171  {
  3172  	return (jit_int)value;
  3173  }
  3174  
  3175  jit_uint jit_uint_to_uint(jit_uint value)
  3176  {
  3177  	return value;
  3178  }
  3179  
  3180  jit_long jit_uint_to_long(jit_uint value)
  3181  {
  3182  	return (jit_long)value;
  3183  }
  3184  
  3185  jit_ulong jit_uint_to_ulong(jit_uint value)
  3186  {
  3187  	return (jit_long)value;
  3188  }
  3189  
  3190  jit_int jit_long_to_int(jit_long value)
  3191  {
  3192  	return (jit_int)value;
  3193  }
  3194  
  3195  jit_uint jit_long_to_uint(jit_long value)
  3196  {
  3197  	return (jit_uint)value;
  3198  }
  3199  
  3200  jit_long jit_long_to_long(jit_long value)
  3201  {
  3202  	return value;
  3203  }
  3204  
  3205  jit_ulong jit_long_to_ulong(jit_long value)
  3206  {
  3207  	return (jit_ulong)value;
  3208  }
  3209  
  3210  jit_int jit_ulong_to_int(jit_ulong value)
  3211  {
  3212  	return (jit_int)value;
  3213  }
  3214  
  3215  jit_uint jit_ulong_to_uint(jit_ulong value)
  3216  {
  3217  	return (jit_uint)value;
  3218  }
  3219  
  3220  jit_long jit_ulong_to_long(jit_ulong value)
  3221  {
  3222  	return (jit_long)value;
  3223  }
  3224  
  3225  jit_ulong jit_ulong_to_ulong(jit_ulong value)
  3226  {
  3227  	return value;
  3228  }
  3229  
  3230  /*@
  3231   * @deftypefun jit_int jit_int_to_sbyte_ovf (jit_int *@var{result}, jit_int @var{value})
  3232   * @deftypefunx jit_int jit_int_to_ubyte_ovf (jit_int *@var{result}, jit_int @var{value})
  3233   * @deftypefunx jit_int jit_int_to_short_ovf (jit_int *@var{result}, jit_int @var{value})
  3234   * @deftypefunx jit_int jit_int_to_ushort_ovf (jit_int *@var{result}, jit_int @var{value})
  3235   * @deftypefunx jit_int jit_int_to_int_ovf (jit_int *@var{result}, jit_int @var{value})
  3236   * @deftypefunx jit_int jit_int_to_uint_ovf (jit_uint *@var{result}, jit_int @var{value})
  3237   * @deftypefunx jit_int jit_int_to_long_ovf (jit_long *@var{result}, jit_int @var{value})
  3238   * @deftypefunx jit_int jit_int_to_ulong_ovf (jit_ulong *@var{result}, jit_int @var{value})
  3239   * @deftypefunx jit_int jit_uint_to_int_ovf (jit_int *@var{result}, jit_uint @var{value})
  3240   * @deftypefunx jit_int jit_uint_to_uint_ovf (jit_uint *@var{result}, jit_uint @var{value})
  3241   * @deftypefunx jit_int jit_uint_to_long_ovf (jit_long *@var{result}, jit_uint @var{value})
  3242   * @deftypefunx jit_int jit_uint_to_ulong_ovf (jit_ulong *@var{result}, jit_uint @var{value})
  3243   * @deftypefunx jit_int jit_long_to_int_ovf (jit_int *@var{result}, jit_long @var{value})
  3244   * @deftypefunx jit_int jit_long_to_uint_ovf (jit_uint *@var{result}, jit_long @var{value})
  3245   * @deftypefunx jit_int jit_long_to_long_ovf (jit_long *@var{result}, jit_long @var{value})
  3246   * @deftypefunx jit_int jit_long_to_ulong_ovf (jit_ulong *@var{result}, jit_long @var{value})
  3247   * @deftypefunx jit_int jit_ulong_to_int_ovf (jit_int *@var{result}, jit_ulong @var{value})
  3248   * @deftypefunx jit_int jit_ulong_to_uint_ovf (jit_uint *@var{result}, jit_ulong @var{value})
  3249   * @deftypefunx jit_int jit_ulong_to_long_ovf (jit_long *@var{result}, jit_ulong @var{value})
  3250   * @deftypefunx jit_int jit_ulong_to_ulong_ovf (jit_ulong *@var{result}, jit_ulong @var{value})
  3251   * Convert between integer types with overflow detection.
  3252   * @end deftypefun
  3253  @*/
  3254  jit_int jit_int_to_sbyte_ovf(jit_int *result, jit_int value)
  3255  {
  3256  	return ((*result = (jit_int)(jit_sbyte)value) == value);
  3257  }
  3258  
  3259  jit_int jit_int_to_ubyte_ovf(jit_int *result, jit_int value)
  3260  {
  3261  	return ((*result = (jit_int)(jit_ubyte)value) == value);
  3262  }
  3263  
  3264  jit_int jit_int_to_short_ovf(jit_int *result, jit_int value)
  3265  {
  3266  	return ((*result = (jit_int)(jit_short)value) == value);
  3267  }
  3268  
  3269  jit_int jit_int_to_ushort_ovf(jit_int *result, jit_int value)
  3270  {
  3271  	return ((*result = (jit_int)(jit_ushort)value) == value);
  3272  }
  3273  
  3274  jit_int jit_int_to_int_ovf(jit_int *result, jit_int value)
  3275  {
  3276  	*result = value;
  3277  	return 1;
  3278  }
  3279  
  3280  jit_int jit_int_to_uint_ovf(jit_uint *result, jit_int value)
  3281  {
  3282  	*result = (jit_uint)value;
  3283  	return (value >= 0);
  3284  }
  3285  
  3286  jit_int jit_int_to_long_ovf(jit_long *result, jit_int value)
  3287  {
  3288  	*result = (jit_long)value;
  3289  	return 1;
  3290  }
  3291  
  3292  jit_int jit_int_to_ulong_ovf(jit_ulong *result, jit_int value)
  3293  {
  3294  	*result = (jit_ulong)(jit_long)value;
  3295  	return (value >= 0);
  3296  }
  3297  
  3298  jit_int jit_uint_to_int_ovf(jit_int *result, jit_uint value)
  3299  {
  3300  	*result = (jit_int)value;
  3301  	return (*result >= 0);
  3302  }
  3303  
  3304  jit_int jit_uint_to_uint_ovf(jit_uint *result, jit_uint value)
  3305  {
  3306  	*result = value;
  3307  	return 1;
  3308  }
  3309  
  3310  jit_int jit_uint_to_long_ovf(jit_long *result, jit_uint value)
  3311  {
  3312  	*result = (jit_long)value;
  3313  	return 1;
  3314  }
  3315  
  3316  jit_int jit_uint_to_ulong_ovf(jit_ulong *result, jit_uint value)
  3317  {
  3318  	*result = (jit_ulong)value;
  3319  	return 1;
  3320  }
  3321  
  3322  jit_int jit_long_to_int_ovf(jit_int *result, jit_long value)
  3323  {
  3324  	*result = (jit_int)value;
  3325  	return (((jit_long)(*result)) == value);
  3326  }
  3327  
  3328  jit_int jit_long_to_uint_ovf(jit_uint *result, jit_long value)
  3329  {
  3330  	*result = (jit_uint)value;
  3331  	return (((jit_long)(*result)) == value);
  3332  }
  3333  
  3334  jit_int jit_long_to_long_ovf(jit_long *result, jit_long value)
  3335  {
  3336  	*result = value;
  3337  	return 1;
  3338  }
  3339  
  3340  jit_int jit_long_to_ulong_ovf(jit_ulong *result, jit_long value)
  3341  {
  3342  	*result = (jit_ulong)value;
  3343  	return (value >= 0);
  3344  }
  3345  
  3346  jit_int jit_ulong_to_int_ovf(jit_int *result, jit_ulong value)
  3347  {
  3348  	*result = (jit_int)value;
  3349  	return (value <= (jit_ulong)(jit_long)jit_max_int);
  3350  }
  3351  
  3352  jit_int jit_ulong_to_uint_ovf(jit_uint *result, jit_ulong value)
  3353  {
  3354  	*result = (jit_uint)value;
  3355  	return (value <= (jit_ulong)jit_max_uint);
  3356  }
  3357  
  3358  jit_int jit_ulong_to_long_ovf(jit_long *result, jit_ulong value)
  3359  {
  3360  	*result = (jit_long)value;
  3361  	return (*result >= 0);
  3362  }
  3363  
  3364  jit_int jit_ulong_to_ulong_ovf(jit_ulong *result, jit_ulong value)
  3365  {
  3366  	*result = value;
  3367  	return 1;
  3368  }
  3369  
  3370  /*@
  3371   * @deftypefun jit_int jit_float32_to_int (jit_float32 @var{value})
  3372   * @deftypefunx jit_uint jit_float32_to_uint (jit_float32 @var{value})
  3373   * @deftypefunx jit_long jit_float32_to_long (jit_float32 @var{value})
  3374   * @deftypefunx jit_ulong jit_float32_to_ulong (jit_float32 @var{value})
  3375   * Convert a 32-bit floating-point value into an integer.
  3376   * @end deftypefun
  3377  @*/
  3378  jit_int jit_float32_to_int(jit_float32 value)
  3379  {
  3380  	return (jit_int)value;
  3381  }
  3382  
  3383  jit_uint jit_float32_to_uint(jit_float32 value)
  3384  {
  3385  	return (jit_uint)value;
  3386  }
  3387  
  3388  jit_long jit_float32_to_long(jit_float32 value)
  3389  {
  3390  	return (jit_long)value;
  3391  }
  3392  
  3393  jit_ulong jit_float32_to_ulong(jit_float32 value)
  3394  {
  3395  	/* Some platforms cannot perform the conversion directly,
  3396  	   so we need to do it in stages */
  3397  	if(jit_float32_is_finite(value))
  3398  	{
  3399  		if(value >= (jit_float32)0.0)
  3400  		{
  3401  			if(value < (jit_float32)9223372036854775808.0)
  3402  			{
  3403  				return (jit_ulong)(jit_long)value;
  3404  			}
  3405  			else if(value < (jit_float32)18446744073709551616.0)
  3406  			{
  3407  				jit_long temp = (jit_long)(value - 9223372036854775808.0);
  3408  				return (jit_ulong)(temp - jit_min_long);
  3409  			}
  3410  			else
  3411  			{
  3412  				return jit_max_ulong;
  3413  			}
  3414  		}
  3415  		else
  3416  		{
  3417  			return 0;
  3418  		}
  3419  	}
  3420  	else if(jit_float32_is_nan(value))
  3421  	{
  3422  		return 0;
  3423  	}
  3424  	else if(value < (jit_float32)0.0)
  3425  	{
  3426  		return 0;
  3427  	}
  3428  	else
  3429  	{
  3430  		return jit_max_ulong;
  3431  	}
  3432  }
  3433  
  3434  /*@
  3435   * @deftypefun jit_int jit_float32_to_int_ovf (jit_int *@var{result}, jit_float32 @var{value})
  3436   * @deftypefunx jit_uint jit_float32_to_uint_ovf (jit_uint *@var{result}, jit_float32 @var{value})
  3437   * @deftypefunx jit_long jit_float32_to_long_ovf (jit_long *@var{result}, jit_float32 @var{value})
  3438   * @deftypefunx jit_ulong jit_float32_to_ulong_ovf (jit_ulong *@var{result}, jit_float32 @var{value})
  3439   * Convert a 32-bit floating-point value into an integer,
  3440   * with overflow detection.  Returns @code{JIT_RESULT_OK} if the conversion
  3441   * was successful or @code{JIT_RESULT_OVERFLOW} if an overflow occurred.
  3442   * @end deftypefun
  3443  @*/
  3444  jit_int jit_float32_to_int_ovf(jit_int *result, jit_float32 value)
  3445  {
  3446  	if(jit_float32_is_finite(value))
  3447  	{
  3448  		if(value > (jit_float32)(-2147483649.0) &&
  3449  		   value < (jit_float32)2147483648.0)
  3450  		{
  3451  			*result = jit_float32_to_int(value);
  3452  			return 1;
  3453  		}
  3454  	}
  3455  	return 0;
  3456  }
  3457  
  3458  jit_int jit_float32_to_uint_ovf(jit_uint *result, jit_float32 value)
  3459  {
  3460  	if(jit_float32_is_finite(value))
  3461  	{
  3462  		if(value >= (jit_float32)0.0 &&
  3463  		   value < (jit_float32)4294967296.0)
  3464  		{
  3465  			*result = jit_float32_to_uint(value);
  3466  			return 1;
  3467  		}
  3468  	}
  3469  	return 0;
  3470  }
  3471  
  3472  jit_int jit_float32_to_long_ovf(jit_long *result, jit_float32 value)
  3473  {
  3474  	if(jit_float32_is_finite(value))
  3475  	{
  3476  		if(value >= (jit_float32)-9223372036854775808.0 &&
  3477  		   value < (jit_float32)9223372036854775808.0)
  3478  		{
  3479  			*result = jit_float32_to_long(value);
  3480  			return 1;
  3481  		}
  3482  		else if(value < (jit_float32)0.0)
  3483  		{
  3484  			/* Account for the range -9223372036854775809.0 to
  3485  			   -9223372036854775808.0, which may get rounded
  3486  			   off if we aren't careful */
  3487  			value += (jit_float32)9223372036854775808.0;
  3488  			if(value > (jit_float32)(-1.0))
  3489  			{
  3490  				*result = jit_min_long;
  3491  				return 1;
  3492  			}
  3493  		}
  3494  	}
  3495  	return 0;
  3496  }
  3497  
  3498  jit_int jit_float32_to_ulong_ovf(jit_ulong *result, jit_float32 value)
  3499  {
  3500  	if(jit_float32_is_finite(value))
  3501  	{
  3502  		if(value >= (jit_float32)0.0)
  3503  		{
  3504  			if(value < (jit_float32)18446744073709551616.0)
  3505  			{
  3506  				*result = jit_float32_to_ulong(value);
  3507  				return 1;
  3508  			}
  3509  		}
  3510  	}
  3511  	return 0;
  3512  }
  3513  
  3514  /*@
  3515   * @deftypefun jit_int jit_float64_to_int (jit_float64 @var{value})
  3516   * @deftypefunx jit_uint jit_float64_to_uint (jit_float64 @var{value})
  3517   * @deftypefunx jit_long jit_float64_to_long (jit_float64 @var{value})
  3518   * @deftypefunx jit_ulong jit_float64_to_ulong (jit_float64 @var{value})
  3519   * Convert a 64-bit floating-point value into an integer.
  3520   * @end deftypefun
  3521  @*/
  3522  jit_int jit_float64_to_int(jit_float64 value)
  3523  {
  3524  	return (jit_int)value;
  3525  }
  3526  
  3527  jit_uint jit_float64_to_uint(jit_float64 value)
  3528  {
  3529  	return (jit_uint)value;
  3530  }
  3531  
  3532  jit_long jit_float64_to_long(jit_float64 value)
  3533  {
  3534  	return (jit_long)value;
  3535  }
  3536  
  3537  jit_ulong jit_float64_to_ulong(jit_float64 value)
  3538  {
  3539  	/* Some platforms cannot perform the conversion directly,
  3540  	   so we need to do it in stages */
  3541  	if(jit_float64_is_finite(value))
  3542  	{
  3543  		if(value >= (jit_float64)0.0)
  3544  		{
  3545  			if(value < (jit_float64)9223372036854775808.0)
  3546  			{
  3547  				return (jit_ulong)(jit_long)value;
  3548  			}
  3549  			else if(value < (jit_float64)18446744073709551616.0)
  3550  			{
  3551  				jit_long temp = (jit_long)(value - 9223372036854775808.0);
  3552  				return (jit_ulong)(temp - jit_min_long);
  3553  			}
  3554  			else
  3555  			{
  3556  				return jit_max_ulong;
  3557  			}
  3558  		}
  3559  		else
  3560  		{
  3561  			return 0;
  3562  		}
  3563  	}
  3564  	else if(jit_float64_is_nan(value))
  3565  	{
  3566  		return 0;
  3567  	}
  3568  	else if(value < (jit_float64)0.0)
  3569  	{
  3570  		return 0;
  3571  	}
  3572  	else
  3573  	{
  3574  		return jit_max_ulong;
  3575  	}
  3576  }
  3577  
  3578  /*@
  3579   * @deftypefun jit_int jit_float64_to_int_ovf (jit_int *@var{result}, jit_float64 @var{value})
  3580   * @deftypefunx jit_uint jit_float64_to_uint_ovf (jit_uint *@var{result}, jit_float64 @var{value})
  3581   * @deftypefunx jit_long jit_float64_to_long_ovf (jit_long *@var{result}, jit_float64 @var{value})
  3582   * @deftypefunx jit_ulong jit_float64_to_ulong_ovf (jit_ulong *@var{result}, jit_float64 @var{value})
  3583   * Convert a 64-bit floating-point value into an integer,
  3584   * with overflow detection.  Returns @code{JIT_RESULT_OK} if the conversion
  3585   * was successful or @code{JIT_RESULT_OVERFLOW} if an overflow occurred.
  3586   * @end deftypefun
  3587  @*/
  3588  jit_int jit_float64_to_int_ovf(jit_int *result, jit_float64 value)
  3589  {
  3590  	if(jit_float64_is_finite(value))
  3591  	{
  3592  		if(value > (jit_float64)(-2147483649.0) &&
  3593  		   value < (jit_float64)2147483648.0)
  3594  		{
  3595  			*result = jit_float64_to_int(value);
  3596  			return 1;
  3597  		}
  3598  	}
  3599  	return 0;
  3600  }
  3601  
  3602  jit_int jit_float64_to_uint_ovf(jit_uint *result, jit_float64 value)
  3603  {
  3604  	if(jit_float64_is_finite(value))
  3605  	{
  3606  		if(value >= (jit_float64)0.0 &&
  3607  		   value < (jit_float64)4294967296.0)
  3608  		{
  3609  			*result = jit_float64_to_uint(value);
  3610  			return 1;
  3611  		}
  3612  	}
  3613  	return 0;
  3614  }
  3615  
  3616  jit_int jit_float64_to_long_ovf(jit_long *result, jit_float64 value)
  3617  {
  3618  	if(jit_float64_is_finite(value))
  3619  	{
  3620  		if(value >= (jit_float64)-9223372036854775808.0 &&
  3621  		   value < (jit_float64)9223372036854775808.0)
  3622  		{
  3623  			*result = jit_float64_to_long(value);
  3624  			return 1;
  3625  		}
  3626  		else if(value < (jit_float64)0.0)
  3627  		{
  3628  			/* Account for the range -9223372036854775809.0 to
  3629  			   -9223372036854775808.0, which may get rounded
  3630  			   off if we aren't careful */
  3631  			value += (jit_float64)9223372036854775808.0;
  3632  			if(value > (jit_float64)(-1.0))
  3633  			{
  3634  				*result = jit_min_long;
  3635  				return 1;
  3636  			}
  3637  		}
  3638  	}
  3639  	return 0;
  3640  }
  3641  
  3642  jit_int jit_float64_to_ulong_ovf(jit_ulong *result, jit_float64 value)
  3643  {
  3644  	if(jit_float64_is_finite(value))
  3645  	{
  3646  		if(value >= (jit_float64)0.0)
  3647  		{
  3648  			if(value < (jit_float64)18446744073709551616.0)
  3649  			{
  3650  				*result = jit_float64_to_ulong(value);
  3651  				return 1;
  3652  			}
  3653  		}
  3654  	}
  3655  	return 0;
  3656  }
  3657  
  3658  /*@
  3659   * @deftypefun jit_int jit_nfloat_to_int (jit_nfloat @var{value})
  3660   * @deftypefunx jit_uint jit_nfloat_to_uint (jit_nfloat @var{value})
  3661   * @deftypefunx jit_long jit_nfloat_to_long (jit_nfloat @var{value})
  3662   * @deftypefunx jit_ulong jit_nfloat_to_ulong (jit_nfloat @var{value})
  3663   * Convert a native floating-point value into an integer.
  3664   * @end deftypefun
  3665  @*/
  3666  jit_int jit_nfloat_to_int(jit_nfloat value)
  3667  {
  3668  	return (jit_int)value;
  3669  }
  3670  
  3671  jit_uint jit_nfloat_to_uint(jit_nfloat value)
  3672  {
  3673  	return (jit_uint)value;
  3674  }
  3675  
  3676  jit_long jit_nfloat_to_long(jit_nfloat value)
  3677  {
  3678  	return (jit_long)value;
  3679  }
  3680  
  3681  jit_ulong jit_nfloat_to_ulong(jit_nfloat value)
  3682  {
  3683  	/* Some platforms cannot perform the conversion directly,
  3684  	   so we need to do it in stages */
  3685  	if(jit_nfloat_is_finite(value))
  3686  	{
  3687  		if(value >= (jit_nfloat)0.0)
  3688  		{
  3689  			if(value < (jit_nfloat)9223372036854775808.0)
  3690  			{
  3691  				return (jit_ulong)(jit_long)value;
  3692  			}
  3693  			else if(value < (jit_nfloat)18446744073709551616.0)
  3694  			{
  3695  				jit_long temp = (jit_long)(value - 9223372036854775808.0);
  3696  				return (jit_ulong)(temp - jit_min_long);
  3697  			}
  3698  			else
  3699  			{
  3700  				return jit_max_ulong;
  3701  			}
  3702  		}
  3703  		else
  3704  		{
  3705  			return 0;
  3706  		}
  3707  	}
  3708  	else if(jit_nfloat_is_nan(value))
  3709  	{
  3710  		return 0;
  3711  	}
  3712  	else if(value < (jit_nfloat)0.0)
  3713  	{
  3714  		return 0;
  3715  	}
  3716  	else
  3717  	{
  3718  		return jit_max_ulong;
  3719  	}
  3720  }
  3721  
  3722  /*@
  3723   * @deftypefun jit_int jit_nfloat_to_int_ovf (jit_int *@var{result}, jit_nfloat @var{value})
  3724   * @deftypefunx jit_uint jit_nfloat_to_uint_ovf (jit_uint *@var{result}, jit_nfloat @var{value})
  3725   * @deftypefunx jit_long jit_nfloat_to_long_ovf (jit_long *@var{result}, jit_nfloat @var{value})
  3726   * @deftypefunx jit_ulong jit_nfloat_to_ulong_ovf (jit_ulong *@var{result}, jit_nfloat @var{value})
  3727   * Convert a native floating-point value into an integer,
  3728   * with overflow detection.  Returns @code{JIT_RESULT_OK} if the conversion
  3729   * was successful or @code{JIT_RESULT_OVERFLOW} if an overflow occurred.
  3730   * @end deftypefun
  3731  @*/
  3732  jit_int jit_nfloat_to_int_ovf(jit_int *result, jit_nfloat value)
  3733  {
  3734  	if(jit_nfloat_is_finite(value))
  3735  	{
  3736  		if(value > (jit_nfloat)(-2147483649.0) &&
  3737  		   value < (jit_nfloat)2147483648.0)
  3738  		{
  3739  			*result = jit_nfloat_to_int(value);
  3740  			return 1;
  3741  		}
  3742  	}
  3743  	return 0;
  3744  }
  3745  
  3746  jit_int jit_nfloat_to_uint_ovf(jit_uint *result, jit_nfloat value)
  3747  {
  3748  	if(jit_nfloat_is_finite(value))
  3749  	{
  3750  		if(value >= (jit_nfloat)0.0 &&
  3751  		   value < (jit_nfloat)4294967296.0)
  3752  		{
  3753  			*result = jit_nfloat_to_uint(value);
  3754  			return 1;
  3755  		}
  3756  	}
  3757  	return 0;
  3758  }
  3759  
  3760  jit_int jit_nfloat_to_long_ovf(jit_long *result, jit_nfloat value)
  3761  {
  3762  	if(jit_nfloat_is_finite(value))
  3763  	{
  3764  		if(value >= (jit_nfloat)-9223372036854775808.0 &&
  3765  		   value < (jit_nfloat)9223372036854775808.0)
  3766  		{
  3767  			*result = jit_nfloat_to_long(value);
  3768  			return 1;
  3769  		}
  3770  		else if(value < (jit_nfloat)0.0)
  3771  		{
  3772  			/* Account for the range -9223372036854775809.0 to
  3773  			   -9223372036854775808.0, which may get rounded
  3774  			   off if we aren't careful */
  3775  			value += (jit_nfloat)9223372036854775808.0;
  3776  			if(value > (jit_nfloat)(-1.0))
  3777  			{
  3778  				*result = jit_min_long;
  3779  				return 1;
  3780  			}
  3781  		}
  3782  	}
  3783  	return 0;
  3784  }
  3785  
  3786  jit_int jit_nfloat_to_ulong_ovf(jit_ulong *result, jit_nfloat value)
  3787  {
  3788  	if(jit_nfloat_is_finite(value))
  3789  	{
  3790  		if(value >= (jit_nfloat)0.0)
  3791  		{
  3792  			if(value < (jit_nfloat)18446744073709551616.0)
  3793  			{
  3794  				*result = jit_nfloat_to_ulong(value);
  3795  				return 1;
  3796  			}
  3797  		}
  3798  	}
  3799  	return 0;
  3800  }
  3801  
  3802  /*@
  3803   * @deftypefun jit_float32 jit_int_to_float32 (jit_int @var{value})
  3804   * @deftypefunx jit_float32 jit_uint_to_float32 (jit_uint @var{value})
  3805   * @deftypefunx jit_float32 jit_long_to_float32 (jit_long @var{value})
  3806   * @deftypefunx jit_float32 jit_ulong_to_float32 (jit_ulong @var{value})
  3807   * Convert an integer into 32-bit floating-point value.
  3808   * @end deftypefun
  3809  @*/
  3810  jit_float32 jit_int_to_float32(jit_int value)
  3811  {
  3812  	return (jit_float32)value;
  3813  }
  3814  
  3815  jit_float32 jit_uint_to_float32(jit_uint value)
  3816  {
  3817  	return (jit_float32)value;
  3818  }
  3819  
  3820  jit_float32 jit_long_to_float32(jit_long value)
  3821  {
  3822  	return (jit_float32)value;
  3823  }
  3824  
  3825  jit_float32 jit_ulong_to_float32(jit_ulong value)
  3826  {
  3827  	/* Some platforms cannot perform the conversion directly,
  3828  	   so we need to do it in stages */
  3829  	if(value < (((jit_ulong)1) << 63))
  3830  	{
  3831  		return (jit_float32)(jit_long)value;
  3832  	}
  3833  	else
  3834  	{
  3835  		return (jit_float32)((jit_long)value) +
  3836  					(jit_float32)18446744073709551616.0;
  3837  	}
  3838  }
  3839  
  3840  /*@
  3841   * @deftypefun jit_float64 jit_int_to_float64 (jit_int @var{value})
  3842   * @deftypefunx jit_float64 jit_uint_to_float64 (jit_uint @var{value})
  3843   * @deftypefunx jit_float64 jit_long_to_float64 (jit_long @var{value})
  3844   * @deftypefunx jit_float64 jit_ulong_to_float64 (jit_ulong @var{value})
  3845   * Convert an integer into 64-bit floating-point value.
  3846   * @end deftypefun
  3847  @*/
  3848  jit_float64 jit_int_to_float64(jit_int value)
  3849  {
  3850  	return (jit_float64)value;
  3851  }
  3852  
  3853  jit_float64 jit_uint_to_float64(jit_uint value)
  3854  {
  3855  	return (jit_float64)value;
  3856  }
  3857  
  3858  jit_float64 jit_long_to_float64(jit_long value)
  3859  {
  3860  	return (jit_float64)value;
  3861  }
  3862  
  3863  jit_float64 jit_ulong_to_float64(jit_ulong value)
  3864  {
  3865  	/* Some platforms cannot perform the conversion directly,
  3866  	   so we need to do it in stages */
  3867  	if(value < (((jit_ulong)1) << 63))
  3868  	{
  3869  		return (jit_float64)(jit_long)value;
  3870  	}
  3871  	else
  3872  	{
  3873  		return (jit_float64)((jit_long)value) +
  3874  					(jit_float64)18446744073709551616.0;
  3875  	}
  3876  }
  3877  
  3878  /*@
  3879   * @deftypefun jit_nfloat jit_int_to_nfloat (jit_int @var{value})
  3880   * @deftypefunx jit_nfloat jit_uint_to_nfloat (jit_uint @var{value})
  3881   * @deftypefunx jit_nfloat jit_long_to_nfloat (jit_long @var{value})
  3882   * @deftypefunx jit_nfloat jit_ulong_to_nfloat (jit_ulong @var{value})
  3883   * Convert an integer into native floating-point value.
  3884   * @end deftypefun
  3885  @*/
  3886  jit_nfloat jit_int_to_nfloat(jit_int value)
  3887  {
  3888  	return (jit_nfloat)value;
  3889  }
  3890  
  3891  jit_nfloat jit_uint_to_nfloat(jit_uint value)
  3892  {
  3893  	return (jit_nfloat)value;
  3894  }
  3895  
  3896  jit_nfloat jit_long_to_nfloat(jit_long value)
  3897  {
  3898  	return (jit_nfloat)value;
  3899  }
  3900  
  3901  jit_nfloat jit_ulong_to_nfloat(jit_ulong value)
  3902  {
  3903  	/* Some platforms cannot perform the conversion directly,
  3904  	   so we need to do it in stages */
  3905  	if(value < (((jit_ulong)1) << 63))
  3906  	{
  3907  		return (jit_nfloat)(jit_long)value;
  3908  	}
  3909  	else
  3910  	{
  3911  		return (jit_nfloat)((jit_long)value) +
  3912  					(jit_nfloat)18446744073709551616.0;
  3913  	}
  3914  }
  3915  
  3916  /*@
  3917   * @deftypefun jit_float64 jit_float32_to_float64 (jit_float32 @var{value})
  3918   * @deftypefunx jit_nfloat jit_float32_to_nfloat (jit_float32 @var{value})
  3919   * @deftypefunx jit_float32 jit_float64_to_float32 (jit_float64 @var{value})
  3920   * @deftypefunx jit_nfloat jit_float64_to_nfloat (jit_float64 @var{value})
  3921   * @deftypefunx jit_float32 jit_nfloat_to_float32 (jit_nfloat @var{value})
  3922   * @deftypefunx jit_float64 jit_nfloat_to_float64 (jit_nfloat @var{value})
  3923   * Convert between floating-point types.
  3924   * @end deftypefun
  3925  @*/
  3926  jit_float64 jit_float32_to_float64(jit_float32 value)
  3927  {
  3928  	return (jit_float64)value;
  3929  }
  3930  
  3931  jit_nfloat jit_float32_to_nfloat(jit_float32 value)
  3932  {
  3933  	return (jit_nfloat)value;
  3934  }
  3935  
  3936  jit_float32 jit_float64_to_float32(jit_float64 value)
  3937  {
  3938  	return (jit_float32)value;
  3939  }
  3940  
  3941  jit_nfloat jit_float64_to_nfloat(jit_float64 value)
  3942  {
  3943  	return (jit_nfloat)value;
  3944  }
  3945  
  3946  jit_float32 jit_nfloat_to_float32(jit_nfloat value)
  3947  {
  3948  	return (jit_float32)value;
  3949  }
  3950  
  3951  jit_float64 jit_nfloat_to_float64(jit_nfloat value)
  3952  {
  3953  	return (jit_float64)value;
  3954  }