Debian Codegraph @

gmpy2/gmpy2.h

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