Exemple #1
0
/**
 * @brief Initialize the hash table
 */
int elist_init(list_t *h, char *name, u_int type)
{
  list_t	*exist;

  NOPROFILER_IN();
  if (type >= aspect_type_nbr)
    {
      fprintf(stderr, "Unable to initialize list %s \n", name);
      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		   "Unable to initialize list", -1);
    }
  exist = elist_find(name);
  if (exist)
    {
#if 1 //__LIST_DEBUG__
      fprintf(stderr, "DEBUG: List %s (%p) already exists in hash with addr %p : NOT CREATING \n", 
	      name, h, exist);
#endif
      NOPROFILER_ROUT(1);
    }
#if __LIST_DEBUG__
  else
    fprintf(stderr, "DEBUG: List %s allocated at %p does not exists in hash : CREATING \n", name, h);
#endif

  bzero(h, sizeof(list_t));
  h->type   = type;
  h->name   = name;
  hash_add(hash_lists, name, h);
  NOPROFILER_ROUT(0);
}
Exemple #2
0
/** 
 * @brief Empty a list 
 */
list_t		*elist_empty(char *name)
{
  list_t	*list;
  char		*newname;
  char		type;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);
  list = elist_find(name);
  if (!list)
    PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL);
  type    = list->type;
  hash_del(hash_lists, name);
  elist_destroy(list);
  XALLOC(__FILE__, __FUNCTION__, __LINE__, 
	 newname, strlen(name) + 1, NULL);
  strncpy(newname, name, strlen(name));
  XALLOC(__FILE__, __FUNCTION__, __LINE__,
  	 list, sizeof(list_t), NULL);
  elist_init(list, newname, type);
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, list);
}
Exemple #3
0
/** 
 * Beginning of the transform command, open a transformation switch 
 */
int			cmd_match()
{
  list_t		*list;
  revmexpr_t		*ind;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);

  /* The first time we enter this command, we have to fetch the params */
  list = (list_t *) world.curjob->iter[world.curjob->curloop].container;
  ind  = world.curjob->iter[world.curjob->curloop].curind;

  if (!list || !ind || strcmp(ind->label, world.curjob->curcmd->param[0]) || 
      list->type != ASPECT_TYPE_EXPR)
    {
      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		   "Match/Rewrite only acts on iterated lists of expressions", -1);
    }

  /* We assume that the rewritten expression is the induction variable */
  world.curjob->recur[world.curjob->curscope].rwrt.matchexpr = ind;
  
  /* Create or flush the transformed expressions output list */
  list = elist_find("transformed");
  if (list)
    {
      elist_empty(list->name);
      world.curjob->recur[world.curjob->curscope].rwrt.transformed = list;
    }
  else
    {
      XALLOC(__FILE__, __FUNCTION__, __LINE__, 
	     world.curjob->recur[world.curjob->curscope].rwrt.transformed, 
	     sizeof(list_t), -1);
      elist_init(world.curjob->recur[world.curjob->curscope].rwrt.transformed, 
		 "transformed", ASPECT_TYPE_EXPR);
    }

  world.curjob->recur[world.curjob->curscope].rwrt.idloop = world.curjob->curloop;
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}
Exemple #4
0
/**
 * Empty a hash table 
 */
int		cmd_empty()
{
  char		buf[BUFSIZ];
  hash_t	*hash;
  list_t	*list;
  int		index;
  char		*name;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);
  for (index = 0; index < world.curjob->curcmd->argc; index++)
    {
      name = revm_lookup_key(world.curjob->curcmd->param[index]);
      hash = hash_find(name);
      if (!hash)
	{
	  list = elist_find(name);
	  if (!list)
	    {
	      snprintf(buf, sizeof(buf), " [W] Unknown list or hash table %s \n\n", name);
	      revm_output(buf);
	      continue;
	    }
	  snprintf(buf, sizeof(buf), "   .:: Empty list %s \n\n", name);
	  revm_output(buf);
	  elist_empty(name);
	}      
      else
	{
	  snprintf(buf, sizeof(buf), "   .:: Empty hash table %s \n\n", name);
	  revm_output(buf);
	  hash_empty(name);
	}
    }

  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}
Exemple #5
0
/**
 * @brief Create container lists
 * @param container Container holding the lists
 * @param linktype CONTAINER_LINK_IN or CONTAINER_LINK_OUT for input or output links list
 * @param uniqid Unique ID to be put into name
 * @return -1 on error and 0 on success
 */
int		container_linklists_create(container_t *container,
					   u_int	linktype,
					   u_int	uniqid)
{
  aspectype_t  *type;
  char		bufname[BUFSIZ];
  char		*prefix;
  list_t	*newlist;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);

  /* Check for prefix (XXX: change to lookup user-configured prefixes ?) */
  switch (container->type)
    {
    case ASPECT_TYPE_BLOC:
      prefix = "bloc";
      break;
    case ASPECT_TYPE_FUNC:
      prefix = "func";
      break;
    default:
      type = aspect_type_get_by_id(container->type);
      if (!type)
	PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
		     "Unable to find type of container", -1);
      prefix = type->name;
    }

  /* Now really allocate the list */
  switch (linktype)
    {
    case CONTAINER_LINK_IN:
      snprintf(bufname, BUFSIZ, "%d_%s_"AFMT"_%s", 
	       uniqid, prefix, *(eresi_Addr *) container->data, "inputs");
      newlist = elist_find(bufname);
      if (newlist)
	container->inlinks = newlist;
      else
	{
	  XALLOC(__FILE__, __FUNCTION__, __LINE__, container->inlinks, sizeof(list_t), -1);
	  elist_init(container->inlinks, strdup(bufname), ASPECT_TYPE_LINK);
	}

      break;
    case CONTAINER_LINK_OUT:
      snprintf(bufname, BUFSIZ, "%d_%s_"AFMT"_%s", 
	       uniqid, prefix, *(eresi_Addr *) container->data, "outputs");
      newlist = elist_find(bufname);
      if (newlist)
	container->outlinks = newlist;
      else
	{
	  XALLOC(__FILE__, __FUNCTION__, __LINE__, container->outlinks, sizeof(list_t), -1);
	  elist_init(container->outlinks, strdup(bufname), ASPECT_TYPE_LINK);
	}
      break;
    default:
      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
		   "Unknown link type", -1);  
    }

  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}