File: mpz.h

package info (click to toggle)
gnu-smalltalk 3.1-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 33,300 kB
  • ctags: 13,999
  • sloc: ansic: 88,106; sh: 23,223; asm: 7,889; perl: 4,493; cpp: 3,539; awk: 1,483; yacc: 1,355; xml: 1,272; makefile: 1,192; lex: 843; sed: 258; objc: 124
file content (149 lines) | stat: -rw-r--r-- 4,958 bytes parent folder | download | duplicates (2)
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
/******************************** -*- C -*- ****************************
 *
 *	Definitions for GNU Smalltalk's multiple precision functions
 *
 *
 ***********************************************************************/

/***********************************************************************
 *
 * Copyright 1991, 2002 Free Software Foundation, Inc.
 *
 * This file is derived from an absurdly old version of the GNU MP Library.
 *
 * The GNU MP library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2, or (at
 * your option) any later version.
 *
 * The GNU MP 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the GNU MP library; see the file COPYING.  If not, write
 * to the Free Software Foundation, 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 ***********************************************************************/

#ifndef GST_MPZ_H
#define GST_MPZ_H

#if HAVE_GMP
#include <gmp.h>

typedef struct
{
  size_t alloc;			/* Number of *limbs* allocated and pointed
				   to by the D field.  */
  ssize_t size;			/* abs(SIZE) is the number of limbs
				   the last field points to.  If SIZE
				   is negative this is a negative
				   number.  */
  mp_limb_t *d;			/* Pointer to the limbs.  */
} gst_mpz;

/**************** Integer (i.e. Z) routines.  ****************/


/* Add two integers.  */
void _gst_mpz_add (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Compute the two's complement AND of two integers.  */
void _gst_mpz_and (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Compute the two's complement inclusive OR of two integers.  */
void _gst_mpz_ior (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Compute the two's complement XOR of two integers.  */
void _gst_mpz_xor (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Assign the bit-complemented value of an integer to another */
void _gst_mpz_com (gst_mpz *dst, const gst_mpz *src) 
  ATTRIBUTE_HIDDEN;

/* Subtract two integers.  */
void _gst_mpz_sub (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Multiply two integers.  */
void _gst_mpz_mul (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Floor DIVision, with Quotient and Remainder, i.e. division that
   rounds the quotient towards -infinity, and with the remainder
   non-negative.  */
void _gst_mpz_fdiv_qr (gst_mpz *, gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Floor DIVision by a Signed Integer, with Quotient and Remainder.  */
mp_limb_t _gst_mpz_fdiv_qr_si (gst_mpz *quot, const gst_mpz *num, intptr_t den) 
  ATTRIBUTE_HIDDEN;

/* Truncated DIVision, with Quotient and Remainder.  */
void _gst_mpz_tdiv_qr (gst_mpz *, gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Truncated DIVision by a Signed Integer, with Quotient and Remainder.  */
mp_limb_t _gst_mpz_tdiv_qr_si (gst_mpz *quot, const gst_mpz *num, intptr_t den) 
  ATTRIBUTE_HIDDEN;

/* Greatest Common Divisor of two numbers.  */
void _gst_mpz_gcd (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Compare two integers U, V.  Return positive, zero, or negative
   based on if U > V, U == V, or U < V.  */
int _gst_mpz_cmp (const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Convert to double */
double _gst_mpz_get_d (const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Convert to long double */
long double _gst_mpz_get_ld (const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Multiply an integer by 2**CNT  */
void _gst_mpz_mul_2exp (gst_mpz *, const gst_mpz *, unsigned) 
  ATTRIBUTE_HIDDEN;

/* Divide an integer by 2**CNT  */
void _gst_mpz_div_2exp (gst_mpz *, const gst_mpz *, unsigned) 
  ATTRIBUTE_HIDDEN;

/* Divide with no remainder.  */
void _gst_mpz_divexact (gst_mpz *, const gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Allocate space for an integer if necessary, and assign an integer
   from another one.  */
void _gst_mpz_set (gst_mpz *, const gst_mpz *) 
  ATTRIBUTE_HIDDEN;

/* Free an integer */
void _gst_mpz_clear (gst_mpz *m) 
  ATTRIBUTE_HIDDEN;

/* Create an integer from an OOP (an instance of a subclass of
   Integer).  Space from the object itself is pointed to on
   little-endian machines, so you should care that no GC's happen
   while we're manipulating integers.  */
void _gst_mpz_from_oop (gst_mpz *, OOP) 
  ATTRIBUTE_HIDDEN;

/* Create an OOP (an instance of a subclass of Integer) from a big
   integer.  */
OOP _gst_oop_from_mpz (gst_mpz *) 
  ATTRIBUTE_HIDDEN;

#endif

#endif /* GST_MPZ_H */