예제 #1
0
int main ()
{
  /* Initialise our map and an iterator to work with it */
  mymap = new std::map<struct foo*, int>();
  std::map<struct foo*, int>::iterator it;

  /* Initialise struct A */
  struct foo *a = new foo();
  a->content = new char[32];
  a->created = 111111;

  /* Initialise struct B */
  struct foo *b = new foo();
  b->content = new char[32];
  b->created = 222222;

  /* Insert and asign some values */
  add_to_map(a, 50);
  add_to_map(b, 500);

  /* Print the contents of our map */
  std::cout << "elements in mymap:" << '\n';
  std::cout << "a => " << mymap->find(a)->second << '\n';
  std::cout << "b => " << mymap->find(b)->second << '\n';

  /* Cleanup */
  delete(mymap);
  return 0;
}
int main(int argc, char **argv) {
    unordered_map<int, TreeNode *> map;
    TreeNode *root = read_tree(argc - 3, argv + 1);
    add_to_map(map, root);
    cout << Solution().lowestCommonAncestor(root,
        map[atoi(argv[argc - 2])], map[atoi(argv[argc - 1])])->val << endl;
    return 0;
}
예제 #3
0
void createProbingPT(const char * phrasetable_path, const char * target_path){
    //Get basepath and create directory if missing
    std::string basepath(target_path);
    mkdir(basepath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);

    //Set up huffman and serialize decoder maps.
    Huffman huffmanEncoder(phrasetable_path); //initialize
    huffmanEncoder.assign_values();
    huffmanEncoder.produce_lookups();
    huffmanEncoder.serialize_maps(target_path);

    //Get uniq lines:
    unsigned long uniq_entries = huffmanEncoder.getUniqLines();

    //Source phrase vocabids
    std::map<uint64_t, std::string> source_vocabids;

    //Read the file
    util::FilePiece filein(phrasetable_path);

    //Init the probing hash table
    size_t size = Table::Size(uniq_entries, 1.2);
    char * mem = new char[size];
    memset(mem, 0, size);
    Table table(mem, size);

    BinaryFileWriter binfile(basepath); //Init the binary file writer.

    line_text prev_line; //Check if the source phrase of the previous line is the same

    //Keep track of the size of each group of target phrases
    uint64_t entrystartidx = 0;
    //uint64_t line_num = 0;


    //Read everything and processs
    while(true){
        try {
            //Process line read
            line_text line;
            line = splitLine(filein.ReadLine());
            //Add source phrases to vocabularyIDs
            add_to_map(&source_vocabids, line.source_phrase);

            if ((binfile.dist_from_start + binfile.extra_counter) == 0) {
                prev_line = line; //For the first iteration assume the previous line is
            } //The same as this one.

            if (line.source_phrase != prev_line.source_phrase){

                //Create a new entry even

                //Create an entry for the previous source phrase:
                Entry pesho;
                pesho.value = entrystartidx;
                //The key is the sum of hashes of individual words. Probably not entirerly correct, but fast
                pesho.key = 0;
                std::vector<uint64_t> vocabid_source = getVocabIDs(prev_line.source_phrase);
                for (int i = 0; i < vocabid_source.size(); i++){
                    pesho.key += vocabid_source[i];
                }
                pesho.bytes_toread = binfile.dist_from_start + binfile.extra_counter - entrystartidx;

                //Put into table
                table.Insert(pesho);

                entrystartidx = binfile.dist_from_start + binfile.extra_counter; //Designate start idx for new entry

                //Encode a line and write it to disk.
                std::vector<unsigned char> encoded_line = huffmanEncoder.full_encode_line(line);
                binfile.write(&encoded_line);

                //Set prevLine
                prev_line = line;

            } else{
                //If we still have the same line, just append to it:
                std::vector<unsigned char> encoded_line = huffmanEncoder.full_encode_line(line);
                binfile.write(&encoded_line);
            }

        } catch (util::EndOfFileException e){
            std::cerr << "Reading phrase table finished, writing remaining files to disk." << std::endl;
            binfile.flush();

            //After the final entry is constructed we need to add it to the phrase_table
            //Create an entry for the previous source phrase:
            Entry pesho;
            pesho.value = entrystartidx;
            //The key is the sum of hashes of individual words. Probably not entirerly correct, but fast
            pesho.key = 0;
            std::vector<uint64_t> vocabid_source = getVocabIDs(prev_line.source_phrase);
            for (int i = 0; i < vocabid_source.size(); i++){
                pesho.key += vocabid_source[i];
            }
            pesho.bytes_toread = binfile.dist_from_start + binfile.extra_counter - entrystartidx;
            //Put into table
            table.Insert(pesho);

            break;
        }
    }

    serialize_table(mem, size, (basepath + "/probing_hash.dat").c_str());

    serialize_map(&source_vocabids, (basepath + "/source_vocabids").c_str());
    
    delete[] mem;

    //Write configfile
    std::ofstream configfile;
    configfile.open((basepath + "/config").c_str());
    configfile << uniq_entries << '\n';
    configfile.close();
}
예제 #4
0
/*
    This is the callback function which will be called by pcap for each packet 
    found in the given dump. Inside this function, we parse Ethernet, IP, ARP,
    TCP, UDP and ICMP headers and store statistics.
*/
void callback_handler(u_char *user, const struct pcap_pkthdr *pcap_hdr, const u_char *packet) {
    int pkt_len = (int)pcap_hdr->len;
    // if this is the first packet we read, store the dump start time
    if (pkt_cnt == 0) {
        start_ts = pcap_hdr->ts;
        smallest = pkt_len;
        largest = pkt_len;
    } else {
        // check whether the current packet is the smallest or largest
        if (pkt_len < smallest)
            smallest = pkt_len;
        if (pkt_len > largest)
            largest = pkt_len;
    }    
    tot_size += pkt_len;
    pkt_cnt++;
    // assign each packet to end time as we don't know which one is the last
    end_ts = pcap_hdr->ts;

    // structures for parsing Ethernet, IP, ARP, TCP, UDP and ICMP headers
    const struct ether_header* eth_hdr;
    const struct ip* ip_hdr;
    const struct arpheader* arp_hdr;
    const struct tcphdr* tcp_hdr;
    const struct udphdr* udp_hdr;
    struct icmp* icmp_hdr;
    char src_ip[INET_ADDRSTRLEN];
    char dst_ip[INET_ADDRSTRLEN];

    // create ethernet header
    eth_hdr = (struct ether_header*)packet;
    // capture source mac address and destination mac address
    char *eth_src_addr = malloc(sizeof(char) * ETHER_ADDR_LEN);
    char *eth_dst_addr = malloc(sizeof(char) * ETHER_ADDR_LEN);
    get_eth_addr(eth_src_addr, (u_char*)eth_hdr->ether_shost);
    get_eth_addr(eth_dst_addr, (u_char*)eth_hdr->ether_dhost);   
    // add captured ethernet addresses into our maps to print later
    add_to_map(&src_eth_info.info_map, eth_src_addr);
    src_eth_info.pkt_count++;
    add_to_map(&dst_eth_info.info_map, eth_dst_addr);
    dst_eth_info.pkt_count++;

    char nw_prot[18];
    // check ethernet header type and get IP, ARP headers
    if (ntohs(eth_hdr->ether_type) == ETHERTYPE_IP) {
        strcpy(nw_prot, "IP");
        // create ip header
        ip_hdr = (struct ip*)(packet + sizeof(struct ether_header));
        // ignore ipv6
        if (ip_hdr->ip_v == 0x6) {
            return;
        }
        // store TTL info
        add_to_int_map(&ttl_info.info_map, ip_hdr->ip_ttl);
        ttl_info.pkt_count++;

        // get source and destination ip addresses
        inet_ntop(AF_INET, &(ip_hdr->ip_src), src_ip, INET_ADDRSTRLEN);
        inet_ntop(AF_INET, &(ip_hdr->ip_dst), dst_ip, INET_ADDRSTRLEN);
        // add captured IP addresses into our maps to print later
        add_to_map(&src_ip_info.info_map, src_ip);
        src_ip_info.pkt_count++;
        add_to_map(&dst_ip_info.info_map, dst_ip);
        dst_ip_info.pkt_count++;

        char trns_prot[10];
        if (ip_hdr->ip_p == IPPROTO_TCP) {
            strcpy(trns_prot, "TCP");
            tcp_hdr = (struct tcphdr*)(packet + sizeof(struct ether_header) + sizeof(struct ip));
            // add TCP source and destination ports into out maps
            add_to_int_map(&src_tcp_ports_info.info_map, ntohs(tcp_hdr->th_sport));
            src_tcp_ports_info.pkt_count++;
            add_to_int_map(&dst_tcp_ports_info.info_map, ntohs(tcp_hdr->th_dport));
            dst_tcp_ports_info.pkt_count++;

            char flag_key[3 * 6];
            process_tcp_flags(flag_key, tcp_hdr->th_flags);
            // add flags into our maps to print later
            add_to_map(&tcp_flag_info.info_map, flag_key);
            tcp_flag_info.pkt_count++;

            // read options
            if (tcp_hdr->th_off * 4 > 20) {
                int end = 0;
                int off = 0;
                int one = 0;
                char opt1[5], opt2[5];
                while (!end) {
                    char *p = (char*)(packet + sizeof(struct ether_header) + sizeof(struct ip) + sizeof(struct tcphdr) + off);
                    // if we encounter 0 that means end of options
                    if (p[0] == 0) {
                        end = 1;
                    } else {
                        if (p[0] != 1) {
                            sprintf(opt1, "%#.2x", (int)p[0]);
                            add_to_map(&tcp_opt_info.info_map, opt1);
                            off += (int)p[1];
                        } else {
                            off += 1;
                            if (!one) {
                                sprintf(opt2, "%#.2x", (int)p[0]);
                                add_to_map(&tcp_opt_info.info_map, opt2);
                            }
                            one = 1;
                        }
                        if (off >= (tcp_hdr->th_off * 4 - 20)) {
                            end = 1;
                        }
                    }
                }
            }
            tcp_opt_info.pkt_count++;
        } else if (ip_hdr->ip_p == IPPROTO_UDP) {
            strcpy(trns_prot, "UDP");
            udp_hdr = (struct udphdr*)(packet + sizeof(struct ether_header) + sizeof(struct ip));
            // add UDP source and destination ports into out maps
            add_to_int_map(&src_udp_ports_info.info_map, ntohs(udp_hdr->uh_sport));
            src_udp_ports_info.pkt_count++;
            add_to_int_map(&dst_udp_ports_info.info_map, ntohs(udp_hdr->uh_dport));
            dst_udp_ports_info.pkt_count++;
        } else if (ip_hdr->ip_p == IPPROTO_ICMP) {
            strcpy(trns_prot, "ICMP");
            icmp_hdr = (struct icmp*)(packet + sizeof(struct ether_header) + sizeof(struct ip));
            // add captured IP addresses into our maps to print later
            add_to_map(&icmp_src_ip_info.info_map, src_ip);
            icmp_src_ip_info.pkt_count++;
            add_to_map(&icmp_dst_ip_info.info_map, dst_ip);
            icmp_dst_ip_info.pkt_count++;

            // add ICMP type and code into our maps
            add_to_int_map(&icmp_type_info.info_map, (int)(icmp_hdr->icmp_type));
            icmp_type_info.pkt_count++;
            add_to_int_map(&icmp_code_info.info_map, (int)(icmp_hdr->icmp_code));
            icmp_code_info.pkt_count++;

            char icmp_cat[20];
            process_icmp_response((int)(icmp_hdr->icmp_type), (int)(icmp_hdr->icmp_code), icmp_cat);
            add_to_map(&icmp_cat_info.info_map, icmp_cat);
            icmp_cat_info.pkt_count++;
        } else {
            // we only have to store the protocol number here
            sprintf(trns_prot, "%#.2x", ip_hdr->ip_p);
        }
        // add transport layer protocol info into map
        add_to_map(&trns_prot_info.info_map, trns_prot);
        trns_prot_info.pkt_count++;
    } else if (ntohs(eth_hdr->ether_type) == ETHERTYPE_ARP) {
        strcpy(nw_prot, "ARP");
        arp_hdr = (struct arpheader*)(packet + sizeof(struct ether_header));
        // buffer for arp key in <mac> / <ip> format. Ex : 00:13:72:89:fd:1f / 129.79.245.139
        char *buf = malloc(sizeof(char) * (ETHER_ADDR_LEN + 5 + INET_ADDRSTRLEN));
        // get arp source mac
        char *arp_src_mac = malloc(sizeof(char) * ETHER_ADDR_LEN);
        get_eth_addr(arp_src_mac, (u_char*)arp_hdr->__ar_sha);
        strcat(buf, arp_src_mac);
        strcat(buf, " / ");
        // get arp source ip
        char *arp_src_ip = malloc(sizeof(char) * INET_ADDRSTRLEN);
        get_ip_addr(arp_src_ip, (u_char*)arp_hdr->__ar_sip);
        strcat(buf, arp_src_ip);
        // store ARP info
        add_to_map(&arp_info.info_map, buf);
        arp_info.pkt_count++;
    } else {
        // 'type' field in ethernet frames can be used for either the protocol or the
        // length of the packet. If it is for protocol, it should be at least 0x0600
        if (ntohs(eth_hdr->ether_type) < 0x0600)
            sprintf(nw_prot, "length = %#.4x", ntohs(eth_hdr->ether_type));
        else
            // we only have to store the protocol number here
            // (ntohs(eth_hdr->ether_type) == ETHERTYPE_IPV6) case will also come here
            // it will just be count as a different protocol
            sprintf(nw_prot, "%#.4x", ntohs(eth_hdr->ether_type));
    }
    // add network protocol info into map
    add_to_map(&nw_prot_info.info_map, nw_prot);
    nw_prot_info.pkt_count++;
}
예제 #5
0
 radio_regmap_t(int radio_num) : soft_regmap_t("radio" + boost::lexical_cast<std::string>(radio_num) + "_regmap") {
     add_to_map(misc_outs_reg, "misc_outs_reg", PRIVATE);
     add_to_map(misc_ins_reg, "misc_ins_reg", PRIVATE);
 }
static void add_to_map(unordered_map<int, TreeNode *> &map, TreeNode *node) {
    if (!node) return;
    map[node->val] = node;
    add_to_map(map, node->left);
    add_to_map(map, node->right);
}
예제 #7
0
gpointer
mono_arch_get_gsharedvt_call_info (gpointer addr, MonoMethodSignature *normal_sig, MonoMethodSignature *gsharedvt_sig, gboolean gsharedvt_in, gint32 vcall_offset, gboolean calli)
{
	GSharedVtCallInfo *info;
	CallInfo *caller_cinfo, *callee_cinfo;
	MonoMethodSignature *caller_sig, *callee_sig;
	int aindex, i;
	gboolean var_ret = FALSE;
	CallInfo *cinfo, *gcinfo;
	MonoMethodSignature *sig, *gsig;
	GPtrArray *map;

	if (gsharedvt_in) {
		caller_sig = normal_sig;
		callee_sig = gsharedvt_sig;
		caller_cinfo = mono_arch_get_call_info (NULL, caller_sig);
		callee_cinfo = mono_arch_get_call_info (NULL, callee_sig);
	} else {
		callee_sig = normal_sig;
		caller_sig = gsharedvt_sig;
		callee_cinfo = mono_arch_get_call_info (NULL, callee_sig);
		caller_cinfo = mono_arch_get_call_info (NULL, caller_sig);
	}

	/*
	 * If GSHAREDVT_IN is true, this means we are transitioning from normal to gsharedvt code. The caller uses the
	 * normal call signature, while the callee uses the gsharedvt signature.
	 * If GSHAREDVT_IN is false, its the other way around.
	 */

	/* sig/cinfo describes the normal call, while gsig/gcinfo describes the gsharedvt call */
	if (gsharedvt_in) {
		sig = caller_sig;
		gsig = callee_sig;
		cinfo = caller_cinfo;
		gcinfo = callee_cinfo;
	} else {
		sig = callee_sig;
		gsig = caller_sig;
		cinfo = callee_cinfo;
		gcinfo = caller_cinfo;
	}

	DEBUG_AMD64_GSHAREDVT_PRINT ("source sig: (%s) return (%s)\n", mono_signature_get_desc (caller_sig, FALSE), mono_type_full_name (mono_signature_get_return_type (caller_sig))); // Leak
	DEBUG_AMD64_GSHAREDVT_PRINT ("dest sig: (%s) return (%s)\n", mono_signature_get_desc (callee_sig, FALSE), mono_type_full_name (mono_signature_get_return_type (callee_sig)));

	if (gcinfo->ret.storage == ArgGsharedvtVariableInReg) {
		/*
		 * The return type is gsharedvt
		 */
		var_ret = TRUE;
	}

	/*
	 * The stack looks like this:
	 * <arguments>
	 * <trampoline frame>
	 * <call area>
	 * We have to map the stack slots in <arguments> to the stack slots in <call area>.
	 */
	map = g_ptr_array_new ();

	for (aindex = 0; aindex < cinfo->nargs; ++aindex) {
		ArgInfo *src_info = &caller_cinfo->args [aindex];
		ArgInfo *dst_info = &callee_cinfo->args [aindex];
		int *src = NULL, *dst = NULL;
		int nsrc = -1, ndst = -1, nslots = 0;

		int arg_marshal = GSHAREDVT_ARG_NONE;
		int arg_slots = 0; // Size in quadwords
		DEBUG_AMD64_GSHAREDVT_PRINT ("-- arg %d in (%s) out (%s)\n", aindex, arg_info_desc (src_info), arg_info_desc (dst_info));

		switch (src_info->storage) {
		case ArgInIReg:
		case ArgInDoubleSSEReg:
		case ArgInFloatSSEReg:
		case ArgValuetypeInReg:
		case ArgOnStack:
			nsrc = get_arg_slots (src_info, &src, TRUE);
			break;
		case ArgGSharedVtInReg:
			handle_marshal_when_src_gsharedvt (dst_info, &arg_marshal, &arg_slots);
			handle_map_when_gsharedvt_in_reg (src_info, &nsrc, &src);
			break;
		case ArgGSharedVtOnStack:
			handle_marshal_when_src_gsharedvt (dst_info, &arg_marshal, &arg_slots);
			handle_map_when_gsharedvt_on_stack (src_info, &nsrc, &src, TRUE);
			break;
		case ArgValuetypeAddrInIReg:
		case ArgValuetypeAddrOnStack:
			nsrc = get_arg_slots (src_info, &src, TRUE);
			break;
		default:
			g_error ("Gsharedvt can't handle source arg type %d", (int)src_info->storage); // Inappropriate value: ArgValuetypeAddrInIReg is for returns only
		}

		switch (dst_info->storage) {
		case ArgInIReg:
		case ArgInDoubleSSEReg:
		case ArgInFloatSSEReg:
		case ArgOnStack:
		case ArgValuetypeInReg:
			ndst = get_arg_slots (dst_info, &dst, FALSE);
			break;
		case ArgGSharedVtInReg:
			handle_marshal_when_dst_gsharedvt (src_info, &arg_marshal);
			handle_map_when_gsharedvt_in_reg (dst_info, &ndst, &dst);
			break;
		case ArgGSharedVtOnStack:
			handle_marshal_when_dst_gsharedvt (src_info, &arg_marshal);
			handle_map_when_gsharedvt_on_stack (dst_info, &ndst, &dst, FALSE);
			break;
		case ArgValuetypeAddrInIReg:
		case ArgValuetypeAddrOnStack:
			ndst = get_arg_slots (dst_info, &dst, FALSE);
			break;
		default:
			g_error ("Gsharedvt can't handle dest arg type %d", (int)dst_info->storage); // See above
		}
		if (nsrc)
			src [0] |= (arg_marshal << SRC_DESCRIPTOR_MARSHAL_SHIFT) | (arg_slots << SLOT_COUNT_SHIFT);

		/* Merge and add to the global list*/
		nslots = MIN (nsrc, ndst);
		DEBUG_AMD64_GSHAREDVT_PRINT ("nsrc %d ndst %d\n", nsrc, ndst);

		for (i = 0; i < nslots; ++i)
			add_to_map (map, src [i], dst [i]);

		g_free (src);
		g_free (dst);
	}

	DEBUG_AMD64_GSHAREDVT_PRINT ("-- return in (%s) out (%s) var_ret %d\n", arg_info_desc (&caller_cinfo->ret),  arg_info_desc (&callee_cinfo->ret), var_ret);

	if (cinfo->ret.storage == ArgValuetypeAddrInIReg) {
		/* Both the caller and the callee pass the vtype ret address in r8 (System V) and RCX or RDX (Windows) */
		g_assert (gcinfo->ret.storage == ArgValuetypeAddrInIReg || gcinfo->ret.storage == ArgGsharedvtVariableInReg);
		add_to_map (map, map_reg (cinfo->ret.reg), map_reg (cinfo->ret.reg));
	}

	info = mono_domain_alloc0 (mono_domain_get (), sizeof (GSharedVtCallInfo) + (map->len * sizeof (int)));
	info->addr = addr;
	info->stack_usage = callee_cinfo->stack_usage;
	info->ret_marshal = GSHAREDVT_RET_NONE;
	info->gsharedvt_in = gsharedvt_in ? 1 : 0;
	info->vret_slot = -1;
	info->calli = calli;

	if (var_ret) {
		g_assert (gcinfo->ret.storage == ArgGsharedvtVariableInReg);
		info->vret_arg_reg = map_reg (gcinfo->ret.reg);
		DEBUG_AMD64_GSHAREDVT_PRINT ("mapping vreg_arg_reg to %d in reg %s\n", info->vret_arg_reg, mono_arch_regname (gcinfo->ret.reg));
	} else {
		info->vret_arg_reg = -1;
	}

#ifdef DEBUG_AMD64_GSHAREDVT
	printf ("final map:\n");
	for (i = 0; i < map->len; i += 2) {
		printf ("\t[%d] src %x dst %x\n ", 
			i / 2,
			GPOINTER_TO_UINT (g_ptr_array_index (map, i)),
			GPOINTER_TO_UINT (g_ptr_array_index (map, i + 1)));
	}
#endif

	info->vcall_offset = vcall_offset;
	info->map_count = map->len / 2;
	for (i = 0; i < map->len; ++i)
		info->map [i] = GPOINTER_TO_UINT (g_ptr_array_index (map, i));
	g_ptr_array_free (map, TRUE);

	/* Compute return value marshalling */
	if (var_ret) {
		/* Compute return value marshalling */
		switch (cinfo->ret.storage) {
		case ArgInIReg:
			if (!gsharedvt_in || sig->ret->byref) {
				info->ret_marshal = GSHAREDVT_RET_IREGS_1;
			} else {
				MonoType *ret = sig->ret;

				// Unwrap enums
				if (ret->type == MONO_TYPE_VALUETYPE)
					ret = mini_type_get_underlying_type (ret);

				switch (ret->type) {
				case MONO_TYPE_I1:
					info->ret_marshal = GSHAREDVT_RET_I1;
					break;
				case MONO_TYPE_BOOLEAN:
				case MONO_TYPE_U1:
					info->ret_marshal = GSHAREDVT_RET_U1;
					break;
				case MONO_TYPE_I2:
					info->ret_marshal = GSHAREDVT_RET_I2;
					break;
				case MONO_TYPE_CHAR:
				case MONO_TYPE_U2:
					info->ret_marshal = GSHAREDVT_RET_U2;
					break;
				case MONO_TYPE_I4:
					info->ret_marshal = GSHAREDVT_RET_I4;
					break;
				case MONO_TYPE_U4:
					info->ret_marshal = GSHAREDVT_RET_U4;
					break;
				case MONO_TYPE_I:
				case MONO_TYPE_U:
				case MONO_TYPE_PTR:
				case MONO_TYPE_FNPTR:
				case MONO_TYPE_CLASS:
				case MONO_TYPE_OBJECT:
				case MONO_TYPE_SZARRAY:
				case MONO_TYPE_ARRAY:
				case MONO_TYPE_STRING:
				case MONO_TYPE_U8:
				case MONO_TYPE_I8:
					info->ret_marshal = GSHAREDVT_RET_I8;
					break;
				case MONO_TYPE_GENERICINST:
					g_assert (!mono_type_generic_inst_is_valuetype (ret));
					info->ret_marshal = GSHAREDVT_RET_I8;
					break;
				default:
					g_error ("Gsharedvt can't handle dst type [%d]", (int)sig->ret->type);
				}
			}
			break;
		case ArgValuetypeInReg:
			info->ret_marshal = GSHAREDVT_RET_IREGS_1 - 1 + cinfo->ret.nregs;
			g_assert (cinfo->ret.nregs == 1); // ABI supports 2-register return but we do not implement this.
			break;
		case ArgInDoubleSSEReg:
		case ArgInFloatSSEReg:
			info->ret_marshal = GSHAREDVT_RET_R8;
			break;
		case ArgValuetypeAddrInIReg:
			break;
		default:
			g_error ("Can't marshal return of storage [%d] %s", (int)cinfo->ret.storage, storage_name (cinfo->ret.storage));
		}

		if (gsharedvt_in && cinfo->ret.storage != ArgValuetypeAddrInIReg) {
			/* Allocate stack space for the return value */
			info->vret_slot = map_stack_slot (info->stack_usage / sizeof (gpointer));
			info->stack_usage += mono_type_stack_size_internal (normal_sig->ret, NULL, FALSE) + sizeof (gpointer);
		}
		DEBUG_AMD64_GSHAREDVT_PRINT ("RET marshal is %s\n", ret_marshal_name [info->ret_marshal]);
	}

	info->stack_usage = ALIGN_TO (info->stack_usage, MONO_ARCH_FRAME_ALIGNMENT);

	g_free (callee_cinfo);
	g_free (caller_cinfo);

	DEBUG_AMD64_GSHAREDVT_PRINT ("allocated an info at %p stack usage %d\n", info, info->stack_usage);
	return info;
}
예제 #8
0
static void initialize_xdf_maps()
{
    // XDF 5.25" 2HD
    /* Adds, in this order: sectors per FAT, sectors per each side of track 0, difference between that and virtual sector number specified in BPB. */
    add_to_map(xdf_track0[0], 9, 17, 2);
    xdf_spt[0] = 3;
    /* Adds, in this order: side, sequential order (not used in PCem), sector size. */
    add_to_map(xdf_map[0][0], 0, 0, 3);
    add_to_map(xdf_map[0][1], 0, 2, 6);
    add_to_map(xdf_map[0][2], 1, 0, 2);
    add_to_map(xdf_map[0][3], 0, 1, 2);
    add_to_map(xdf_map[0][4], 1, 2, 6);
    add_to_map(xdf_map[0][5], 1, 1, 3);

    // XDF 3.5" 2HD
    add_to_map(xdf_track0[1], 11, 19, 4);
    xdf_spt[1] = 4;
    add_to_map(xdf_map[1][0], 0, 0, 3);
    add_to_map(xdf_map[1][1], 0, 2, 4);
    add_to_map(xdf_map[1][2], 1, 3, 6);
    add_to_map(xdf_map[1][3], 0, 1, 2);
    add_to_map(xdf_map[1][4], 1, 1, 2);
    add_to_map(xdf_map[1][5], 0, 3, 6);
    add_to_map(xdf_map[1][6], 1, 0, 4);
    add_to_map(xdf_map[1][7], 1, 2, 3);

    // XDF 3.5" 2ED
    add_to_map(xdf_track0[2], 22, 37, 9);
    xdf_spt[2] = 4;
    add_to_map(xdf_map[2][0], 0, 0, 3);
    add_to_map(xdf_map[2][1], 0, 1, 4);
    add_to_map(xdf_map[2][2], 0, 2, 5);
    add_to_map(xdf_map[2][3], 0, 3, 7);
    add_to_map(xdf_map[2][4], 1, 0, 3);
    add_to_map(xdf_map[2][5], 1, 1, 4);
    add_to_map(xdf_map[2][6], 1, 2, 5);
    add_to_map(xdf_map[2][7], 1, 3, 7);

    // XXDF 3.5" 2HD
    add_to_map(xdf_track0[3], 12, 20, 4);
    xdf_spt[3] = 2;
    add_to_map(xdf_map[3][0], 0, 0, 5);
    add_to_map(xdf_map[3][1], 1, 1, 6);
    add_to_map(xdf_map[3][2], 0, 1, 6);
    add_to_map(xdf_map[3][3], 1, 0, 5);

    // XXDF 3.5" 2ED
    add_to_map(xdf_track0[4], 21, 39, 9);
    xdf_spt[4] = 2;
    add_to_map(xdf_map[4][0], 0, 0, 6);
    add_to_map(xdf_map[4][1], 1, 1, 7);
    add_to_map(xdf_map[4][2], 0, 1, 7);
    add_to_map(xdf_map[4][3], 1, 0, 6);

    xdf_maps_initialized = 1;
}