Example #1
0
static void	*getMoreMem(int size)
{
  int		units;
  void		*address;
  t_header	*tmp;

  units = size;
  if (units < MIN_MALLOC)
    units = MIN_MALLOC;
  address = sbrk(units);
  if (address == (void *)-1)
    return (NULL);
  tmp = address;
  tmp->magic = MALLOC_MAGIC;
  tmp->next = NULL;
  if (MIN_MALLOC - size >= THRESHOLD)
    {
      tmp->size = size - sizeof(*tmp);
      split_end(tmp);
    }
  else
    tmp->size = size - sizeof(*tmp);
  if (gl_lowlimit == NULL)
    gl_lowlimit = tmp;
  return (tmp);
}
std::string OpenCLParser::getTypedKernelName(std::string line) {

	boost::regex split_bgn("template\\s+__attribute__\\(\\(mangled_name\\(");
	boost::regex split_end("\\)");
	boost::sregex_token_iterator it;

	it = boost::sregex_token_iterator(line.begin(),line.end(), split_bgn, -1);
	it++;
	line = (*it);
	it = boost::sregex_token_iterator(line.begin(),line.end(), split_end, -1);
	line = *it;
	return line;
}
std::string OpenCLParser::getKernelType(std::string line) {

	boost::regex split_bgn("template\\s+<class\\s+");
	boost::regex split_end("\\s*>");
	boost::sregex_token_iterator it;

	it = boost::sregex_token_iterator(line.begin(),line.end(), split_bgn, -1);
	it++;
	line = (*it);
	it = boost::sregex_token_iterator(line.begin(),line.end(), split_end, -1);
	line = *it;
	return line;
}
std::string OpenCLParser::getKernelName(std::string line) {

	boost::regex split_bgn("\\_*\\_*kernel\\s+void\\s+");
	boost::regex split_end("\\(");
	boost::sregex_token_iterator it;

	it = boost::sregex_token_iterator(line.begin(),line.end(), split_bgn, -1);
	it++;
	line = (*it);
	it = boost::sregex_token_iterator(line.begin(),line.end(), split_end, -1);
	line = *it;
	return line;
}
std::string OpenCLParser::getTypedKernelLine(std::string line) {

	std::string kernel_name = getKernelName(line);
	boost::regex split_bgn(kernel_name);
	boost::regex split_end("\\;");
	boost::sregex_token_iterator it;

	it = boost::sregex_token_iterator(line.begin(),line.end(), split_bgn, -1);
	it++;
	it++;
	line = (*it);
	it = boost::sregex_token_iterator(line.begin(),line.end(), split_end, -1);
	line = *it;
	return line;
}