Exemplo n.º 1
0
MATRIZ crearMatriz() {
  MATRIZ m;
  int i, j, ind;
  int il, ir, ju, jd; // left of i, right of i, up of j, down of j
  
  for (j=0; j < L; j++) {
    for (i=0; i < L; i++) {
      ind = POS(i, j);
      il = DECR(i);
      ir = INCR(i);
      ju = DECR(j);
      jd = INCR(j);
      
      m.u[ind] = POS(i, ju);
      m.d[ind] = POS(i, jd);
      m.l[ind] = POS(il, j);
      m.r[ind] = POS(ir, j);
      m.ul[ind] = POS(il, ju);
      m.ur[ind] = POS(ir, ju);
      m.dl[ind] = POS(il, jd);
      m.dr[ind] = POS(ir, jd);
    }
  }
  
  return m;
}
Exemplo n.º 2
0
Arquivo: item.c Projeto: huayl/pelikan
static inline void
_item_dealloc(struct item **it_p)
{
    uint8_t id = (*it_p)->id;

    DECR(slab_metrics, item_curr);
    INCR(slab_metrics, item_dealloc);
    PERSLAB_DECR(id, item_curr);

    slab_put_item(*it_p, id);
    *it_p = NULL;
}
Exemplo n.º 3
0
END_TEST

START_TEST(test_fpn)
{
    test_reset();
    ck_assert(test_metrics->f.fpn == 0.0);
    INCR(test_metrics, f);
    ck_assert(test_metrics->f.fpn == 0.0);
    INCR_N(test_metrics, f, 2);
    ck_assert(test_metrics->f.fpn == 0.0);
    UPDATE_VAL(test_metrics, f, 2.1);
    ck_assert(test_metrics->f.fpn == 2.1);
    DECR(test_metrics, f);
    ck_assert(test_metrics->f.fpn == 2.1);
    DECR_N(test_metrics, f, 5);
    ck_assert(test_metrics->f.fpn == 2.1);
}
Exemplo n.º 4
0
END_TEST

START_TEST(test_gauge)
{
    test_reset();
    ck_assert_int_eq(test_metrics->g.gauge, 0);
    INCR(test_metrics, g);
    ck_assert_int_eq(test_metrics->g.gauge, 1);
    INCR_N(test_metrics, g, 2);
    ck_assert_int_eq(test_metrics->g.gauge, 3);
    UPDATE_VAL(test_metrics, g, 2);
    ck_assert_int_eq(test_metrics->g.gauge, 2);
    DECR(test_metrics, g);
    ck_assert_int_eq(test_metrics->g.gauge, 1);
    DECR_N(test_metrics, g, 5);
    ck_assert_int_eq(test_metrics->g.gauge, -4);
}
Exemplo n.º 5
0
struct request *
request_borrow(void)
{
    struct request *req;

    FREEPOOL_BORROW(req, &reqp, next, request_create);
    if (req == NULL) {
        log_debug("borrow req failed: OOM %d");

        return NULL;
    }
    request_reset(req);

    DECR(request_metrics, request_free);
    INCR(request_metrics, request_borrow);
    log_vverb("borrowing req %p", req);

    return req;
}
Exemplo n.º 6
0
struct response *
response_borrow(void)
{
    struct response *rsp;

    FREEPOOL_BORROW(rsp, &rspp, next, response_create);
    if (rsp == NULL) {
        log_debug("borrow rsp failed: OOM %d");

        return NULL;
    }
    response_reset(rsp);

    DECR(response_metrics, response_free);
    INCR(response_metrics, response_borrow);
    log_vverb("borrowing rsp %p", rsp);

    return rsp;
}
Exemplo n.º 7
0
Arquivo: item.c Projeto: huayl/pelikan
/*
 * Unlinks an item from the hash table.
 */
static void
_item_unlink(struct item *it)
{
    ASSERT(it->magic == ITEM_MAGIC);

    log_verb("unlink it %p of id %"PRIu8" at offset %"PRIu32, it, it->id,
            it->offset);

    if (it->is_linked) {
        it->is_linked = 0;
        hashtable_delete(item_key(it), it->klen, hash_table);
    }
    DECR(slab_metrics, item_linked_curr);
    INCR(slab_metrics, item_unlink);
    DECR_N(slab_metrics, item_keyval_byte, it->klen + it->vlen);
    DECR_N(slab_metrics, item_val_byte, it->vlen);
    PERSLAB_DECR_N(it->id, item_keyval_byte, it->klen + it->vlen);
    PERSLAB_DECR_N(it->id, item_val_byte, it->vlen);
}
Exemplo n.º 8
0
  void process::adjust_call_stack_pre(uintptr_t pc)
  {
    uintptr_t s = 0x0, func = 0x0;

    // known BP?
    try { pelf_->get_byte_at(pc); } catch(...) { return; }

    // leaving function?
    if (! pelf_->is_func_addr(pc)) {
      // yes, leaving
      if (call_stack_.empty()) {
	call_level_ = 0;
      } else {
	try {
          func = pelf_->get_func_addr(pc);
	} catch(...) { return; }
        
        // excluded (-X) function?
        const std::string fn = pelf_->get_funcname(func);
        if (opts_->exclude_syms_.find(fn) != opts_->exclude_syms_.end()) {
          return;
        }

        const size_t UNUSED_ orig_cl = call_level_;
        do { 
          s = call_stack_.top(); call_stack_.pop(); 
          DECR(call_level_);
          if (orig_cl - call_level_ > 1 && s != func) { 
            // mis-indent finder for me..
            // std::fprintf(stderr, "SKIPPED %08x\n", s); std::fflush(stderr); 
          }
        } while (!call_stack_.empty() && (s != func));

      }
    }

    return;
  }
Exemplo n.º 9
0
/* secondary data manipulation */
static void
linkdata(void)
{
	int i, j;

	/* array linkages */
	for (i = 1; i <= LOCSIZ; i++)
		if (ltext[i].seekadr != 0 && travel[i] != 0)
			if ((travel[i]->tverb) == 1)
				cond[i] = 2;
	for (j = 100; j > 0; j--)
		if (fixd[j] > 0) {
			drop(j + 100, fixd[j]);
			drop(j, plac[j]);
		}
	for (j = 100; j > 0; j--) {
		fixed[j] = fixd[j];
		if (plac[j] != 0 && fixd[j] <= 0)
			drop(j, plac[j]);
	}

	maxtrs = 79;
	tally = 0;
	tally2 = 0;

	for (i = 50; i <= maxtrs; i++) {
		if (ptext[i].seekadr != 0)
			prop[i] = -1;
		tally -= prop[i];
	}

	/* define mnemonics */
	keys  = vocab(DECR(k,e,y,s,\0), 1, 0);
	lamp  = vocab(DECR(l,a,m,p,\0), 1, 0);
	grate = vocab(DECR(g,r,a,t,e), 1, 0);
	cage  = vocab(DECR(c,a,g,e,\0),1, 0);
	rod   = vocab(DECR(r,o,d,\0,\0),1, 0);
	rod2 = rod + 1;
	steps = vocab(DECR(s,t,e,p,s),1, 0);
	bird  = vocab(DECR(b,i,r,d,\0),1, 0);
	door  = vocab(DECR(d,o,o,r,\0),1, 0);
	pillow= vocab(DECR(p,i,l,l,o), 1, 0);
	snake = vocab(DECR(s,n,a,k,e), 1, 0);
	fissur= vocab(DECR(f,i,s,s,u), 1, 0);
	tablet= vocab(DECR(t,a,b,l,e), 1, 0);
	clam  = vocab(DECR(c,l,a,m,\0),1, 0);
	oyster= vocab(DECR(o,y,s,t,e), 1, 0);
	magzin= vocab(DECR(m,a,g,a,z), 1, 0);
	dwarf = vocab(DECR(d,w,a,r,f), 1, 0);
	knife = vocab(DECR(k,n,i,f,e), 1, 0);
	food  = vocab(DECR(f,o,o,d,\0),1, 0);
	bottle= vocab(DECR(b,o,t,t,l), 1, 0);
	water = vocab(DECR(w,a,t,e,r), 1, 0);
	oil   = vocab(DECR(o,i,l,\0,\0),1, 0);
	plant = vocab(DECR(p,l,a,n,t), 1, 0);
	plant2 = plant + 1;
	axe   = vocab(DECR(a,x,e,\0,\0), 1, 0);
	mirror= vocab(DECR(m,i,r,r,o), 1, 0);
	dragon= vocab(DECR(d,r,a,g,o), 1, 0);
	chasm = vocab(DECR(c,h,a,s,m), 1, 0);
	troll = vocab(DECR(t,r,o,l,l), 1, 0);
	troll2 = troll + 1;
	bear  = vocab(DECR(b,e,a,r,\0),1, 0);
	messag= vocab(DECR(m,e,s,s,a), 1, 0);
	vend  = vocab(DECR(v,e,n,d,i), 1, 0);
	batter= vocab(DECR(b,a,t,t,e), 1, 0);

	nugget= vocab(DECR(g,o,l,d,\0),1, 0);
	coins = vocab(DECR(c,o,i,n,s), 1, 0);
	chest = vocab(DECR(c,h,e,s,t), 1, 0);
	eggs  = vocab(DECR(e,g,g,s,\0),1, 0);
	tridnt= vocab(DECR(t,r,i,d,e), 1, 0);
	vase  = vocab(DECR(v,a,s,e,\0),1, 0);
	emrald= vocab(DECR(e,m,e,r,a), 1, 0);
	pyram = vocab(DECR(p,y,r,a,m), 1, 0);
	pearl = vocab(DECR(p,e,a,r,l), 1, 0);
	rug   = vocab(DECR(r,u,g,\0,\0),1, 0);
	chain = vocab(DECR(c,h,a,i,n), 1, 0);

	back  = vocab(DECR(b,a,c,k,\0),0, 0);
	look  = vocab(DECR(l,o,o,k,\0),0, 0);
	cave  = vocab(DECR(c,a,v,e,\0),0, 0);
	null  = vocab(DECR(n,u,l,l,\0),0, 0);
	entrnc= vocab(DECR(e,n,t,r,a), 0, 0);
	dprssn= vocab(DECR(d,e,p,r,e), 0, 0);
	enter = vocab(DECR(e,n,t,e,r), 0, 0);

	pour  = vocab(DECR(p,o,u,r,\0), 2, 0);
	say   = vocab(DECR(s,a,y,\0,\0),2, 0);
	lock  = vocab(DECR(l,o,c,k,\0),2, 0);
	throw = vocab(DECR(t,h,r,o,w), 2, 0);
	find  = vocab(DECR(f,i,n,d,\0),2, 0);
	invent= vocab(DECR(i,n,v,e,n), 2, 0);

	/* initialize dwarves */
	chloc = 114;
	chloc2 = 140;
	for (i = 1; i <= 6; i++)
		dseen[i] = FALSE;
	dflag = 0;
	dloc[1] = 19;
	dloc[2] = 27;
	dloc[3] = 33;
	dloc[4] = 44;
	dloc[5] = 64;
	dloc[6] = chloc;
	daltlc = 18;

	/* random flags & ctrs */
	turns = 0;
	lmwarn = FALSE;
	iwest = 0;
	knfloc = 0;
	detail = 0;
	abbnum = 5;
	for (i = 0; i <= 4; i++)
		if (rtext[2 * i + 81].seekadr != 0)
			maxdie = i + 1;
	numdie = holdng = dkill = foobar = bonus = 0;
	clock1 = 30;
	clock2 = 50;
	saved = 0;
	closng = panic = closed = scorng = FALSE;
}
static void
linkdata(void)
{				/* secondary data manipulation */
	int     i, j;

	/* array linkages */
	for (i = 1; i < LOCSIZE; i++)
		if (ltext[i].seekadr != 0 && travel[i] != 0)
			if ((travel[i]->tverb) == 1)
				cond[i] = 2;
	for (j = 100; j > 0; j--)
		if (fixd[j] > 0) {
			drop(j + 100, fixd[j]);
			drop(j, plac[j]);
		}
	for (j = 100; j > 0; j--) {
		fixed[j] = fixd[j];
		if (plac[j] != 0 && fixd[j] <= 0)
			drop(j, plac[j]);
	}

	maxtrs = 79;
	tally = 0;
	tally2 = 0;

	for (i = 50; i <= maxtrs; i++) {
		if (ptext[i].seekadr != 0)
			prop[i] = -1;
		tally -= prop[i];
	}

	/* define mnemonics */
	keys = vocab(DECR('k', 'e', 'y', 's', '\0'), 1, 0);
	lamp = vocab(DECR('l', 'a', 'm', 'p', '\0'), 1, 0);
	grate = vocab(DECR('g', 'r', 'a', 't', 'e'), 1, 0);
	cage = vocab(DECR('c', 'a', 'g', 'e', '\0'), 1, 0);
	rod = vocab(DECR('r', 'o', 'd', '\0', '\0'), 1, 0);
	rod2 = rod + 1;
	steps = vocab(DECR('s', 't', 'e', 'p', 's'), 1, 0);
	bird = vocab(DECR('b', 'i', 'r', 'd', '\0'), 1, 0);
	door = vocab(DECR('d', 'o', 'o', 'r', '\0'), 1, 0);
	pillow = vocab(DECR('p', 'i', 'l', 'l', 'o'), 1, 0);
	snake = vocab(DECR('s', 'n', 'a', 'k', 'e'), 1, 0);
	fissure = vocab(DECR('f', 'i', 's', 's', 'u'), 1, 0);
	tablet = vocab(DECR('t', 'a', 'b', 'l', 'e'), 1, 0);
	clam = vocab(DECR('c', 'l', 'a', 'm', '\0'), 1, 0);
	oyster = vocab(DECR('o', 'y', 's', 't', 'e'), 1, 0);
	magazine = vocab(DECR('m', 'a', 'g', 'a', 'z'), 1, 0);
	dwarf = vocab(DECR('d', 'w', 'a', 'r', 'f'), 1, 0);
	knife = vocab(DECR('k', 'n', 'i', 'f', 'e'), 1, 0);
	food = vocab(DECR('f', 'o', 'o', 'd', '\0'), 1, 0);
	bottle = vocab(DECR('b', 'o', 't', 't', 'l'), 1, 0);
	water = vocab(DECR('w', 'a', 't', 'e', 'r'), 1, 0);
	oil = vocab(DECR('o', 'i', 'l', '\0', '\0'), 1, 0);
	plant = vocab(DECR('p', 'l', 'a', 'n', 't'), 1, 0);
	plant2 = plant + 1;
	axe = vocab(DECR('a', 'x', 'e', '\0', '\0'), 1, 0);
	mirror = vocab(DECR('m', 'i', 'r', 'r', 'o'), 1, 0);
	dragon = vocab(DECR('d', 'r', 'a', 'g', 'o'), 1, 0);
	chasm = vocab(DECR('c', 'h', 'a', 's', 'm'), 1, 0);
	troll = vocab(DECR('t', 'r', 'o', 'l', 'l'), 1, 0);
	troll2 = troll + 1;
	bear = vocab(DECR('b', 'e', 'a', 'r', '\0'), 1, 0);
	message = vocab(DECR('m', 'e', 's', 's', 'a'), 1, 0);
	vend = vocab(DECR('v', 'e', 'n', 'd', 'i'), 1, 0);
	batter = vocab(DECR('b', 'a', 't', 't', 'e'), 1, 0);

	nugget = vocab(DECR('g', 'o', 'l', 'd', '\0'), 1, 0);
	coins = vocab(DECR('c', 'o', 'i', 'n', 's'), 1, 0);
	chest = vocab(DECR('c', 'h', 'e', 's', 't'), 1, 0);
	eggs = vocab(DECR('e', 'g', 'g', 's', '\0'), 1, 0);
	trident = vocab(DECR('t', 'r', 'i', 'd', 'e'), 1, 0);
	vase = vocab(DECR('v', 'a', 's', 'e', '\0'), 1, 0);
	emerald = vocab(DECR('e', 'm', 'e', 'r', 'a'), 1, 0);
	pyramid = vocab(DECR('p', 'y', 'r', 'a', 'm'), 1, 0);
	pearl = vocab(DECR('p', 'e', 'a', 'r', 'l'), 1, 0);
	rug = vocab(DECR('r', 'u', 'g', '\0', '\0'), 1, 0);
	chain = vocab(DECR('c', 'h', 'a', 'i', 'n'), 1, 0);

	back = vocab(DECR('b', 'a', 'c', 'k', '\0'), 0, 0);
	look = vocab(DECR('l', 'o', 'o', 'k', '\0'), 0, 0);
	cave = vocab(DECR('c', 'a', 'v', 'e', '\0'), 0, 0);
	null = vocab(DECR('n', 'u', 'l', 'l', '\0'), 0, 0);
	entrance = vocab(DECR('e', 'n', 't', 'r', 'a'), 0, 0);
	depression = vocab(DECR('d', 'e', 'p', 'r', 'e'), 0, 0);
	enter = vocab(DECR('e', 'n', 't', 'e', 'r'), 0, 0);

	pour = vocab(DECR('p', 'o', 'u', 'r', '\0'), 2, 0);
	say = vocab(DECR('s', 'a', 'y', '\0', '\0'), 2, 0);
	lock = vocab(DECR('l', 'o', 'c', 'k', '\0'), 2, 0);
	throw = vocab(DECR('t', 'h', 'r', 'o', 'w'), 2, 0);
	find = vocab(DECR('f', 'i', 'n', 'd', '\0'), 2, 0);
	invent = vocab(DECR('i', 'n', 'v', 'e', 'n'), 2, 0);

	/* initialize dwarves */
	chloc = 114;
	chloc2 = 140;
	for (i = 1; i <= 6; i++)
		dseen[i] = FALSE;
	dflag = 0;
	dloc[1] = 19;
	dloc[2] = 27;
	dloc[3] = 33;
	dloc[4] = 44;
	dloc[5] = 64;
	dloc[6] = chloc;
	daltloc = 18;

	/* random flags & ctrs */
	turns = 0;
	lmwarn = FALSE;
	iwest = 0;
	knfloc = 0;
	detail = 0;
	abbnum = 5;
	for (i = 0; i <= 4; i++)
		if (rtext[2 * i + 81].seekadr != 0)
			maxdie = i + 1;
	numdie = holding = dkill = foobar = bonus = 0;
	clock1 = 30;
	clock2 = 50;
	saved = 0;
	isclosing = panic = closed = scoring = FALSE;
}