/** * Title: GMP MP 5.0.x special bindings * File: libgmp-iforth.c * Log file: gmpfr.log * Test files: gmpfr-test.fs * Author: David N. Williams * License: LGPL 3 * Version: 0.9.1 * Started: February 28, 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 wraps gmp macros into callable functions, for * the iForth dynlibs interface. * This library provides wrappers for libgmp 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 #include #define slong signed long int #define ulong unsigned long int /*** Wrappers for gmp macros ***/ int GMP_VERSION_MAJOR_macro (void) { return (int) __GNU_MP_VERSION; } int GMP_VERSION_MINOR_macro (void) { return (int) __GNU_MP_VERSION_MINOR; } int GMP_VERSION_PATCHLEVEL_macro (void) { return (int) __GNU_MP_VERSION_PATCHLEVEL; } slong mpz_sgn_macro (mpz_ptr op) { return mpz_sgn (op); } slong mpf_sgn_macro (mpf_ptr op) { return mpf_sgn (op); } slong mpq_sgn_macro (mpq_ptr op) { return mpq_sgn (op); } slong mpz_cmp_si_macro (mpz_ptr op1, slong op2) { return mpz_cmp_si (op1, op2); } slong mpz_cmp_ui_macro (mpz_ptr op1, ulong op2) { return mpz_cmp_ui (op1, op2); } slong mpz_odd_p_macro (mpz_ptr op) { return mpz_odd_p (op); } slong mpz_even_p_macro (mpz_ptr op) { return mpz_odd_p (op); } slong mpq_cmp_ui_macro (mpq_ptr op1, ulong num2, ulong den2) { return mpq_cmp_ui (op1, num2, den2); } slong mpq_cmp_si_macro (mpq_ptr op1, slong num2, ulong den2) { return mpq_cmp_si (op1, num2, den2); } mpz_srcptr mpq_numref_macro (mpq_ptr op) { return mpq_numref (op); } mpz_srcptr mpq_denref_macro (mpq_ptr op) { return mpq_denref (op); } slong sizeof_mpz (void) { return sizeof (mpz_t); } slong sizeof_mpq (void) { return sizeof (mpq_t); } slong sizeof_mpf (void) { return sizeof (mpf_t); } slong bits_per_mp_limb (void) { return mp_bits_per_limb; } slong sizeof_gmp_randstate (void) { return sizeof (gmp_randstate_t); } const char * gmp_version_const (void) { return gmp_version; }