Ejemplo n.º 1
0
/* 5.Resolving implicit levels. */
static int bidi_resolveImplicit(TYPERUN **ptype_rl_list, int base_level)
{
    TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL;
    int max_level = base_level;
    DBGLOG ("\n5:Resolving implicit levels\n");

    for (pp = type_rl_list->next; pp->next; pp = pp->next) {
        BidiCharType this_type;
        int level;

        this_type = TYPE(pp);
        level = LEVEL(pp);

        /* I1. Even */
        /* I2. Odd */
        if (BIDI_IS_NUMBER(this_type))
            LEVEL(pp) = (level + 2) & ~1;
        else
            LEVEL(pp) = (level ^ BIDI_DIR_TO_LEVEL(this_type)) + (level & 1);

        if (LEVEL(pp) > max_level)
            max_level = LEVEL(pp);
    }
    compact_list (type_rl_list);
#ifdef BIDI_DEBUG
    if (bidi_debug) {
        print_run_types(type_rl_list);
        print_resolved_levels (type_rl_list);
        print_resolved_types (type_rl_list);
    }
#endif
    return max_level;
}
Ejemplo n.º 2
0
static void bidi_reorder_cb(void* context, BidiStrIndex len,
                            TYPERUN **ptype_rl_list, BidiLevel max_level, CB_DO_REORDER cb)
{
    int i = 0;
    TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL;

    /* L2. Reorder. */
    DBGLOG("\n6:Reordering\n");

    for(i = max_level; i > 0; i--) {
        for (pp = type_rl_list->next; pp->next; pp = pp->next) {
            if (LEVEL (pp) >= i) {
                /* Find all stretches that are >= i.*/
                BidiStrIndex len = LEN(pp), pos = POS(pp);
                TYPERUN *pp1 = pp->next;
                while (pp1->next && LEVEL(pp1) >= i) {
                    len += LEN(pp1);
                    pp1 = pp1->next;
                }
                pp = pp1->prev;
                cb(context, len, pos);
            }
        }
    }
    DBGLOG("\nReordering, Done\n");
}
Ejemplo n.º 3
0
Archivo: partition.c Proyecto: rolk/ug
INT NS_DIM_PREFIX CheckPartitioning (MULTIGRID *theMG)
{
  INT i,_restrict_;
  ELEMENT *theElement;
  ELEMENT *theFather;
  GRID    *theGrid;

  _restrict_ = 0;

  /* reset used flags */
  for (i=TOPLEVEL(theMG); i>0; i--)
  {
    theGrid = GRID_ON_LEVEL(theMG,i);
    for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL;
         theElement=SUCCE(theElement))
    {
      if (LEAFELEM(theElement))
      {
        theFather = theElement;
        while (EMASTER(theFather) && ECLASS(theFather)!=RED_CLASS
               && LEVEL(theFather)>0)
        {
          theFather = EFATHER(theFather);
        }

        /* if element with red element class does not exist */
        /* or is ghost -> partitioning must be restricted   */
        if (!EMASTER(theFather))
        {
          UserWriteF(PFMT "elem=" EID_FMTX  " cannot be refined\n",
                     me,EID_PRTX(theFather));
          _restrict_ = 1;
          continue;
        }
        if (COARSEN(theFather))
        {
          /* level 0 elements cannot be coarsened */
          if (LEVEL(theFather)<=1) continue;
          if (!EMASTER(EFATHER(theFather)))
          {
            UserWriteF(PFMT "elem=" EID_FMTX " cannot be coarsened\n",
                       me,EID_PRTX(theFather));
            _restrict_ = 1;
          }
        }
      }
    }
  }

  _restrict_ = UG_GlobalMaxINT(_restrict_);
  if (me==master && _restrict_==1)
  {
    UserWriteF("CheckPartitioning(): partitioning is not valid for refinement\n");
    UserWriteF("                     cleaning up ...\n");
  }

  return(_restrict_);
}
Ejemplo n.º 4
0
/* Enable the hardware event by setting its bit in its EMR */
static inline void enable_systemasic_irq(unsigned int irq)
{
	__u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
	__u32 mask;

	mask = inl(emr);
	mask |= (1 << EVENT_BIT(irq));
	outl(mask, emr);
}
Ejemplo n.º 5
0
static void compact_list (TYPERUN *list)
{
    if (list->next) {
        for (list = list->next; list; list = list->next) {
            if (TYPE (list->prev) == TYPE (list) && LEVEL (list->prev) == LEVEL (list))
                list = merge_with_prev (list);
        }
    }
}
Ejemplo n.º 6
0
Archivo: ds.c Proyecto: gagallo7/linux
void __init intel_pmu_pebs_data_source_skl(bool pmem)
{
	u64 pmem_or_l4 = pmem ? LEVEL(PMEM) : LEVEL(L4);

	pebs_data_source[0x08] = OP_LH | pmem_or_l4 | P(SNOOP, HIT);
	pebs_data_source[0x09] = OP_LH | pmem_or_l4 | REM | P(SNOOP, HIT);
	pebs_data_source[0x0b] = OP_LH | LEVEL(RAM) | REM | P(SNOOP, NONE);
	pebs_data_source[0x0c] = OP_LH | LEVEL(ANY_CACHE) | REM | P(SNOOPX, FWD);
	pebs_data_source[0x0d] = OP_LH | LEVEL(ANY_CACHE) | REM | P(SNOOP, HITM);
}
Ejemplo n.º 7
0
/* Enable the hardware event by setting its bit in its EMR */
static inline void enable_systemasic_irq(struct irq_data *data)
{
	unsigned int irq = data->irq;
	__u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
	__u32 mask;

	mask = inl(emr);
	mask |= (1 << EVENT_BIT(irq));
	outl(mask, emr);
}
Ejemplo n.º 8
0
/* Enable the hardware event by setting its bit in its EMR */
static inline void enable_systemasic_irq(unsigned int irq)
{
	unsigned long flags;
	__u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
	__u32 mask;

	save_and_cli(flags);
	mask = inl(emr);
	mask |= (1 << EVENT_BIT(irq));
	outl(mask, emr);
	restore_flags(flags);
}
Ejemplo n.º 9
0
static void compact_neutrals (TYPERUN *list)
{
    if (list->next)
    {
        for (list = list->next; list; list = list->next)
        {
            if (LEVEL (list->prev) == LEVEL (list) &&
                    ((TYPE(list->prev) == TYPE (list)
                      || (BIDI_IS_NEUTRAL (TYPE (list->prev))
                          && BIDI_IS_NEUTRAL (TYPE (list))))))
                list = merge_with_prev (list);
        }
    }
}
Ejemplo n.º 10
0
/*
NAME    {* fdd\_scanallvar *}
SECTION {* fdd *}
SHORT   {* Finds one satisfying value of all FDD variables *}
PROTO   {* int* fdd_scanallvar(BDD r) *}
DESCR   {* Finds one satisfying assignment in {\tt r} of all the defined
           FDD variables. Each value is stored in an array which is
	   returned. The size of this array is exactly the number of
	   FDD variables defined. It is the user's responsibility to
	   free this array using {\tt free()}. *}
RETURN  {* An array with all satisfying values. If {\tt r} is the trivially
           false BDD, then NULL is returned. *}
ALSO    {* fdd\_scanvar *}
*/
int* fdd_scanallvar(BDD r)
{
   int n;
   char *store;
   int *res;
   BDD p = r;

   CHECKa(r,NULL);
   if (r == bddfalse)
      return NULL;

   store = NEW(char,bddvarnum);
   for (n=0 ; n<bddvarnum ; n++)
      store[n] = 0;

   while (!ISCONST(p))
   {
      if (!ISZERO(LOW(p)))
      {
	 store[bddlevel2var[LEVEL(p)]] = 0;
	 p = LOW(p);
      }
      else
      {
	 store[bddlevel2var[LEVEL(p)]] = 1;
	 p = HIGH(p);
      }
   }

   res = NEW(int, fdvarnum);

   for (n=0 ; n<fdvarnum ; n++)
   {
      int m;
      int val=0;

      for (m=domain[n].binsize-1 ; m>=0 ; m--)
	 if ( store[domain[n].ivar[m]] )
	    val = val*2 + 1;
         else
	    val = val*2;

      res[n] = val;
   }

   free(store);

   return res;
}
Ejemplo n.º 11
0
/*
NAME    {* bdd\_scanset *}
SECTION {* kernel *}
SHORT   {* returns an integer representation of a variable set *}
PROTO   {* int bdd_scanset(BDD r, int **v, int *n) *}
DESCR   {* Scans a variable set {\tt r} and copies the stored variables into
           an integer array of variable numbers. The argument {\tt v} is
	   the address of an integer pointer where the array is stored and
	   {\tt n} is a pointer to an integer where the number of elements
	   are stored. It is the users responsibility to make sure the
	   array is deallocated by a call to {\tt free(v)}. The numbers
	   returned are guaranteed to be in ascending order. *}
ALSO    {* bdd\_makeset *}
RETURN  {* Zero on success, otherwise a negative error code. *}
*/
int bdd_scanset(BDD r, int **varset, int *varnum)
{
   int n, num;

   CHECK(r);
   if (r < 2)
   {
      *varnum = 0;
      *varset = NULL;
      return 0;
   }
   
   for (n=r, num=0 ; n > 1 ; n=HIGH(n))
      num++;

   if (((*varset) = (int *)malloc(sizeof(int)*num)) == NULL)
      return bdd_error(BDD_MEMORY);
   
   for (n=r, num=0 ; n > 1 ; n=HIGH(n))
      (*varset)[num++] = bddlevel2var[LEVEL(n)];

   *varnum = num;

   return 0;
}
Ejemplo n.º 12
0
/* Acknowledge a hardware event by writing its bit back to its ESR */
static void mask_ack_systemasic_irq(struct irq_data *data)
{
	unsigned int irq = data->irq;
	__u32 esr = ESR_BASE + (LEVEL(irq) << 2);
	disable_systemasic_irq(data);
	outl((1 << EVENT_BIT(irq)), esr);
}
Ejemplo n.º 13
0
static void insert_level(int levToInsert) {
	int n;
    for (n = 2; n < bddnodesize; n++) {
        int lev, lo, hi, newLev, hash, r, r2, NEXT_r;
        if (LOW(n) == INVALID_BDD) continue;
        lev = LEVEL(n);
        if (lev <= levToInsert || lev == bddvarnum-1) {
            continue;
        }
        lo = LOW(n);
        hi = HIGH(n);
        newLev = lev+1;
        hash = NODEHASH(lev, lo, hi);
        r = HASH(hash);
        r2 = 0;
        while (r != n && r != 0) {
            r2 = r;
            r = NEXT(r);
        }
        NEXT_r = NEXT(r);
        if (r2 == 0) {
            SETHASH(hash, NEXT_r);
        } else {
            SETNEXT(r2, NEXT_r);
        }
        SETLEVEL(n, newLev);
        lo = LOW(n); hi = HIGH(n);
        hash = NODEHASH(newLev, lo, hi);
        r = HASH(hash);
        SETHASH(hash, n);
        SETNEXT(n, r);
    }
}
Ejemplo n.º 14
0
void bidi_get_embeddlevels(const char* charset_name, Glyph32* glyphs, BidiStrIndex len,
                           Uint8* embedding_level_list, Uint8 type)
{
    int i = 0;
    BidiLevel max_level = 1;
    TYPERUN *type_rl_list = NULL, *pp;

#ifdef BIDI_DEBUG
    bidi_debug = TRUE;
#endif

    bidi_set_typetable(charset_name);

    print_hexstr(glyphs, len, FALSE);

    /* W1~W7, N1~N2, I1~I2, Get the Embedding Level. */
    bidi_resolve_string(glyphs, len, &type_rl_list, &max_level);

    /* type = 0, get the logical embedding level; else visual level.*/
    for (pp = type_rl_list->next; pp->next; pp = pp->next) {
        BidiStrIndex pos = POS (pp), len = LEN (pp);
        for(i = 0; i < len; i++)
            embedding_level_list[pos + i] = LEVEL(pp);
    }
    if (type) {
        bidi_reorder_cb(embedding_level_list, len, &type_rl_list, max_level,
                        bidi_index_reverse);
    }

    /* free typerun list.*/
    free_typerun_list(type_rl_list);

    print_hexstr(glyphs, len, TRUE);
}
Ejemplo n.º 15
0
void bdd_fprinttable(FILE *ofile, BDD r)
{
   BddNode *node;
   int n;
   
   fprintf(ofile, "ROOT: %d\n", r);
   if (r < 2)
      return;

   bdd_mark(r);
   
   for (n=0 ; n<bddnodesize ; n++)
   {
      if (LEVEL(n) & MARKON)
      {
	 node = &bddnodes[n];
	 
	 LEVELp(node) &= MARKOFF;

	 fprintf(ofile, "[%5d] ", n);
	 if (filehandler)
	    filehandler(ofile, bddlevel2var[LEVELp(node)]);
	 else
	    fprintf(ofile, "%3d", bddlevel2var[LEVELp(node)]);

	 fprintf(ofile, ": %3d", LOWp(node));
	 fprintf(ofile, " %3d", HIGHp(node));
	 fprintf(ofile, "\n");
      }
   }
}
Ejemplo n.º 16
0
void
display_dam_stuff (CHAR_DATA * ch)
{
  char buff[500];
  sprintf (buff, "Kick_dam....: %s --> %ld %ld %ld %ld\n", damt.kick_dam,
	   translate (damt.kick_dam,
		      LEVEL (ch), ch),
	   translate (damt.kick_dam,
		      LEVEL (ch), ch),
	   translate (damt.kick_dam,
		      LEVEL (ch), ch),
	   translate (damt.kick_dam,
		      LEVEL (ch), ch));
  send_to_char (buff, ch);
  return;
}
Ejemplo n.º 17
0
/*
NAME    {* bdd\_var *}
SECTION {* info *}
SHORT   {* gets the variable labeling the bdd *}
PROTO   {* int bdd_var(BDD r) *}
DESCR   {* Gets the variable labeling the bdd {\tt r}. *}
RETURN  {* The variable number. *}
*/
int bdd_var(BDD root)
{
   CHECK(root);
   if (root < 2)
      return bdd_error(BDD_ILLBDD);

   return (bddlevel2var[LEVEL(root)]);
}
Ejemplo n.º 18
0
//---------------------------------------------------------------------------
//
// QuantizeColor
//
// Returns the palette table index of an RGB color by traversing the
// octree to the leaf level
//
int QuantizeColor(OctreeType *tree, RGBType *color)
{
	if (tree->isleaf) {
		return tree->index;
	}
	else {
        QuantizeColor(tree->child[LEVEL(color,6-tree->level)],color);
	}
}
Ejemplo n.º 19
0
Archivo: jbuddy.c Proyecto: Sable/jedd
// returns 1 on success, 0 if there are no cubes
extern int firstCube( int r, int n, int cube[] ) {
    int origR = r;
    memset(cube, -1, n*sizeof(*cube) );
    while( r >= 2 ) {
        cube[bdd_level2var(LEVEL(r))] = 0;
        r = LOW(r);
    }
    if( r == 0 ) return nextCube( origR, n, cube );
    else return 1;
}
Ejemplo n.º 20
0
static void bdd_fprintdot_rec(FILE* ofile, BDD r)
{
   if (ISCONST(r) || MARKED(r))
      return;

   fprintf(ofile, "%d [label=\"", r);
   if (filehandler)
      filehandler(ofile, bddlevel2var[LEVEL(r)]);
   else
      fprintf(ofile, "%d", bddlevel2var[LEVEL(r)]);
   fprintf(ofile, "\"];\n");

   fprintf(ofile, "%d -> %d [style=dotted];\n", r, LOW(r));
   fprintf(ofile, "%d -> %d [style=filled];\n", r, HIGH(r));

   SETMARK(r);
   
   bdd_fprintdot_rec(ofile, LOW(r));
   bdd_fprintdot_rec(ofile, HIGH(r));
}
Ejemplo n.º 21
0
void bdd_fprintall(FILE *ofile)
{
   int n;
   
   for (n=0 ; n<bddnodesize ; n++)
   {
      if (LOW(n) != -1)
      {
	 fprintf(ofile, "[%5d - %2d] ", n, bddnodes[n].refcou);
	 if (filehandler)
	    filehandler(ofile, bddlevel2var[LEVEL(n)]);
	 else
	    fprintf(ofile, "%3d", bddlevel2var[LEVEL(n)]);

	 fprintf(ofile, ": %3d", LOW(n));
	 fprintf(ofile, " %3d", HIGH(n));
	 fprintf(ofile, "\n");
      }
   }
}
Ejemplo n.º 22
0
/* 2.Resolving Explicit levels.
 *   now nothing need to do.*/
static void bidi_resolveExplicit (TYPERUN **ptype_rl_list, BidiCharType base_dir)
{
    TYPERUN *type_rl_list = *ptype_rl_list, *pp = NULL;
    DBGLOG("\n2:Resolving weak types\n");

    for (pp = type_rl_list->next; pp->next; pp = pp->next)
    {
        LEVEL(pp) = BIDI_DIR_TO_LEVEL(base_dir);
    }
    return;
}
Ejemplo n.º 23
0
/*
NAME    {* bdd\_var *}
SECTION {* info *}
SHORT   {* gets the variable labeling the bdd *}
PROTO   {* int bdd_var(BDD r) *}
DESCR   {* Gets the variable labeling the bdd {\tt r}. *}
RETURN  {* The variable number. *}
*/
int bdd_var(BDD root)
{
   BUDDY_PROLOGUE;
   ADD_ARG1(T_BDD,root);

   CHECK(root);
   if (root < 2)
      RETURN(bdd_error(BDD_ILLBDD));

   RETURN(bddlevel2var[LEVEL(root)]);
}
Ejemplo n.º 24
0
static void print_resolved_levels(TYPERUN *pp)
{
    fprintf(stderr, "   Levels: ");
    while(pp) {
        BidiStrIndex i;
        for(i = 0; i < LEN (pp); i++)
            fprintf(stderr, "%c", bidi_level[(int)LEVEL(pp)]);
        pp = pp->next;
    }
    fprintf(stderr, "\n");
}
Ejemplo n.º 25
0
static void bdd_printset_rec(FILE *ofile, int r, int *set)
{
   int n;
   int first;
   
   if (r == 0)
      return;
   else
   if (r == 1)
   {
      fprintf(ofile, "<");
      first = 1;
      
      for (n=0 ; n<bddvarnum ; n++)
      {
	 if (set[n] > 0)
	 {
	    if (!first)
	       fprintf(ofile, ", ");
	    first = 0;
	    if (filehandler)
	       filehandler(ofile, bddlevel2var[n]);
	    else
	       fprintf(ofile, "%d", bddlevel2var[n]);
	    fprintf(ofile, ":%d", (set[n]==2 ? 1 : 0));
	 }
      }

      fprintf(ofile, ">");
   }
   else
   {
      set[LEVEL(r)] = 1;
      bdd_printset_rec(ofile, LOW(r), set);
      
      set[LEVEL(r)] = 2;
      bdd_printset_rec(ofile, HIGH(r), set);
      
      set[LEVEL(r)] = 0;
   }
}
Ejemplo n.º 26
0
static char *lin_bid(card bid)
{
	static char buf[3];
	if (bid == bid_pass)
		return "p";
	else if (bid == bid_x)
		return "d";
	else if (bid == bid_xx)
		return "r";
	snprintf(buf, sizeof (buf), "%d%c", LEVEL(bid), "CDHSN"[DENOM(bid)]);
	return buf;
}
Ejemplo n.º 27
0
int bdd_noderesize(int doRehash)
{
   BddNode *newnodes;
   int oldsize = bddnodesize;
   int n;

   if (bddnodesize >= bddmaxnodesize  &&  bddmaxnodesize > 0)
      return -1;
   
   bddnodesize = bddnodesize << 1;

   if (bddnodesize > oldsize + bddmaxnodeincrease)
      bddnodesize = oldsize + bddmaxnodeincrease;

   if (bddnodesize > bddmaxnodesize  &&  bddmaxnodesize > 0)
      bddnodesize = bddmaxnodesize;

   bddnodesize = bdd_prime_lte(bddnodesize);
   
   if (resize_handler != NULL)
      resize_handler(oldsize, bddnodesize);

   newnodes = (BddNode*)realloc(bddnodes, sizeof(BddNode)*bddnodesize);
   if (newnodes == NULL)
      return bdd_error(BDD_MEMORY);
   bddnodes = newnodes;

   if (doRehash)
      for (n=0 ; n<oldsize ; n++)
	 bddnodes[n].hash = 0;
   
   for (n=oldsize ; n<bddnodesize ; n++)
   {
      bddnodes[n].refcou = 0;
      bddnodes[n].hash = 0;
      LEVEL(n) = 0;
      LOW(n) = -1;
      bddnodes[n].next = n+1;
   }
   bddnodes[bddnodesize-1].next = bddfreepos;
   bddfreepos = oldsize;
   bddfreenum += bddnodesize - oldsize;

   if (doRehash)
      bdd_gbc_rehash();

   bddresized = 1;
   
   return 0;
}
Ejemplo n.º 28
0
bool 
is_note_to (CHAR_DATA * ch, NOTE_DATA * pnote)
{
  if (!str_cmp (NAME (ch), pnote->sender))
    return TRUE;
  if ((is_name ("all", pnote->to_list)) || is_name ("clan", pnote->to_list))
    return TRUE;
  if (IS_IMMORTAL (ch) && (is_name ("immortal", pnote->to_list) ||is_name ("imm", pnote->to_list) ||is_name ("imms", pnote->to_list) ||is_name ("admin", pnote->to_list) ||is_name ("admins", pnote->to_list)))
    return TRUE;
  if (is_name (NAME (ch), pnote->to_list))
    return TRUE;
  if (LEVEL (ch) >= MAX_LEVEL)
    return TRUE;
  return FALSE;
}
/*=================================================*
 * create_node allocates enough space for the node *
 *=================================================*/
NODE *create_node()
        {
                NODE *ndp=(NODE *)malloc(sizeof(NODE));

                if(ndp==NULL)
                        fatal_error("no more room for NODE");

                PARENT(ndp)=NULL;
                SIBLING(ndp)=NULL;
                CHILD(ndp)=NULL;
                INFO(ndp)=create_data_info();
                LEVEL(ndp)=0;

                return(ndp);
        }
Ejemplo n.º 30
0
//----------------------------------------------------------------------------
//
// InsertTree
//
// Insert a color into the octree
//
void InsertTree(OctreeType **tree, RGBType *color, uint depth)
{
    int level;

    if (*tree == (OctreeType *)NULL) {
        *tree = CreateOctNode(depth);
	}
    if ((*tree)->isleaf) {
        (*tree)->npixels++;
        (*tree)->redsum += color->r;
        (*tree)->greensum += color->g;
        (*tree)->bluesum += color->b;
	}
	else {
		InsertTree(&((*tree)->child[LEVEL(color, TREEDEPTH-depth)]),
				   color,
				   depth+1);
	}
}