Stasinos noticed that _YAP_ breaks C standard: use Yap_ instead.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@691 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc
2002-11-18 18:18:05 +00:00
parent 212c64f782
commit d7f80ea1ad
77 changed files with 6703 additions and 6703 deletions

View File

@@ -9,14 +9,14 @@
**************************************************************************
* *
* File: mpe.c *
* Last rev: $Date: 2002-11-11 17:38:03 $ *
* Last rev: $Date: 2002-11-18 18:16:43 $ *
* mods: *
* comments: Interface to an MPE library *
* *
*************************************************************************/
#ifndef lint
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpe.c,v 1.4 2002-11-11 17:38:03 vsc Exp $";
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpe.c,v 1.5 2002-11-18 18:16:43 vsc Exp $";
#endif
#include "Yap.h"
@@ -204,14 +204,14 @@ p_log() /* mpe_log(+EventType, +EventNum, +EventStr) */
void
_YAP_InitMPE(void)
Yap_InitMPE(void)
{
_YAP_InitCPred( "mpe_open", 0, p_init, SafePredFlag );
_YAP_InitCPred( "mpe_start", 0, p_start, SafePredFlag );
_YAP_InitCPred( "mpe_close", 1, p_close, SafePredFlag );
_YAP_InitCPred( "mpe_create_event", 1, p_create_event, SafePredFlag );
_YAP_InitCPred( "mpe_create_state", 4, p_create_state, SafePredFlag );
_YAP_InitCPred( "mpe_log", 3, p_log, SafePredFlag );
Yap_InitCPred( "mpe_open", 0, p_init, SafePredFlag );
Yap_InitCPred( "mpe_start", 0, p_start, SafePredFlag );
Yap_InitCPred( "mpe_close", 1, p_close, SafePredFlag );
Yap_InitCPred( "mpe_create_event", 1, p_create_event, SafePredFlag );
Yap_InitCPred( "mpe_create_state", 4, p_create_state, SafePredFlag );
Yap_InitCPred( "mpe_log", 3, p_log, SafePredFlag );
}
#endif /* HAVE_MPE */

View File

@@ -9,14 +9,14 @@
**************************************************************************
* *
* File: mpi.c *
* Last rev: $Date: 2002-11-12 10:25:11 $ *
* Last rev: $Date: 2002-11-18 18:16:51 $ *
* mods: *
* comments: Interface to an MPI library *
* *
*************************************************************************/
#ifndef lint
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.15 2002-11-12 10:25:11 stasinos Exp $";
static char *rcsid = "$Header: /Users/vitor/Yap/yap-cvsbackup/library/mpi/mpi.c,v 1.16 2002-11-18 18:16:51 vsc Exp $";
#endif
#include "Yap.h"
@@ -82,8 +82,8 @@ expand_buffer( int space )
tmp = malloc( bufsize + space );
if( tmp == NULL ) {
_YAP_Error(SYSTEM_ERROR, TermNil, "out of memory" );
_YAP_exit( EXIT_FAILURE );
Yap_Error(SYSTEM_ERROR, TermNil, "out of memory" );
Yap_exit( EXIT_FAILURE );
}
memcpy( tmp, buf, bufsize );
#if 0
@@ -100,8 +100,8 @@ expand_buffer( int space )
printf("realloc'ed space...");
#endif
if( buf == NULL ) {
_YAP_Error(SYSTEM_ERROR, TermNil, "out of memory");
_YAP_exit( EXIT_FAILURE );
Yap_Error(SYSTEM_ERROR, TermNil, "out of memory");
Yap_exit( EXIT_FAILURE );
}
#endif
@@ -158,43 +158,43 @@ mpi_parse(void)
CELL *old_H;
/* Scans the term using stack space */
_YAP_eot_before_eof = FALSE;
Yap_eot_before_eof = FALSE;
/* the first arg is the getc_for_read, diff only if CharConv is on */
tokstart = _YAP_tokptr = _YAP_toktide = _YAP_tokenizer(mpi_getc, mpi_getc);
tokstart = Yap_tokptr = Yap_toktide = Yap_tokenizer(mpi_getc, mpi_getc);
/* preserve value of H after scanning: otherwise we may lose strings
and floats */
old_H = H;
if ( mpi_eob() && !_YAP_eot_before_eof) {
if ( mpi_eob() && !Yap_eot_before_eof) {
if (tokstart != NIL && tokstart->Tok != Ord (eot_tok)) {
/* we got the end of file from an abort */
if (_YAP_ErrorMessage == "Abort") {
if (Yap_ErrorMessage == "Abort") {
TR = old_TR;
return TermNil;
}
/* we need to force the next reading to also give end of file.*/
buf[bufptr] = EOF;
_YAP_ErrorMessage = "[ Error: end of file found before end of term ]";
Yap_ErrorMessage = "[ Error: end of file found before end of term ]";
} else {
/* restore TR */
TR = old_TR;
return (_YAP_unify_constant(t, MkAtomTerm(AtomEof)));
return (Yap_unify_constant(t, MkAtomTerm(AtomEof)));
}
}
repeat_cycle:
TR_before_parse = TR;
if( _YAP_ErrorMessage || (t = _YAP_Parse())==0 ) {
if (_YAP_ErrorMessage && (strcmp(_YAP_ErrorMessage,"Stack Overflow") == 0)) {
if( Yap_ErrorMessage || (t = Yap_Parse())==0 ) {
if (Yap_ErrorMessage && (strcmp(Yap_ErrorMessage,"Stack Overflow") == 0)) {
/* ignore term we just built */
TR = TR_before_parse;
H = old_H;
if (_YAP_growstack_in_parser(&old_TR, &tokstart, &_YAP_VarTable)) {
if (Yap_growstack_in_parser(&old_TR, &tokstart, &Yap_VarTable)) {
old_H = H;
_YAP_tokptr = _YAP_toktide = tokstart;
_YAP_ErrorMessage = NULL;
Yap_tokptr = Yap_toktide = tokstart;
Yap_ErrorMessage = NULL;
goto repeat_cycle;
}
}
@@ -206,8 +206,8 @@ mpi_parse(void)
failing the predicate: the parse cannot fail unless there
is a problem with MPI or the pretty printer.
*/
_YAP_Error(SYSTEM_ERROR, TermNil, "Failed to parse MPI_Recv()'ed term" );
_YAP_exit( EXIT_FAILURE );
Yap_Error(SYSTEM_ERROR, TermNil, "Failed to parse MPI_Recv()'ed term" );
Yap_exit( EXIT_FAILURE );
} else {
/* parsing succeeded */
@@ -257,7 +257,7 @@ Yap exit(FAILURE), whereas in Yap/LAM mpi_open/3 simply fails.
Term t;
t = MkIntegerTerm(retv);
_YAP_Error( SYSTEM_ERROR, t, "MPI_Init() returned non-zero" );
Yap_Error( SYSTEM_ERROR, t, "MPI_Init() returned non-zero" );
return FALSE;
}
#endif
@@ -265,9 +265,9 @@ Yap exit(FAILURE), whereas in Yap/LAM mpi_open/3 simply fails.
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
MPI_Get_processor_name( processor_name, &namelen );
retv = _YAP_unify(t_rank, MkIntTerm(rank));
retv = retv && _YAP_unify(t_numprocs, MkIntTerm(numprocs));
retv = retv && _YAP_unify(t_procname, MkAtomTerm(_YAP_LookupAtom(processor_name)));
retv = Yap_unify(t_rank, MkIntTerm(rank));
retv = retv && Yap_unify(t_numprocs, MkIntTerm(numprocs));
retv = retv && Yap_unify(t_procname, MkAtomTerm(Yap_LookupAtom(processor_name)));
return retv;
}
@@ -289,25 +289,25 @@ p_mpi_send() /* mpi_send(+data, +destination, +tag) */
/* The first argument (data) must be bound */
if (IsVarTerm(t_data)) {
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_send");
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_send");
return (FALSE);
}
/* The second and third args must be bount to integers */
if (IsVarTerm(t_dest)) {
_YAP_Error(INSTANTIATION_ERROR, t_dest, "mpi_send");
Yap_Error(INSTANTIATION_ERROR, t_dest, "mpi_send");
return (FALSE);
} else if( !IsIntegerTerm(t_dest) ) {
_YAP_Error(TYPE_ERROR_INTEGER, t_dest, "mpi_send");
Yap_Error(TYPE_ERROR_INTEGER, t_dest, "mpi_send");
return (FALSE);
} else {
dest = IntOfTerm( t_dest );
}
if (IsVarTerm(t_tag)) {
_YAP_Error(INSTANTIATION_ERROR, t_tag, "mpi_send");
Yap_Error(INSTANTIATION_ERROR, t_tag, "mpi_send");
return (FALSE);
} else if( !IsIntegerTerm(t_tag) ) {
_YAP_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_send");
Yap_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_send");
return (FALSE);
} else {
tag = IntOfTerm( t_tag );
@@ -315,7 +315,7 @@ p_mpi_send() /* mpi_send(+data, +destination, +tag) */
bufptr = 0;
/* Turn the term into its ASCII representation */
_YAP_plwrite( t_data, mpi_putc, 5 );
Yap_plwrite( t_data, mpi_putc, 5 );
bufstrlen = (size_t)bufptr;
/* The buf is not NULL-terminated and does not have the
@@ -363,7 +363,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
/* The first argument (data) must be unbound */
if(!IsVarTerm(t_data)) {
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_receive");
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_receive");
return FALSE;
}
@@ -373,7 +373,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
if (IsVarTerm(t_orig)) {
orig = MPI_ANY_SOURCE;
} else if( !IsIntegerTerm(t_orig) ) {
_YAP_Error(TYPE_ERROR_INTEGER, t_orig, "mpi_receive");
Yap_Error(TYPE_ERROR_INTEGER, t_orig, "mpi_receive");
return (FALSE);
} else {
orig = IntOfTerm( t_orig );
@@ -384,7 +384,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
if (IsVarTerm(t_tag)) {
tag = MPI_ANY_TAG;
} else if( !IsIntegerTerm(t_tag) ) {
_YAP_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_receive");
Yap_Error(TYPE_ERROR_INTEGER, t_tag, "mpi_receive");
return (FALSE);
} else
tag = IntOfTerm( t_tag );
@@ -412,7 +412,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
/* Already know the source from MPI_Probe() */
if( orig == MPI_ANY_SOURCE ) {
orig = status.MPI_SOURCE;
retv = _YAP_unify(t_orig, MkIntTerm(orig));
retv = Yap_unify(t_orig, MkIntTerm(orig));
if( retv == FALSE ) {
printf("PROBLEM: file %s, line %d\n", __FILE__, __LINE__);
}
@@ -421,7 +421,7 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
/* Already know the tag from MPI_Probe() */
if( tag == MPI_ANY_TAG ) {
tag = status.MPI_TAG;
retv = _YAP_unify(t_tag, MkIntTerm(status.MPI_TAG));
retv = Yap_unify(t_tag, MkIntTerm(status.MPI_TAG));
if( retv == FALSE ) {
printf("PROBLEM: file %s, line %d\n", __FILE__, __LINE__);
}
@@ -451,13 +451,13 @@ p_mpi_receive() /* mpi_receive(-data, ?orig, ?tag) */
/* parse received string into a Prolog term */
bufptr = 0;
retv = _YAP_unify(ARG1, mpi_parse());
retv = Yap_unify(ARG1, mpi_parse());
#if 0
/* check up on mpi_parse():
convert the newly-parsed term back to text and print */
bufptr = 0;
_YAP_plwrite( t_data, mpi_putc, 5 );
Yap_plwrite( t_data, mpi_putc, 5 );
mpi_putc( 0, '.' );
mpi_putc( 0, ' ' );
buf[bufptr] = 0;
@@ -484,7 +484,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
/* The second argument must be bound to an integer (the rank of
root processor */
if (IsVarTerm(t_root)) {
_YAP_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
return FALSE;
}
root = IntOfTerm( t_root );
@@ -493,12 +493,12 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
be bound to the term to be sent. */
if( root == rank ) {
if( IsVarTerm(t_data) ) {
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
return FALSE;
}
bufptr = 0;
/* Turn the term into its ASCII representation */
_YAP_plwrite( t_data, mpi_putc, 5 );
Yap_plwrite( t_data, mpi_putc, 5 );
/* NULL-terminate the string and add the ". " termination
required by the parser. */
buf[bufptr] = 0;
@@ -509,7 +509,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
/* The third argument must be bound to an integer (the maximum length
of the broadcast term's ASCII representation */
if (IsVarTerm(t_max_size)) {
_YAP_Error(INSTANTIATION_ERROR, t_max_size, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_max_size, "mpi_bcast");
return FALSE;
}
/* allow for the ". " bit and the NULL at the end */
@@ -543,7 +543,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
else {
/* ARG1 must be unbound so that it can receive data */
if( !IsVarTerm(t_data) ) {
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
return FALSE;
}
@@ -551,7 +551,7 @@ p_mpi_bcast3() /* mpi_bcast( ?data, +root, +max_size ) */
bufptr = 0;
/* parse received string into a Prolog term */
return _YAP_unify(mpi_parse(), ARG1);
return Yap_unify(mpi_parse(), ARG1);
}
}
@@ -570,7 +570,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
/* The second argument must be bound to an integer (the rank of
root processor */
if (IsVarTerm(t_root)) {
_YAP_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_root, "mpi_bcast");
return FALSE;
}
root = IntOfTerm( t_root );
@@ -580,12 +580,12 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
be bound to the term to be sent. */
if( root == rank ) {
if( IsVarTerm(t_data) ) {
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
return FALSE;
}
bufptr = 0;
/* Turn the term into its ASCII representation */
_YAP_plwrite( t_data, mpi_putc, 5 );
Yap_plwrite( t_data, mpi_putc, 5 );
/* NULL-terminate the string and add the ". " termination
required by the parser. */
buf[bufptr] = 0;
@@ -595,7 +595,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
/* Otherwise, it must a variable */
else {
if( !IsVarTerm(t_data) ) {
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
return FALSE;
}
}
@@ -631,7 +631,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
else {
/* ARG1 must be unbound so that it can receive data */
if( !IsVarTerm(t_data) ) {
_YAP_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
Yap_Error(INSTANTIATION_ERROR, t_data, "mpi_bcast");
return FALSE;
}
@@ -639,7 +639,7 @@ p_mpi_bcast2() /* mpi_bcast( ?data, +root ) */
bufptr = 0;
/* parse received string into a Prolog term */
return _YAP_unify(ARG1, mpi_parse());
return Yap_unify(ARG1, mpi_parse());
}
}
@@ -662,31 +662,31 @@ p_mpi_barrier() /* mpi_barrier/0 */
void
_YAP_InitMPI(void)
Yap_InitMPI(void)
{
int i,j;
mpi_argv = malloc( _YAP_argc * sizeof(char *) );
mpi_argv[0] = strdup( _YAP_argv[0] );
mpi_argv = malloc( Yap_argc * sizeof(char *) );
mpi_argv[0] = strdup( Yap_argv[0] );
bufsize = RECV_BUF_SIZE;
buf = malloc(bufsize * sizeof(char));
for( i=1; i<_YAP_argc; ++i ) {
if( !strcmp(_YAP_argv[i], "--") ) { ++i; break; }
for( i=1; i<Yap_argc; ++i ) {
if( !strcmp(Yap_argv[i], "--") ) { ++i; break; }
}
for( j=1; i<_YAP_argc; ++i, ++j ) {
mpi_argv[j] = strdup( _YAP_argv[i] );
for( j=1; i<Yap_argc; ++i, ++j ) {
mpi_argv[j] = strdup( Yap_argv[i] );
}
mpi_argc = j;
mpi_argv[0] = strdup( _YAP_argv[0] );
mpi_argv[0] = strdup( Yap_argv[0] );
#if 0
/* DEBUG */
printf( "_YAP_argc = %d\n", _YAP_argc );
for( i=0; i<_YAP_argc; ++i ) {
printf( "%d %s\n", i, _YAP_argv[i] );
printf( "Yap_argc = %d\n", Yap_argc );
for( i=0; i<Yap_argc; ++i ) {
printf( "%d %s\n", i, Yap_argv[i] );
}
#endif
@@ -698,7 +698,7 @@ _YAP_InitMPI(void)
}
#endif
/* With MPICH MPI__YAP_Init() must be called during initialisation,
/* With MPICH MPI_Yap_Init() must be called during initialisation,
but with LAM it can be called from Prolog (mpi_open/3).
See also the comment at "if ! HAVE_LIBMPICH" above!
*/
@@ -711,8 +711,8 @@ _YAP_InitMPI(void)
Term t;
t = MkIntegerTerm(retv);
_YAP_Error(SYSTEM_ERROR, t, "MPI_Init() returned non-zero");
_YAP_exit( EXIT_FAILURE );
Yap_Error(SYSTEM_ERROR, t, "MPI_Init() returned non-zero");
Yap_exit( EXIT_FAILURE );
}
#if 0
/* DEBUG */
@@ -723,13 +723,13 @@ _YAP_InitMPI(void)
}
#endif
_YAP_InitCPred( "mpi_open", 3, p_mpi_open, SyncPredFlag );
_YAP_InitCPred( "mpi_close", 0, p_mpi_close, SafePredFlag|SyncPredFlag );
_YAP_InitCPred( "mpi_send", 3, p_mpi_send, SafePredFlag|SyncPredFlag );
_YAP_InitCPred( "mpi_receive", 3, p_mpi_receive, SyncPredFlag );
_YAP_InitCPred( "mpi_bcast", 3, p_mpi_bcast3, SyncPredFlag );
_YAP_InitCPred( "mpi_bcast", 2, p_mpi_bcast2, SyncPredFlag );
_YAP_InitCPred( "mpi_barrier", 0, p_mpi_barrier, SyncPredFlag );
Yap_InitCPred( "mpi_open", 3, p_mpi_open, SyncPredFlag );
Yap_InitCPred( "mpi_close", 0, p_mpi_close, SafePredFlag|SyncPredFlag );
Yap_InitCPred( "mpi_send", 3, p_mpi_send, SafePredFlag|SyncPredFlag );
Yap_InitCPred( "mpi_receive", 3, p_mpi_receive, SyncPredFlag );
Yap_InitCPred( "mpi_bcast", 3, p_mpi_bcast3, SyncPredFlag );
Yap_InitCPred( "mpi_bcast", 2, p_mpi_bcast2, SyncPredFlag );
Yap_InitCPred( "mpi_barrier", 0, p_mpi_barrier, SyncPredFlag );
}
#endif /* HAVE_MPI */