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