Esempio n. 1
0
Assembler::Register LocationAddress::fixed_register() {
  if (code_generator()->omit_stack_frame()) {
    return Assembler::jsp;
  } else {
    return is_local() ? Assembler::fp : Assembler::jsp;
  }
}
Esempio n. 2
0
bool LocationAddress::has_fixed_offset(jint& fixed_offset) {
  int base_offset;
  int actual_index;

  CodeGenerator* gen = code_generator() ;

  if (gen->omit_stack_frame()) {
    // Everything is accessed using jsp
    actual_index = frame()->stack_pointer() - index();
    fixed_offset = JavaFrame::arg_offset_from_sp(actual_index);     
  } else {
    // With a stack frame: locals are accessed using fp
    //                     stacks are accessed using jsp
    if (is_local()) {
      // The offset from the fp that would have it point at the end of the
      // locals block 
      base_offset = JavaFrame::end_of_locals_offset();
      actual_index = gen->root_method()->max_locals() - 1 - index();
    } else {
      if (Assembler::jsp == Assembler::sp) {
        // We need to make sure that we don't put something beyond
        // the current end of stack
        gen->ensure_sufficient_stack_for(index(), type());
      } 
      base_offset = 0;
      actual_index = gen->frame()->stack_pointer() - index();
    }
    fixed_offset = base_offset + JavaFrame::arg_offset_from_sp(actual_index);
  }
  return true;
}
Esempio n. 3
0
/* generate a fake reply
 * it assumes the REPLY_LOCK is already held and returns unlocked */
static void fake_reply(struct cell *t, int branch, int code )
{
	struct cancel_info cancel_data;
	short do_cancel_branch;
	enum rps reply_status;

	init_cancel_info(&cancel_data);
	do_cancel_branch = is_invite(t) && prepare_cancel_branch(t, branch, 0);
	/* mark branch as canceled */
	t->uac[branch].request.flags|=F_RB_CANCELED;
	t->uac[branch].request.flags|=F_RB_RELAYREPLY;
	if ( is_local(t) ) {
		reply_status=local_reply( t, FAKED_REPLY, branch, 
					  code, &cancel_data );
	} else {
		/* rely reply, but don't put on wait, we still need t
		 * to send the cancels */
		reply_status=relay_reply( t, FAKED_REPLY, branch, code,
					  &cancel_data, 0 );
	}
	/* now when out-of-lock do the cancel I/O */
#ifdef CANCEL_REASON_SUPPORT
	if (do_cancel_branch) cancel_branch(t, branch, &cancel_data.reason, 0);
#else /* CANCEL_REASON_SUPPORT */
	if (do_cancel_branch) cancel_branch(t, branch, 0);
#endif /* CANCEL_REASON_SUPPORT */
	/* it's cleaned up on error; if no error occurred and transaction
	   completed regularly, I have to clean-up myself
	*/
	if (reply_status == RPS_COMPLETED)
		put_on_wait(t);
}
int is_console_enabled(osm_subn_opt_t * p_opt)
{
	/* checks for a variety of types of consoles - default is off or 0 */
	if (p_opt)
		return is_local(p_opt->console) || is_loopback(p_opt->console)
			|| is_remote(p_opt->console);
	return 0;
}
Esempio n. 5
0
 optional<unsigned> get_fn_idx(expr const & fn) {
     if (!is_local(fn)) return optional<unsigned>();
     for (unsigned fnidx = 0; fnidx < m_old_fns.size(); fnidx++) {
         if (mlocal_name(fn) == mlocal_name(m_old_fns[fnidx]))
             return optional<unsigned>(fnidx);
     }
     return optional<unsigned>();
 }
Esempio n. 6
0
void test_host(struct parsedfile *config, char *host) {
	struct serverent *path;
	char *hostname, *port;
	char separator;
	unsigned long portno = 0;
	int af;
	int flag;
	struct sockaddr_in addr4;
#ifdef ENABLE_IPV6
	struct sockaddr_in6 addr6;
#endif
	void *hostaddr;
	char buf[60];

	/* See if a port has been specified */
	hostname = strsplit(&separator, &host, ": \t\n");
	if (separator == ':') {
		port = strsplit(NULL, &host, " \t\n");
		if (port)
			portno = strtol(port, NULL, 0);
	}

	/* First resolve the host to an ip */
#ifdef ENABLE_IPV6
	if ((flag = resolve_ip(AF_INET6, hostname, 0, 1, (void *) &addr6)) == -1) {
#endif
		af = AF_INET;
		flag = resolve_ip(AF_INET, hostname, 0, 1, (void *) &addr4);
		hostaddr = (void *) &addr4.sin_addr;
#ifdef ENABLE_IPV6
	} else {
		af = AF_INET6;
		hostaddr = (void *) &addr6.sin6_addr;
	}
#endif
	if (flag == -1) {
		fprintf(stderr, "Error: Cannot resolve %s\n", host);
		return;
	} else {
		inet_ntop(af, hostaddr, buf, 60);
		printf("Finding path for %s...\n", buf);
		if (!(is_local(config, af, hostaddr))) {
			printf("Path is local\n");
		} else {
			pick_server(config, &path, af, hostaddr, portno);
			if (path == &(config->defaultserver)) {
				printf("Path is via default server:\n");
				show_server(config, path, 1);
			} else {
				printf("Host is reached via this path:\n");
				show_server(config, path, 0);
			}
		}
	}

	return;
}
Esempio n. 7
0
DictionaryDatum
Node::get_status_base()
{
  DictionaryDatum dict = get_status_dict_();

  assert( dict.valid() );

  // add information available for all nodes
  ( *dict )[ names::local ] = is_local();
  ( *dict )[ names::model ] = LiteralDatum( get_name() );

  // add information available only for local nodes
  if ( is_local() )
  {
    ( *dict )[ names::global_id ] = get_gid();
    ( *dict )[ names::frozen ] = is_frozen();
    ( *dict )[ names::node_uses_wfr ] = node_uses_wfr();
    ( *dict )[ names::thread ] = get_thread();
    ( *dict )[ names::vp ] = get_vp();
    if ( parent_ )
    {
      ( *dict )[ names::parent ] = parent_->get_gid();

      // LIDs are only sensible for nodes with parents.
      // Add 1 as we count lids internally from 0, but from
      // 1 in the user interface.
      ( *dict )[ names::local_id ] = get_lid() + 1;
    }
  }

  ( *dict )[ names::thread_local_id ] = get_thread_lid();
  ( *dict )[ names::supports_precise_spikes ] = is_off_grid();

  // This is overwritten with a corresponding value in the
  // base classes for stimulating and recording devices, and
  // in other special node classes
  ( *dict )[ names::element_type ] = LiteralDatum( names::neuron );

  // now call the child class' hook
  get_status( dict );

  assert( dict.valid() );
  return dict;
}
Esempio n. 8
0
/**
 * This function will be called from a SER process when a reply is received for
 * the transaction. The SER processes only have acces to the EventDispatcher 
 * fifo (not to the ActionDispatcher) so EventDispatcher will be the one who 
 * will send the event to the AppServer.
 */
void uac_cb(struct cell* t, int type,struct tmcb_params *rcvd_params)
{
   as_msg_p my_as_ev=0;
   int mylen,code,i;
   struct as_uac_param *ev_info;
   struct sip_msg *msg;
   char *buffer;

   ev_info=(struct as_uac_param*)*rcvd_params->param;
   msg=rcvd_params->rpl;
   code=rcvd_params->code;
   buffer=0;
   if(!ev_info || !ev_info->who){
      return;
   }

   if(type == TMCB_LOCAL_COMPLETED && !ev_info->destroy_cb_set) {
      if(seas_f.tmb.register_tmcb(NULL, t, TMCB_DESTROY , uac_cleanup_cb, (void*)ev_info, 0) <= 0) {
         LM_ERR( "register_tmcb for destroy callback failed\n");
         goto error;
      }
      ev_info->destroy_cb_set = 1;
   }

   LM_DBG("reply to UAC Transaction for AS:%.*s code: %d\n",
		   ev_info->who->name.len,ev_info->who->name.s,code);
   LM_DBG("transaction %p Nr_of_outgoings:%d is_Local:%c\n",
		   t,t->nr_of_outgoings,is_local(t)?'y':'n');
   for(i=0;i<t->nr_of_outgoings;i++)
      LM_DBG("UAC[%d].last_received=%d\n",i,t->uac[i].last_received);
   if(!(my_as_ev=shm_malloc(sizeof(as_msg_t)))){
      LM_ERR("no more shared mem\n");
      goto error;
   }
   if(!(buffer=create_as_action_reply(t,rcvd_params,ev_info->uac_id,ev_info->processor_id,&mylen))){
      LM_ERR("failed to encode message\n");
      goto error;
   }
   my_as_ev->as = ev_info->who;
   my_as_ev->msg = buffer;
   my_as_ev->len = mylen;
   my_as_ev->type = RES_IN;
   my_as_ev->transaction = t;
   if(write(write_pipe,&my_as_ev,sizeof(as_msg_p))<=0){
      goto error;
   }
   goto exit;
error:
   if(my_as_ev){
      shm_free(my_as_ev);
   }
   if(buffer)
      shm_free(buffer);
exit:
   return ;
}
static optional<head_index> to_head_index(expr type) {
    // TODO(dhs): we will want to filter this set,
    // because some constants are treated specially by this module
    // (e.g. [eq] and [not])
    expr const & f = get_app_fn(type);
    if (is_constant(f) || is_local(f))
        return optional<head_index>(head_index(f));
    else
        return optional<head_index>();
}
Esempio n. 10
0
// Check whether rhs is of the form (mvar l_1 ... l_n) where mvar is a metavariable,
// and l_i's are local constants, and mvar does not occur in found_mvars.
// If it is return true and update found_mvars
static bool is_valid_congr_hyp_rhs(expr const & rhs, name_set & found_mvars) {
    buffer<expr> rhs_args;
    expr const & rhs_fn = get_app_args(rhs, rhs_args);
    if (!is_metavar(rhs_fn) || found_mvars.contains(mlocal_name(rhs_fn)))
        return false;
    for (expr const & arg : rhs_args)
        if (!is_local(arg))
            return false;
    found_mvars.insert(mlocal_name(rhs_fn));
    return true;
}
Esempio n. 11
0
void collect_locals(expr const & e, expr_struct_set & ls) {
    if (!has_local(e))
        return;
    for_each(e, [&](expr const & e, unsigned) {
            if (!has_local(e))
                return false;
            if (is_local(e))
                ls.insert(e);
            return true;
        });
}
Esempio n. 12
0
static bool is_routable(const unsigned char *ipaddr)
{
	return is_valid(ipaddr) &&
		!(	is_RFC1918(ipaddr) ||
			is_RFC3927(ipaddr) ||
			is_RFC4862(ipaddr) ||
			(is_RFC4193(ipaddr) && !is_tor(ipaddr)) ||
			is_RFC4843(ipaddr) ||
			is_local(ipaddr)
		);
}
Esempio n. 13
0
jint LocationAddress::compute_base_offset() {
  // compute the base offset for this location address
  if (is_local()) {
    const int max_locals = Compiler::root()->method()->max_locals();
    // bp + 8 acts like a stack pointer for the locals
    return 2 * sizeof(int)
        + JavaFrame::arg_offset_from_sp(max_locals - index() - 1);
  } else {
    code_generator()->ensure_sufficient_stack_for(index(), type());      
    return JavaFrame::arg_offset_from_sp(frame()->stack_pointer() - index());
  } 
}
Esempio n. 14
0
vm_obj clear(expr const & H, tactic_state const & s) {
    lean_assert(is_local(H));
    try {
        optional<expr> mvar  = s.get_main_goal();
        if (!mvar) return mk_no_goals_exception(s);
        metavar_context mctx = s.mctx();
        expr new_mvar        = clear(mctx, *mvar, H);
        return mk_tactic_success(set_mctx_goals(s, mctx, cons(new_mvar, tail(s.goals()))));
    } catch (exception & ex) {
        return mk_tactic_exception(ex, s);
    }
}
Esempio n. 15
0
bool is_ceqv(tmp_type_context & tctx, expr e) {
    if (has_expr_metavar(e))
        return false;
    name_set to_find;
    // Define a procedure for removing arguments from to_find.
    auto visitor_fn = [&](expr const & e, unsigned) {
        if (is_local(e)) {
            to_find.erase(mlocal_name(e));
            return false;
        } else if (is_metavar(e)) {
            return false;
        } else {
            return true;
        }
    };
    environment const & env = tctx.env();
    bool is_std = is_standard(env);
    buffer<expr> hypotheses; // arguments that are propositions
    while (is_pi(e)) {
        if (!to_find.empty()) {
            // Support for dependent types.
            // We may find the instantiation for the previous arguments
            // by matching the type.
            for_each(binding_domain(e), visitor_fn);
        }
        expr local = tctx.mk_tmp_local(binding_domain(e));
        if (binding_info(e).is_inst_implicit()) {
            // If the argument can be instantiated by type class resolution, then
            // we don't need to find it in the lhs
        } else if (is_std && tctx.is_prop(binding_domain(e))) {
            // If the argument is a proposition, we store it in hypotheses.
            // We check whether the lhs occurs in hypotheses or not.
            hypotheses.push_back(binding_domain(e));
        } else {
            to_find.insert(mlocal_name(local));
        }
        e = instantiate(binding_body(e), local);
    }
    expr lhs, rhs;
    if (!is_simp_relation(env, e, lhs, rhs))
        return false;
    // traverse lhs, and remove found variables from to_find
    for_each(lhs, visitor_fn);
    if (!to_find.empty())
        return false;
    // basic looping ceq detection: the left-hand-side should not occur in the right-hand-side,
    // nor it should occur in any of the hypothesis
    if (occurs(lhs, rhs))
        return false;
    if (std::any_of(hypotheses.begin(), hypotheses.end(), [&](expr const & h) { return occurs(lhs, h); }))
        return false;
    return true;
}
Esempio n. 16
0
File: util.cpp Progetto: cpehle/lean
static bool is_typeformer_app(buffer<name> const & typeformer_names, expr const & e) {
    expr const & fn = get_app_fn(e);
    if (!is_local(fn))
        return false;
    unsigned r = 0;
    for (name const & n : typeformer_names) {
        if (mlocal_name(fn) == n)
            return true;
        r++;
    }
    return false;
}
Esempio n. 17
0
static optional<unsigned> is_typeformer_app(buffer<name> const & typeformer_names, expr const & e) {
    expr const & fn = get_app_fn(e);
    if (!is_local(fn))
        return optional<unsigned>();
    unsigned r = 0;
    for (name const & n : typeformer_names) {
        if (mlocal_name(fn) == n)
            return optional<unsigned>(r);
        r++;
    }
    return optional<unsigned>();
}
Esempio n. 18
0
optional<expr> has_expr_metavar_strict(expr const & e) {
    if (!has_expr_metavar(e))
        return none_expr();
    optional<expr> r;
    for_each(e, [&](expr const & e, unsigned) {
            if (r || !has_expr_metavar(e)) return false;
            if (is_meta(e)) { r = e; return false; }
            if (is_local(e)) return false; // do not visit type
            return true;
        });
    return r;
}
Esempio n. 19
0
struct transport *transport_get(struct remote *remote, const char *url)
{
	struct transport *ret = xcalloc(1, sizeof(*ret));

	ret->remote = remote;
	ret->url = url;

	if (!prefixcmp(url, "rsync://")) {
		ret->get_refs_list = get_refs_via_rsync;
		ret->fetch = fetch_objs_via_rsync;
		ret->push = rsync_transport_push;

	} else if (!prefixcmp(url, "http://")
	        || !prefixcmp(url, "https://")
	        || !prefixcmp(url, "ftp://")) {
#ifdef NO_CURL
		error("git was compiled without libcurl support.");
#else
		ret->get_refs_list = get_refs_via_curl;
		ret->fetch = fetch_objs_via_curl;
		ret->push = curl_transport_push;
#endif
		ret->disconnect = disconnect_walker;

	} else if (is_local(url) && is_file(url)) {
		struct bundle_transport_data *data = xcalloc(1, sizeof(*data));
		ret->data = data;
		ret->get_refs_list = get_refs_from_bundle;
		ret->fetch = fetch_refs_from_bundle;
		ret->disconnect = close_bundle;

	} else {
		struct git_transport_data *data = xcalloc(1, sizeof(*data));
		ret->data = data;
		ret->set_option = set_git_option;
		ret->get_refs_list = get_refs_via_connect;
		ret->fetch = fetch_refs_via_pack;
		ret->push = git_transport_push;
		ret->disconnect = disconnect_git;

		data->thin = 1;
		data->conn = NULL;
		data->uploadpack = "git-upload-pack";
		if (remote && remote->uploadpack)
			data->uploadpack = remote->uploadpack;
		data->receivepack = "git-receive-pack";
		if (remote && remote->receivepack)
			data->receivepack = remote->receivepack;
	}

	return ret;
}
Esempio n. 20
0
static bool validate_locals(expr const & r, unsigned num_locals, expr const * locals) {
    bool failed = false;
    for_each(r, [&](expr const & e, unsigned) {
            if (!has_local(e) || failed) return false;
            if (is_local(e) &&
                !std::any_of(locals, locals + num_locals,
                             [&](expr const & l) { return mlocal_name(l) == mlocal_name(e); })) {
                failed = true;
                return false;
            }
            return true;
        });
    return !failed;
}
Esempio n. 21
0
int t_is_local(struct sip_msg* p_msg)
{
    struct cell* t;
    if(t_check(p_msg,0) != 1){
	LOG(L_ERR,"ERROR: t_is_local: no transaction found\n");
	return -1;
    }
    t = get_t();
    if(!t){
	LOG(L_ERR,"ERROR: t_is_local: transaction found is NULL\n");
	return -1;
    }
    
    return is_local(t);
}
Esempio n. 22
0
unsigned hash_bi(expr const & e) {
    unsigned h = e.hash();
    for_each(e, [&](expr const & e, unsigned) {
            if (is_binding(e)) {
                h = hash(h, hash(binding_name(e).hash(), binding_info(e).hash()));
            } else if (is_local(e)) {
                h = hash(h, hash(mlocal_name(e).hash(), local_info(e).hash()));
                return false; // do not visit type
            } else if (is_metavar(e)) {
                return false; // do not visit type
            }
            return true;
        });
    return h;
}
Esempio n. 23
0
static list<unsigned> collect_deps(expr const & type, buffer<expr> const & locals) {
    buffer<unsigned> deps;
    for_each(type, [&](expr const & e, unsigned) {
            if (is_local(e)) {
                unsigned idx;
                for (idx = 0; idx < locals.size(); idx++)
                    if (locals[idx] == e)
                        break;
                if (idx < locals.size() && std::find(deps.begin(), deps.end(), idx) == deps.end())
                    deps.push_back(idx);
            }
            return has_local(e); // continue the search only if e has locals
        });
    std::sort(deps.begin(), deps.end());
    return to_list(deps);
}
Esempio n. 24
0
bool contains_local(expr const & e, name const & n) {
    if (!has_local(e))
        return false;
    bool result = false;
    for_each(e, [&](expr const & e, unsigned) {
            if (result || !has_local(e))  {
                return false;
            } else if (is_local(e) && mlocal_name(e) == n) {
                result = true;
                return false;
            } else {
                return true;
            }
        });
    return result;
}
Esempio n. 25
0
 virtual optional<constraints> next() {
     while (!empty(m_local_instances)) {
         expr inst         = head(m_local_instances);
         m_local_instances = tail(m_local_instances);
         if (!is_local(inst))
             continue;
         if (auto r = try_instance(inst, mlocal_type(inst)))
             return r;
     }
     while (!empty(m_instances)) {
         name inst   = head(m_instances);
         m_instances = tail(m_instances);
         if (auto cs = try_instance(inst))
             return cs;
     }
     return optional<constraints>();
 }
Esempio n. 26
0
void DealDamageComponent::on_init() {
  auto body(get_user()->get_component<PhysicsBodyComponent>());
  if (body) {
    body->start_contact.connect([this](PhysicsBodyComponent* self, PhysicsBodyComponent* other, math::vec2 const&) {
      auto net_object(dynamic_cast<NetworkObject*>(other->get_user()));
      if (!net_object || net_object->is_local()) {
        auto life = other->get_user()->get_component<LifeComponent>();
        if (life) {
          life->decrease(Amount(), DamageSourceID(), self->get_linear_velocity()*0.5);
        }
      }

      return true;
    });
  } else {
    LOG_WARNING << "Failed to initialize DealDamageComponent: No PhysicsBodyComponent found!" << std::endl;
  }
}
Esempio n. 27
0
expr clear(metavar_context & mctx, expr const & mvar, expr const & H) {
    lean_assert(is_metavar(mvar));
    lean_assert(is_local(H));
    optional<metavar_decl> g   = mctx.get_metavar_decl(mvar);
    if (!g) throw exception("clear tactic failed, there are no goals to be solved");
    local_context lctx         = g->get_context();
    optional<local_decl> d     = lctx.get_local_decl(H);
    if (!d)
        throw exception(sstream() << "clear tactic failed, unknown '" << local_pp_name(H) << "' hypothesis");
    if (depends_on(g->get_type(), mctx, 1, &H))
        throw exception(sstream() << "clear tactic failed, target type depends on '" << local_pp_name(H) << "'");
    if (optional<local_decl> d2 = lctx.has_dependencies(*d, mctx))
        throw exception(sstream() << "clear tactic failed, hypothesis '" << d2->get_pp_name() << "' depends on '" << local_pp_name(H) << "'");
    lctx.clear(*d);
    expr new_mvar              = mctx.mk_metavar_decl(lctx, g->get_type());
    mctx.assign(mvar, new_mvar);
    return new_mvar;
}
Esempio n. 28
0
/*
 * Strip username (and password) from a URL and return
 * it in a newly allocated string.
 */
char *transport_anonymize_url(const char *url)
{
	char *anon_url, *scheme_prefix, *anon_part;
	size_t anon_len, prefix_len = 0;

	anon_part = strchr(url, '@');
	if (is_local(url) || !anon_part)
		goto literal_copy;

	anon_len = strlen(++anon_part);
	scheme_prefix = strstr(url, "://");
	if (!scheme_prefix) {
		if (!strchr(anon_part, ':'))
			/* cannot be "me@there:/path/name" */
			goto literal_copy;
	} else {
		const char *cp;
		/* make sure scheme is reasonable */
		for (cp = url; cp < scheme_prefix; cp++) {
			switch (*cp) {
				/* RFC 1738 2.1 */
			case '+': case '.': case '-':
				break; /* ok */
			default:
				if (isalnum(*cp))
					break;
				/* it isn't */
				goto literal_copy;
			}
		}
		/* @ past the first slash does not count */
		cp = strchr(scheme_prefix + 3, '/');
		if (cp && cp < anon_part)
			goto literal_copy;
		prefix_len = scheme_prefix - url + 3;
	}
	anon_url = xcalloc(1, 1 + prefix_len + anon_len);
	memcpy(anon_url, url, prefix_len);
	memcpy(anon_url + prefix_len, anon_part, anon_len);
	return anon_url;
literal_copy:
	return xstrdup(url);
}
Esempio n. 29
0
list<list<name>> collect_choice_symbols(expr const & e) {
    buffer<list<name>> r;
    for_each(e, [&](expr const & e, unsigned) {
            if (is_choice(e)) {
                buffer<name> cs;
                for (unsigned i = 0; i < get_num_choices(e); i++) {
                    expr const & c = get_app_fn(get_choice(e, i));
                    if (is_constant(c))
                        cs.push_back(const_name(c));
                    else if (is_local(c))
                        cs.push_back(mlocal_pp_name(c));
                }
                if (cs.size() > 1)
                    r.push_back(to_list(cs));
            }
            return true;
        });
    return to_list(r);
}
Esempio n. 30
0
void set_final_timer( /* struct s_table *h_table, */ struct cell *t )
{
	if ( !is_local(t) && t->uas.request->REQ_METHOD==METHOD_INVITE ) {
		/* crank timers for negative replies */
		if (t->uas.status>=300) {
			start_retr(&t->uas.response);
			return;
		}
		/* local UAS retransmits too */
		if (t->relaied_reply_branch==-2 && t->uas.status>=200) {
			/* we retransmit 200/INVs regardless of transport --
			   even if TCP used, UDP could be used upstream and
			   loose the 200, which is not retransmitted by proxies
			*/
			force_retr( &t->uas.response );
			return;
		}
	} 
	put_on_wait(t);
}