2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
|
|
|
** **
|
|
|
|
** The YapTab/YapOr/OPTYap systems **
|
|
|
|
** **
|
|
|
|
** YapTab extends the Yap Prolog engine to support sequential tabling **
|
|
|
|
** YapOr extends the Yap Prolog engine to support or-parallelism **
|
|
|
|
** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
|
|
|
|
** **
|
|
|
|
** **
|
|
|
|
** Yap Prolog was developed at University of Porto, Portugal **
|
|
|
|
** **
|
|
|
|
************************************************************************/
|
2005-05-31 09:24:24 +01:00
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/***********************
|
2001-04-09 20:54:03 +01:00
|
|
|
** Includes **
|
2010-04-03 05:58:14 +01:00
|
|
|
***********************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
#include "Yap.h"
|
|
|
|
#if defined(YAPOR) || defined(TABLING)
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2003-11-05 16:12:25 +00:00
|
|
|
#include <stdlib.h>
|
2001-04-09 20:54:03 +01:00
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
2005-06-03 19:28:11 +01:00
|
|
|
#endif /* HAVE_UNISTD_H */
|
2001-04-09 20:54:03 +01:00
|
|
|
#if HAVE_STDARG_H
|
|
|
|
#include <stdarg.h>
|
2005-06-03 19:28:11 +01:00
|
|
|
#endif /* HAVE_STDARG_H */
|
|
|
|
#include "Yatom.h"
|
|
|
|
#include "yapio.h"
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/************************************************
|
2001-04-09 20:54:03 +01:00
|
|
|
** Global variables are defined here **
|
2010-04-03 05:58:14 +01:00
|
|
|
************************************************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-01-14 15:58:19 +00:00
|
|
|
#ifndef THREADS
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
struct worker WORKER;
|
|
|
|
#endif /* YAPOR */
|
2010-04-03 05:58:14 +01:00
|
|
|
#endif /* ! THREADS */
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
|
|
|
|
/*******************************
|
2001-04-09 20:54:03 +01:00
|
|
|
** Global functions **
|
2010-04-03 05:58:14 +01:00
|
|
|
*******************************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
void itos(int i, char *s) {
|
|
|
|
int n,r,j;
|
|
|
|
n = 10;
|
|
|
|
while (n <= i) n *= 10;
|
|
|
|
j = 0;
|
|
|
|
while (n > 1) {
|
|
|
|
n = n / 10;
|
|
|
|
r = i / n;
|
|
|
|
i = i - r * n;
|
|
|
|
s[j++] = r + '0';
|
|
|
|
}
|
|
|
|
s[j] = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void information_message(const char *mesg,...) {
|
|
|
|
va_list args;
|
|
|
|
va_start(args, mesg);
|
2002-05-03 16:30:36 +01:00
|
|
|
fprintf(stderr, "[ ");
|
|
|
|
vfprintf(stderr, mesg, args);
|
|
|
|
fprintf(stderr, " ]\n");
|
2001-04-09 20:54:03 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(YAPOR_ERRORS) || defined(TABLING_ERRORS)
|
|
|
|
void error_message(const char *mesg, ...) {
|
|
|
|
va_list args;
|
|
|
|
va_start(args, mesg);
|
|
|
|
#ifdef YAPOR
|
|
|
|
LOCK(GLOBAL_LOCKS_stderr_messages);
|
|
|
|
#endif /* YAPOR */
|
2005-05-31 01:49:49 +01:00
|
|
|
fprintf(stderr, "% POTENCIAL ERROR- ");
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
fprintf(stderr, "W%d: ", worker_id);
|
|
|
|
#endif /* YAPOR */
|
|
|
|
vfprintf(stderr, mesg, args);
|
2005-05-31 01:49:49 +01:00
|
|
|
fprintf(stderr, "\n");
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
UNLOCK(GLOBAL_LOCKS_stderr_messages);
|
|
|
|
#endif /* YAPOR */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
|
|
|
#endif /* YAPOR || TABLING */
|