fix interface and docs

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1492 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2006-01-02 03:35:45 +00:00
parent 2d4d1f1ea8
commit 72214cb08c
3 changed files with 29 additions and 8 deletions

View File

@ -10,8 +10,11 @@
* File: c_interface.c * * File: c_interface.c *
* comments: c_interface primitives definition * * comments: c_interface primitives definition *
* * * *
* Last rev: $Date: 2006-01-02 02:25:44 $,$Author: vsc $ * * Last rev: $Date: 2006-01-02 03:35:44 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.79 2006/01/02 02:25:44 vsc
* cannot release space from external GMPs.
*
* Revision 1.78 2006/01/02 02:16:18 vsc * Revision 1.78 2006/01/02 02:16:18 vsc
* support new interface between YAP and GMP, so that we don't rely on our own * support new interface between YAP and GMP, so that we don't rely on our own
* allocation routines. * allocation routines.
@ -443,7 +446,7 @@ YAP_BigNumOfTerm(Term t, void *b)
return; return;
if (!IsBigIntTerm(t)) if (!IsBigIntTerm(t))
return; return;
mpz_init_set(bz,Yap_BigIntOfTerm(t)); mpz_set(bz,Yap_BigIntOfTerm(t));
#endif /* USE_GMP */ #endif /* USE_GMP */
} }

View File

@ -10716,13 +10716,31 @@ a big int, creating a term from a big integer and to access the value
of a big int from a term. of a big int from a term.
@example @example
YAP_Bool YAP_IsBigNumTerm(YAP_Term @var{t}) YAP_Bool YAP_IsBigNumTerm(YAP_Term @var{t})
YAP_Term YAP_MkBigNumTerm(YAP_Int @var{i}) YAP_Term YAP_MkBigNumTerm(void *@var{b})
YAP_Int YAP_BigNumOfTerm(YAP_Term @var{t}) void *YAP_BigNumOfTerm(YAP_Term @var{t}, void *@var{b})
@end example @end example
@noindent @noindent
YAP must support bignum for the configuration you are using (check YAP must support bignum for the configuration you are using (check the
the YAP configuration and setup). For now, Yap only supports the GNU YAP configuration and setup). For now, Yap only supports the GNU GMP
GMP library and the @code{MP_INT *} type. library, and @code{void *} will be a cast for @code{mpz_t}. Notice
that @code{YAP_BigNumOfTerm} requires the number to be already
initialised. As an example, we show how to print a bignum:
@example
static int
p_print_bignum(void)
{
mpz_t mz;
if (!YAP_IsBigNumTerm(YAP_ARG1))
return FALSE;
mpz_init(mz);
YAP_BigNumOfTerm(YAP_ARG1, mz);
gmp_printf("Shows up as %Zd\n", mz);
mpz_clear(mz);
}
@end example
Currently, no primitives are supplied to users for manipulating data base Currently, no primitives are supplied to users for manipulating data base
references. references.

View File

@ -116,7 +116,7 @@ extern X_API YAP_Term PROTO(YAP_MkBigNumTerm,(void *));
extern X_API YAP_Int PROTO(YAP_IntOfTerm,(YAP_Term)); extern X_API YAP_Int PROTO(YAP_IntOfTerm,(YAP_Term));
/* void * BigNumOfTerm(Term) */ /* void * BigNumOfTerm(Term) */
extern X_API void *PROTO(YAP_BigNumOfTerm,(YAP_Term)); extern X_API void *PROTO(YAP_BigNumOfTerm,(YAP_Term, void *));
/* Term MkFloatTerm(YAP_Float) */ /* Term MkFloatTerm(YAP_Float) */
extern X_API YAP_Term PROTO(YAP_MkFloatTerm,(YAP_Float)); extern X_API YAP_Term PROTO(YAP_MkFloatTerm,(YAP_Float));