Exemple #1
0
void LoopUnrolling::
cmdline_configure(const std::vector<std::string>& argv,
                                std::vector<std::string>* unknown_args) 
{
     unsigned index=0;
     if (!cmdline_find(argv, index, "-unroll", unknown_args)) return;
     ++index;
     if (index < argv.size() && argv[index] == "-locond") {
        opt = (LoopUnrolling::UnrollOpt)(opt | LoopUnrolling::COND_LEFTOVER);
        ++index;
     }
     if (index < argv.size() && argv[index] == "-nvar") {
        opt = (LoopUnrolling::UnrollOpt)(opt | LoopUnrolling::USE_NEWVAR);
        ++index;
     }
     if (index < argv.size() && argv[index] == "poet") {
          opt = (LoopUnrolling::UnrollOpt)(opt | LoopUnrolling::POET_TUNING);
          ++index;
     }
     if (index < argv.size() && ((unrollsize = atoi(argv[index].c_str())) > 0)) 
         ++index;
     else
        {
             std::cerr << "invalid unrolling size. Use default (4)\n";
             unrollsize = 4;
        }
     if (unknown_args != 0)
         append_args(argv,index,*unknown_args);
}
Exemple #2
0
void
tf_indent_multi_line(LogMessage *msg, gint argc, GString *argv[], GString *text)
{
  gchar *p, *new_line;

  /* append the message text(s) to the template string */
  append_args(argc, argv, text);

  /* look up the \n-s and insert a \t after them */
  p = text->str;
  new_line = memchr(p, '\n', text->len);
  while(new_line)
    {
      if (*(gchar *)(new_line + 1) != '\t')
        {
          g_string_insert_c(text, new_line - p + 1, '\t');
        }
      new_line = memchr(new_line + 1, '\n', p + text->len - new_line);
    }
}
Exemple #3
0
static int get_inp (ffio *G) {
/****************************************************************************************
The primary command reader for gie. Reads a block of gie input, cleans up repeated
whitespace etc. The block is stored in G->args. Returns 1 on success, 0 otherwise.
****************************************************************************************/
    G->args[0] = 0;

    if (0==skip_to_next_tag (G))
        return 0;
    G->tag = at_tag (G);

    if (nullptr==G->tag)
        return 0;

    do {
        append_args (G);
        if (0==nextline (G))
            return 0;
    } while (!at_end_delimiter (G));

    pj_shrink (G->args);
    return 1;
}
int main(int argc,char** argv,char *envp[])
{
	int a;
	f = stdin;
	if((a = set_opts(argc,argv)) < argc) f = fopen(argv[a],"r");

	if(argfile != NULL) read_file(argfile);
	//printf("%d %d %s\n",ignore_errors,verbose,argfile);
	char input[128];
	while(fgets(input,sizeof(input),f)!=NULL)
	{
		unsigned int j = 0;
		//input[strlen(input)-1] = '\0';
		find_first_comment(input);
		char* toks[64];
		char* token;
		token = strtok(input," ");
		while(token !=NULL)
		{
			toks[j++] = token;
			token = strtok(NULL," ");
		}
		toks[j] = NULL;

		char **args;
		if(argfile != NULL) args = append_args(j,toks);
		else args = toks;

		if(verbose) print_argv(args);
		int exitstat;
		switch(child_pid = fork())
		{
			case -1:
				exit(1);
			case 0:
				child_stat = execvp(args[0],args);
				exit(child_stat);
			default:
				if (timeout)
				{
					exitstat = th(0);
					milliseconds = 0;
				}
				else
				{
					waitpid(child_pid, &child_stat,0);
					exitstat = WEXITSTATUS(child_stat);
				}
				if(argfile != NULL) free(args);
		}

		if (exitstat)
		{
			if(ignore_errors) error_seen = 1;
			else 
			{	
				if(exitstat == -2) exit(2);
				else exit(1);
			}
		}
	}
	return error_seen;
}
Exemple #5
0
static void
tf_echo(LogMessage *msg, gint argc, GString *argv[], GString *result)
{
  append_args(argc, argv, result);
}
Exemple #6
0
int main(int argc,char** argv,char *envp[])
{
	int a;
	f = stdin;
	if((a = set_opts(argc,argv)) < argc) f = fopen(argv[a],"r");

	if(argfile != NULL) read_file(argfile);

	//printf("%d %d %s\n",ignore_errors,verbose,argfile);
	char input[128];
	int stat = 0;
	while(fgets(input,sizeof(input),f)!=NULL)
	{
		unsigned int j = 0;
		input[strlen(input)-1] = '\0';
		if(input[0] !='#') 
		{
			char* toks[64];
			char* token;
			token = strtok(input," ");
			while(token !=NULL)
			{
				toks[j++] = token;
				token = strtok(NULL," ");
			}
			toks[j] = NULL;

			char **args;
			if(argfile != NULL) args = append_args(j,toks);
			else args = toks;

			if(verbose) print_argv(args);
			struct itimerval new;
			switch(child_pid = fork())
			{
				case -1:
					exit(1);
				case 0:
					stat = execvp(args[0],args);
					exit(stat);
				default:
					/*
					memset(&sa,0,sizeof(sa));
					sa.sa_handler = timeout_handler;
					sigaction(SIGALRM,&sa,NULL);
					*/
					signal(SIGALRM,timeout_handler);
					ualarm(1000,0);
					/*
					new.it_interval.tv_usec = 0;
					new.it_interval.tv_sec = 0;
					new.it_value.tv_sec =  1;
					new.it_value.tv_usec =(long int)1000*ms;
					setitimer(ITIMER_REAL, &new,NULL);
					*/
					waitpid(child_pid,&stat,0);
					if(argfile != NULL) free(args);
			}

			int exitstat = WEXITSTATUS(stat);
			if (exitstat)
			{
				if(ignore_errors) error_seen = 1;
				else exit(1);
			}
		}
	}