예제 #1
0
template<typename Tok> JS::Result<ParseNode*>
BinASTParser<Tok>::parse(const uint8_t* start, const size_t length)
{
    auto result = parseAux(start, length);
    poison(); // Make sure that the parser is never used again accidentally.
    return result;
}
예제 #2
0
void Player::attack(Player& rhs)
{
	//initial damage calc
	int doDam = damage*damMult;
	if (shieldColor() == "Red" && turn % 2 == 0) doDam = 0;	
	if (weaponColor() == "Red" && rand() % 100 < 20) doDam *= 2;
	if (weaponColor() == "Yellow" && rand() % 100 < 15) doDam = 0;

	//is it dodged
	if (rhs.armorColor() == "Blue" && rand()%100 < 15) 
	{
		return;
	}

	//shield properties
	if (rhs.shieldColor() == "Red" && turn % 2 == 0 && weaponColor() != "Yellow") doDam = 0;
	if (rhs.shieldColor() == "Blue" && weaponColor() != "Yellow") doDam = doDam*0.8;
	if (rhs.shieldColor() == "Green" && weaponColor() != "Yellow") poison();

	//status effects
	if (weaponColor() == "Blue" && rand() % 100 < 10 && doDam > 0) rhs.stun();
	if (weaponColor() == "Green") rhs.bleed();

	//deal damage
	rhs.hurt(doDam);
	if (rhs.armorColor() == "Green") hurt(doDam / 2);
}
예제 #3
0
static long
do_waitid(const unsigned int idtype,
	  const unsigned int id,
	  const siginfo_t *const infop,
	  const unsigned int options,
	  const struct rusage *const rusage)
{
	sigset_t mask = {};
	sigaddset(&mask, SIGCHLD);

	assert(sigprocmask(SIG_BLOCK, &mask, NULL) == 0);
	long rc = syscall(__NR_waitid, poison(idtype), poison(id),
			  infop, poison(options), rusage);
	assert(sigprocmask(SIG_UNBLOCK, &mask, NULL) == 0);
	return rc;
}
// --- ref_cas_with_check
// Write barriered compare of Rcmp with memory, if equal set memory to Rval. Set
// flags dependent on success. Returns relpc of where NPE info should be added.
// NB on failure Rcmp contains the value from memory, this will be poisoned and
// not lvb-ed. ie. you shouldn't use this value.
int C1_MacroAssembler::ref_cas_with_check(RInOuts, Register Rbase, Register Rcmp, Register Rtmp0, Register Rtmp1,
                                          RKeepIns, Register Rindex, int off, int scale, Register Rval,
                                          CodeEmitInfo *info) {
  assert0( Rcmp == RAX );
  Label checked, strip;

#ifdef ASSERT
  verify_oop(Rval, MacroAssembler::OopVerify_Store);
  verify_oop(Rcmp, MacroAssembler::OopVerify_Move);
  if (RefPoisoning) move8(Rtmp1,Rval); // Save Rval
#endif

  null_chk( Rval,strip  ); // NULLs are always safe to store

  pre_write_barrier_compiled(RInOuts::a, Rtmp0, Rtmp1,
                             RKeepIns::a, Rbase, off, Rindex, scale, Rval,
                             info);

#ifdef ASSERT
  if (RefPoisoning) {
    mov8  (Rtmp1,Rval);  // Save Rval again as it will have been squashed by the barrier
    always_poison(Rval); // Must store poisoned ref
  }
#endif // ASSERT
bind(strip);
  verify_not_null_oop(Rbase, MacroAssembler::OopVerify_StoreBase);
  cvta2va(Rbase);
#ifdef ASSERT
  if (RefPoisoning) {
    poison(Rcmp);      // Compared register must also be posioned
  }
#endif // ASSERT
bind(checked);
  int npe_relpc = rel_pc();
#ifdef ASSERT
  // check the value to be cas-ed is an oop, npe on this rather than the store
  if (should_verify_oop(MacroAssembler::OopVerify_OverWrittenField))
    npe_relpc = verify_oop (Rbase, off, Rindex, scale, MacroAssembler::OopVerify_OverWrittenField);
#endif
  if (Rindex == noreg) locked()->cas8 (Rbase, off, Rval);
  else                 locked()->cas8 (Rbase, off, Rindex, scale, Rval);
#ifdef ASSERT
  pushf();
  if (RefPoisoning) {
    mov8    (Rval,Rtmp1); // Restore unpoisoned Rval
    unpoison(Rcmp);       // Compared register must also be unposioned
  }
  verify_oop(Rval, MacroAssembler::OopVerify_Move);
  verify_oop(Rcmp, MacroAssembler::OopVerify_Move);
  popf();
#endif
  return npe_relpc;
}
static inline void add_to_backlog(hdr_t* hdr) {
    ScopedPthreadMutexLocker locker(&backlog_lock);
    hdr->tag = BACKLOG_TAG;
    backlog_num++;
    add_locked(hdr, &backlog_tail, &backlog_head);
    poison(hdr);
    /* If we've exceeded the maximum backlog, clear it up */
    while (backlog_num > gMallocDebugBacklog) {
        hdr_t* gone = backlog_tail;
        del_from_backlog_locked(gone);
        dlfree(gone->base);
    }
}
예제 #6
0
파일: fdb.c 프로젝트: mq24705/apps
bool
update_fdb( hash_table *fdb, const uint8_t mac[ OFP_ETH_ALEN ], uint64_t dpid, uint16_t port ) {
    assert( fdb != NULL );
    assert( mac != NULL );
    assert( port != 0 );

    fdb_entry *entry = lookup_hash_entry( fdb, mac );

    debug( "Updating fdb ( mac = %02x:%02x:%02x:%02x:%02x:%02x, dpid = %#" PRIx64 ", port = %u ).",
           mac[ 0 ], mac[ 1 ], mac[ 2 ], mac[ 3 ], mac[ 4 ], mac[ 5 ], dpid, port );

    if ( entry != NULL ) {
        if ( ( entry->dpid == dpid ) && ( entry->port == port ) ) {
            entry->updated_at = time( NULL );

            return true;
        }

        if ( entry->created_at + HOST_MOVE_GUARD_SEC < time( NULL ) ) {
            // Poisoning when the terminal moves
            poison( entry->dpid, mac );

            entry->dpid = dpid;
            entry->port = port;
            entry->created_at = time( NULL );
            entry->updated_at = entry->created_at;

            return true;
        }

        warn( "Failed to update fdb because host move detected in %d sec "
              "( mac = %02x:%02x:%02x:%02x:%02x:%02x, "
              "dpid = %#" PRIx64 " -> %#" PRIx64 ", port = %u -> %u ).",
              HOST_MOVE_GUARD_SEC,
              mac[ 0 ], mac[ 1 ], mac[ 2 ], mac[ 3 ], mac[ 4 ], mac[ 5 ],
              entry->dpid, dpid, entry->port, port );

        return false;
    }

    entry = xmalloc( sizeof( fdb_entry ) );
    entry->dpid = dpid;
    memcpy( entry->mac, mac, OFP_ETH_ALEN );
    entry->port = port;
    entry->created_at = time( NULL );
    entry->updated_at = entry->created_at;
    insert_hash_entry( fdb, entry->mac, entry );

    return true;
}
예제 #7
0
void poison(int a,int x,int pos[],int inf[],int upper[],int h[])
{
    int i=pos[a];
    if(i!=-1)
    {
    while(sup[i][0]==a)
    {
        //int test=(h[sup[i][1]]>0);
        h[sup[i][1]]-=x;
        if(/*test==1 && */h[sup[i][1]]<=0){decr_sup(sup[i][1],inf,upper);h[sup[i][1]]=1000000000;}
        poison(sup[i][1],x,pos,inf,upper,h);
        i++;
    }
}}
예제 #8
0
main()
{
    int q,i,k,type,A,X;
    //    cin>>n;
    scanf("%d",&n);
    sup[0][0]=-1;sup[0][1]=0;

    int pos[n+1],inf[n+1],upper[n+1],h[n+1];
    for(i=1;i<=n;i++)
    {
        pos[i]=-1;inf[i]=0;
	//        cin>>h[i]>>sup[i][0];
	scanf("%d %d",&h[i],&sup[i][0]);
        upper[i]=sup[i][0];
        sup[i][1]=i;
    }
    qsort(sup,n+1,2*sizeof(int),compare);
    //for(i=0;i<n+1;i++)cout<<sup[i][0]<<" "<<sup[i][1]<<endl;cout<<endl;

    i=0;
    while(sup[i][0]!=-1){
      k = sup[i][0];
      pos[sup[i][0]]=i;
      while(sup[i][0]==k)
	i++;
    }
    //for(i=0;i<n+1;i++)cout<<pos[i]<<endl;cout<<endl;
    for(i=1;i<=n;i++)inf[i]=count_inf(i,inf,pos);
    inf[0]=n;
    //for(i=0;i<=n;i++)cout<<inf[i]<<endl;cout<<endl;
    //    cin>>q;
    scanf("%d",&q);
    while(q--)
    {
      //      cin>>type;
      scanf("%d",&type);
    if(type==1)
    {
      //        cin>>A>>X;
      scanf("%d %d",&A,&X);
        poison(A,X,pos,inf,upper,h);
    }
    else
    {
      //        cin>>A;
      scanf("%d",&A);
      //        cout<<inf[A]<<endl;
      printf("%d\n",inf[A]);
    }}
}
예제 #9
0
void CStdPoolOfThreads::KillAllThreads(TKillFlags flags)
{
    TACValue n, old_max;
    bool queuing_was_forbidden;
    {{
        CMutexGuard guard(m_Mutex);
        old_max = m_MaxThreads;
        queuing_was_forbidden = m_QueuingForbidden;
        m_MaxThreads = 0;  // Forbid spawning new threads
        m_QueuingForbidden = false; // Always queue normally here.
        n = m_ThreadCount.Get(); // Capture for use without mutex
    }}

    {{
        TACValue n2 = TACValue(m_Threads.size());
        if (n != n2) {
            ERR_POST(Warning << "Registered " << n2 << " threads but expected "
                     << n);
            if (n < n2) {
                n = n2;
            }
        }
    }}

    CRef<CStdRequest> poison(new CFatalRequest);

    for (TACValue i = 0;  i < n;  ) {
        try {
            WaitForRoom();
            AcceptRequest(poison);
            ++i;
        } catch (CBlockingQueueException&) { // guard against races
            continue;
        }
    }
    NON_CONST_ITERATE(TThreads, it, m_Threads) {
        if ((flags & fKill_Wait) != 0) {
            (*it)->Join();
        } else {
            (*it)->Detach();
        }
    }
    m_Threads.clear();
    CMutexGuard guard(m_Mutex);
    m_QueuingForbidden = queuing_was_forbidden;
    if ((flags & fKill_Reopen) != 0) {
        m_MaxThreads = old_max;
    }
}
예제 #10
0
static inline void add_to_backlog(struct hdr *hdr)
{
    pthread_mutex_lock(&backlog_lock);
    hdr->tag = BACKLOG_TAG;
    backlog_num++;
    add_locked(hdr, &backlog_tail, &backlog_head);
    poison(hdr);
    /* If we've exceeded the maximum backlog, clear it up */
    while (backlog_num > malloc_double_free_backlog) {
        struct hdr *gone = backlog_tail;
        del_from_backlog_locked(gone);
        dlfree(gone);
    }
    pthread_mutex_unlock(&backlog_lock);
}
예제 #11
0
void
CPoolOfThreads_ForServer::KillAllThreads(bool wait)
{
    m_KilledAll = true;

    CRef<CStdRequest> poison(new CFatalRequest_ForServer);

    for (TACValue i = 0;  i < m_MaxThreads; ++i) {
        AcceptRequest(poison);
    }
    NON_CONST_ITERATE(TThreads, it, m_Threads) {
        if (wait) {
            (*it)->Join();
        } else {
            (*it)->Detach();
        }
    }
    m_Threads.clear();
}
예제 #12
0
static void
connection_free(struct connection *c)
{
    struct linked_server *ls, *n;

    connection_check(c);

    list_for_each_entry_safe(ls, n, &c->servers, siblings)
        connection_server_dispose(c, ls);

    connection_disconnect(c);

    if (c->client.reconnecting)
        event_del(&c->client.reconnect_event);

    client_version_free(&c->client_version);

    poison(c, sizeof(*c));
    free(c);
}
예제 #13
0
	void game::generate_library()
	{
		m_library = std::make_shared<library>();

		// buffs
		rl::person::status_t poison(10, [&](rl::person &c, rl::person::status_t &s) { c.health() = c.health() - 1; });
		poison.register_apply([&](rl::person &target, rl::person::status_t &s)
		{
			m_broadcasts.emplace_back("* poisoned *", color(0, 1, 0), target.position(), 0.5);
		});
		poison.appearance({ '-', 0xffff00 });
		poison.name("Poison");
		poison.tag("poison");
		m_library->insert(poison);

		// skills

		rl::person::action_t::range_t bite_range(0, 1);
		rl::person::action_t bite(rl::person::action_t::target_fn([&](rl::person::caster_t *user, rl::person::target_t unit)
		{
			if (user && unit)
			{
				point start = user->position();

				// status
				//unit->accept(rl::effect(m_library->prototype<rl::person::status_t>("poison")));

				// popup
				m_broadcasts.emplace_back(std::to_string(-8), color(1, 0, 0), unit->position(), 0.75);

				// visual
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25;
					vector up = pos + vector(0, 0.25);
					return up.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * -0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 + vector(0.15, 0);
					vector up = pos + vector(0, 0.25);
					return up.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * -0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 - vector(0.15, 0);
					vector up = pos + vector(0, 0.25);
					return up.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * -0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25;
					vector down = pos - vector(0, 0.25);
					return down.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * 0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 + vector(0.15, 0);
					vector down = pos - vector(0, 0.25);
					return down.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * 0.5, 0.25));
				m_projectiles.push_back(projectile({ '>', 0xff0000 }, {},
					[start, unit](projectile::timespan_t phase)
				{
					point fin = unit->position();
					vector pos = fin + vector((fin - start).normalized()) * -0.25 - vector(0.15, 0);
					vector down = pos - vector(0, 0.25);
					return down.lerp(pos, (std::min)(phase, 1.0));
				}, 3.14 * 0.5, 0.25));
			}
		}), rl::person::action_t::target_check_fn([&, bite_range](rl::person::caster_t *user, rl::person::target_t unit)
		{
			return user && unit && user != unit.get() && rl::person::action_t::in_range(bite_range, distance(user->position(), unit->position()));
		}));
		bite.name("Bite");
		bite.range(bite_range);
		bite.tag("bite");
		m_library->insert(bite);

		rl::person::action_t pyroblast(rl::person::action_t::target_fn([&](rl::person::caster_t *user, rl::person::target_t unit)
		{
			if (user)
			{
				//broadcast({ "puff!", 0xffffff, user->position() });
			}
			if (user && unit)
			{
				vector start = user->position();
				vector fin = unit->position();
				//m_projectiles.push_back(projectile('*', 0xff0000, color(30, 10, 10), [=](projectile::timespan_t phase) { return start.lerp(fin, (std::min)(phase, 1.0)); }));
			}
		}), rl::person::action_t::target_check_fn([&](rl::person::caster_t *user, rl::person::target_t unit)
		{
			return true;
		}));
		pyroblast.tag("pyroblast");
		m_library->insert(pyroblast);

		// heal
		rl::person::action_t::ground_fn h([&](rl::person::caster_t *user, const point &position)
		{
			user->health() = user->health() + 1;
		});
		rl::person::action_t::ground_check_fn hc([&](rl::person::caster_t *user, const point &position)
		{
			return true;
		});
		rl::person::action_t heal(h, hc);
		heal.tag("heal");
		m_library->insert(heal);

		// teleport
		rl::person::action_t::ground_fn teleport_fn([&](rl::person::caster_t *user, const point &position)
		{
			m_scene->focus(position);
			m_scene->move(*user, position);
		});
		rl::person::action_t::ground_check_fn teleport_check_fn([&](rl::person::caster_t *user, const point &position)
		{
			return true;
		});
		rl::person::action_t teleport(teleport_fn, teleport_check_fn);
		teleport.tag("teleport");
		m_library->insert(teleport);

		// npc

		rl::npc rat;
		rat.fraction(0);
		rat.appearance({ 'r', 0xff0000, 0.62f });
		rat.health() = 100;
		rat.tag("mob_rat");
		rat.name("Rat");
		rat.add_skill(bite);
		m_library->insert(rat);

		// ore
		rl::item ore;
		ore.appearance('o');
		ore.name("copper ore");
		ore.tag("ore_copper");
		ore.stackable(true);
		m_library->insert(ore);

		// placeables
		rl::unit lantern;
		lantern.appearance({ ' ', color(1, 1, 1) });
		lantern.light({ { 3, 3, 3 }, true, true });
		lantern.tag("lantern");
		m_library->insert(lantern);

		rl::door door;
		door.appearance({ ' ', 0x333333 }, { '+', 0x333333 });
		door.tag("door");
		m_library->insert(door);

		// items
		{
			rl::item ff;
			ff.name("Firetail Mushroom");
			ff.tag("f_red");
			m_library->insert(ff);
		}
		{
			rl::item flora;
			flora.name("Glowing Moss");
			flora.tag("f_green");
			m_library->insert(flora);
		}
		{
			rl::item flora;
			flora.name("Cave Lily");
			flora.tag("f_blue");
			m_library->insert(flora);
		}

		// flora
		rl::deposit f1(m_library->make<rl::item>("f_red"));
		f1.tag("fireflower");
		f1.name("Gribus Ognelisius");
		f1.appearance({ '*', color(1, 0, 0), 0.75 });
		f1.light({ { 3, 0, 0 }, true, true });
		f1.invincible(true);
		m_library->insert(f1);

		rl::deposit f2(m_library->make<rl::item>("f_blue"));
		f2.tag("iceflower");
		f2.appearance({ '*', color(0, 0, 1), 0.75 });
		f2.light({ { 0, 0, 3 }, true, true });
		f2.invincible(true);
		m_library->insert(f2);

		rl::deposit flower(m_library->make<rl::item>("f_green"));
		flower.tag("felflower");
		flower.appearance({ '*', color(0, 1, 0), 0.75 });
		flower.light({ { 0, 3, 0 }, true, true });
		flower.invincible(true);
		m_library->insert(flower);
	}
예제 #14
0
파일: tinjpage.c 프로젝트: ystk/debian-ltp
void testmem(char *msg, char *page, enum rmode mode)
{
	printf("%s page %p\n", msg, page);
	poison(msg, page, mode);
	recover(msg, page, mode);
}
예제 #15
0
bool pc_record_type::runTrap(short trap_type, short trap_level, short diff)
{
	short r1,skill,i,num_hits = 1,i_level;
	short trap_odds[30] = {5,30,35,42,48, 55,63,69,75,77,
							78,80,82,84,86, 88,90,92,94,96,98,99,99,99,99,99,99,99,99,99};

	num_hits += trap_level;

	if (trap_type == TRAP_RANDOM)
		trap_type = get_ran(1,1,4);

	/// ??? => no trap after all ;)
	if (trap_type == 6)
		return true;

	i = statAdj(SKILL_DEXTERITY);

	if ((i_level = getProtLevel(ITEM_THIEVING)) > 0)
		i += i_level / 2;

	skill = minmax(0, 20, skills[SKILL_DISARM_TRAPS] + skills[SKILL_LUCK] / 2 + 1 - c_town.difficulty + 2 * i);

	r1 = get_ran(1,0,100) + diff;
	// Nimble?
	if (traits[TRAIT_NIMBLE] == true)	r1 -= 6;

	if (r1 < trap_odds[skill])
	{
		add_string_to_buf("  Trap disarmed.            ");
		return true;
	}
		else add_string_to_buf("  Disarm failed.          ");

	switch (trap_type)
	{
		case TRAP_BLADE:
			for (i = 0; i < num_hits; i++)
			{
				add_string_to_buf("  A knife flies out!              ");
				damage(get_ran(2 + c_town.difficulty / 14,1,10),DAMAGE_WEAPON,-1);
			}
			break;

		case TRAP_DART:
			add_string_to_buf("  A dart flies out.              ");
			poison((3 + c_town.difficulty / 14) + (trap_level * 2));
			break;

		case TRAP_GAS:
			add_string_to_buf("  Poison gas pours out.          ");
			adven.poison((2 + c_town.difficulty / 14) + trap_level * 2);
			break;

		case TRAP_EXPLOSION:
			for (i = 0; i < num_hits; i++)
			{
				add_string_to_buf("  There is an explosion.        ");
				adven.damage(get_ran(3 + c_town.difficulty / 13,1,8), DAMAGE_FIRE);
			}
			break;

		case TRAP_SLEEP_RAY:
			add_string_to_buf("  A purple ray flies out.          ");
			sleep((200 + c_town.difficulty * 100) + (trap_level * 400),12,50);
			break;

		case TRAP_DRAIN_XP:
			add_string_to_buf("  You feel weak.            ");
			experience = max(0, experience - (40 + trap_level * 30));
			break;

		case TRAP_ALERT:
			add_string_to_buf("  An alarm goes off!!!            ");
			set_town_status(0);
			break;

		case TRAP_FLAMES:
			add_string_to_buf("  Flames shoot from the walls.        ");
			adven.damage(get_ran(10 + trap_level * 5,1,8),DAMAGE_FIRE);
			break;

		case TRAP_DUMBFOUND:
			add_string_to_buf("  You feel disoriented.        ");
			adven.dumbfound(2 + trap_level * 2);
			break;

		case TRAP_DISEASE:
			add_string_to_buf("  You prick your finger. ");
			disease((3 + c_town.difficulty / 14) + (trap_level * 2));
			break;

		case TRAP_DISEASE_ALL:
			add_string_to_buf("  A foul substance sprays out.");
			adven.disease((2 + c_town.difficulty / 14) + (trap_level * 2));
			break;

		default:
			add_string_to_buf("  (ERROR: Unknown type of trap!)");
			break;
	}

	put_pc_screen();
	put_item_screen(stat_window,0);
	return true;
}