1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* gmpy2.h *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Python interface to the GMP, MPFR, and MPC multiple precision *
* libraries. *
* *
* Copyright 2000 - 2009 Alex Martelli *
* *
* Copyright 2008 - 2024 Case Van Horsen *
* *
* This file is part of GMPY2. *
* *
* GMPY2 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. *
* *
* GMPY2 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 GMPY2; if not, see <http://www.gnu.org/licenses/> *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
gmpy C API extension header file.
Part of Python's gmpy module since version 0.4
Created by Pearu Peterson <pearu@cens.ioc.ee>, November 2000.
Edited by A. Martelli <aleaxit@yahoo.com>, December 2000.
Edited by Case Van Horsen <casevh@gmail.com>, 2009, 2010, 2011.
Version 1.02, February 2007.
Version 1.03, June 2008
Version 1.04, June 2008 (no changes)
Version 1.05, February 2009 (support MPIR)
Version 1.20, January 2010 (remove obsolete MS hacks) casevh
Version 2.00, April 2010 (change to gmpy2) casevh
October 2010 (added Py_hash_t) casevh
December 2010 (added mpfr, mpc) casevh
January 2011 (add Pygmpy_context) casevh
April 2011 (split into multiple files) casevh
Version 2.10 August 2014 (reflect major rewrite during 2013/2014) casevh
*/
#ifndef Py_GMPYMODULE_H
#define Py_GMPYMODULE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Structure of gmpy2.h
*
* Revised 17-APR-2017 casevh
*
* 1. Checks for specific Python versions.
* 2. Include headers for GMP/MPIR, MPFR, and MPC.
* 3. Define public C-API.
* 1. Define gmpy2 types.
* 2. Define the public API.
*
*/
/* Check for minimum Python version requirements. */
#if PY_VERSION_HEX < 0x03070000
# error "GMPY2 requires Python 3.7 or later."
#endif
/* Include headers for GMP, MPFR, and MPC. */
#include <gmp.h>
#include <mpfr.h>
#include <mpc.h>
/* Check MPFR and MPC versions. */
/* gmpy2 supports the two most recent major versions of MPFR and MPC.
*
* As of gmpy2 2.2.0, the code assumes the MPFR version is at least 4.1.0
* and new features included in 4.2.0 are guarded by #ifdef MPFR_420.
* For MPC, the minumum version is assumed to 1.2.1 and new features
* included in 1.3.0 are guarded by #ifdef MPC_130.
*
*/
#if (!defined(MPFR_VERSION) || (MPFR_VERSION < MPFR_VERSION_NUM(4,1,0)))
# error "GMPY2 requires MPFR 4.1.0 or later."
#endif
#if (defined(MPFR_VERSION) && (MPFR_VERSION >= MPFR_VERSION_NUM(4,2,0)))
# define MPFR_420
#endif
#if (!defined(MPC_VERSION) || (MPC_VERSION < MPC_VERSION_NUM(1,2,1)))
# error "GMPY2 requires MPC 1.2.1 or later."
#endif
#if (defined(MPC_VERSION) && (MPC_VERSION == MPC_VERSION_NUM(1,3,0)))
# define MPC_130
#endif
/* GMPY2 Public API */
/* Types
* MPZ_Object
* XMPZ_Object (mutable version of MPZ_Object)
* MPQ_Object
* XMPQ_Object (mutable version of MPQ_Object)
* MPFR_Object
* XMPFR_Object (mutable version of MPFR_Object)
* MPC_Object
* XMPC_Object (mutable version of MPC_Object)
* CTXT_Object
* RandomState_Object
*/
typedef struct {
PyObject_HEAD
mpz_t z;
Py_hash_t hash_cache;
} MPZ_Object;
typedef struct {
PyObject_HEAD
mpz_t z;
} XMPZ_Object;
typedef struct {
PyObject_HEAD
mpq_t q;
Py_hash_t hash_cache;
} MPQ_Object;
typedef struct {
PyObject_HEAD
mpfr_t f;
Py_hash_t hash_cache;
int rc;
} MPFR_Object;
typedef struct {
PyObject_HEAD
mpc_t c;
Py_hash_t hash_cache;
int rc;
} MPC_Object;
typedef struct {
PyObject_HEAD
gmp_randstate_t state;
} RandomState_Object;
typedef struct {
mpfr_prec_t mpfr_prec; /* current precision in bits, for MPFR */
mpfr_rnd_t mpfr_round; /* current rounding mode for float (MPFR) */
mpfr_exp_t emax; /* maximum exponent */
mpfr_exp_t emin; /* minimum exponent */
int subnormalize; /* if 1, subnormalization is performed */
int underflow; /* did an underflow occur? */
int overflow; /* did an overflow occur? */
int inexact; /* was the result inexact? */
int invalid; /* invalid operation (i.e. NaN)? */
int erange; /* did a range error occur? */
int divzero; /* divided by zero? */
int traps; /* if 0, do not trap any exceptions */
/* if not 0, then raise traps per bits above */
mpfr_prec_t real_prec; /* current precision in bits, for Re(MPC) */
mpfr_prec_t imag_prec; /* current precision in bits, for Im(MPC) */
mpfr_rnd_t real_round; /* current rounding mode for Re(MPC) */
mpfr_rnd_t imag_round; /* current rounding mode for Im(MPC) */
int allow_complex; /* if 1, allow mpfr functions to return an mpc */
int rational_division; /* if 1, mpz/mpz returns an mpq result */
int allow_release_gil; /* if 1, allow mpz functions to release the GIL */
} gmpy_context;
typedef struct {
PyObject_HEAD
gmpy_context ctx;
PyObject *token;
} CTXT_Object;
#define MPZ(obj) (((MPZ_Object*)(obj))->z)
#define MPQ(obj) (((MPQ_Object*)(obj))->q)
#define MPFR(obj) (((MPFR_Object*)(obj))->f)
#define MPC(obj) (((MPC_Object*)(obj))->c)
/* Start of the C-API definitions */
#define MPZ_Type_NUM 0
#define XMPZ_Type_NUM 1
#define MPQ_Type_NUM 2
#define XMPQ_Type_NUM 3
#define MPFR_Type_NUM 4
#define XMPFR_Type_NUM 5
#define MPC_Type_NUM 6
#define XMPC_Type_NUM 7
#define CTXT_Type_NUM 8
#define RandomState_Type_NUM 10
/* The following functions are found in gmpy2_cache. */
#define GMPy_MPZ_New_NUM 11
#define GMPy_MPZ_New_RETURN MPZ_Object *
#define GMPy_MPZ_New_PROTO (CTXT_Object *context)
#define GMPy_MPZ_NewInit_NUM 12
#define GMPy_MPZ_NewInit_RETURN PyObject *
#define GMPy_MPZ_NewInit_PROTO (PyTypeObject *type, PyObject *args, PyObject *keywds)
#define GMPy_MPZ_Dealloc_NUM 13
#define GMPy_MPZ_Dealloc_RETURN void
#define GMPy_MPZ_Dealloc_PROTO (MPZ_Object *self)
/* The following function is found in gmpy2_convert_gmp. */
#define GMPy_MPZ_ConvertArg_NUM 14
#define GMPy_MPZ_ConvertArg_RETURN int
#define GMPy_MPZ_ConvertArg_PROTO (PyObject *arg, PyObject **ptr)
/* The following functions are found in gmpy2_cache. */
#define GMPy_XMPZ_New_NUM 15
#define GMPy_XMPZ_New_RETURN XMPZ_Object *
#define GMPy_XMPZ_New_PROTO (CTXT_Object *context)
#define GMPy_XMPZ_NewInit_NUM 16
#define GMPy_XMPZ_NewInit_RETURN PyObject *
#define GMPy_XMPZ_NewInit_PROTO (PyTypeObject *type, PyObject *args, PyObject *keywds)
#define GMPy_XMPZ_Dealloc_NUM 17
#define GMPy_XMPZ_Dealloc_RETURN void
#define GMPy_XMPZ_Dealloc_PROTO (XMPZ_Object *self)
/* The following functions are found in gmpy2_cache. */
#define GMPy_MPQ_New_NUM 18
#define GMPy_MPQ_New_RETURN MPQ_Object *
#define GMPy_MPQ_New_PROTO (CTXT_Object *context)
#define GMPy_MPQ_NewInit_NUM 19
#define GMPy_MPQ_NewInit_RETURN PyObject *
#define GMPy_MPQ_NewInit_PROTO (PyTypeObject *type, PyObject *args, PyObject *keywds)
#define GMPy_MPQ_Dealloc_NUM 20
#define GMPy_MPQ_Dealloc_RETURN void
#define GMPy_MPQ_Dealloc_PROTO (MPQ_Object *self)
/* The following function is found in gmpy2_convert_gmp. */
#define GMPy_MPQ_ConvertArg_NUM 21
#define GMPy_MPQ_ConvertArg_RETURN int
#define GMPy_MPQ_ConvertArg_PROTO (PyObject *arg, PyObject **ptr)
/* The following functions are found in gmpy2_cache. */
#define GMPy_MPFR_New_NUM 22
#define GMPy_MPFR_New_RETURN MPFR_Object *
#define GMPy_MPFR_New_PROTO (mpfr_prec_t bits, CTXT_Object *context)
#define GMPy_MPFR_NewInit_NUM 23
#define GMPy_MPFR_NewInit_RETURN PyObject *
#define GMPy_MPFR_NewInit_PROTO (PyTypeObject *type, PyObject *args, PyObject *keywds)
#define GMPy_MPFR_Dealloc_NUM 24
#define GMPy_MPFR_Dealloc_RETURN void
#define GMPy_MPFR_Dealloc_PROTO (MPFR_Object *self)
/* The following function is found in gmpy2_convert_gmp. */
#define GMPy_MPFR_ConvertArg_NUM 25
#define GMPy_MPFR_ConvertArg_RETURN int
#define GMPy_MPFR_ConvertArg_PROTO (PyObject *arg, PyObject **ptr)
/* The following functions are found in gmpy2_cache. */
#define GMPy_MPC_New_NUM 26
#define GMPy_MPC_New_RETURN MPC_Object *
#define GMPy_MPC_New_PROTO (mpfr_prec_t rprec, mpfr_prec_t iprec, CTXT_Object *context)
#define GMPy_MPC_NewInit_NUM 27
#define GMPy_MPC_NewInit_RETURN PyObject *
#define GMPy_MPC_NewInit_PROTO (PyTypeObject *type, PyObject *args, PyObject *keywds)
#define GMPy_MPC_Dealloc_NUM 28
#define GMPy_MPC_Dealloc_RETURN void
#define GMPy_MPC_Dealloc_PROTO (MPC_Object *self)
/* The following function is found in gmpy2_convert_gmp. */
#define GMPy_MPC_ConvertArg_NUM 29
#define GMPy_MPC_ConvertArg_RETURN int
#define GMPy_MPC_ConvertArg_PROTO (PyObject *arg, PyObject **ptr)
/* Total number of C-API pointers. */
#define GMPy_API_pointers 30
/* End of C-API definitions. */
#ifdef GMPY2_MODULE
#define PyString_1Char(obj) (PyUnicode_READY(obj) ? (Py_UCS4)0 : PyUnicode_READ_CHAR(obj, 0))
#define PyStrOrUnicode_Check(op) (PyBytes_Check(op) || PyUnicode_Check(op))
#ifndef ABS
# define ABS(a) (((a) < 0) ? -(a) : (a))
#endif
#if defined(MS_WIN32) && defined(_MSC_VER)
/* so one won't need to link explicitly to gmp.lib...: */
# pragma comment(lib,"gmp.lib")
# define USE_ALLOCA 1
# define inline __inline
#endif
#ifdef __GNUC__
# define USE_ALLOCA 1
#endif
#ifndef alloca
# ifdef __GNUC__
# define alloca __builtin_alloca
# else
# ifdef _MSC_VER
# include <malloc.h>
# define alloca _alloca
# else
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
char *alloca ();
# endif
# endif
# endif
#endif
#define ALLOC_THRESHOLD 8192
#define INDEX_ERROR(msg) PyErr_SetString(PyExc_IndexError, msg)
#define TYPE_ERROR(msg) PyErr_SetString(PyExc_TypeError, msg)
#define VALUE_ERROR(msg) PyErr_SetString(PyExc_ValueError, msg)
#define ZERO_ERROR(msg) PyErr_SetString(PyExc_ZeroDivisionError, msg)
#define SYSTEM_ERROR(msg) PyErr_SetString(PyExc_SystemError, msg)
#define OVERFLOW_ERROR(msg) PyErr_SetString(PyExc_OverflowError, msg)
#define RUNTIME_ERROR(msg) PyErr_SetString(PyExc_RuntimeError, msg)
#define GMPY_DEFAULT -1
/* To prevent excessive memory usage, we don't want to save very large
* numbers in the cache. The default value specified in the options
* structure is 128 words (512 bytes on 32-bit platforms, 1024 bytes on
* 64-bit platforms).
*/
#define MAX_CACHE_LIMBS 16384
/* The maximum number of objects that can be saved in a cache is specified
* here. The default value is 100.*/
#define MAX_CACHE 1000
#ifdef USE_ALLOCA
# define TEMP_ALLOC(B, S) \
if(S < ALLOC_THRESHOLD) { \
B = alloca(S); \
} else { \
if(!(B = malloc(S))) { \
PyErr_NoMemory(); \
return NULL; \
} \
}
# define TEMP_FREE(B, S) if(S >= ALLOC_THRESHOLD) free(B)
#else
# define TEMP_ALLOC(B, S) \
if(!(B = malloc(S))) { \
PyErr_NoMemory(); \
return NULL; \
}
# define TEMP_FREE(B, S) free(B)
#endif
#ifndef Py_SIZE
# define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
#endif
#ifndef Py_TYPE
# define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif
/* Import a collection of general purpose macros. */
#include "gmpy2_macros.h"
/* Import the files that complete the definition of the types defined above. */
#include "gmpy2_mpz.h"
#include "gmpy2_xmpz.h"
#include "gmpy2_mpq.h"
#include "gmpy2_mpfr.h"
#include "gmpy2_mpc.h"
#include "gmpy2_context.h"
#include "gmpy2_random.h"
/* Import the header files that provide the various functions. */
/* Support object caching, creation, and deletion. */
#include "gmpy2_cache.h"
/* Suport for miscellaneous functions (ie. version, license, etc.). */
#include "gmpy2_misc.h"
/* Support conversion to/from binary format. */
#include "gmpy2_binary.h"
/* Support for mpz/xmpz specific functions. */
#include "gmpy2_convert.h"
#include "gmpy2_convert_utils.h"
#include "gmpy2_convert_gmp.h"
#include "gmpy2_convert_mpfr.h"
#include "gmpy2_convert_mpc.h"
#include "gmpy2_mpz_divmod.h"
#include "gmpy2_mpz_divmod2exp.h"
#include "gmpy2_mpz_pack.h"
#include "gmpy2_mpz_bitops.h"
#include "gmpy2_mpz_misc.h"
#include "gmpy2_xmpz_inplace.h"
#include "gmpy2_xmpz_misc.h"
#include "gmpy2_xmpz_limbs.h"
/* Support for mpq specific functions. */
#include "gmpy2_mpq_misc.h"
/* Support for mpfr specific functions. */
#include "gmpy2_mpfr_misc.h"
/* Support for mpc specific functions. */
#include "gmpy2_mpc_misc.h"
/* Support Lucas sequences. */
#include "gmpy_mpz_lucas.h"
/* Support probable-prime tests. */
#include "gmpy_mpz_prp.h"
/* Support higher-level Python methods and functions; generally not
* specific to a single type.
*/
#include "gmpy2_abs.h"
#include "gmpy2_add.h"
#include "gmpy2_divmod.h"
#include "gmpy2_floordiv.h"
#include "gmpy2_minus.h"
#include "gmpy2_mod.h"
#include "gmpy2_mul.h"
#include "gmpy2_plus.h"
#include "gmpy2_pow.h"
#include "gmpy2_sub.h"
#include "gmpy2_truediv.h"
#include "gmpy2_math.h"
#include "gmpy2_const.h"
#include "gmpy2_square.h"
#include "gmpy2_format.h"
#include "gmpy2_hash.h"
#include "gmpy2_fused.h"
#include "gmpy2_muldiv_2exp.h"
#include "gmpy2_predicate.h"
#include "gmpy2_sign.h"
#include "gmpy2_richcompare.h"
#include "gmpy2_cmp.h"
#ifdef VECTOR
# include "gmpy2_vector.h"
#endif /* defined(VECTOR) */
#else /* defined(GMPY2_MODULE) */
/* This section is used for other C-coded modules that use gmpy2's API. */
static void **GMPy_C_API;
#define MPZ_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[MPZ_Type_NUM])
#define XMPZ_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[XMPZ_Type_NUM])
#define MPQ_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[MPQ_Type_NUM])
#define XMPQ_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[XMPQ_Type_NUM])
#define MPFR_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[MPFR_Type_NUM])
#define XMPFR_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[XMPFR_Type_NUM])
#define MPC_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[MPC_Type_NUM])
#define XMPC_Check(op) ((op)->ob_type == (PyTypeObject*)GMPy_C_API[XMPC_Type_NUM])
#define GMPy_MPZ_New (*(GMPy_MPZ_New_RETURN (*)GMPy_MPZ_New_PROTO) GMPy_C_API[GMPy_MPZ_New_NUM])
#define GMPy_MPZ_NewInit (*(GMPy_MPZ_NewInit_RETURN (*)GMPy_MPZ_NewInit_PROTO) GMPy_C_API[GMPy_MPZ_NewInit_NUM])
#define GMPy_MPZ_Dealloc (*(GMPy_MPZ_Dealloc_RETURN (*)GMPy_MPZ_Dealloc_PROTO) GMPy_C_API[GMPy_MPZ_Dealloc_NUM])
#define GMPy_MPZ_ConvertArg (*(GMPy_MPZ_ConvertArg_RETURN (*)GMPy_MPZ_ConvertArg_PROTO) GMPy_C_API[GMPy_MPZ_ConvertArg_NUM])
#define GMPy_XMPZ_New (*(GMPy_XMPZ_New_RETURN (*)GMPy_XMPZ_New_PROTO) GMPy_C_API[GMPy_XMPZ_New_NUM])
#define GMPy_XMPZ_NewInit (*(GMPy_XMPZ_NewInit_RETURN (*)GMPy_XMPZ_NewInit_PROTO) GMPy_C_API[GMPy_XMPZ_NewInit_NUM])
#define GMPy_XMPZ_Dealloc (*(GMPy_XMPZ_Dealloc_RETURN (*)GMPy_XMPZ_Dealloc_PROTO) GMPy_C_API[GMPy_XMPZ_Dealloc_NUM])
#define GMPy_MPQ_New (*(GMPy_MPQ_New_RETURN (*)GMPy_MPQ_New_PROTO) GMPy_C_API[GMPy_MPQ_New_NUM])
#define GMPy_MPQ_NewInit (*(GMPy_MPQ_NewInit_RETURN (*)GMPy_MPQ_NewInit_PROTO) GMPy_C_API[GMPy_MPQ_NewInit_NUM])
#define GMPy_MPQ_Dealloc (*(GMPy_MPQ_Dealloc_RETURN (*)GMPy_MPQ_Dealloc_PROTO) GMPy_C_API[GMPy_MPQ_Dealloc_NUM])
#define GMPy_MPQ_ConvertArg (*(GMPy_MPQ_ConvertArg_RETURN (*)GMPy_MPQ_ConvertArg_PROTO) GMPy_C_API[GMPy_MPQ_ConvertArg_NUM])
#define GMPy_MPFR_New (*(GMPy_MPFR_New_RETURN (*)GMPy_MPFR_New_PROTO) GMPy_C_API[GMPy_MPFR_New_NUM])
#define GMPy_MPFR_NewInit (*(GMPy_MPFR_NewInit_RETURN (*)GMPy_MPFR_NewInit_PROTO) GMPy_C_API[GMPy_MPFR_NewInit_NUM])
#define GMPy_MPFR_Dealloc (*(GMPy_MPFR_Dealloc_RETURN (*)GMPy_MPFR_Dealloc_PROTO) GMPy_C_API[GMPy_MPFR_Dealloc_NUM])
#define GMPy_MPFR_ConvertArg (*(GMPy_MPFR_ConvertArg_RETURN (*)GMPy_MPFR_ConvertArg_PROTO) GMPy_C_API[GMPy_MPFR_ConvertArg_NUM])
#define GMPy_MPC_New (*(GMPy_MPC_New_RETURN (*)GMPy_MPC_New_PROTO) GMPy_C_API[GMPy_MPC_New_NUM])
#define GMPy_MPC_NewInit (*(GMPy_MPC_NewInit_RETURN (*)GMPy_MPC_NewInit_PROTO) GMPy_C_API[GMPy_MPC_NewInit_NUM])
#define GMPy_MPC_Dealloc (*(GMPy_MPC_Dealloc_RETURN (*)GMPy_MPC_Dealloc_PROTO) GMPy_C_API[GMPy_MPC_Dealloc_NUM])
#define GMPy_MPC_ConvertArg (*(GMPy_MPC_ConvertArg_RETURN (*)GMPy_MPC_ConvertArg_PROTO) GMPy_C_API[GMPy_MPC_ConvertArg_NUM])
static int
import_gmpy2(void)
{
GMPy_C_API = (void **)PyCapsule_Import("gmpy2._C_API", 0);
return (GMPy_C_API != NULL) ? 0 : -1;
}
#endif /* defined(GMPY2_MODULE) */
#ifdef __cplusplus
}
#endif /* defined(__cplusplus */
#endif /* !defined(Py_GMPYMODULE_H */
|