2015-11-05 15:47:36 +00:00
|
|
|
// @{
|
|
|
|
|
|
|
|
/**
|
|
|
|
@addtogroup YAPOS
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* In this routine we shall try to include the inevitably machine dependant
|
|
|
|
* routines. These include, for the moment : Time, A rudimentary form of
|
|
|
|
* signal handling, OS calls,
|
|
|
|
*
|
|
|
|
* Vitor Santos Costa, February 1987
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-04-10 14:21:17 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2016-01-31 10:33:32 +00:00
|
|
|
#if _WIN32 || defined(__MINGW32__)
|
|
|
|
#if !defined(MINGW_HAS_SECURE_API)
|
|
|
|
#define MINGW_HAS_SECURE_API 1
|
2015-11-05 15:47:36 +00:00
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
//#undef _POSIX_
|
|
|
|
#endif
|
|
|
|
#include "Yap.h"
|
|
|
|
#include "YapHeap.h"
|
2016-04-10 14:21:17 +01:00
|
|
|
#include "YapText.h"
|
2016-04-12 16:04:33 +01:00
|
|
|
#include "Yatom.h"
|
|
|
|
#include "eval.h"
|
|
|
|
#include "yapio.h"
|
2016-06-03 17:05:18 +01:00
|
|
|
|
|
|
|
// Win32 InputOutput Support
|
2016-01-31 10:33:32 +00:00
|
|
|
#if _WIN32 || defined(__MINGW32__)
|
|
|
|
#include <winsock2.h>
|
|
|
|
/* Windows */
|
2016-04-12 16:04:33 +01:00
|
|
|
#include "Shlwapi.h"
|
|
|
|
#include <direct.h>
|
2016-01-31 10:33:32 +00:00
|
|
|
#include <io.h>
|
|
|
|
#include <windows.h>
|
2016-06-03 17:05:18 +01:00
|
|
|
#ifndef S_ISDIR
|
2016-10-20 04:44:59 +01:00
|
|
|
#define S_ISDIR(x) (((x)&_S_IFDIR) == _S_IFDIR)
|
2016-06-03 17:05:18 +01:00
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
#endif
|
2016-06-03 17:05:18 +01:00
|
|
|
|
2016-01-31 10:33:32 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_STDARG_H
|
|
|
|
#include <stdarg.h>
|
|
|
|
#endif
|
2015-11-05 15:47:36 +00:00
|
|
|
#include <stdlib.h>
|
2016-01-31 10:33:32 +00:00
|
|
|
|
2016-06-03 17:05:18 +01:00
|
|
|
#if HAVE_SYS_PARAM_Hb
|
2016-01-31 10:33:32 +00:00
|
|
|
#include <sys/param.h>
|
2016-04-12 16:04:33 +01:00
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
|
|
|
|
#if HAVE_STDARG_H
|
|
|
|
#include <stdarg.h>
|
2015-11-05 15:47:36 +00:00
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
#if HAVE_CTYPE_H
|
|
|
|
#include <ctype.h>
|
2015-11-05 15:47:36 +00:00
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
#if HAVE_SYS_PARAMS_H
|
|
|
|
#include <sys/params.h>
|
2015-11-05 15:47:36 +00:00
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
#if HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_STAT_H
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
2016-04-12 16:04:33 +01:00
|
|
|
#if HAVE_SYS_SELECT_H && !_MSC_VER && !defined(__MINGW32__)
|
2016-01-31 10:33:32 +00:00
|
|
|
#include <sys/select.h>
|
2015-11-05 15:47:36 +00:00
|
|
|
#endif
|
|
|
|
#if HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
#if HAVE_LIBGEN_H
|
|
|
|
#include <libgen.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_WCTYPE_H
|
|
|
|
#include <wctype.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_LIMITS_H
|
|
|
|
#include <limits.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_ERRNO_H
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
2015-11-05 15:47:36 +00:00
|
|
|
#if !HAVE_STRNCAT
|
2016-04-12 16:04:33 +01:00
|
|
|
#define strncat(X, Y, Z) strcat(X, Y)
|
2015-11-05 15:47:36 +00:00
|
|
|
#endif
|
|
|
|
#if !HAVE_STRNCPY
|
2016-04-12 16:04:33 +01:00
|
|
|
#define strncpy(X, Y, Z) strcpy(X, Y)
|
2015-11-05 15:47:36 +00:00
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
#include "iopreds.h"
|
|
|
|
|
|
|
|
#if HAVE_SIGNAL_H
|
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
2016-06-03 17:05:18 +01:00
|
|
|
#ifdef HAVE_ERRNO_H
|
|
|
|
#include <errno.h>
|
|
|
|
#endif
|
|
|
|
/* CYGWIN seems to include this automatically */
|
|
|
|
#if HAVE_FENV_H // && !defined(__CYGWIN__)
|
|
|
|
#include <fenv.h>
|
|
|
|
#endif
|
|
|
|
|
2016-01-31 10:33:32 +00:00
|
|
|
#ifdef MPW
|
2016-04-12 16:04:33 +01:00
|
|
|
#define signal sigset
|
2016-01-31 10:33:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* windows.h does not like absmi.h, this
|
|
|
|
should fix it for now */
|
|
|
|
#include <math.h>
|
|
|
|
#if HAVE_SYS_TIME_H && !_MSC_VER
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_SYS_WAIT_H && !defined(__MINGW32__) && !_MSC_VER
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
2015-11-05 15:47:36 +00:00
|
|
|
#if HAVE_GETPWNAM
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
|
|
|
#include <ctype.h>
|
|
|
|
#if HAVE_SYS_STAT_H
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_SYS_TYPES_H
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_FCNTL_H
|
|
|
|
#include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_WORDEXP_H
|
|
|
|
#include <wordexp.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_GLOB_H
|
|
|
|
#include <glob.h>
|
|
|
|
#endif
|
|
|
|
#if HAVE_LIBGEN_H
|
|
|
|
#include <libgen.h>
|
|
|
|
#endif
|
2016-01-31 10:33:32 +00:00
|
|
|
#if defined(HAVE_READLINE_READLINE_H)
|
2015-11-05 15:47:36 +00:00
|
|
|
#include <readline/readline.h>
|
|
|
|
#endif
|
|
|
|
|
2016-04-12 16:04:33 +01:00
|
|
|
void Yap_InitRandom(void);
|
|
|
|
void Yap_InitTime(int wid);
|
|
|
|
void Yap_InitOSSignals(int wid);
|
2015-11-05 15:47:36 +00:00
|
|
|
void Yap_InitWTime(void);
|