Debian Codegraph @

vendor/mruby-source/mrbgems/mruby-bigint/core/bigint.h

raw
1 /**
2 ** @file mruby/bigint.h - Multi-precision Integer
3 **
4 ** See Copyright Notice in mruby.h
5 */
6
7 #ifndef MRUBY_BIGINT_H
8 #define MRUBY_BIGINT_H
9 /*
10 * FREE GMP - a public domain implementation of a subset of the
11 * gmp library
12 *
13 * I hearby place the file in the public domain.
14 *
15 * Do whatever you want with this code. Change it. Sell it. Claim you
16 * wrote it.
17 * Bugs, complaints, flames, rants: please send email to
18 * Mark Henderson <[email protected]>
19 * I'm already aware that fgmp is considerably slower than gmp
20 *
21 * CREDITS:
22 * Paul Rouse <[email protected]> - generic bug fixes, mpz_sqrt and
23 * mpz_sqrtrem, and modifications to get fgmp to compile on a system
24 * with int and long of different sizes (specifically MS-DOS,286 compiler)
25 * Also see the file "notes" included with the fgmp distribution, for
26 * more credits.
27 *
28 * VERSION 1.0 - beta 5
29 */
30
31 #include <sys/types.h>
32
33 #if defined(MRB_INT32) && defined(_WIN32) && !defined(MRB_NO_MPZ64BIT)
34 #define MRB_NO_MPZ64BIT
35 #endif
36
37 #ifdef MRB_NO_MPZ64BIT
38 typedef uint16_t mp_limb;
39 typedef uint32_t mp_dbl_limb;
40 typedef int32_t mp_dbl_limb_signed;
41 #define MPZ_DIG_SIZE 16
42 #else
43 typedef uint32_t mp_limb;
44 typedef uint64_t mp_dbl_limb;
45 typedef int64_t mp_dbl_limb_signed;
46 #define MPZ_DIG_SIZE 32
47 #endif
48
49 typedef struct _mpz_t {
50 mp_limb *p;
51 short sn;
52 size_t sz;
53 } mpz_t;
54
55 struct RBigint {
56 MRB_OBJECT_HEADER;
57 mpz_t mp;
58 };
59 #define RBIGINT(v) ((struct RBigint*)mrb_ptr(v))
60
61 mrb_static_assert_object_size(struct RBigint);
62
63 #endif /* MRUBY_BIGINT_H */