?? gmp.h
字號:
/* Definitions for GNU multiple precision functions. -*- mode: c -*-Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003,2004 Free Software Foundation, Inc.This file is part of the GNU MP Library.The GNU MP Library is free software; you can redistribute it and/or modifyit under the terms of the GNU Lesser General Public License as published bythe Free Software Foundation; either version 2.1 of the License, or (at youroption) any later version.The GNU MP Library is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITYor FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General PublicLicense for more details.You should have received a copy of the GNU Lesser General Public Licensealong with the GNU MP Library; see the file COPYING.LIB. If not, write tothe Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,MA 02111-1307, USA. */#ifndef __GMP_H__#if defined (__cplusplus)#include <iosfwd> /* for istream, ostream */#endif/* Instantiated by configure. */#if ! defined (__GMP_WITHIN_CONFIGURE)#define __GMP_BITS_PER_MP_LIMB 32#define __GMP_HAVE_HOST_CPU_FAMILY_power 0#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0#define GMP_LIMB_BITS 32#define GMP_NAIL_BITS 0#endif#define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS)#define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)#define GMP_NUMB_MAX GMP_NUMB_MASK#define GMP_NAIL_MASK (~ GMP_NUMB_MASK)/* The following (everything under ifndef __GNU_MP__) must be identical in gmp.h and mp.h to allow both to be included in an application or during the library build. */#ifndef __GNU_MP__#define __GNU_MP__ 4#define __need_size_t /* tell gcc stddef.h we only want size_t */#if defined (__cplusplus)#include <cstddef> /* for size_t */#else#include <stddef.h> /* for size_t */#endif#undef __need_size_t/* Instantiated by configure. */#if ! defined (__GMP_WITHIN_CONFIGURE)/* #undef _LONG_LONG_LIMB */#define __GMP_LIBGMP_DLL 1#endif/* __STDC__ - some ANSI compilers define this only to 0, hence the use of "defined" and not "__STDC__-0". In particular Sun workshop C 5.0 sets __STDC__ to 0, but requires "##" for token pasting. _AIX - gnu ansidecl.h asserts that all known AIX compilers are ANSI but don't always define __STDC__. _mips - gnu ansidecl.h says the RISC/OS MIPS compiler is ANSI in SVR4 mode, but doesn't define __STDC__. _MSC_VER - Microsoft C is ANSI, but __STDC__ is undefined unless the /Za option is given (in which case it's 1). _WIN32 - tested for by gnu ansidecl.h, no doubt on the assumption that all w32 compilers are ansi. */#if defined (__STDC__) \ || defined (__cplusplus) \ || defined (_AIX) \ || defined (__DECC) \ || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ || defined (_MSC_VER) \ || defined (_WIN32)#define __GMP_HAVE_CONST 1#define __GMP_HAVE_PROTOTYPES 1#define __GMP_HAVE_TOKEN_PASTE 1#else#define __GMP_HAVE_CONST 0#define __GMP_HAVE_PROTOTYPES 0#define __GMP_HAVE_TOKEN_PASTE 0#endif#if __GMP_HAVE_CONST#define __gmp_const const#define __gmp_signed signed#else#define __gmp_const#define __gmp_signed#endif/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in all other circumstances. When compiling objects for libgmp, __GMP_DECLSPEC is an export directive, or when compiling for an application it's an import directive. The two cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles (and not defined from an application). __GMP_DECLSPEC_XX is similarly used for libgmpxx. __GMP_WITHIN_GMPXX indicates when building libgmpxx, and in that case libgmpxx functions are exports, but libgmp functions which might get called are imports. libmp.la uses __GMP_DECLSPEC, just as if it were libgmp.la. libgmp and libmp don't call each other, so there's no conflict or confusion. Libtool DLL_EXPORT define is not used. There's no attempt to support GMP built both static and DLL. Doing so would mean applications would have to tell us which of the two is going to be used when linking, and that seems very tedious and error prone if using GMP by hand, and equally tedious from a package since autoconf and automake don't give much help. __GMP_DECLSPEC is required on all documented global functions and variables, the various internals in gmp-impl.h etc can be left unadorned. But internals used by the test programs or speed measuring programs should have __GMP_DECLSPEC, and certainly constants or variables must have it or the wrong address will be resolved. */#if defined (__GNUC__)#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__)#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__)#endif#if defined (_MSC_VER) || defined (__BORLANDC__)#define __GMP_DECLSPEC_EXPORT __declspec(dllexport)#define __GMP_DECLSPEC_IMPORT __declspec(dllimport)#endif#ifdef __WATCOMC__#define __GMP_DECLSPEC_EXPORT __export#define __GMP_DECLSPEC_IMPORT __import#endif#ifdef __IBMC__#define __GMP_DECLSPEC_EXPORT _Export#define __GMP_DECLSPEC_IMPORT _Import#endif#if __GMP_LIBGMP_DLL#if __GMP_WITHIN_GMP/* compiling to go into a DLL libgmp */#define __GMP_DECLSPEC __GMP_DECLSPEC_EXPORT#else/* compiling to go into an application which will link to a DLL libgmp */#define __GMP_DECLSPEC __GMP_DECLSPEC_IMPORT#endif#else/* all other cases */#define __GMP_DECLSPEC#endif#ifdef __GMP_SHORT_LIMBtypedef unsigned int mp_limb_t;typedef int mp_limb_signed_t;#else#ifdef _LONG_LONG_LIMBtypedef unsigned long long int mp_limb_t;typedef long long int mp_limb_signed_t;#elsetypedef unsigned long int mp_limb_t;typedef long int mp_limb_signed_t;#endif#endiftypedef mp_limb_t * mp_ptr;typedef __gmp_const mp_limb_t * mp_srcptr;#if defined (_CRAY) && ! defined (_CRAYMPP)/* plain `int' is much faster (48 bits) */#define __GMP_MP_SIZE_T_INT 1typedef int mp_size_t;typedef int mp_exp_t;#else#define __GMP_MP_SIZE_T_INT 0typedef long int mp_size_t;typedef long int mp_exp_t;#endiftypedef struct{ int _mp_alloc; /* Number of *limbs* allocated and pointed to by the _mp_d field. */ int _mp_size; /* abs(_mp_size) is the number of limbs the last field points to. If _mp_size is negative this is a negative number. */ mp_limb_t *_mp_d; /* Pointer to the limbs. */} __mpz_struct;#endif /* __GNU_MP__ */typedef __mpz_struct MP_INT;typedef __mpz_struct mpz_t[1];typedef struct{ __mpz_struct _mp_num; __mpz_struct _mp_den;} __mpq_struct;typedef __mpq_struct MP_RAT;typedef __mpq_struct mpq_t[1];typedef struct{ int _mp_prec; /* Max precision, in number of `mp_limb_t's. Set by mpf_init and modified by mpf_set_prec. The area pointed to by the _mp_d field contains `prec' + 1 limbs. */ int _mp_size; /* abs(_mp_size) is the number of limbs the last field points to. If _mp_size is negative this is a negative number. */ mp_exp_t _mp_exp; /* Exponent, in the base of `mp_limb_t'. */ mp_limb_t *_mp_d; /* Pointer to the limbs. */} __mpf_struct;/* typedef __mpf_struct MP_FLOAT; */typedef __mpf_struct mpf_t[1];/* Available random number generation algorithms. */typedef enum{ GMP_RAND_ALG_DEFAULT = 0, GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential. */} gmp_randalg_t;/* Linear congruential data struct. */typedef struct { mpz_t _mp_a; /* Multiplier. */ unsigned long int _mp_c; /* Adder. */ mpz_t _mp_m; /* Modulus (valid only if m2exp == 0). */ unsigned long int _mp_m2exp; /* If != 0, modulus is 2 ^ m2exp. */} __gmp_randata_lc;/* Random state struct. */typedef struct{ mpz_t _mp_seed; /* Current seed. */ gmp_randalg_t _mp_alg; /* Algorithm used. */ union { /* Algorithm specific data. */ __gmp_randata_lc *_mp_lc; /* Linear congruential. */ } _mp_algdata;} __gmp_randstate_struct;typedef __gmp_randstate_struct gmp_randstate_t[1];/* Types for function declarations in gmp files. *//* ??? Should not pollute user name space with these ??? */typedef __gmp_const __mpz_struct *mpz_srcptr;typedef __mpz_struct *mpz_ptr;typedef __gmp_const __mpf_struct *mpf_srcptr;typedef __mpf_struct *mpf_ptr;typedef __gmp_const __mpq_struct *mpq_srcptr;typedef __mpq_struct *mpq_ptr;/* This is not wanted in mp.h, so put it outside the __GNU_MP__ common section. */#if __GMP_LIBGMP_DLL#if __GMP_WITHIN_GMPXX/* compiling to go into a DLL libgmpxx */#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_EXPORT#else/* compiling to go into a application which will link to a DLL libgmpxx */#define __GMP_DECLSPEC_XX __GMP_DECLSPEC_IMPORT#endif#else/* all other cases */#define __GMP_DECLSPEC_XX#endif#if __GMP_HAVE_PROTOTYPES#define __GMP_PROTO(x) x#else#define __GMP_PROTO(x) ()#endif#ifndef __MPN#if __GMP_HAVE_TOKEN_PASTE#define __MPN(x) __gmpn_##x#else#define __MPN(x) __gmpn_/**/x#endif#endif#if defined (FILE) \ || defined (H_STDIO) \ || defined (_H_STDIO) /* AIX */ \ || defined (_STDIO_H) /* glibc, Sun, SCO */ \ || defined (_STDIO_H_) /* BSD, OSF */ \ || defined (__STDIO_H) /* Borland */ \ || defined (__STDIO_H__) /* IRIX */ \ || defined (_STDIO_INCLUDED) /* HPUX */ \ || defined (__dj_include_stdio_h_) /* DJGPP */ \ || defined (_FILE_DEFINED) /* Microsoft */ \ || defined (__STDIO__) /* Apple MPW MrC */ \ || defined (_MSL_STDIO_H) /* Metrowerks */#define _GMP_H_HAVE_FILE 1#endif/* In ISO C, if a prototype involving "struct obstack *" is given without that structure defined, then the struct is scoped down to just the prototype, causing a conflict if it's subsequently defined for real. So only give prototypes if we've got obstack.h. */#if defined (_OBSTACK_H) /* glibc <obstack.h> */#define _GMP_H_HAVE_OBSTACK 1#endif/* The prototypes for gmp_vprintf etc are provided only if va_list is available, via an application having included <stdarg.h> or <varargs.h>. Usually va_list is a typedef so can't be tested directly, but va_start is almost certainly a macro, so look for that. <stdio.h> will define some sort of va_list for vprintf and vfprintf, but let's not bother trying to use that since it's not standard and since application uses for gmp_vprintf etc will almost certainly require the whole <stdarg.h> or <varargs.h> anyway. */#ifdef va_start#define _GMP_H_HAVE_VA_LIST 1#endif/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */#if defined (__GNUC__) && defined (__GNUC_MINOR__)#define __GMP_GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))#else#define __GMP_GNUC_PREREQ(maj, min) 0#endif/* "pure" is in gcc 2.96 and up, see "(gcc)Function Attributes". Basically it means a function does nothing but examine its arguments and memory (global or via arguments) to generate a return value, but changes nothing and has no side-effects. */#if __GMP_GNUC_PREREQ (2,96)#define __GMP_ATTRIBUTE_PURE __attribute__ ((__pure__))#else#define __GMP_ATTRIBUTE_PURE
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -