Beispiel #1
0
/*-------------------------------------------------------------------------*
 * PL_START_PROLOG                                                         *
 *                                                                         *
 *-------------------------------------------------------------------------*/
int
Pl_Start_Prolog(int argc, char *argv[])
{
  int i, x;
  char *p;

  setlocale(LC_ALL, "");
  setlocale(LC_NUMERIC, "C");	/* make sure floats come out right... */

  Pl_Init_Machine();

  pl_os_argc = argc;
  pl_os_argv = argv;

  Set_Line_Buf(stdout);
  Set_Line_Buf(stderr);

  for (i = 0; i < NB_OF_STACKS; i++)
    {
      if (pl_fd_init_solver == NULL && strcmp(pl_stk_tbl[i].name, "cstr") == 0)
	{			/* FD solver not linked */
	  pl_stk_tbl[i].size = 0;
	  continue;
	}

      if ((pl_stk_tbl[i].size = KBytes_To_Wam_Words(*(pl_stk_tbl[i].p_def_size)))
	  == 0)
	pl_stk_tbl[i].size = pl_stk_tbl[i].default_size;

      if (!pl_fixed_sizes && *pl_stk_tbl[i].env_var_name)
	{
	  p = (char *) getenv(pl_stk_tbl[i].env_var_name);
	  if (p && *p)
	    {
	      sscanf(p, "%d", &x);
	      pl_stk_tbl[i].size = KBytes_To_Wam_Words(x);
	    }
	}
    }

  Pl_M_Allocate_Stacks();
  Save_Machine_Regs(init_buff_regs);

#ifndef NO_MACHINE_REG_FOR_REG_BANK
  Init_Reg_Bank(Global_Stack);  /* allocated X regs + other non alloc regs */
  Global_Stack += REG_BANK_SIZE; /* at the beginning of the heap */
  Global_Size -= REG_BANK_SIZE;
#endif

  /* must be changed to store global info (see the debugger) */
  heap_actual_start = Global_Stack;

  Pl_Init_Atom();
  Pl_Init_Pred();
  Pl_Init_Oper();

#ifndef NO_USE_LINEDIT
  if (pl_le_initialize != NULL)
    pl_use_gui = (*pl_le_initialize)();
  else
#endif
    pl_use_gui = 0;

  if (pl_init_stream_supp)
    (*pl_init_stream_supp)();

  Pl_Reset_Prolog();
  Pl_Fd_Init_Solver();

  Pl_Find_Linked_Objects();

  return nb_user_directives;
}
Beispiel #2
0
/*-------------------------------------------------------------------------*
 * PL_START_PROLOG                                                         *
 *                                                                         *
 *-------------------------------------------------------------------------*/
int
Pl_Start_Prolog(int argc, char *argv[])
{
  int i, x;
  char *p;
  void (*copy_of_pl_init_stream_supp)() = Pl_Dummy_Ptr(pl_init_stream_supp);
#if defined(_WIN32) || defined(__CYGWIN__)
  DWORD y;
#endif

  Set_Locale();

  pl_os_argc = argc;
  pl_os_argv = argv;

  pl_home = Get_Prolog_Path(argv[0], &pl_devel_mode);

  Pl_Init_Machine();

  Set_Line_Buf(stdout);
  Set_Line_Buf(stderr);

  for (i = 0; i < NB_OF_STACKS; i++)
    {
      if (pl_fd_init_solver == NULL && strcmp(pl_stk_tbl[i].name, "cstr") == 0)
        {                       /* FD solver not linked */
          pl_stk_tbl[i].size = 0;
          continue;
        }

      if ((pl_stk_tbl[i].size = KBytes_To_Wam_Words(*(pl_stk_tbl[i].p_def_size))) == 0)
        pl_stk_tbl[i].size = pl_stk_tbl[i].default_size;

      if (!pl_fixed_sizes && *pl_stk_tbl[i].env_var_name)
        {
          p = (char *) getenv(pl_stk_tbl[i].env_var_name);
          if (p && *p)
            {
              sscanf(p, "%d", &x);
              pl_stk_tbl[i].size = KBytes_To_Wam_Words(x);
            }
#if defined(_WIN32) || defined(__CYGWIN__)
          if (Read_Windows_Registry(pl_stk_tbl[i].env_var_name, REG_DWORD, &y, sizeof(x)))
            pl_stk_tbl[i].size = KBytes_To_Wam_Words(y);
#endif
        }      
    }

  /* similar treatment for max_atom */

  if ((pl_max_atom = pl_def_max_atom) == 0)
    pl_max_atom = DEFAULT_MAX_ATOM;
  
  if (!pl_fixed_sizes)
    {
      p = (char *) getenv(ENV_VAR_MAX_ATOM);
      if (p && *p)
	{
	  sscanf(p, "%d", &x);
	  pl_max_atom = x;
	}
#if defined(_WIN32) || defined(__CYGWIN__)
      if (Read_Windows_Registry(ENV_VAR_MAX_ATOM, REG_DWORD, &y, sizeof(x)))
	pl_max_atom = y;
#endif
    }

  Pl_Allocate_Stacks();
  Save_Machine_Regs(init_buff_regs);

#ifndef NO_MACHINE_REG_FOR_REG_BANK
  Init_Reg_Bank(Global_Stack);  /* allocated X regs + other non alloc regs */
  Global_Stack += REG_BANK_SIZE; /* at the beginning of the heap */
  Global_Size -= REG_BANK_SIZE;
#endif

  /* must be changed to store global info (see the debugger) */
  heap_actual_start = Global_Stack;

  Pl_Init_Atom();
  Pl_Init_Pred();
  Pl_Init_Oper();

  pl_le_mode = 0;	/* not compiled with linedit or deactivated (using env var) */

#ifndef NO_USE_LINEDIT
  if (pl_le_initialize != NULL)
    pl_le_mode = (*pl_le_initialize)();
#endif

  if (copy_of_pl_init_stream_supp)
    (*copy_of_pl_init_stream_supp)();

  Pl_Reset_Prolog();
  Pl_Fd_Init_Solver();

  Pl_Find_Linked_Objects();

  return nb_user_directives;
}