remove half, and add macro toggle in ap_* headers

This commit is contained in:
Yuanjie Huang 2018-11-28 21:14:19 -08:00
parent 5ae3fee9fa
commit dc612ceee3
11 changed files with 42 additions and 7732 deletions

View file

@ -53,6 +53,7 @@
// ----------------------------------------------------------------------
// Forward declaration of all AP types.
#include <ap_decl.h>
// Macro functions
@ -593,7 +594,7 @@ static inline unsigned char guess_radix(const char* s) {
// ----------------------------------------------------------------------
// Forward declaration of all AP types.
#ifdef _AP_ENABLE_HALF_
// Before ap_private definition.
#ifdef __SYNTHESIS__
#define _HLS_HALF_DEFINED_
@ -601,13 +602,6 @@ typedef __fp16 half;
#else
class half;
#endif
// FIXME previously, ap_int_syn.h includes hls_half.h, which includes cmath.h
// even during synthesis. Some test cases are spoiled...
#ifdef __cplusplus
#ifndef __SYNTHESIS__
#include <cmath>
#endif
#endif
// ----------------------------------------------------------------------
@ -706,6 +700,7 @@ INLINE unsigned int floatToRawBits(float pf) {
return LD.__L;
}
#ifdef _AP_ENABLE_HALF_
INLINE unsigned short halfToRawBits(half pf) {
#ifdef __SYNTHESIS__
union {
@ -718,6 +713,7 @@ INLINE unsigned short halfToRawBits(half pf) {
return pf.get_bits();
#endif
}
#endif
// usigned long long is at least 64-bit
INLINE double rawBitsToDouble(ap_ulong pi) {
@ -739,6 +735,7 @@ INLINE float rawBitsToFloat(unsigned long pi) {
return LD.__D;
}
#ifdef _AP_ENABLE_HALF_
// short is at least 16-bit
INLINE half rawBitsToHalf(unsigned short pi) {
#ifdef __SYNTHESIS__
@ -755,6 +752,7 @@ INLINE half rawBitsToHalf(unsigned short pi) {
return __D;
#endif
}
#endif
#endif // ifndef __AP_COMMON_H__ else

View file

@ -175,7 +175,9 @@ struct ap_fixed : ap_fixed_base<_AP_W, _AP_I, true, _AP_Q, _AP_O, _AP_N> {
CTOR(unsigned long)
CTOR(ap_slong)
CTOR(ap_ulong)
#ifdef _AP_ENABLE_HALF_
CTOR(half)
#endif
CTOR(float)
CTOR(double)
#undef CTOR
@ -323,7 +325,9 @@ struct ap_ufixed : ap_fixed_base<_AP_W, _AP_I, false, _AP_Q, _AP_O, _AP_N> {
CTOR(unsigned long)
CTOR(ap_slong)
CTOR(ap_ulong)
#ifdef _AP_ENABLE_HALF_
CTOR(half)
#endif
CTOR(float)
CTOR(double)
#undef CTOR

View file

@ -60,8 +60,10 @@
// for ap_int_base and its reference types.
#include <ap_int.h>
#ifndef __SYNTHESIS__
#ifdef _AP_ENABLE_HALF_
// for half type
#include <hls_half.h>
#endif
// for std io
#include <iostream>
#endif
@ -670,8 +672,10 @@ struct ap_fixed_base : _AP_ROOT_TYPE<_AP_W, _AP_S> {
// TODO more optimized implementation.
INLINE ap_fixed_base(float d) { *this = ap_fixed_base(double(d)); }
#ifdef _AP_ENABLE_HALF_
// TODO more optimized implementation.
INLINE ap_fixed_base(half d) { *this = ap_fixed_base(double(d)); }
#endif
// @}
/// @name assign operator
@ -970,6 +974,7 @@ struct ap_fixed_base : _AP_ROOT_TYPE<_AP_W, _AP_S> {
return rawBitsToFloat(m);
}
#ifdef _AP_ENABLE_HALF_
/// convert function to half.
/** only round-half-to-even mode supported, does not obey FE env. */
INLINE half to_half() const {
@ -1016,6 +1021,7 @@ struct ap_fixed_base : _AP_ROOT_TYPE<_AP_W, _AP_S> {
// cast to fp
return rawBitsToHalf(m);
}
#endif
// FIXME inherited from old code, this may loose precision!
INLINE operator long double() const { return (long double)to_double(); }
@ -1024,7 +1030,9 @@ struct ap_fixed_base : _AP_ROOT_TYPE<_AP_W, _AP_S> {
INLINE operator float() const { return to_float(); }
#ifdef _AP_ENABLE_HALF_
INLINE operator half() const { return to_half(); }
#endif
INLINE operator bool() const { return (bool)Base::V != 0; }

View file

@ -157,7 +157,9 @@ struct ap_int : ap_int_base<_AP_W, true> {
#undef CTOR
ap_int(double val) : Base(val) {}
ap_int(float val) : Base(val) {}
#ifdef _AP_ENABLE_HALF_
ap_int(half val) : Base(val) {}
#endif
// ap_int_base will guess radix if radix is not provided.
INLINE ap_int(const char* s) : Base(s) {}
@ -289,7 +291,9 @@ struct ap_uint : ap_int_base<_AP_W, false> {
#undef CTOR
ap_uint(double val) : Base(val) {}
ap_uint(float val) : Base(val) {}
#ifdef _AP_ENABLE_HALF_
ap_uint(half val) : Base(val) {}
#endif
// ap_int_base will guess radix if radix is not provided.
INLINE ap_uint(const char* s) : Base(s) {}

View file

@ -63,7 +63,9 @@
#include <ap_common.h>
#ifndef __SYNTHESIS__
#ifdef _AP_ENABLE_HALF_
#include <hls_half.h>
#endif
#include <iostream>
#include <string.h>
#endif
@ -250,12 +252,14 @@ struct ap_int_base : public _AP_ROOT_TYPE<_AP_W, _AP_S> {
CTOR_FROM_INT(ap_ulong, _AP_SIZE_ap_slong, false)
#undef CTOR_FROM_INT
#ifdef _AP_ENABLE_HALF_
/// ctor from half.
// TODO optimize
INLINE ap_int_base(half op) {
ap_int_base<_AP_W, _AP_S> t((float)op);
Base::V = t.V;
}
#endif
/// ctor from float.
INLINE ap_int_base(float op) {
@ -1426,7 +1430,9 @@ OP_BIN_WITH_PTR(-)
OP_BIN_WITH_FLOAT(+, C_TYPE) \
OP_BIN_WITH_FLOAT(-, C_TYPE)
#ifdef _AP_ENABLE_HALF_
ALL_OP_WITH_FLOAT(half)
#endif
ALL_OP_WITH_FLOAT(float)
ALL_OP_WITH_FLOAT(double)

View file

@ -86,9 +86,6 @@ typedef unsigned __int64 uint64_t;
#include <stdint.h>
#endif
// FIXME eventually, this should have nothing to do with half.
#include "hls_half.h"
#ifndef INLINE
#define INLINE inline
// Enable to debug ap_int/ap_fixed
@ -1484,10 +1481,11 @@ ASSIGN_OP_FROM_INT(long)
ASSIGN_OP_FROM_INT(unsigned long)
ASSIGN_OP_FROM_INT(ap_slong)
ASSIGN_OP_FROM_INT(ap_ulong)
#if 0
ASSIGN_OP_FROM_INT(half)
//FIXME cast half to integer ?
ASSIGN_OP_FROM_INT(float)
ASSIGN_OP_FROM_INT(double)
#endif
#undef ASSIGN_OP_FROM_INT
// XXX This is a must to prevent pointer being converted to bool.
@ -1646,9 +1644,11 @@ ASSIGN_OP_FROM_INT(double)
CTOR(unsigned long)
CTOR(ap_slong)
CTOR(ap_ulong)
#if 0
CTOR(half)
CTOR(float)
CTOR(double)
#endif
#undef CTOR
template <int _AP_W1, bool _AP_S1, bool _AP_OPT>
@ -2494,9 +2494,11 @@ ASSIGN_OP_FROM_INT(double)
OP_LEFT_SHIFT_CTYPE(unsigned long, false)
OP_LEFT_SHIFT_CTYPE(long long, true)
OP_LEFT_SHIFT_CTYPE(unsigned long long, false)
#if 0
OP_LEFT_SHIFT_CTYPE(half, false)
OP_LEFT_SHIFT_CTYPE(float, false)
OP_LEFT_SHIFT_CTYPE(double, false)
#endif
#undef OP_LEFT_SHIFT_CTYPE
@ -2538,9 +2540,11 @@ ASSIGN_OP_FROM_INT(double)
OP_RIGHT_SHIFT_CTYPE(unsigned long, false)
OP_RIGHT_SHIFT_CTYPE(unsigned long long, false)
OP_RIGHT_SHIFT_CTYPE(long long, true)
#if 0
OP_RIGHT_SHIFT_CTYPE(half, false)
OP_RIGHT_SHIFT_CTYPE(float, false)
OP_RIGHT_SHIFT_CTYPE(double, false)
#endif
#undef OP_RIGHT_SHIFT_CTYPE
@ -3368,9 +3372,11 @@ class ap_private<_AP_W, _AP_S, false> {
CTOR(unsigned long, false)
CTOR(ap_slong, true)
CTOR(ap_ulong, false)
#if 0
CTOR(half, false)
CTOR(float, false)
CTOR(double, false)
#endif
#undef CTOR
/// @returns true if the number of bits <= 64, false otherwise.
@ -3955,9 +3961,11 @@ class ap_private<_AP_W, _AP_S, false> {
OP_LEFT_SHIFT_CTYPE(unsigned long, false)
OP_LEFT_SHIFT_CTYPE(unsigned long long, false)
OP_LEFT_SHIFT_CTYPE(long long, true)
#if 0
OP_LEFT_SHIFT_CTYPE(half, false)
OP_LEFT_SHIFT_CTYPE(float, false)
OP_LEFT_SHIFT_CTYPE(double, false)
#endif
#undef OP_LEFT_SHIFT_CTYPE
template <int _AP_W2, bool _AP_S2>
@ -3998,9 +4006,11 @@ class ap_private<_AP_W, _AP_S, false> {
OP_RIGHT_SHIFT_CTYPE(unsigned long, false)
OP_RIGHT_SHIFT_CTYPE(unsigned long long, false)
OP_RIGHT_SHIFT_CTYPE(long long, true)
#if 0
OP_RIGHT_SHIFT_CTYPE(half, false)
OP_RIGHT_SHIFT_CTYPE(float, false)
OP_RIGHT_SHIFT_CTYPE(double, false)
#endif
#undef OP_RIGHT_SHIFT_CTYPE
template <int _AP_W2, bool _AP_S2>

View file

@ -1,371 +0,0 @@
//----------------------------------------------------------------------------
// ____ ____
// / /\/ /
// /___/ \ / Vendor: Xilinx
// \ \ \/ Version: 6.0
// \ \ Filename: $RCSfile: floating_point_v7_0_bitacc_cmodel.h,v $
// / / Date Last Modified: $Date: 2011/06/15 13:06:43 $
// /___/ /\ Date Created: 2011
//
// Device : All
// Library : floating_point_v7_0
// Purpose : Header file for bit accurate model of Floating Point Operator
// Revision: $Revision: 1.6.6.2 $
//
//------------------------------------------------------------------------------
// (c) Copyright 2011-2012 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
// laws.
//
// DISCLAIMER
// This disclaimer is not a license and does not grant any
// rights to the materials distributed herewith. Except as
// otherwise provided in a valid license issued to you by
// Xilinx, and to the maximum extent permitted by applicable
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
// (2) Xilinx shall not be liable (whether in contract or tort,
// including negligence, or under any other theory of
// liability) for any loss or damage of any kind or nature
// related to, arising under or in connection with these
// materials, including for any direct, or any indirect,
// special, incidental, or consequential loss or damage
// (including loss of data, profits, goodwill, or any type of
// loss or damage suffered as a result of any action brought
// by a third party) even if such damage or loss was
// reasonably foreseeable or Xilinx had been advised of the
// possibility of the same.
//
// CRITICAL APPLICATIONS
// Xilinx products are not designed or intended to be fail-
// safe, or for use in any application requiring fail-safe
// performance, such as life-support or safety devices or
// systems, Class III medical devices, nuclear facilities,
// applications related to the deployment of airbags, or any
// other applications that could lead to death, personal
// injury, or severe property or environmental damage
// (individually and collectively, "Critical
// Applications"). Customer assumes the sole risk and
// liability of any use of Xilinx products in Critical
// Applications, subject only to applicable laws and
// regulations governing limitations on product liability.
//
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
// PART OF THIS FILE AT ALL TIMES.
//------------------------------------------------------------------------------
#ifndef __xip_fpo_bitacc_cmodel_h
#define __xip_fpo_bitacc_cmodel_h
#ifdef NT
#define __XIP_FPO_DLLIMPORT __declspec(dllimport)
#define __XIP_FPO_DLLEXPORT __declspec(dllexport)
#else
#define __XIP_FPO_DLLIMPORT
#define __XIP_FPO_DLLEXPORT
#endif
// Only define __XIP_FPO_BUILD_DLL when building the C model DLL; do not define it when using the C model
#ifdef __XIP_FPO_BUILD_DLL
#define __XIP_FPO_DLL __XIP_FPO_DLLEXPORT
#else
#define __XIP_FPO_DLL __XIP_FPO_DLLIMPORT
#endif
/* Extra define for functions with variable numbers of arguments */
#define __XIP_FPO_SENTINEL_ATTR
#if defined (__GNUC__)
# if __GNUC__ >= 4
# undef __XIP_FPO_SENTINEL_ATTR
# define __XIP_FPO_SENTINEL_ATTR __attribute__ ((sentinel))
# endif
#endif
/* Define Floating Point Operator core version number */
#define XIP_FPO_VERSION_MAJOR 6
#define XIP_FPO_VERSION_MINOR 2
#define XIP_FPO_REVISION 0
/* Version string does not include revision if revision is 0 (revision >0 reserved for future use) */
#define XIP_FPO_VERSION_STRING "6.2"
/* Use C99 exact width integer types for 64-bit integers and *_uj and *_sj functions */
// For Windows platforms, stdint.h and inttypes.h are not present in Visual Studio 2005/2008
// Therefore we define the required types ourselves
// For Linux platforms, we need to continue using stdint.h (and not re-define intmax_t, uintmax_t)
// because SysGen already uses this header.
#ifdef NT
typedef signed char xint8;
typedef signed short xint16;
typedef signed int xint32;
typedef signed long long xint64;
typedef unsigned char xuint8;
typedef unsigned short xuint16;
typedef unsigned int xuint32;
typedef unsigned long long xuint64;
typedef xint64 intmax_t;
typedef xuint64 uintmax_t;
#else
#include <stdint.h>
typedef int8_t xint8;
typedef int16_t xint16;
typedef int32_t xint32;
typedef int64_t xint64;
typedef uint8_t xuint8;
typedef uint16_t xuint16;
typedef uint32_t xuint32;
typedef uint64_t xuint64;
#endif
#include <stdbool.h>
// REVISIT: included before mpfr.h to permit definition of prototypes for mpfr_printf
#include <stdio.h>
// Force MPFR to use intmax_t and uintmax_t types (the compiled libraries have the functions that use these)
#define MPFR_USE_INTMAX_T
// Tell MPIR on Windows platforms that it is compiled into a DLL
#ifdef NT
#define __GMP_LIBGMP_DLL 1
#endif
/* Check if GMP is included, and try to include it (Works with local GMP)
Note that where MPIR is provided as a compatible alternative to GMP,
it also provides a gmp.h header file to allow MPIR and GMP to be easily interchanged.
Select the correct gmp.h by setting the -I option (includes path) for your compiler. */
#ifndef __GMP_H__
#include <gmp.h>
#endif
/* Check if MPFR is included, and try to include it (Works with local MPFR) */
#ifndef __MPFR_H
#include <mpfr.h>
#endif
/* Precision of mantissa or exponent (bits) */
typedef long xip_fpo_prec_t;
/* Definition of sign */
typedef int xip_fpo_sign_t;
/* Definition of exponent */
typedef long xip_fpo_exp_t;
/* The main floating point number structure */
typedef struct {
xip_fpo_prec_t _xip_fpo_exp_prec;
xip_fpo_prec_t _xip_fpo_mant_prec;
xip_fpo_sign_t _xip_fpo_sign;
xip_fpo_exp_t _xip_fpo_exp;
mp_limb_t *_xip_fpo_d;
} __xip_fpo_struct;
/* The main fixed point number structure */
typedef struct {
xip_fpo_prec_t _xip_fpo_i_prec;
xip_fpo_prec_t _xip_fpo_frac_prec;
xint64 _xip_fpo_i;
xint64 _xip_fpo_frac;
} __xip_fpo_fix_struct;
/* User-visible types for floating point and fixed point numbers */
typedef __xip_fpo_struct xip_fpo_t[1];
typedef __xip_fpo_fix_struct xip_fpo_fix_t[1];
/* Pointers to floating point and fixed point numbers, for function prototypes */
typedef __xip_fpo_struct *xip_fpo_ptr;
typedef const __xip_fpo_struct *xip_fpo_srcptr;
typedef __xip_fpo_fix_struct *xip_fpo_fix_ptr;
typedef const __xip_fpo_fix_struct *xip_fpo_fix_srcptr;
/* Definition of exception flags - return type of most functions
Flags are as follows:
bit 0 : underflow
bit 1 : overflow
bit 2 : invalid operation
bit 3 : divide by zero
bit 4 : operation not supported
bit 5 : Accumulator Input Overflow
bit 6 : Accumulator Overflow
*/
typedef int xip_fpo_exc_t;
#ifdef __cplusplus
extern "C" {
#endif
typedef struct xil_fpo_accum_state xil_fpo_accum_state;
/* Information functions */
__XIP_FPO_DLL const char * xip_fpo_get_version (void);
/* Initialization functions */
__XIP_FPO_DLL void xip_fpo_init2 (xip_fpo_ptr, xip_fpo_prec_t, xip_fpo_prec_t);
__XIP_FPO_DLL void xip_fpo_fix_init2 (xip_fpo_fix_ptr, xip_fpo_prec_t, xip_fpo_prec_t);
__XIP_FPO_DLL void xip_fpo_inits2 (xip_fpo_prec_t, xip_fpo_prec_t, xip_fpo_ptr, ...) __XIP_FPO_SENTINEL_ATTR;
__XIP_FPO_DLL void xip_fpo_fix_inits2 (xip_fpo_prec_t, xip_fpo_prec_t, xip_fpo_fix_ptr, ...) __XIP_FPO_SENTINEL_ATTR;
__XIP_FPO_DLL void xip_fpo_clear (xip_fpo_ptr);
__XIP_FPO_DLL void xip_fpo_fix_clear (xip_fpo_fix_ptr);
__XIP_FPO_DLL void xip_fpo_clears (xip_fpo_ptr, ...) __XIP_FPO_SENTINEL_ATTR;
__XIP_FPO_DLL void xip_fpo_fix_clears (xip_fpo_fix_ptr, ...) __XIP_FPO_SENTINEL_ATTR;
__XIP_FPO_DLL void xip_fpo_set_prec (xip_fpo_ptr, xip_fpo_prec_t, xip_fpo_prec_t);
__XIP_FPO_DLL void xip_fpo_fix_set_prec (xip_fpo_fix_ptr, xip_fpo_prec_t, xip_fpo_prec_t);
__XIP_FPO_DLL xip_fpo_prec_t xip_fpo_get_prec_mant (xip_fpo_ptr);
__XIP_FPO_DLL xip_fpo_prec_t xip_fpo_get_prec_exp (xip_fpo_ptr);
__XIP_FPO_DLL xip_fpo_prec_t xip_fpo_fix_get_prec_frac (xip_fpo_fix_ptr);
__XIP_FPO_DLL xip_fpo_prec_t xip_fpo_fix_get_prec_int (xip_fpo_fix_ptr);
/* Assignment functions */
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set (xip_fpo_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set (xip_fpo_fix_ptr, xip_fpo_fix_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_ui (xip_fpo_ptr, unsigned long);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_ui (xip_fpo_fix_ptr, unsigned long);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_si (xip_fpo_ptr, long);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_si (xip_fpo_fix_ptr, long);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_uj (xip_fpo_ptr, uintmax_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_uj (xip_fpo_fix_ptr, uintmax_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_sj (xip_fpo_ptr, intmax_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_sj (xip_fpo_fix_ptr, intmax_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_flt (xip_fpo_ptr, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_flt (xip_fpo_fix_ptr, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_d (xip_fpo_ptr, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_d (xip_fpo_fix_ptr, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_z (xip_fpo_ptr, mpz_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_z (xip_fpo_fix_ptr, mpz_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_q (xip_fpo_ptr, mpq_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_q (xip_fpo_fix_ptr, mpq_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_f (xip_fpo_ptr, mpf_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_f (xip_fpo_fix_ptr, mpf_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_fr (xip_fpo_ptr, mpfr_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_fr (xip_fpo_fix_ptr, mpfr_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_ui_2exp (xip_fpo_ptr, unsigned long, xip_fpo_exp_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_si_2exp (xip_fpo_ptr, long, xip_fpo_exp_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_uj_2exp (xip_fpo_ptr, uintmax_t, intmax_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_sj_2exp (xip_fpo_ptr, intmax_t, intmax_t);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_set_str (xip_fpo_ptr, const char *, int);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_set_str (xip_fpo_fix_ptr, const char *, int);
__XIP_FPO_DLL void xip_fpo_set_nan (xip_fpo_ptr);
__XIP_FPO_DLL void xip_fpo_set_inf (xip_fpo_ptr, int);
__XIP_FPO_DLL void xip_fpo_set_zero (xip_fpo_ptr, int);
/* Conversion functions */
__XIP_FPO_DLL unsigned long xip_fpo_get_ui (xip_fpo_srcptr);
__XIP_FPO_DLL unsigned long xip_fpo_fix_get_ui (xip_fpo_fix_srcptr);
__XIP_FPO_DLL long xip_fpo_get_si (xip_fpo_srcptr);
__XIP_FPO_DLL long xip_fpo_fix_get_si (xip_fpo_fix_srcptr);
__XIP_FPO_DLL uintmax_t xip_fpo_get_uj (xip_fpo_srcptr);
__XIP_FPO_DLL uintmax_t xip_fpo_fix_get_uj (xip_fpo_fix_srcptr);
__XIP_FPO_DLL intmax_t xip_fpo_get_sj (xip_fpo_srcptr);
__XIP_FPO_DLL intmax_t xip_fpo_fix_get_sj (xip_fpo_fix_srcptr);
__XIP_FPO_DLL float xip_fpo_get_flt (xip_fpo_srcptr);
__XIP_FPO_DLL float xip_fpo_fix_get_flt (xip_fpo_fix_srcptr);
__XIP_FPO_DLL double xip_fpo_get_d (xip_fpo_srcptr);
__XIP_FPO_DLL double xip_fpo_fix_get_d (xip_fpo_fix_srcptr);
__XIP_FPO_DLL double xip_fpo_get_d_2exp (long *, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_get_z (mpz_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_get_z (mpz_ptr, xip_fpo_fix_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_get_f (mpf_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_get_f (mpf_ptr, xip_fpo_fix_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_get_fr (mpfr_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fix_get_fr (mpfr_ptr, xip_fpo_fix_srcptr);
__XIP_FPO_DLL char * xip_fpo_get_str (char *, xip_fpo_exp_t *, int, int, xip_fpo_srcptr);
__XIP_FPO_DLL char * xip_fpo_fix_get_str (char *, int, xip_fpo_fix_srcptr);
__XIP_FPO_DLL void xip_fpo_free_str (char *);
__XIP_FPO_DLL void xip_fpo_fix_free_str (char *);
__XIP_FPO_DLL int xip_fpo_sizeinbase (xip_fpo_srcptr, int);
__XIP_FPO_DLL int xip_fpo_fix_sizeinbase (xip_fpo_fix_srcptr, int);
/* Operation functions */
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_add (xip_fpo_ptr, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_add_flt (float *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_add_d (double *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_sub (xip_fpo_ptr, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_sub_flt (float *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_sub_d (double *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_mul (xip_fpo_ptr, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_mul_flt (float *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_mul_d (double *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fma (xip_fpo_ptr, xip_fpo_srcptr, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fma_flt (float *, float, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fma_d (double *, double, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fms (xip_fpo_ptr, xip_fpo_srcptr, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fms_flt (float *, float, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fms_d (double *, double, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_div (xip_fpo_ptr, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_div_flt (float *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_div_d (double *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_rec (xip_fpo_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_rec_flt (float *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_rec_d (double *, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_abs (xip_fpo_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_abs_flt (float *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_abs_d (double *, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_log (xip_fpo_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_log_flt (float *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_log_d (double *, double);
__XIP_FPO_DLL int xip_fpo_exp_array (xip_fpo_t * , xip_fpo_t * , xip_fpo_exc_t *, unsigned long long);
__XIP_FPO_DLL void xip_fpo_exp_flt_array (float * , float * , xip_fpo_exc_t *, unsigned long long);
__XIP_FPO_DLL void xip_fpo_exp_d_array (double * , double * , xip_fpo_exc_t *, unsigned long long);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_exp (xip_fpo_ptr , xip_fpo_srcptr );
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_exp_flt (float * , float );
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_exp_d (double * , double );
__XIP_FPO_DLL struct xil_fpo_accum_state * xip_fpo_accum_create_state (int , int , int , int , int);
__XIP_FPO_DLL void xip_fpo_accum_reset_state (struct xil_fpo_accum_state *);
__XIP_FPO_DLL void xip_fpo_accum_destroy_state (struct xil_fpo_accum_state *);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_accum_sample (xip_fpo_t, xip_fpo_t, bool, struct xil_fpo_accum_state *);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_accum_sample_flt (float *, float , bool, struct xil_fpo_accum_state *);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_accum_sample_d (double *, double , bool, struct xil_fpo_accum_state *);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_sqrt (xip_fpo_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_sqrt_flt (float *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_sqrt_d (double *, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_recsqrt (xip_fpo_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_recsqrt_flt (float *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_recsqrt_d (double *, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_unordered (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_unordered_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_unordered_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_equal (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_equal_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_equal_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_less (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_less_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_less_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_lessequal (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_lessequal_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_lessequal_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_greater (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_greater_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_greater_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_greaterequal (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_greaterequal_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_greaterequal_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_notequal (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_notequal_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_notequal_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_condcode (int *, xip_fpo_srcptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_condcode_flt (int *, float, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_condcode_d (int *, double, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttofix (xip_fpo_fix_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttofix_int_flt (int *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttofix_int_d (int *, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fixtoflt (xip_fpo_ptr, xip_fpo_fix_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fixtoflt_flt_int (float *, int);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_fixtoflt_d_int (double *, int);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttoflt (xip_fpo_ptr, xip_fpo_srcptr);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttoflt_flt_flt (float *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttoflt_flt_d (float *, double);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttoflt_d_flt (double *, float);
__XIP_FPO_DLL xip_fpo_exc_t xip_fpo_flttoflt_d_d (double *, double);
#ifdef __cplusplus
} /* End of "C" linkage block */
#endif
#endif // __xip_fpo_bitacc_cmodel_h

File diff suppressed because it is too large Load diff

View file

@ -1,665 +0,0 @@
/* -*- c -*-*/
/*
#- (c) Copyright 2011-2019 Xilinx, Inc. All rights reserved.
#-
#- This file contains confidential and proprietary information
#- of Xilinx, Inc. and is protected under U.S. and
#- international copyright and other intellectual property
#- laws.
#-
#- DISCLAIMER
#- This disclaimer is not a license and does not grant any
#- rights to the materials distributed herewith. Except as
#- otherwise provided in a valid license issued to you by
#- Xilinx, and to the maximum extent permitted by applicable
#- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
#- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
#- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
#- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
#- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
#- (2) Xilinx shall not be liable (whether in contract or tort,
#- including negligence, or under any other theory of
#- liability) for any loss or damage of any kind or nature
#- related to, arising under or in connection with these
#- materials, including for any direct, or any indirect,
#- special, incidental, or consequential loss or damage
#- (including loss of data, profits, goodwill, or any type of
#- loss or damage suffered as a result of any action brought
#- by a third party) even if such damage or loss was
#- reasonably foreseeable or Xilinx had been advised of the
#- possibility of the same.
#-
#- CRITICAL APPLICATIONS
#- Xilinx products are not designed or intended to be fail-
#- safe, or for use in any application requiring fail-safe
#- performance, such as life-support or safety devices or
#- systems, Class III medical devices, nuclear facilities,
#- applications related to the deployment of airbags, or any
#- other applications that could lead to death, personal
#- injury, or severe property or environmental damage
#- (individually and collectively, "Critical
#- Applications"). Customer assumes the sole risk and
#- liability of any use of Xilinx products in Critical
#- Applications, subject only to applicable laws and
#- regulations governing limitations on product liability.
#-
#- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
#- PART OF THIS FILE AT ALL TIMES.
#- ************************************************************************
*
*
*/
#ifndef __AESL_FPO_H__
#define __AESL_FPO_H__
#ifndef __SYNTHESIS__
#include <math.h>
#endif
#include <assert.h>
#if defined __arm__ && !(defined HLS_NO_XIL_FPO_LIB)
#warning "Xilinx Floating Point Operator IP core does not provide simulation models for ARM architecture. Automatically defining HLS_NO_XIL_FPO_LIB in order to avoid this library dependency, although bit-accurate simulation of some functions is no longer possible. You can make this warning go away by adding this define yourself before including any other files."
#define HLS_NO_XIL_FPO_LIB
#endif
#ifdef __SYNTHESIS__
#define HLS_FPO_SQRTF(a) __builtin_sqrtf(a)
#define HLS_FPO_SQRT(a) __builtin_sqrt(a)
#define HLS_FPO_RECSQRTF(a) (1.0f/__builtin_sqrtf(a))
#define HLS_FPO_RECSQRT(a) (1.0/__builtin_sqrt(a))
#define HLS_FPO_ABSF(a) __builtin_fabsf(a)
#define HLS_FPO_ABS(a) __builtin_fabs(a)
#define HLS_FPO_LOGF(a) __builtin_logf(a)
#define HLS_FPO_LOG(a) __builtin_log(a)
#define HLS_FPO_EXPF(a) __builtin_expf(a)
#define HLS_FPO_EXP(a) __builtin_exp(a)
#else// csim
#ifdef HLS_NO_XIL_FPO_LIB
#define HLS_FPO_SQRTF(a) sqrtf(a)
#define HLS_FPO_SQRT(a) sqrt(a)
#define HLS_FPO_RECSQRTF(a) (1.0f/sqrtf(a))
#define HLS_FPO_RECSQRT(a) (1.0/sqrt(a))
#define HLS_FPO_ABSF(a) fabsf(a)
#define HLS_FPO_ABS(a) fabs(a)
#define HLS_FPO_LOGF(a) logf(a)
#define HLS_FPO_LOG(a) log(a)
#define HLS_FPO_EXPF(a) expf(a)
#define HLS_FPO_EXP(a) exp(a)
#else
#define HLS_FPO_SQRTF(a) xil_fpo_sqrt_flt(a)
#define HLS_FPO_SQRT(a) xil_fpo_sqrt_d(a)
#define HLS_FPO_RECSQRTF(a) xil_fpo_recsqrt_flt(a)
#define HLS_FPO_RECSQRT(a) xil_fpo_recsqrt_d(a)
#define HLS_FPO_ABSF(a) xil_fpo_abs_flt(a)
#define HLS_FPO_ABS(a) xil_fpo_abs_d(a)
#define HLS_FPO_LOGF(a) xil_fpo_log_flt(a)
#define HLS_FPO_LOG(a) xil_fpo_log_d(a)
#define HLS_FPO_EXPF(a) xil_fpo_exp_flt(a)
#define HLS_FPO_EXP(a) xil_fpo_exp_d(a)
#endif //HLS_NO_XIL_FPO_LIB
#endif //__SYNTHESIS__
#if (defined __SYNTHESIS__ || defined HLS_NO_XIL_FPO_LIB)
#define HLS_FPO_ADDF(a,b) ((a) + (b))
#define HLS_FPO_ADD(a,b) ((a) + (b))
#define HLS_FPO_SUBF(a,b) ((a) - (b))
#define HLS_FPO_SUB(a,b) ((a) - (b))
#define HLS_FPO_MULF(a,b) ((a) * (b))
#define HLS_FPO_MUL(a,b) ((a) * (b))
#define HLS_FPO_DIVF(a,b) ((a)/(b))
#define HLS_FPO_DIV(a,b) ((a)/(b))
#define HLS_FPO_RECF(a) (1.0f/(a))
#define HLS_FPO_RECIPF(a) HLS_FPO_RECF(a)
#define HLS_FPO_REC(a) (1.0/(a))
#define HLS_FPO_RECIP(a) HLS_FPO_REC(a)
#define HLS_FPO_RSQRTF(a) HLS_FPO_RECSQRTF(a)
#define HLS_FPO_RSQRT(a) HLS_FPO_RECSQRT(a)
//#define HLS_FPO_UNORDEREDF(a,b)
//#define HLS_FPO_UNORDERED(a,b)
#define HLS_FPO_EQUALF(a,b) ((a) == (b))
#define HLS_FPO_EQUAL(a,b) ((a) == (b))
#define HLS_FPO_LESSF(a,b) ((a) < (b))
#define HLS_FPO_LESS(a,b) ((a) < (b))
#define HLS_FPO_LESSEQUALF(a,b) ((a) <= (b))
#define HLS_FPO_LESSEQUAL(a,b) ((a) <= (b))
#define HLS_FPO_GREATERF(a,b) ((a) > (b))
#define HLS_FPO_GREATER(a,b) ((a) > (b))
#define HLS_FPO_GREATEREQUALF(a,b) ((a) >= (b))
#define HLS_FPO_GREATEREQUAL(a,b) ((a) >= (b))
#define HLS_FPO_NOTEQUALF(a,b) ((a) != (b))
#define HLS_FPO_NOTEQUAL(a,b) ((a) != (b))
//#define HLS_FPO_CONDCODEF(a,b)
//#define HLS_FPO_CONDCODE(a,b)
#define HLS_FPO_FTOI(a) ((int)(a))
#define HLS_FPO_DTOI(a) ((int)(a))
#define HLS_FPO_ITOF(a) ((float)(a))
#define HLS_FPO_ITOD(a) ((double)(a))
#define HLS_FPO_FTOF(a) ((float)(a))
#define HLS_FPO_DTOF(a) ((float)(a))
#define HLS_FPO_FTOD(a) ((double)(a))
#define HLS_FPO_DTOD(a) ((double)(a))
#else
#define HLS_FPO_ADDF(a,b) xil_fpo_add_flt(a,b)
#define HLS_FPO_ADD(a,b) xil_fpo_add_d(a,b)
#define HLS_FPO_SUBF(a,b) xil_fpo_sub_flt(a,b)
#define HLS_FPO_SUB(a,b) xil_fpo_sub_d(a,b)
#define HLS_FPO_MULF(a,b) xil_fpo_mul_flt(a,b)
#define HLS_FPO_MUL(a,b) xil_fpo_mul_d(a,b)
#define HLS_FPO_DIVF(a,b) xil_fpo_div_flt(a,b)
#define HLS_FPO_DIV(a,b) xil_fpo_div_d(a,b)
#define HLS_FPO_RECF(a) xil_fpo_rec_flt(a)
#define HLS_FPO_RECIPF(a) HLS_FPO_RECF(a)
#define HLS_FPO_REC(a) xil_fpo_rec_d(a)
#define HLS_FPO_RECIP(a) HLS_FPO_REC(a)
#define HLS_FPO_RSQRTF(a) HLS_FPO_RECSQRTF(a)
#define HLS_FPO_RSQRT(a) HLS_FPO_RECSQRT(a)
#define HLS_FPO_UNORDEREDF(a,b) xil_fpo_unordered_flt(a,b)
#define HLS_FPO_UNORDERED(a,b) xil_fpo_unordered_d(a,b)
#define HLS_FPO_EQUALF(a,b) xil_fpo_equal_flt(a,b)
#define HLS_FPO_EQUAL(a,b) xil_fpo_equal_d(a,b)
#define HLS_FPO_LESSF(a,b) xil_fpo_less_flt(a,b)
#define HLS_FPO_LESS(a,b) xil_fpo_less_d(a,b)
#define HLS_FPO_LESSEQUALF(a,b) xil_fpo_lessequal_flt(a,b)
#define HLS_FPO_LESSEQUAL(a,b) xil_fpo_lessequal_d(a,b)
#define HLS_FPO_GREATERF(a,b) xil_fpo_greater_flt(a,b)
#define HLS_FPO_GREATER(a,b) xil_fpo_greater_d(a,b)
#define HLS_FPO_GREATEREQUALF(a,b) xil_fpo_greaterequal_flt(a,b)
#define HLS_FPO_GREATEREQUAL(a,b) xil_fpo_greaterequal_d(a,b)
#define HLS_FPO_NOTEQUALF(a,b) xil_fpo_notequal_flt(a,b)
#define HLS_FPO_NOTEQUAL(a,b) xil_fpo_notequal_d(a,b)
#define HLS_FPO_CONDCODEF(a,b) xil_fpo_condcode_flt(a,b)
#define HLS_FPO_CONDCODE(a,b) xil_fpo_condcode_d(a,b)
#define HLS_FPO_FTOI(a) xil_fpo_flttofix_int_flt(a)
#define HLS_FPO_DTOI(a) xil_fpo_flttofix_int_d(a)
#define HLS_FPO_ITOF(a) xil_fpo_fixtoflt_flt_int(a)
#define HLS_FPO_ITOD(a) xil_fpo_fixtoflt_d_int(a)
#define HLS_FPO_FTOF(a) xil_fpo_flttoflt_flt_flt(a)
#define HLS_FPO_DTOF(a) xil_fpo_flttoflt_flt_d(a)
#define HLS_FPO_FTOD(a) xil_fpo_flttoflt_d_flt(a)
#define HLS_FPO_DTOD(a) xil_fpo_flttoflt_d_d(a)
#include "floating_point_v7_0_bitacc_cmodel.h" // Must include before GMP and MPFR
#include "gmp.h"
#include "mpfr.h"
////////////////////////////////////////////////////////////////////////
// Operation functions: add
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_add_flt(float a, float b)
{
float res_flt = 0.0f;
// xip_fpo_add_flt
xip_fpo_add_flt(&res_flt, a, b); // normal operation
return res_flt;
}
inline double xil_fpo_add_d(double a, double b)
{
double res_d = 0.0;
// xip_fpo_add_d
xip_fpo_add_d(&res_d, a, b); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: subtract
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_sub_flt(float a, float b)
{
float res_flt = 0.0f;
// xip_fpo_sub_flt
xip_fpo_sub_flt(&res_flt, a, b); // normal operation
return res_flt;
}
inline double xil_fpo_sub_d(double a, double b)
{
double res_d = 0.0;
// xip_fpo_sub_d
xip_fpo_sub_d(&res_d, a, b); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: multiply
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_mul_flt(float a, float b)
{
float res_flt = 0.0f;
// xip_fpo_mul_flt
xip_fpo_mul_flt(&res_flt, a, b); // normal operation
return res_flt;
}
inline double xil_fpo_mul_d(double a, double b)
{
double res_d = 0.0;
// xip_fpo_mul_d
xip_fpo_mul_d(&res_d, a, b); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: divide
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_div_flt(float a, float b)
{
float res_flt = 0.0f;
// xip_fpo_div_flt
xip_fpo_div_flt(&res_flt, a, b); // normal operation
return res_flt;
}
inline double xil_fpo_div_d(double a, double b)
{
double res_d = 0.0;
// xip_fpo_div_d
xip_fpo_div_d(&res_d, a, b); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: reciprocal
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_rec_flt(float a)
{
float res_flt = 0.0f;
// xip_fpo_rec_flt
xip_fpo_rec_flt(&res_flt, a); // normal operation
return res_flt;
}
inline double xil_fpo_rec_d(double a)
{
double res_d = 0.0;
// xip_fpo_rec_d
xip_fpo_rec_d(&res_d, a); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: square root
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_sqrt_flt(float a)
{
// printf("Testing operation functions: square root\n");
float res_flt = 0.0f;
// xip_fpo_sqrt_flt
xip_fpo_sqrt_flt(&res_flt, a); // normal operation
// printf("float = sqrtf(a), and got res_flt=%f\n", res_flt);
return res_flt;
}
inline double xil_fpo_sqrt_d(double a)
{
double res_d = 0.0;
// xip_fpo_sqrt_d
xip_fpo_sqrt_d(&res_d, a); // normal operation
// printf("double = sqrt(a), and got res_d=%f\n", res_d);
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: reciprocal square root
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_recsqrt_flt(float a)
{
float res_flt = 0.0f;
// xip_fpo_recsqrt_flt
xip_fpo_recsqrt_flt(&res_flt, a); // normal operation
return res_flt;
}
inline double xil_fpo_recsqrt_d(double a)
{
double res_d = 0.0;
// xip_fpo_recsqrt_d
xip_fpo_recsqrt_d(&res_d, a); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: absolute value
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_abs_flt(float a)
{
float res_flt = 0.0f;
xip_fpo_abs_flt(&res_flt, a);
return res_flt;
}
inline double xil_fpo_abs_d(double a)
{
double res_d = 0.0;
xip_fpo_abs_d(&res_d, a);
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: logarithm
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_log_flt(float a)
{
float res_flt = 0.0f;
// xip_fpo_log_flt
xip_fpo_log_flt(&res_flt, a); // normal operation
return res_flt;
}
inline double xil_fpo_log_d(double a)
{
double res_d = 0.0;
// xip_fpo_log_d
xip_fpo_log_d(&res_d, a); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: Exponential
////////////////////////////////////////////////////////////////////////
inline float xil_fpo_exp_flt(float a)
{
float res_flt = 0.0f;
// xip_fpo_exp_flt
xip_fpo_exp_flt(&res_flt, a); // normal operation
return res_flt;
}
inline double xil_fpo_exp_d(double a)
{
double res_d = 0.0;
// xip_fpo_exp_d
xip_fpo_exp_d(&res_d, a); // normal operation
return res_d;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare unordered
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_unordered_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_unordered_flt
xip_fpo_unordered_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_unordered_d(double a, double b)
{
int res_int = 0;
// xip_fpo_unordered_d
xip_fpo_unordered_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare equal
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_equal_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_equal_flt
xip_fpo_equal_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_equal_d(double a, double b)
{
int res_int = 0;
// xip_fpo_equal_d
xip_fpo_equal_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare less than
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_less_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_less_flt
xip_fpo_less_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_less_d(double a, double b)
{
int res_int = 0;
// xip_fpo_less_d
xip_fpo_less_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare less than or equal
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_lessequal_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_lessequal_flt
xip_fpo_lessequal_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_lessequal_d(double a, double b)
{
int res_int = 0;
// xip_fpo_lessequal_d
xip_fpo_lessequal_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare greater than
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_greater_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_greater_flt
xip_fpo_greater_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_greater_d(double a, double b)
{
int res_int = 0;
// xip_fpo_greater_d
xip_fpo_greater_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare greater than or equal
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_greaterequal_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_greaterequal_flt
xip_fpo_greaterequal_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_greaterequal_d(double a, double b)
{
int res_int = 0;
// xip_fpo_greaterequal_d
xip_fpo_greaterequal_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare not equal
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_notequal_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_notequal_flt
xip_fpo_notequal_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_notequal_d(double a, double b)
{
int res_int = 0;
xip_fpo_notequal_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Operation functions: compare condition code
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_condcode_flt(float a, float b)
{
int res_int = 0;
// xip_fpo_condcode_flt
xip_fpo_condcode_flt(&res_int, a, b); // normal operation
return res_int;
}
inline int xil_fpo_condcode_d(double a, double b)
{
int res_int = 0;
// xip_fpo_condcode_d
xip_fpo_condcode_d(&res_int, a, b); // normal operation
return res_int;
}
////////////////////////////////////////////////////////////////////////
// Conversion functions: conversion code
////////////////////////////////////////////////////////////////////////
inline int xil_fpo_flttofix_int_flt(float a)
{
int res_int = 0;
// xip_fpo_flttofix_int_flt
xip_fpo_flttofix_int_flt(&res_int, a); // normal operation
return res_int;
}
inline int xil_fpo_flttofix_int_d(double a)
{
int res_int = 0;
// xip_fpo_flttofix_int_d
xip_fpo_flttofix_int_d(&res_int, a); // normal operation
return res_int;
}
inline float xil_fpo_fixtoflt_flt_int(int a)
{
float res_flt = 0.0f;
// xip_fpo_fixtoflt_flt_int
xip_fpo_fixtoflt_flt_int(&res_flt, a); // normal operation
return res_flt;
}
inline double xil_fpo_fixtoflt_d_int(int a)
{
double res_d = 0.0;
// xip_fpo_fixtoflt_d_int
xip_fpo_fixtoflt_d_int(&res_d, a); // normal operation
return res_d;
}
inline float xil_fpo_flttoflt_flt_flt(float a)
{
float res_flt = 0.0f;
// xip_fpo_flttoflt_flt_flt
xip_fpo_flttoflt_flt_flt(&res_flt, a); // normal operation
return res_flt;
}
inline float xil_fpo_flttoflt_flt_d(double a)
{
float res_flt = 0.0f;
// xip_fpo_flttoflt_flt_d
xip_fpo_flttoflt_flt_d(&res_flt, a); // normal operation
return res_flt;
}
inline double xil_fpo_flttoflt_d_flt(float a)
{
double res_d = 0.0;
// xip_fpo_flttoflt_d_flt
xip_fpo_flttoflt_d_flt(&res_d, a); // normal operation
return res_d;
}
inline double xil_fpo_flttoflt_d_d(double a)
{
double res_d = 0.0;
// xip_fpo_flttoflt_d_d
xip_fpo_flttoflt_d_d(&res_d, a); // normal operation
return res_d;
}
#endif
#endif /* #ifndef __AESL_FPO_H__*/

File diff suppressed because it is too large Load diff

View file

@ -1,945 +0,0 @@
/* mpfr.h -- Include file for mpfr.
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by the Arenaire and Cacao projects, INRIA.
This file is part of the GNU MPFR Library.
The GNU MPFR Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The GNU MPFR Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef __MPFR_H
#define __MPFR_H
/* Define MPFR version number */
#define MPFR_VERSION_MAJOR 3
#define MPFR_VERSION_MINOR 0
#define MPFR_VERSION_PATCHLEVEL 1
#define MPFR_VERSION_STRING "3.0.1-p4"
/* Macros dealing with MPFR VERSION */
#define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
#define MPFR_VERSION \
MPFR_VERSION_NUM(MPFR_VERSION_MAJOR,MPFR_VERSION_MINOR,MPFR_VERSION_PATCHLEVEL)
/* Check if GMP is included, and try to include it (Works with local GMP) */
#ifndef __GMP_H__
# include <gmp.h>
#endif
/* Check if stdio.h is included or if the user wants FILE */
#if defined (_GMP_H_HAVE_FILE) || defined (MPFR_USE_FILE)
# define _MPFR_H_HAVE_FILE 1
#endif
#if defined (_GMP_H_HAVE_VA_LIST)
# define _MPFR_H_HAVE_VA_LIST 1
#endif
/* Check if <stdint.h> / <inttypes.h> is included or if the user
explicitly wants intmax_t. Automatical detection is done by
checking:
- INTMAX_C and UINTMAX_C, but not if the compiler is a C++ one
(as suggested by Patrick Pelissier) because the test does not
work well in this case. See:
http://websympa.loria.fr/wwsympa/arc/mpfr/2010-02/msg00025.html
We do not check INTMAX_MAX and UINTMAX_MAX because under Solaris,
these macros are always defined by <limits.h> (i.e. even when
<stdint.h> and <inttypes.h> are not included).
- _STDINT_H (defined by the glibc) and _STDINT_H_ (defined under
Mac OS X), but this test may not work with all implementations.
Portable software should not rely on these tests.
*/
#if (defined (INTMAX_C) && defined (UINTMAX_C) && !defined(__cplusplus)) || \
defined (MPFR_USE_INTMAX_T) || defined (_STDINT_H) || defined (_STDINT_H_)
# define _MPFR_H_HAVE_INTMAX_T 1
#endif
/* Avoid some problems with macro expansion if the user defines macros
with the same name as keywords. By convention, identifiers and macro
names starting with mpfr_ are reserved by MPFR. */
typedef void mpfr_void;
typedef int mpfr_int;
typedef unsigned int mpfr_uint;
typedef long mpfr_long;
typedef unsigned long mpfr_ulong;
typedef size_t mpfr_size_t;
/* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
Warning! Changing the contents of this enum should be seen as an
interface change since the old and the new types are not compatible
(the integer type compatible with the enumerated type can even change,
see ISO C99, 6.7.2.2#4), and in Makefile.am, AGE should be set to 0.
MPFR_RNDU must appear just before MPFR_RNDD (see
MPFR_IS_RNDUTEST_OR_RNDDNOTTEST in mpfr-impl.h).
MPFR_RNDF has been added, though not implemented yet, in order to avoid
to break the ABI once faithful rounding gets implemented.
If you change the order of the rounding modes, please update the routines
in texceptions.c which assume 0=RNDN, 1=RNDZ, 2=RNDU, 3=RNDD, 4=RNDA.
*/
typedef enum {
MPFR_RNDN=0, /* round to nearest, with ties to even */
MPFR_RNDZ, /* round toward zero */
MPFR_RNDU, /* round toward +Inf */
MPFR_RNDD, /* round toward -Inf */
MPFR_RNDA, /* round away from zero */
MPFR_RNDF, /* faithful rounding (not implemented yet) */
MPFR_RNDNA=-1 /* round to nearest, with ties away from zero (mpfr_round) */
} mpfr_rnd_t;
/* kept for compatibility with MPFR 2.4.x and before */
#define GMP_RNDN MPFR_RNDN
#define GMP_RNDZ MPFR_RNDZ
#define GMP_RNDU MPFR_RNDU
#define GMP_RNDD MPFR_RNDD
/* Define precision : 1 (short), 2 (int) or 3 (long) (DON'T USE IT!)*/
#ifndef _MPFR_PREC_FORMAT
# if __GMP_MP_SIZE_T_INT == 1
# define _MPFR_PREC_FORMAT 2
# else
# define _MPFR_PREC_FORMAT 3
# endif
#endif
/* Let's make mpfr_prec_t signed in order to avoid problems due to the
usual arithmetic conversions when mixing mpfr_prec_t and mpfr_exp_t
in an expression (for error analysis) if casts are forgotten. */
#if _MPFR_PREC_FORMAT == 1
typedef short mpfr_prec_t;
typedef unsigned short mpfr_uprec_t;
#elif _MPFR_PREC_FORMAT == 2
typedef int mpfr_prec_t;
typedef unsigned int mpfr_uprec_t;
#elif _MPFR_PREC_FORMAT == 3
typedef long mpfr_prec_t;
typedef unsigned long mpfr_uprec_t;
#else
# error "Invalid MPFR Prec format"
#endif
/* Definition of precision limits without needing <limits.h> */
/* Note: the casts allows the expression to yield the wanted behavior
for _MPFR_PREC_FORMAT == 1 (due to integer promotion rules). */
#define MPFR_PREC_MIN 2
#define MPFR_PREC_MAX ((mpfr_prec_t)((mpfr_uprec_t)(~(mpfr_uprec_t)0)>>1))
/* Definition of sign */
typedef int mpfr_sign_t;
/* Definition of the exponent: same as in GMP. */
typedef mp_exp_t mpfr_exp_t;
/* Definition of the standard exponent limits */
#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
#define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
/* Definition of the main structure */
typedef struct {
mpfr_prec_t _mpfr_prec;
mpfr_sign_t _mpfr_sign;
mpfr_exp_t _mpfr_exp;
mp_limb_t *_mpfr_d;
} __mpfr_struct;
/* Compatibility with previous types of MPFR */
#ifndef mp_rnd_t
# define mp_rnd_t mpfr_rnd_t
#endif
#ifndef mp_prec_t
# define mp_prec_t mpfr_prec_t
#endif
/*
The represented number is
_sign*(_d[k-1]/B+_d[k-2]/B^2+...+_d[0]/B^k)*2^_exp
where k=ceil(_mp_prec/GMP_NUMB_BITS) and B=2^GMP_NUMB_BITS.
For the msb (most significant bit) normalized representation, we must have
_d[k-1]>=B/2, unless the number is singular.
We must also have the last k*GMP_NUMB_BITS-_prec bits set to zero.
*/
typedef __mpfr_struct mpfr_t[1];
typedef __mpfr_struct *mpfr_ptr;
typedef __gmp_const __mpfr_struct *mpfr_srcptr;
/* For those who need a direct and fast access to the sign field.
However it is not in the API, thus use it at your own risk: it might
not be supported, or change name, in further versions!
Unfortunately, it must be defined here (instead of MPFR's internal
header file mpfr-impl.h) because it is used by some macros below.
*/
#define MPFR_SIGN(x) ((x)->_mpfr_sign)
/* Stack interface */
typedef enum {
MPFR_NAN_KIND = 0,
MPFR_INF_KIND = 1, MPFR_ZERO_KIND = 2, MPFR_REGULAR_KIND = 3
} mpfr_kind_t;
/* GMP defines:
+ size_t: Standard size_t
+ __GMP_ATTRIBUTE_PURE Attribute for math functions.
+ __GMP_NOTHROW For C++: can't throw .
+ __GMP_EXTERN_INLINE Attribute for inline function.
* __gmp_const const (Supports for K&R compiler only for mpfr.h).
+ __GMP_DECLSPEC_EXPORT compiling to go into a DLL
+ __GMP_DECLSPEC_IMPORT compiling to go into a application
*/
/* Extra MPFR defines */
#define __MPFR_SENTINEL_ATTR
#if defined (__GNUC__)
# if __GNUC__ >= 4
# undef __MPFR_SENTINEL_ATTR
# define __MPFR_SENTINEL_ATTR __attribute__ ((sentinel))
# endif
#endif
/* Prototypes: Support of K&R compiler */
#if defined (__GMP_PROTO)
# define _MPFR_PROTO __GMP_PROTO
#elif defined (__STDC__) || defined (__cplusplus)
# define _MPFR_PROTO(x) x
#else
# define _MPFR_PROTO(x) ()
#endif
/* Support for WINDOWS Dll:
Check if we are inside a MPFR build, and if so export the functions.
Otherwise does the same thing as GMP */
#if defined(__MPFR_WITHIN_MPFR) && __GMP_LIBGMP_DLL
# define __MPFR_DECLSPEC __GMP_DECLSPEC_EXPORT
#else
# define __MPFR_DECLSPEC __GMP_DECLSPEC
#endif
/* Note: In order to be declared, some functions need a specific
system header to be included *before* "mpfr.h". If the user
forgets to include the header, the MPFR function prototype in
the user object file is not correct. To avoid wrong results,
we raise a linker error in that case by changing their internal
name in the library (prefixed by __gmpfr instead of mpfr). See
the lines of the form "#define mpfr_xxx __gmpfr_xxx" below. */
#if defined (__cplusplus)
extern "C" {
#endif
__MPFR_DECLSPEC __gmp_const char * mpfr_get_version _MPFR_PROTO ((void));
__MPFR_DECLSPEC __gmp_const char * mpfr_get_patches _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_buildopt_tls_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_buildopt_decimal_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_set_emin _MPFR_PROTO ((mpfr_exp_t));
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_min _MPFR_PROTO ((void));
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emin_max _MPFR_PROTO ((void));
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_set_emax _MPFR_PROTO ((mpfr_exp_t));
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_min _MPFR_PROTO ((void));
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_emax_max _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_set_default_rounding_mode _MPFR_PROTO((mpfr_rnd_t));
__MPFR_DECLSPEC mpfr_rnd_t mpfr_get_default_rounding_mode _MPFR_PROTO((void));
__MPFR_DECLSPEC __gmp_const char *
mpfr_print_rnd_mode _MPFR_PROTO((mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_clear_flags _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_clear_underflow _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_clear_overflow _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_clear_nanflag _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_clear_inexflag _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_clear_erangeflag _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_set_underflow _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_set_overflow _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_set_nanflag _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_set_inexflag _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_set_erangeflag _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_underflow_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_overflow_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_nanflag_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_inexflag_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_erangeflag_p _MPFR_PROTO ((void));
__MPFR_DECLSPEC int
mpfr_check_range _MPFR_PROTO ((mpfr_ptr, int, mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_init2 _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t));
__MPFR_DECLSPEC void mpfr_init _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void mpfr_clear _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void
mpfr_inits2 _MPFR_PROTO ((mpfr_prec_t, mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
__MPFR_DECLSPEC void
mpfr_inits _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
__MPFR_DECLSPEC void
mpfr_clears _MPFR_PROTO ((mpfr_ptr, ...)) __MPFR_SENTINEL_ATTR;
__MPFR_DECLSPEC int
mpfr_prec_round _MPFR_PROTO ((mpfr_ptr, mpfr_prec_t, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_can_round _MPFR_PROTO ((mpfr_srcptr, mpfr_exp_t, mpfr_rnd_t, mpfr_rnd_t,
mpfr_prec_t));
__MPFR_DECLSPEC mpfr_prec_t mpfr_min_prec _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_exp _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_set_exp _MPFR_PROTO ((mpfr_ptr, mpfr_exp_t));
__MPFR_DECLSPEC mpfr_prec_t mpfr_get_prec _MPFR_PROTO((mpfr_srcptr));
__MPFR_DECLSPEC void mpfr_set_prec _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
__MPFR_DECLSPEC void mpfr_set_prec_raw _MPFR_PROTO((mpfr_ptr, mpfr_prec_t));
__MPFR_DECLSPEC void mpfr_set_default_prec _MPFR_PROTO((mpfr_prec_t));
__MPFR_DECLSPEC mpfr_prec_t mpfr_get_default_prec _MPFR_PROTO((void));
__MPFR_DECLSPEC int mpfr_set_d _MPFR_PROTO ((mpfr_ptr, double, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_set_flt _MPFR_PROTO ((mpfr_ptr, float, mpfr_rnd_t));
#ifdef MPFR_WANT_DECIMAL_FLOATS
__MPFR_DECLSPEC int mpfr_set_decimal64 _MPFR_PROTO ((mpfr_ptr, _Decimal64,
mpfr_rnd_t));
#endif
__MPFR_DECLSPEC int
mpfr_set_ld _MPFR_PROTO ((mpfr_ptr, long double, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_z _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_z_2exp _MPFR_PROTO ((mpfr_ptr, mpz_srcptr, mpfr_exp_t, mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_set_nan _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void mpfr_set_inf _MPFR_PROTO ((mpfr_ptr, int));
__MPFR_DECLSPEC void mpfr_set_zero _MPFR_PROTO ((mpfr_ptr, int));
__MPFR_DECLSPEC int
mpfr_set_f _MPFR_PROTO ((mpfr_ptr, mpf_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_get_f _MPFR_PROTO ((mpf_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_set_si _MPFR_PROTO ((mpfr_ptr, long, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_ui _MPFR_PROTO ((mpfr_ptr, unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_si_2exp _MPFR_PROTO ((mpfr_ptr, long, mpfr_exp_t, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_ui_2exp _MPFR_PROTO ((mpfr_ptr,unsigned long,mpfr_exp_t,mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_q _MPFR_PROTO ((mpfr_ptr, mpq_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_init_set_str _MPFR_PROTO ((mpfr_ptr, __gmp_const char *, int,
mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set4 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t, int));
__MPFR_DECLSPEC int
mpfr_abs _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_neg _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_signbit _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int
mpfr_setsign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, int, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_copysign _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr, mpfr_rnd_t));
#ifdef _MPFR_H_HAVE_INTMAX_T
#define mpfr_set_sj __gmpfr_set_sj
#define mpfr_set_sj_2exp __gmpfr_set_sj_2exp
#define mpfr_set_uj __gmpfr_set_uj
#define mpfr_set_uj_2exp __gmpfr_set_uj_2exp
#define mpfr_get_sj __gmpfr_mpfr_get_sj
#define mpfr_get_uj __gmpfr_mpfr_get_uj
__MPFR_DECLSPEC int mpfr_set_sj _MPFR_PROTO ((mpfr_t, intmax_t, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_sj_2exp _MPFR_PROTO ((mpfr_t, intmax_t, intmax_t, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_set_uj _MPFR_PROTO ((mpfr_t, uintmax_t, mpfr_rnd_t));
__MPFR_DECLSPEC int
mpfr_set_uj_2exp _MPFR_PROTO ((mpfr_t, uintmax_t, intmax_t, mpfr_rnd_t));
__MPFR_DECLSPEC intmax_t mpfr_get_sj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC uintmax_t mpfr_get_uj _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
#endif
__MPFR_DECLSPEC mpfr_exp_t mpfr_get_z_2exp _MPFR_PROTO ((mpz_ptr, mpfr_srcptr));
__MPFR_DECLSPEC float mpfr_get_flt _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC double mpfr_get_d _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
#ifdef MPFR_WANT_DECIMAL_FLOATS
__MPFR_DECLSPEC _Decimal64 mpfr_get_decimal64 _MPFR_PROTO ((mpfr_srcptr,
mpfr_rnd_t));
#endif
__MPFR_DECLSPEC long double mpfr_get_ld _MPFR_PROTO ((mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC double mpfr_get_d1 _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC double mpfr_get_d_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC long double mpfr_get_ld_2exp _MPFR_PROTO ((long*, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC long mpfr_get_si _MPFR_PROTO ((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC unsigned long mpfr_get_ui _MPFR_PROTO ((mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC char*mpfr_get_str _MPFR_PROTO ((char*, mpfr_exp_t*, int, size_t,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_get_z _MPFR_PROTO ((mpz_ptr z, mpfr_srcptr f,
mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_free_str _MPFR_PROTO ((char *));
__MPFR_DECLSPEC int mpfr_urandom _MPFR_PROTO ((mpfr_ptr, gmp_randstate_t,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_urandomb _MPFR_PROTO ((mpfr_ptr, gmp_randstate_t));
__MPFR_DECLSPEC void mpfr_nextabove _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void mpfr_nextbelow _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void mpfr_nexttoward _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr));
#ifdef _MPFR_H_HAVE_FILE
#define mpfr_inp_str __gmpfr_inp_str
#define mpfr_out_str __gmpfr_out_str
__MPFR_DECLSPEC size_t mpfr_inp_str _MPFR_PROTO ((mpfr_ptr, FILE*, int,
mpfr_rnd_t));
__MPFR_DECLSPEC size_t mpfr_out_str _MPFR_PROTO ((FILE*, int, size_t,
mpfr_srcptr, mpfr_rnd_t));
#define mpfr_fprintf __gmpfr_fprintf
__MPFR_DECLSPEC int mpfr_fprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
...));
#endif
__MPFR_DECLSPEC int mpfr_printf _MPFR_PROTO ((__gmp_const char*, ...));
__MPFR_DECLSPEC int mpfr_asprintf _MPFR_PROTO ((char**, __gmp_const char*,
...));
__MPFR_DECLSPEC int mpfr_sprintf _MPFR_PROTO ((char*, __gmp_const char*,
...));
__MPFR_DECLSPEC int mpfr_snprintf _MPFR_PROTO ((char*, size_t,
__gmp_const char*, ...));
#ifdef _MPFR_H_HAVE_VA_LIST
#ifdef _MPFR_H_HAVE_FILE
#define mpfr_vfprintf __gmpfr_vfprintf
__MPFR_DECLSPEC int mpfr_vfprintf _MPFR_PROTO ((FILE*, __gmp_const char*,
va_list));
#endif /* _MPFR_H_HAVE_FILE */
#define mpfr_vprintf __gmpfr_vprintf
#define mpfr_vasprintf __gmpfr_vasprintf
#define mpfr_vsprintf __gmpfr_vsprintf
#define mpfr_vsnprintf __gmpfr_vsnprintf
__MPFR_DECLSPEC int mpfr_vprintf _MPFR_PROTO ((__gmp_const char*, va_list));
__MPFR_DECLSPEC int mpfr_vasprintf _MPFR_PROTO ((char**, __gmp_const char*,
va_list));
__MPFR_DECLSPEC int mpfr_vsprintf _MPFR_PROTO ((char*, __gmp_const char*,
va_list));
__MPFR_DECLSPEC int mpfr_vsnprintf _MPFR_PROTO ((char*, size_t,
__gmp_const char*, va_list));
#endif /* _MPFR_H_HAVE_VA_LIST */
__MPFR_DECLSPEC int mpfr_pow _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_pow_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_pow_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_ui_pow_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
unsigned long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_ui_pow _MPFR_PROTO ((mpfr_ptr, unsigned long int,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_pow_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sqrt_ui _MPFR_PROTO ((mpfr_ptr, unsigned long,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_rec_sqrt _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_add _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_mul _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_add_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_ui_sub _MPFR_PROTO ((mpfr_ptr, unsigned long,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_mul_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_ui_div _MPFR_PROTO ((mpfr_ptr, unsigned long,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_add_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_si_sub _MPFR_PROTO ((mpfr_ptr, long int,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_mul_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long int, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_si_div _MPFR_PROTO ((mpfr_ptr, long int,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_add_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
double, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
double, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_d_sub _MPFR_PROTO ((mpfr_ptr, double,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_mul_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
double, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_d _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
double, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_d_div _MPFR_PROTO ((mpfr_ptr, double,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sqr _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_const_pi _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_const_log2 _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_const_euler _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_const_catalan _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_agm _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_log _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_log2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_log10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_log1p _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_exp2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_exp10 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_expm1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_eint _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_li2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cmp _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_cmp3 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr, int));
__MPFR_DECLSPEC int mpfr_cmp_d _MPFR_PROTO ((mpfr_srcptr, double));
__MPFR_DECLSPEC int mpfr_cmp_ld _MPFR_PROTO ((mpfr_srcptr, long double));
__MPFR_DECLSPEC int mpfr_cmpabs _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_cmp_ui _MPFR_PROTO ((mpfr_srcptr, unsigned long));
__MPFR_DECLSPEC int mpfr_cmp_si _MPFR_PROTO ((mpfr_srcptr, long));
__MPFR_DECLSPEC int mpfr_cmp_ui_2exp _MPFR_PROTO ((mpfr_srcptr, unsigned long,
mpfr_exp_t));
__MPFR_DECLSPEC int mpfr_cmp_si_2exp _MPFR_PROTO ((mpfr_srcptr, long,
mpfr_exp_t));
__MPFR_DECLSPEC void mpfr_reldiff _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_eq _MPFR_PROTO((mpfr_srcptr, mpfr_srcptr,
unsigned long));
__MPFR_DECLSPEC int mpfr_sgn _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_mul_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_2exp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_mul_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_2ui _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_mul_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_2si _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
long, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_rint _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_round _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_trunc _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_ceil _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_floor _MPFR_PROTO((mpfr_ptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_rint_round _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_rint_trunc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_rint_ceil _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_rint_floor _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_frac _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_modf _MPFR_PROTO ((mpfr_ptr, mpfr_ptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_remquo _MPFR_PROTO ((mpfr_ptr, long*, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_remainder _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fmod _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_ulong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_slong_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_uint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_sint_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_ushort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_sshort_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_uintmax_p _MPFR_PROTO((mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fits_intmax_p _MPFR_PROTO((mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_extract _MPFR_PROTO ((mpz_ptr, mpfr_srcptr,
unsigned int));
__MPFR_DECLSPEC void mpfr_swap _MPFR_PROTO ((mpfr_ptr, mpfr_ptr));
__MPFR_DECLSPEC void mpfr_dump _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_nan_p _MPFR_PROTO((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_inf_p _MPFR_PROTO((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_number_p _MPFR_PROTO((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_integer_p _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_zero_p _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_regular_p _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_greater_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_greaterequal_p _MPFR_PROTO ((mpfr_srcptr,
mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_less_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_lessequal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_lessgreater_p _MPFR_PROTO((mpfr_srcptr,mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_equal_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_unordered_p _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_atanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_acosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_asinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cosh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sinh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_tanh _MPFR_PROTO((mpfr_ptr,mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sinh_cosh _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sech _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_csch _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_coth _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_acos _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_asin _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_atan _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sin _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sin_cos _MPFR_PROTO ((mpfr_ptr, mpfr_ptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cos _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_tan _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_atan2 _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sec _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_csc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_hypot _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_erf _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_erfc _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cbrt _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_root _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,unsigned long,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_gamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_lngamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_lgamma _MPFR_PROTO((mpfr_ptr,int*,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_digamma _MPFR_PROTO((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_zeta _MPFR_PROTO ((mpfr_ptr,mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_zeta_ui _MPFR_PROTO ((mpfr_ptr,unsigned long,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fac_ui _MPFR_PROTO ((mpfr_ptr, unsigned long int,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_j0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_j1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_jn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_y0 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_y1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_yn _MPFR_PROTO ((mpfr_ptr, long, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_ai _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_min _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_max _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_dim _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_mul_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_add_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub_z _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpz_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cmp_z _MPFR_PROTO ((mpfr_srcptr, mpz_srcptr));
__MPFR_DECLSPEC int mpfr_mul_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_div_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_add_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub_q _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpq_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_cmp_q _MPFR_PROTO ((mpfr_srcptr, mpq_srcptr));
__MPFR_DECLSPEC int mpfr_cmp_f _MPFR_PROTO ((mpfr_srcptr, mpf_srcptr));
__MPFR_DECLSPEC int mpfr_fma _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_fms _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sum _MPFR_PROTO ((mpfr_ptr, mpfr_ptr *__gmp_const,
unsigned long, mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_free_cache _MPFR_PROTO ((void));
__MPFR_DECLSPEC int mpfr_subnormalize _MPFR_PROTO ((mpfr_ptr, int,
mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_strtofr _MPFR_PROTO ((mpfr_ptr, __gmp_const char *,
char **, int, mpfr_rnd_t));
__MPFR_DECLSPEC size_t mpfr_custom_get_size _MPFR_PROTO ((mpfr_prec_t));
__MPFR_DECLSPEC void mpfr_custom_init _MPFR_PROTO ((void *, mpfr_prec_t));
__MPFR_DECLSPEC void * mpfr_custom_get_significand _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC mpfr_exp_t mpfr_custom_get_exp _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC void mpfr_custom_move _MPFR_PROTO ((mpfr_ptr, void *));
__MPFR_DECLSPEC void mpfr_custom_init_set _MPFR_PROTO ((mpfr_ptr, int,
mpfr_exp_t, mpfr_prec_t, void *));
__MPFR_DECLSPEC int mpfr_custom_get_kind _MPFR_PROTO ((mpfr_srcptr));
#if defined (__cplusplus)
}
#endif
/* DON'T USE THIS! (For MPFR-public macros only, see below.)
The mpfr_sgn macro uses the fact that __MPFR_EXP_NAN and __MPFR_EXP_ZERO
are the smallest values.
FIXME: In the following macros, the cast of an unsigned type with MSB set
to the signed type mpfr_exp_t yields an integer overflow, which can give
unexpected results with future compilers and aggressive optimisations.
Why not working only with signed types, using INT_MIN and LONG_MIN? */
#if __GMP_MP_SIZE_T_INT
#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2))
#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1))
#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3))
#else
#define __MPFR_EXP_NAN ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2))
#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1))
#define __MPFR_EXP_INF ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3))
#endif
/* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
#ifndef MPFR_EXTENSION
# if defined(MPFR_USE_EXTENSION)
# define MPFR_EXTENSION __extension__
# else
# define MPFR_EXTENSION
# endif
#endif
/* Warning! This macro doesn't work with K&R C (e.g., compare the "gcc -E"
output with and without -traditional) and shouldn't be used internally.
For public use only, but see the MPFR manual. */
#define MPFR_DECL_INIT(_x, _p) \
MPFR_EXTENSION mp_limb_t __gmpfr_local_tab_##_x[((_p)-1)/GMP_NUMB_BITS+1]; \
MPFR_EXTENSION mpfr_t _x = {{(_p),1,__MPFR_EXP_NAN,__gmpfr_local_tab_##_x}}
/* Fast access macros to replace function interface.
If the USER don't want to use the macro interface, let him make happy
even if it produces faster and smaller code. */
#ifndef MPFR_USE_NO_MACRO
/* Inlining theses functions is both faster and smaller */
#define mpfr_nan_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_NAN)
#define mpfr_inf_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_INF)
#define mpfr_zero_p(_x) ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
#define mpfr_regular_p(_x) ((_x)->_mpfr_exp > __MPFR_EXP_INF)
#define mpfr_sgn(_x) \
((_x)->_mpfr_exp < __MPFR_EXP_INF ? \
(mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
MPFR_SIGN (_x))
/* Prevent them from using as lvalues */
#define MPFR_VALUE_OF(x) (0 ? (x) : (x))
#define mpfr_get_prec(_x) MPFR_VALUE_OF((_x)->_mpfr_prec)
#define mpfr_get_exp(_x) MPFR_VALUE_OF((_x)->_mpfr_exp)
/* Note: if need be, the MPFR_VALUE_OF can be used for other expressions
(of any type). Thanks to Wojtek Lerch and Tim Rentsch for the idea. */
#define mpfr_round(a,b) mpfr_rint((a), (b), MPFR_RNDNA)
#define mpfr_trunc(a,b) mpfr_rint((a), (b), MPFR_RNDZ)
#define mpfr_ceil(a,b) mpfr_rint((a), (b), MPFR_RNDU)
#define mpfr_floor(a,b) mpfr_rint((a), (b), MPFR_RNDD)
#define mpfr_cmp_ui(b,i) mpfr_cmp_ui_2exp((b),(i),0)
#define mpfr_cmp_si(b,i) mpfr_cmp_si_2exp((b),(i),0)
#define mpfr_set(a,b,r) mpfr_set4(a,b,r,MPFR_SIGN(b))
#define mpfr_abs(a,b,r) mpfr_set4(a,b,r,1)
#define mpfr_copysign(a,b,c,r) mpfr_set4(a,b,r,MPFR_SIGN(c))
#define mpfr_setsign(a,b,s,r) mpfr_set4(a,b,r,(s) ? -1 : 1)
#define mpfr_signbit(x) (MPFR_SIGN(x) < 0)
#define mpfr_cmp(b, c) mpfr_cmp3(b, c, 1)
#define mpfr_mul_2exp(y,x,n,r) mpfr_mul_2ui((y),(x),(n),(r))
#define mpfr_div_2exp(y,x,n,r) mpfr_div_2ui((y),(x),(n),(r))
/* When using GCC, optimize certain common comparisons and affectations.
+ Remove ICC since it defines __GNUC__ but produces a
huge number of warnings if you use this code.
VL: I couldn't reproduce a single warning when enabling these macros
with icc 10.1 20080212 on Itanium. But with this version, __ICC isn't
defined (__INTEL_COMPILER is, though), so that these macros are enabled
anyway. Checking with other ICC versions is needed. Possibly detect
whether warnings are produced or not with a configure test.
+ Remove C++ too, since it complains too much. */
/* Added casts to improve robustness in case of undefined behavior and
compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
use such extensions, but these macros will be used by 3rd-party code,
where such extensions may be required.
Moreover casts to unsigned long have been added to avoid warnings in
programs that use MPFR and are compiled with -Wconversion; such casts
are OK since if X is a constant expression, then (unsigned long) X is
also a constant expression, so that the optimizations still work. The
warnings are probably related to the following two bugs:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
and the casts could be removed once these bugs are fixed.
Casts shouldn't be used on the generic calls (to the ..._2exp functions),
where implicit conversions are performed. Indeed, having at least one
implicit conversion in the macro allows the compiler to emit diagnostics
when normally expected, for instance in the following call:
mpfr_set_ui (x, "foo", MPFR_RNDN);
If this is not possible (for future macros), one of the tricks described
on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
be used. */
#if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
#if (__GNUC__ >= 2)
#undef mpfr_cmp_ui
/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
But warning! mpfr_sgn is specified as a macro in the API, thus the macro
mustn't be used if side effects are possible, like here. */
#define mpfr_cmp_ui(_f,_u) \
(__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
(mpfr_sgn) (_f) : \
mpfr_cmp_ui_2exp ((_f), (_u), 0))
#undef mpfr_cmp_si
#define mpfr_cmp_si(_f,_s) \
(__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) : \
mpfr_cmp_si_2exp ((_f), (_s), 0))
#if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
#undef mpfr_set_ui
#define mpfr_set_ui(_f,_u,_r) \
(__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ? \
__extension__ ({ \
mpfr_ptr _p = (_f); \
_p->_mpfr_sign = 1; \
_p->_mpfr_exp = __MPFR_EXP_ZERO; \
(mpfr_void) (_r); 0; }) : \
mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
#endif
#undef mpfr_set_si
#define mpfr_set_si(_f,_s,_r) \
(__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ? \
mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) : \
mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
#endif
#endif
/* Macro version of mpfr_stack interface for fast access */
#define mpfr_custom_get_size(p) ((mpfr_size_t) \
(((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
#define mpfr_custom_init(m,p) do {} while (0)
#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
#define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
#define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
#define mpfr_custom_init_set(x,k,e,p,m) do { \
mpfr_ptr _x = (x); \
mpfr_exp_t _e; \
mpfr_kind_t _t; \
mpfr_int _s, _k; \
_k = (k); \
if (_k >= 0) { \
_t = (mpfr_kind_t) _k; \
_s = 1; \
} else { \
_t = (mpfr_kind_t) -k; \
_s = -1; \
} \
_e = _t == MPFR_REGULAR_KIND ? (e) : \
_t == MPFR_NAN_KIND ? __MPFR_EXP_NAN : \
_t == MPFR_INF_KIND ? __MPFR_EXP_INF : __MPFR_EXP_ZERO; \
_x->_mpfr_prec = (p); \
_x->_mpfr_sign = _s; \
_x->_mpfr_exp = _e; \
_x->_mpfr_d = (mp_limb_t*) (m); \
} while (0)
#define mpfr_custom_get_kind(x) \
( (x)->_mpfr_exp > __MPFR_EXP_INF ? \
(mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x) \
: (x)->_mpfr_exp == __MPFR_EXP_INF ? \
(mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x) \
: (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND \
: (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
#endif /* MPFR_USE_NO_MACRO */
/* Theses are defined to be macros */
#define mpfr_init_set_si(x, i, rnd) \
( mpfr_init(x), mpfr_set_si((x), (i), (rnd)) )
#define mpfr_init_set_ui(x, i, rnd) \
( mpfr_init(x), mpfr_set_ui((x), (i), (rnd)) )
#define mpfr_init_set_d(x, d, rnd) \
( mpfr_init(x), mpfr_set_d((x), (d), (rnd)) )
#define mpfr_init_set_ld(x, d, rnd) \
( mpfr_init(x), mpfr_set_ld((x), (d), (rnd)) )
#define mpfr_init_set_z(x, i, rnd) \
( mpfr_init(x), mpfr_set_z((x), (i), (rnd)) )
#define mpfr_init_set_q(x, i, rnd) \
( mpfr_init(x), mpfr_set_q((x), (i), (rnd)) )
#define mpfr_init_set(x, y, rnd) \
( mpfr_init(x), mpfr_set((x), (y), (rnd)) )
#define mpfr_init_set_f(x, y, rnd) \
( mpfr_init(x), mpfr_set_f((x), (y), (rnd)) )
/* Compatibility layer -- obsolete functions and macros */
#define mpfr_cmp_abs mpfr_cmpabs
#define mpfr_round_prec(x,r,p) mpfr_prec_round(x,p,r)
#define __gmp_default_rounding_mode (mpfr_get_default_rounding_mode())
#define __mpfr_emin (mpfr_get_emin())
#define __mpfr_emax (mpfr_get_emax())
#define __mpfr_default_fp_bit_precision (mpfr_get_default_fp_bit_precision())
#define MPFR_EMIN_MIN mpfr_get_emin_min()
#define MPFR_EMIN_MAX mpfr_get_emin_max()
#define MPFR_EMAX_MIN mpfr_get_emax_min()
#define MPFR_EMAX_MAX mpfr_get_emax_max()
#define mpfr_version (mpfr_get_version())
#ifndef mpz_set_fr
# define mpz_set_fr mpfr_get_z
#endif
#define mpfr_add_one_ulp(x,r) \
(mpfr_sgn (x) > 0 ? mpfr_nextabove (x) : mpfr_nextbelow (x))
#define mpfr_sub_one_ulp(x,r) \
(mpfr_sgn (x) > 0 ? mpfr_nextbelow (x) : mpfr_nextabove (x))
#define mpfr_get_z_exp mpfr_get_z_2exp
#define mpfr_custom_get_mantissa mpfr_custom_get_significand
#endif /* __MPFR_H*/