Exemplo n.º 1
0
Arquivo: Hpc.c Projeto: alexbiehl/ghc
void
startupHpc(void)
{
  char *hpc_tixdir;
  char *hpc_tixfile;

  if (moduleHash == NULL) {
      // no modules were registered with hs_hpc_module, so don't bother
      // creating the .tix file.
      return;
  }

  if (hpc_inited != 0) {
    return;
  }
  hpc_inited = 1;
  hpc_pid    = getpid();
  hpc_tixdir = getenv("HPCTIXDIR");
  hpc_tixfile = getenv("HPCTIXFILE");

  debugTrace(DEBUG_hpc,"startupHpc");

  /* XXX Check results of mallocs/strdups, and check we are requesting
         enough bytes */
  if (hpc_tixfile != NULL) {
    tixFilename = strdup(hpc_tixfile);
  } else if (hpc_tixdir != NULL) {
    /* Make sure the directory is present;
     * conditional code for mkdir lifted from lndir.c
     */
#ifdef WIN32
    mkdir(hpc_tixdir);
#else
    mkdir(hpc_tixdir,0777);
#endif
    /* Then, try open the file
     */
    tixFilename = (char *) stgMallocBytes(strlen(hpc_tixdir) +
                                          strlen(prog_name) + 12,
                                          "Hpc.startupHpc");
    sprintf(tixFilename,"%s/%s-%d.tix",hpc_tixdir,prog_name,(int)hpc_pid);
  } else {
    tixFilename = (char *) stgMallocBytes(strlen(prog_name) + 6,
                                          "Hpc.startupHpc");
    sprintf(tixFilename, "%s.tix", prog_name);
  }

  if (init_open(fopen(tixFilename,"r"))) {
    readTix();
  }
}
Exemplo n.º 2
0
int			get_path(t_rooms *end, t_rooms *start)
{
	t_open		*open_list;
	t_close		*close_list;

	open_list = init_open(end);
	close_list = NULL;
	algo_path(start, open_list, close_list);
	if (start->weight == INT_MAX)
	{
		ft_printf("ERROR\n");
		exit(0);
	}
	return (1);
}
Exemplo n.º 3
0
int		init_sh(char **env, t_sh **sh)
{
    set_static_tty(env);
    my_signals();
    gbgc_init();
    init_open();
    if (((*sh) = gbgc_calloc(sizeof(t_sh))) == NULL)
        return (false);
    if (((*sh)->env = convert_envtab(env)) == NULL)
        return (my_perror("env return null"));
    (*sh)->rdl.prompt = "Such prompt $> ";
    if (isatty(STDIN_FILENO) && env[0] != NULL)
    {
        (*sh)->tty = false;
        if ((getent_term(env)) == false)
            return (false);
        if (!rawmode())
            return (false);
        (*sh)->tty = true;
    }
    else
        (*sh)->tty = false;
    return (true);
}