/** * Title: GNU MPFR 3.0.x special bindings * File: libmpfr-iforth.c * Log file: gmpfr.log * Test file: gmpfr-test.fs * Author: David N. Williams * License: LGPL 3 * Version: 0.9.1 * Started: April 22, 2011 * Revised: January 5, 2020 * * For the sake of the LGPL, any part of this library not * derived from the GNU Multiple Precision library is * * Copyright (C) 2011, 2012, 2020 by David N. Williams * * This 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. * * This 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 Library General Public License for more * details. * * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA. * * If you take advantage of the option in the LGPL to put a * particular version of this library under the GPL, the author * would regard it as polite if you would put any direct * modifications under the LGPL as well, and include a copy of * this request near the beginning of the modified library * source. A "direct modification" is one that enhances or * extends the library in line with its original concept, as * opposed to developing a distinct application or library which * might use it. * * This library provides wrappers for libmpfr functions that * need special handling in the iForth dynlibs interface, either * because of macros, or for returns that need to be long * instead of int for 64 bit ABI's. Some of them are not called * when the ABI is 32 bits. */ #include /* As far as I understand, it makes no difference for building this library whether gmp.h is the 32- or 64-bit version, because GMP_LIMB_BITS is referenced neither here nor in mpfr.h. */ #include #include #define slong signed long int #define ulong unsigned long int /*** Wrappers for mpfr macros ***/ slong mpfr_init_set_macro (mpfr_ptr rop, mpfr_ptr op, mpfr_rnd_t rnd) { return (slong) mpfr_init_set (rop, op, rnd); } slong mpfr_init_set_ui_macro (mpfr_ptr rop, mpfr_ulong op, mpfr_rnd_t rnd) { return (slong) mpfr_init_set_ui (rop, op, rnd); } slong mpfr_init_set_si_macro (mpfr_ptr rop, mpfr_long op, mpfr_rnd_t rnd) { return (slong) mpfr_init_set_si (rop, op, rnd); } slong mpfr_init_set_d_macro (mpfr_ptr rop, double op, mpfr_rnd_t rnd) { return (slong) mpfr_init_set_d (rop, op, rnd); } slong mpfr_init_set_z_macro (mpfr_ptr rop, mpz_ptr op, mpfr_rnd_t rnd) { return (slong) mpfr_init_set_z (rop, op, rnd); } slong mpfr_init_set_q_macro (mpfr_ptr rop, mpq_ptr op, mpfr_rnd_t rnd) { return (slong) mpfr_init_set_q (rop, op, rnd); } slong mpfr_init_set_f_macro (mpfr_ptr rop, mpf_ptr op, mpfr_rnd_t rnd) { return (slong) mpfr_init_set_f (rop, op, rnd); } ulong mpfr_get_prec_macro (mpfr_ptr op) // mpfr_prec_t is actually signed { return (ulong) mpfr_get_prec (op); } slong mpfr_get_exp_macro (mpfr_ptr op) { return (slong) mpfr_get_exp (op); } slong mpfr_set_macro (mpfr_ptr rop, mpfr_ptr op, mpfr_rnd_t rnd) { return (slong) mpfr_set (rop, op, rnd); } slong mpfr_copysign_macro (mpfr_ptr rop, mpfr_ptr op1, mpfr_ptr op2, mpfr_rnd_t rnd) { return (slong) mpfr_copysign (rop, op1, op2, rnd); } slong mpfr_signbit_macro (mpfr_ptr op) { return (slong) mpfr_signbit (op); } /* BEGIN 64-bit ABI */ int mpfr_lgamma_lsgn (mpfr_t rop, int *signp, mpfr_t op, mpfr_rnd_t rnd) { int t = mpfr_lgamma (rop, signp, op, rnd); *(long*)signp = *signp; return t; } /* END 64-bit ABI */ ulong sizeof_mpfr (void) { return (ulong) sizeof (mpfr_t); } int MPFR_VERSION_MAJOR_macro (void) { return (int) MPFR_VERSION_MAJOR; } int MPFR_VERSION_MINOR_macro (void) { return (int) MPFR_VERSION_MINOR; } int MPFR_VERSION_PATCHLEVEL_macro (void) { return (int) MPFR_VERSION_PATCHLEVEL; } slong MPFR_PREC_MIN_macro (void) { return (slong) MPFR_PREC_MIN; } slong MPFR_PREC_MAX_macro (void) { return (slong) MPFR_PREC_MAX; } slong MPFR_EMAX_DEFAULT_macro (void) { return (slong) MPFR_EMAX_DEFAULT; } slong MPFR_EMIN_DEFAULT_macro (void) { return (slong) MPFR_EMIN_DEFAULT; } ulong MPFR_RNDN_macro (void) { return (ulong) MPFR_RNDN; } ulong MPFR_RNDZ_macro (void) { return (ulong) MPFR_RNDZ; } ulong MPFR_RNDU_macro (void) { return (ulong) MPFR_RNDU; } ulong MPFR_RNDD_macro (void) { return (ulong) MPFR_RNDD; } ulong MPFR_RNDA_macro (void) { return (ulong) MPFR_RNDA; } ulong MPFR_RNDF_macro (void) { return (ulong) MPFR_RNDF; } ulong MPFR_RNDNA_macro (void) { return (ulong) MPFR_RNDNA; }