[project @ 2000-08-04 23:28:04 by lewie]
[ghc.git] / ghc / rts / gmp / mp.h
1 /* mp.h -- Definitions for Berkeley compatible multiple precision functions.
2
3 Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
4
5 This file is part of the GNU MP Library.
6
7 The GNU MP Library is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Library General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 The GNU MP Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with the GNU MP Library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 MA 02111-1307, USA. */
21
22 #ifndef __MP_H__
23
24 #ifndef __GNU_MP__
25 #define __GNU_MP__ 2
26 #define __need_size_t
27 #include <stddef.h>
28 #undef __need_size_t
29
30 #if defined (__STDC__) || defined (__cplusplus)
31 #define __gmp_const const
32 #else
33 #define __gmp_const
34 #endif
35
36 #if defined (__GNUC__)
37 #define __gmp_inline __inline__
38 #else
39 #define __gmp_inline
40 #endif
41
42 #ifndef _EXTERN_INLINE
43 #ifdef __GNUC__
44 #define _EXTERN_INLINE extern __inline__
45 #else
46 #define _EXTERN_INLINE static
47 #endif
48 #endif
49
50 #ifdef _SHORT_LIMB
51 typedef unsigned int mp_limb_t;
52 typedef int mp_limb_signed_t;
53 #else
54 #ifdef _LONG_LONG_LIMB
55 typedef unsigned long long int mp_limb_t;
56 typedef long long int mp_limb_signed_t;
57 #else
58 typedef unsigned long int mp_limb_t;
59 typedef long int mp_limb_signed_t;
60 #endif
61 #endif
62
63 typedef mp_limb_t * mp_ptr;
64 typedef __gmp_const mp_limb_t * mp_srcptr;
65 typedef int mp_size_t;
66 typedef long int mp_exp_t;
67
68 #ifndef __MP_SMALL__
69 typedef struct
70 {
71 mp_size_t _mp_alloc; /* Number of *limbs* allocated and pointed
72 to by the D field. */
73 mp_size_t _mp_size; /* abs(SIZE) is the number of limbs
74 the last field points to. If SIZE
75 is negative this is a negative
76 number. */
77 mp_limb_t *_mp_d; /* Pointer to the limbs. */
78 } __mpz_struct;
79 #else
80 typedef struct
81 {
82 short int _mp_alloc; /* Number of *limbs* allocated and pointed
83 to by the D field. */
84 short int _mp_size; /* abs(SIZE) is the number of limbs
85 the last field points to. If SIZE
86 is negative this is a negative
87 number. */
88 mp_limb_t *_mp_d; /* Pointer to the limbs. */
89 } __mpz_struct;
90 #endif
91 #endif /* __GNU_MP__ */
92
93 /* User-visible types. */
94 typedef __mpz_struct MINT;
95
96 #ifdef __STDC__
97 void mp_set_memory_functions (void *(*) (size_t),
98 void *(*) (void *, size_t, size_t),
99 void (*) (void *, size_t));
100 MINT *itom (signed short int);
101 MINT *xtom (const char *);
102 void move (const MINT *, MINT *);
103 void madd (const MINT *, const MINT *, MINT *);
104 void msub (const MINT *, const MINT *, MINT *);
105 void mult (const MINT *, const MINT *, MINT *);
106 void mdiv (const MINT *, const MINT *, MINT *, MINT *);
107 void sdiv (const MINT *, signed short int, MINT *, signed short int *);
108 void msqrt (const MINT *, MINT *, MINT *);
109 void pow (const MINT *, const MINT *, const MINT *, MINT *);
110 void rpow (const MINT *, signed short int, MINT *);
111 void gcd (const MINT *, const MINT *, MINT *);
112 int mcmp (const MINT *, const MINT *);
113 void min (MINT *);
114 void mout (const MINT *);
115 char *mtox (const MINT *);
116 void mfree (MINT *);
117
118 #else
119
120 void mp_set_memory_functions ();
121 MINT *itom ();
122 MINT *xtom ();
123 void move ();
124 void madd ();
125 void msub ();
126 void mult ();
127 void mdiv ();
128 void sdiv ();
129 void msqrt ();
130 void pow ();
131 void rpow ();
132 void gcd ();
133 int mcmp ();
134 void min ();
135 void mout ();
136 char *mtox ();
137 void mfree ();
138 #endif
139
140 #define __MP_H__
141 #endif /* __MP_H__ */