Exemplo n.º 1
0
Arquivo: quiksort.c Projeto: bnibni/DS
void quiksort(int a[], int l, int h)
{
	if(l < h){
	int k = getmid(a, l, h);
	quiksort(a, l, k-1);
	quiksort(a, k+1, h);
	}
}
Exemplo n.º 2
0
 ListNode* sortList(ListNode* head) {
     if(head && head->next) {
         ListNode* mid = getmid(head), *start = mid->next;
         mid->next = NULL;
         head = sortList(head);
         start = sortList(start);
         return merge(head, start);
     } else return head;
 }
Exemplo n.º 3
0
/*
 * find cpu node for the boot processor
 *
 * sets globals:
 * 	cb_mid
 */
static pnode_t
get_cpu_node(void)
{
	static char *props[] = { "upa-portid", "portid", NULL };
	pnode_t node;
	char *str, *name, **propp;
	uint_t cpu_id;
	int err;

	str = "get_cpu_node";
	name = "cpu";

	cb_mid = getmid();
	for (node = prom_rootnode(); ; node = prom_nextnode(node)) {
		node = prom_findnode_bydevtype(node, name);
		if (node == OBP_NONODE) {
			prom_printf("\n%s: cant find node for devtype \"%s\"\n",
			    str, name);
			break;
		}

		cpu_id = (uint_t)-1;
		for (propp = props; *propp; propp++) {
			err = get_intprop(node, *propp, &cpu_id);
			CB_VPRINTF(("    cpu node 0x%x, "
			    "prop \"%s\", cpu_id %d\n",
			    node, *propp, (int)cpu_id));
			if (err == 0)
				break;
		}

		if (cpu_id == cb_mid)
			return (node);
	}

	return (OBP_NONODE);
}