Index: uspace/lib/c/generic/async.c
===================================================================
--- uspace/lib/c/generic/async.c	(revision 1b20da07baaa3e3c424f62c927274e676e4295cd)
+++ uspace/lib/c/generic/async.c	(revision f1380b76772fb5d1aa03637b5e57bd9b929fea61)
@@ -125,32 +125,32 @@
 	/** List of inactive exchanges */
 	list_t exch_list;
-	
+
 	/** Session interface */
 	iface_t iface;
-	
+
 	/** Exchange management style */
 	exch_mgmt_t mgmt;
-	
+
 	/** Session identification */
 	int phone;
-	
+
 	/** First clone connection argument */
 	sysarg_t arg1;
-	
+
 	/** Second clone connection argument */
 	sysarg_t arg2;
-	
+
 	/** Third clone connection argument */
 	sysarg_t arg3;
-	
+
 	/** Exchange mutex */
 	fibril_mutex_t mutex;
-	
+
 	/** Number of opened exchanges */
 	atomic_t refcnt;
-	
+
 	/** Mutex for stateful connections */
 	fibril_mutex_t remote_state_mtx;
-	
+
 	/** Data for stateful connections */
 	void *remote_state_data;
@@ -161,11 +161,11 @@
 	/** Link into list of inactive exchanges */
 	link_t sess_link;
-	
+
 	/** Link into global list of inactive exchanges */
 	link_t global_link;
-	
+
 	/** Session pointer */
 	async_sess_t *sess;
-	
+
 	/** Exchange identification */
 	int phone;
@@ -184,5 +184,5 @@
 typedef struct {
 	link_t link;
-	
+
 	cap_handle_t chandle;
 	ipc_call_t call;
@@ -192,17 +192,17 @@
 typedef struct {
 	awaiter_t wdata;
-	
+
 	/** If reply was received. */
 	bool done;
-	
+
 	/** If the message / reply should be discarded on arrival. */
 	bool forget;
-	
+
 	/** If already destroyed. */
 	bool destroyed;
-	
+
 	/** Pointer to where the answer data is stored. */
 	ipc_call_t *dataptr;
-	
+
 	errno_t retval;
 } amsg_t;
@@ -211,5 +211,5 @@
 typedef struct {
 	ht_link_t link;
-	
+
 	task_id_t in_task_id;
 	atomic_t refcnt;
@@ -220,32 +220,32 @@
 typedef struct {
 	awaiter_t wdata;
-	
+
 	/** Hash table link. */
 	ht_link_t link;
-	
+
 	/** Incoming client task ID. */
 	task_id_t in_task_id;
-	
+
 	/** Incoming phone hash. */
 	sysarg_t in_phone_hash;
-	
+
 	/** Link to the client tracking structure. */
 	client_t *client;
-	
+
 	/** Messages that should be delivered to this fibril. */
 	list_t msg_queue;
-	
+
 	/** Identification of the opening call. */
 	cap_handle_t chandle;
-	
+
 	/** Call data of the opening call. */
 	ipc_call_t call;
-	
+
 	/** Identification of the closing call. */
 	cap_handle_t close_chandle;
-	
+
 	/** Fibril function that will be used to handle the connection. */
 	async_port_handler_t handler;
-	
+
 	/** Client data */
 	void *data;
@@ -255,14 +255,14 @@
 typedef struct {
 	ht_link_t link;
-	
+
 	/** Interface ID */
 	iface_t iface;
-	
+
 	/** Futex protecting the hash table */
 	futex_t futex;
-	
+
 	/** Interface ports */
 	hash_table_t port_hash_table;
-	
+
 	/** Next available port ID */
 	port_id_t port_id_avail;
@@ -272,11 +272,11 @@
 typedef struct {
 	ht_link_t link;
-	
+
 	/** Port ID */
 	port_id_t id;
-	
+
 	/** Port connection handler */
 	async_port_handler_t handler;
-	
+
 	/** Client data */
 	void *data;
@@ -286,11 +286,11 @@
 typedef struct {
 	ht_link_t link;
-	
+
 	/** Notification method */
 	sysarg_t imethod;
-	
+
 	/** Notification handler */
 	async_notification_handler_t handler;
-	
+
 	/** Notification data */
 	void *data;
@@ -303,5 +303,5 @@
 {
 	struct timeval tv = { 0, 0 };
-	
+
 	to->inlist = false;
 	to->occurred = false;
@@ -335,5 +335,5 @@
 		awaiter_initialize(&msg->wdata);
 	}
-	
+
 	return msg;
 }
@@ -456,5 +456,5 @@
 	if (!interface)
 		return NULL;
-	
+
 	bool ret = hash_table_create(&interface->port_hash_table, 0, 0,
 	    &port_hash_table_ops);
@@ -463,11 +463,11 @@
 		return NULL;
 	}
-	
+
 	interface->iface = iface;
 	futex_initialize(&interface->futex, 1);
 	interface->port_id_avail = 0;
-	
+
 	hash_table_insert(&interface_hash_table, &interface->link);
-	
+
 	return interface;
 }
@@ -479,18 +479,18 @@
 	if (!port)
 		return NULL;
-	
+
 	futex_down(&interface->futex);
-	
+
 	port_id_t id = interface->port_id_avail;
 	interface->port_id_avail++;
-	
+
 	port->id = id;
 	port->handler = handler;
 	port->data = data;
-	
+
 	hash_table_insert(&interface->port_hash_table, &port->link);
-	
+
 	futex_up(&interface->futex);
-	
+
 	return port;
 }
@@ -516,9 +516,9 @@
 	if ((iface & IFACE_MOD_MASK) == IFACE_MOD_CALLBACK)
 		return EINVAL;
-	
+
 	interface_t *interface;
-	
+
 	futex_down(&async_futex);
-	
+
 	ht_link_t *link = hash_table_find(&interface_hash_table, &iface);
 	if (link)
@@ -526,10 +526,10 @@
 	else
 		interface = async_new_interface(iface);
-	
+
 	if (!interface) {
 		futex_up(&async_futex);
 		return ENOMEM;
 	}
-	
+
 	port_t *port = async_new_port(interface, handler, data);
 	if (!port) {
@@ -537,9 +537,9 @@
 		return ENOMEM;
 	}
-	
+
 	*port_id = port->id;
-	
+
 	futex_up(&async_futex);
-	
+
 	return EOK;
 }
@@ -548,5 +548,5 @@
 {
 	assert(handler != NULL);
-	
+
 	fallback_port_handler = handler;
 	fallback_port_data = data;
@@ -645,5 +645,5 @@
 {
 	client_t *client = NULL;
-	
+
 	futex_down(&async_futex);
 	ht_link_t *link = hash_table_find(&client_hash_table, &client_id);
@@ -656,10 +656,10 @@
 			client->in_task_id = client_id;
 			client->data = async_client_data_create();
-			
+
 			atomic_set(&client->refcnt, 1);
 			hash_table_insert(&client_hash_table, &client->link);
 		}
 	}
-	
+
 	futex_up(&async_futex);
 	return client;
@@ -669,7 +669,7 @@
 {
 	bool destroy;
-	
+
 	futex_down(&async_futex);
-	
+
 	if (atomic_predec(&client->refcnt) == 0) {
 		hash_table_remove(&client_hash_table, &client->in_task_id);
@@ -677,11 +677,11 @@
 	} else
 		destroy = false;
-	
+
 	futex_up(&async_futex);
-	
+
 	if (destroy) {
 		if (client->data)
 			async_client_data_destroy(client->data);
-		
+
 		free(client);
 	}
@@ -701,10 +701,10 @@
 {
 	assert(arg);
-	
+
 	/*
 	 * Setup fibril-local connection pointer.
 	 */
 	fibril_connection = (connection_t *) arg;
-	
+
 	/*
 	 * Add our reference for the current connection in the client task
@@ -712,5 +712,5 @@
 	 * hash in a new tracking structure.
 	 */
-	
+
 	client_t *client = async_client_get(fibril_connection->in_task_id, true);
 	if (!client) {
@@ -718,7 +718,7 @@
 		return 0;
 	}
-	
+
 	fibril_connection->client = client;
-	
+
 	/*
 	 * Call the connection handler function.
@@ -726,10 +726,10 @@
 	fibril_connection->handler(fibril_connection->chandle,
 	    &fibril_connection->call, fibril_connection->data);
-	
+
 	/*
 	 * Remove the reference for this client task connection.
 	 */
 	async_client_put(client);
-	
+
 	/*
 	 * Remove myself from the connection hash table.
@@ -741,5 +741,5 @@
 	});
 	futex_up(&async_futex);
-	
+
 	/*
 	 * Answer all remaining messages with EHANGUP.
@@ -749,10 +749,10 @@
 		    list_get_instance(list_first(&fibril_connection->msg_queue),
 		    msg_t, link);
-		
+
 		list_remove(&msg->link);
 		ipc_answer_0(msg->chandle, EHANGUP);
 		free(msg);
 	}
-	
+
 	/*
 	 * If the connection was hung-up, answer the last call,
@@ -761,5 +761,5 @@
 	if (fibril_connection->close_chandle)
 		ipc_answer_0(fibril_connection->close_chandle, EOK);
-	
+
 	free(fibril_connection);
 	return EOK;
@@ -793,8 +793,8 @@
 		if (chandle != CAP_NIL)
 			ipc_answer_0(chandle, ENOMEM);
-		
+
 		return (uintptr_t) NULL;
 	}
-	
+
 	conn->in_task_id = in_task_id;
 	conn->in_phone_hash = in_phone_hash;
@@ -804,29 +804,29 @@
 	conn->handler = handler;
 	conn->data = data;
-	
+
 	if (call)
 		conn->call = *call;
-	
+
 	/* We will activate the fibril ASAP */
 	conn->wdata.active = true;
 	conn->wdata.fid = fibril_create(connection_fibril, conn);
-	
+
 	if (conn->wdata.fid == 0) {
 		free(conn);
-		
+
 		if (chandle != CAP_NIL)
 			ipc_answer_0(chandle, ENOMEM);
-		
+
 		return (uintptr_t) NULL;
 	}
-	
+
 	/* Add connection to the connection hash table */
-	
+
 	futex_down(&async_futex);
 	hash_table_insert(&conn_hash_table, &conn->link);
 	futex_up(&async_futex);
-	
+
 	fibril_add_ready(conn->wdata.fid);
-	
+
 	return conn->wdata.fid;
 }
@@ -852,22 +852,22 @@
 	if ((iface & IFACE_MOD_CALLBACK) != IFACE_MOD_CALLBACK)
 		return EINVAL;
-	
+
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	ipc_call_t answer;
 	aid_t req = async_send_3(exch, IPC_M_CONNECT_TO_ME, iface, arg1, arg2,
 	    &answer);
-	
+
 	errno_t ret;
 	async_wait_for(req, &ret);
 	if (ret != EOK)
 		return (errno_t) ret;
-	
+
 	sysarg_t phone_hash = IPC_GET_ARG5(answer);
 	interface_t *interface;
-	
+
 	futex_down(&async_futex);
-	
+
 	ht_link_t *link = hash_table_find(&interface_hash_table, &iface);
 	if (link)
@@ -875,10 +875,10 @@
 	else
 		interface = async_new_interface(iface);
-	
+
 	if (!interface) {
 		futex_up(&async_futex);
 		return ENOMEM;
 	}
-	
+
 	port_t *port = async_new_port(interface, handler, data);
 	if (!port) {
@@ -886,14 +886,14 @@
 		return ENOMEM;
 	}
-	
+
 	*port_id = port->id;
-	
+
 	futex_up(&async_futex);
-	
+
 	fid_t fid = async_new_connection(answer.in_task_id, phone_hash,
 	    CAP_NIL, NULL, handler, data);
 	if (fid == (uintptr_t) NULL)
 		return ENOMEM;
-	
+
 	return EOK;
 }
@@ -937,19 +937,19 @@
 {
 	assert(wd);
-	
+
 	wd->to_event.occurred = false;
 	wd->to_event.inlist = true;
-	
+
 	link_t *tmp = timeout_list.head.next;
 	while (tmp != &timeout_list.head) {
 		awaiter_t *cur
 		    = list_get_instance(tmp, awaiter_t, to_event.link);
-		
+
 		if (tv_gteq(&cur->to_event.expires, &wd->to_event.expires))
 			break;
-		
+
 		tmp = tmp->next;
 	}
-	
+
 	list_insert_before(&wd->to_event.link, tmp);
 }
@@ -971,7 +971,7 @@
 {
 	assert(call);
-	
+
 	futex_down(&async_futex);
-	
+
 	ht_link_t *link = hash_table_find(&conn_hash_table, &(conn_key_t){
 		.task_id = call->in_task_id,
@@ -982,7 +982,7 @@
 		return false;
 	}
-	
+
 	connection_t *conn = hash_table_get_inst(link, connection_t, link);
-	
+
 	msg_t *msg = malloc(sizeof(*msg));
 	if (!msg) {
@@ -990,15 +990,15 @@
 		return false;
 	}
-	
+
 	msg->chandle = chandle;
 	msg->call = *call;
 	list_append(&msg->link, &conn->msg_queue);
-	
+
 	if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP)
 		conn->close_chandle = chandle;
-	
+
 	/* If the connection fibril is waiting for an event, activate it */
 	if (!conn->wdata.active) {
-		
+
 		/* If in timeout list, remove it */
 		if (conn->wdata.to_event.inlist) {
@@ -1006,9 +1006,9 @@
 			list_remove(&conn->wdata.to_event.link);
 		}
-		
+
 		conn->wdata.active = true;
 		fibril_add_ready(conn->wdata.fid);
 	}
-	
+
 	futex_up(&async_futex);
 	return true;
@@ -1026,7 +1026,7 @@
 
 	assert(call);
-	
+
 	futex_down(&async_futex);
-	
+
 	ht_link_t *link = hash_table_find(&notification_hash_table,
 	    &IPC_GET_IMETHOD(*call));
@@ -1037,7 +1037,7 @@
 		data = notification->data;
 	}
-	
+
 	futex_up(&async_futex);
-	
+
 	if (handler)
 		handler(call, data);
@@ -1063,18 +1063,18 @@
 	if (!notification)
 		return ENOMEM;
-	
+
 	futex_down(&async_futex);
-	
+
 	sysarg_t imethod = notification_avail;
 	notification_avail++;
-	
+
 	notification->imethod = imethod;
 	notification->handler = handler;
 	notification->data = data;
-	
+
 	hash_table_insert(&notification_hash_table, &notification->link);
-	
+
 	futex_up(&async_futex);
-	
+
 	cap_handle_t cap;
 	errno_t rc = ipc_irq_subscribe(inr, imethod, ucode, &cap);
@@ -1096,5 +1096,5 @@
 	// TODO: Remove entry from hash table
 	//       to avoid memory leak
-	
+
 	return ipc_irq_unsubscribe(cap);
 }
@@ -1116,18 +1116,18 @@
 	if (!notification)
 		return ENOMEM;
-	
+
 	futex_down(&async_futex);
-	
+
 	sysarg_t imethod = notification_avail;
 	notification_avail++;
-	
+
 	notification->imethod = imethod;
 	notification->handler = handler;
 	notification->data = data;
-	
+
 	hash_table_insert(&notification_hash_table, &notification->link);
-	
+
 	futex_up(&async_futex);
-	
+
 	return ipc_event_subscribe(evno, imethod);
 }
@@ -1149,18 +1149,18 @@
 	if (!notification)
 		return ENOMEM;
-	
+
 	futex_down(&async_futex);
-	
+
 	sysarg_t imethod = notification_avail;
 	notification_avail++;
-	
+
 	notification->imethod = imethod;
 	notification->handler = handler;
 	notification->data = data;
-	
+
 	hash_table_insert(&notification_hash_table, &notification->link);
-	
+
 	futex_up(&async_futex);
-	
+
 	return ipc_event_task_subscribe(evno, imethod);
 }
@@ -1204,5 +1204,5 @@
 	assert(call);
 	assert(fibril_connection);
-	
+
 	/* Why doing this?
 	 * GCC 4.1.0 coughs on fibril_connection-> dereference.
@@ -1212,7 +1212,7 @@
 	 */
 	connection_t *conn = fibril_connection;
-	
+
 	futex_down(&async_futex);
-	
+
 	if (usecs) {
 		getuptime(&conn->wdata.to_event.expires);
@@ -1220,5 +1220,5 @@
 	} else
 		conn->wdata.to_event.inlist = false;
-	
+
 	/* If nothing in queue, wait until something arrives */
 	while (list_empty(&conn->msg_queue)) {
@@ -1236,10 +1236,10 @@
 			return conn->close_chandle;
 		}
-		
+
 		if (usecs)
 			async_insert_timeout(&conn->wdata);
-		
+
 		conn->wdata.active = false;
-		
+
 		/*
 		 * Note: the current fibril will be rescheduled either due to a
@@ -1249,5 +1249,5 @@
 		 */
 		fibril_switch(FIBRIL_TO_MANAGER);
-		
+
 		/*
 		 * Futex is up after getting back from async_manager.
@@ -1262,13 +1262,13 @@
 		}
 	}
-	
+
 	msg_t *msg = list_get_instance(list_first(&conn->msg_queue),
 	    msg_t, link);
 	list_remove(&msg->link);
-	
+
 	cap_handle_t chandle = msg->chandle;
 	*call = msg->call;
 	free(msg);
-	
+
 	futex_up(&async_futex);
 	return chandle;
@@ -1286,10 +1286,10 @@
 	if (!client)
 		return NULL;
-	
+
 	if (!client->data) {
 		async_client_put(client);
 		return NULL;
 	}
-	
+
 	return client->data;
 }
@@ -1298,11 +1298,11 @@
 {
 	client_t *client = async_client_get(client_id, false);
-	
+
 	assert(client);
 	assert(client->data);
-	
+
 	/* Drop the reference we got in async_get_client_data_by_hash(). */
 	async_client_put(client);
-	
+
 	/* Drop our own reference we got at the beginning of this function. */
 	async_client_put(client);
@@ -1312,19 +1312,19 @@
 {
 	port_t *port = NULL;
-	
+
 	futex_down(&async_futex);
-	
+
 	ht_link_t *link = hash_table_find(&interface_hash_table, &iface);
 	if (link) {
 		interface_t *interface =
 		    hash_table_get_inst(link, interface_t, link);
-		
+
 		link = hash_table_find(&interface->port_hash_table, &port_id);
 		if (link)
 			port = hash_table_get_inst(link, port_t, link);
 	}
-	
+
 	futex_up(&async_futex);
-	
+
 	return port;
 }
@@ -1342,12 +1342,12 @@
 {
 	assert(call);
-	
+
 	/* Kernel notification */
 	if ((chandle == CAP_NIL) && (call->flags & IPC_CALL_NOTIF)) {
 		fibril_t *fibril = (fibril_t *) __tcb_get()->fibril_data;
 		unsigned oldsw = fibril->switches;
-		
+
 		process_notification(call);
-		
+
 		if (oldsw != fibril->switches) {
 			/*
@@ -1365,16 +1365,16 @@
 			fibril_switch(FIBRIL_FROM_DEAD);
 		}
-		
+
 		return;
 	}
-	
+
 	/* New connection */
 	if (IPC_GET_IMETHOD(*call) == IPC_M_CONNECT_ME_TO) {
 		iface_t iface = (iface_t) IPC_GET_ARG1(*call);
 		sysarg_t in_phone_hash = IPC_GET_ARG5(*call);
-		
+
 		async_port_handler_t handler = fallback_port_handler;
 		void *data = fallback_port_data;
-		
+
 		// TODO: Currently ignores all ports but the first one
 		port_t *port = async_find_port(iface, 0);
@@ -1383,14 +1383,14 @@
 			data = port->data;
 		}
-		
+
 		async_new_connection(call->in_task_id, in_phone_hash, chandle,
 		    call, handler, data);
 		return;
 	}
-	
+
 	/* Try to route the call through the connection hash table */
 	if (route_call(chandle, call))
 		return;
-	
+
 	/* Unknown call from unknown phone - hang it up */
 	ipc_answer_0(chandle, EHANGUP);
@@ -1402,19 +1402,19 @@
 	struct timeval tv;
 	getuptime(&tv);
-	
+
 	futex_down(&async_futex);
-	
+
 	link_t *cur = list_first(&timeout_list);
 	while (cur != NULL) {
 		awaiter_t *waiter =
 		    list_get_instance(cur, awaiter_t, to_event.link);
-		
+
 		if (tv_gt(&waiter->to_event.expires, &tv))
 			break;
-		
+
 		list_remove(&waiter->to_event.link);
 		waiter->to_event.inlist = false;
 		waiter->to_event.occurred = true;
-		
+
 		/*
 		 * Redundant condition?
@@ -1425,8 +1425,8 @@
 			fibril_add_ready(waiter->fid);
 		}
-		
+
 		cur = list_first(&timeout_list);
 	}
-	
+
 	futex_up(&async_futex);
 }
@@ -1448,7 +1448,7 @@
 			continue;
 		}
-		
+
 		futex_down(&async_futex);
-		
+
 		suseconds_t timeout;
 		unsigned int flags = SYNCH_FLAGS_NONE;
@@ -1456,8 +1456,8 @@
 			awaiter_t *waiter = list_get_instance(
 			    list_first(&timeout_list), awaiter_t, to_event.link);
-			
+
 			struct timeval tv;
 			getuptime(&tv);
-			
+
 			if (tv_gteq(&tv, &waiter->to_event.expires)) {
 				futex_up(&async_futex);
@@ -1485,12 +1485,12 @@
 			timeout = SYNCH_NO_TIMEOUT;
 		}
-		
+
 		atomic_inc(&threads_in_ipc_wait);
-		
+
 		ipc_call_t call;
 		errno_t rc = ipc_wait_cycle(&call, timeout, flags);
-		
+
 		atomic_dec(&threads_in_ipc_wait);
-		
+
 		assert(rc == EOK);
 
@@ -1524,10 +1524,10 @@
 {
 	futex_up(&async_futex);
-	
+
 	/*
 	 * async_futex is always locked when entering manager
 	 */
 	async_manager_worker();
-	
+
 	return 0;
 }
@@ -1555,19 +1555,19 @@
 	    &interface_hash_table_ops))
 		abort();
-	
+
 	if (!hash_table_create(&client_hash_table, 0, 0, &client_hash_table_ops))
 		abort();
-	
+
 	if (!hash_table_create(&conn_hash_table, 0, 0, &conn_hash_table_ops))
 		abort();
-	
+
 	if (!hash_table_create(&notification_hash_table, 0, 0,
 	    &notification_hash_table_ops))
 		abort();
-	
+
 	session_ns = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (session_ns == NULL)
 		abort();
-	
+
 	session_ns->iface = 0;
 	session_ns->mgmt = EXCHANGE_ATOMIC;
@@ -1576,8 +1576,8 @@
 	session_ns->arg2 = 0;
 	session_ns->arg3 = 0;
-	
+
 	fibril_mutex_initialize(&session_ns->remote_state_mtx);
 	session_ns->remote_state_data = NULL;
-	
+
 	list_initialize(&session_ns->exch_list);
 	fibril_mutex_initialize(&session_ns->mutex);
@@ -1600,22 +1600,22 @@
 {
 	assert(arg);
-	
+
 	futex_down(&async_futex);
-	
+
 	amsg_t *msg = (amsg_t *) arg;
 	msg->retval = retval;
-	
+
 	/* Copy data after futex_down, just in case the call was detached */
 	if ((msg->dataptr) && (data))
 		*msg->dataptr = *data;
-	
+
 	write_barrier();
-	
+
 	/* Remove message from timeout list */
 	if (msg->wdata.to_event.inlist)
 		list_remove(&msg->wdata.to_event.link);
-	
+
 	msg->done = true;
-	
+
 	if (msg->forget) {
 		assert(msg->wdata.active);
@@ -1625,5 +1625,5 @@
 		fibril_add_ready(msg->wdata.fid);
 	}
-	
+
 	futex_up(&async_futex);
 }
@@ -1650,15 +1650,15 @@
 	if (exch == NULL)
 		return 0;
-	
+
 	amsg_t *msg = amsg_create();
 	if (msg == NULL)
 		return 0;
-	
+
 	msg->dataptr = dataptr;
 	msg->wdata.active = true;
-	
+
 	ipc_call_async_4(exch->phone, imethod, arg1, arg2, arg3, arg4, msg,
 	    reply_received);
-	
+
 	return (aid_t) msg;
 }
@@ -1688,15 +1688,15 @@
 	if (exch == NULL)
 		return 0;
-	
+
 	amsg_t *msg = amsg_create();
 	if (msg == NULL)
 		return 0;
-	
+
 	msg->dataptr = dataptr;
 	msg->wdata.active = true;
-	
+
 	ipc_call_async_5(exch->phone, imethod, arg1, arg2, arg3, arg4, arg5,
 	    msg, reply_received);
-	
+
 	return (aid_t) msg;
 }
@@ -1712,30 +1712,30 @@
 {
 	assert(amsgid);
-	
+
 	amsg_t *msg = (amsg_t *) amsgid;
-	
+
 	futex_down(&async_futex);
-	
+
 	assert(!msg->forget);
 	assert(!msg->destroyed);
-	
+
 	if (msg->done) {
 		futex_up(&async_futex);
 		goto done;
 	}
-	
+
 	msg->wdata.fid = fibril_get_id();
 	msg->wdata.active = false;
 	msg->wdata.to_event.inlist = false;
-	
+
 	/* Leave the async_futex locked when entering this function */
 	fibril_switch(FIBRIL_TO_MANAGER);
-	
+
 	/* Futex is up automatically after fibril_switch */
-	
+
 done:
 	if (retval)
 		*retval = msg->retval;
-	
+
 	amsg_destroy(msg);
 }
@@ -1758,17 +1758,17 @@
 {
 	assert(amsgid);
-	
+
 	amsg_t *msg = (amsg_t *) amsgid;
-	
+
 	futex_down(&async_futex);
-	
+
 	assert(!msg->forget);
 	assert(!msg->destroyed);
-	
+
 	if (msg->done) {
 		futex_up(&async_futex);
 		goto done;
 	}
-	
+
 	/*
 	 * Negative timeout is converted to zero timeout to avoid
@@ -1777,8 +1777,8 @@
 	if (timeout < 0)
 		timeout = 0;
-	
+
 	getuptime(&msg->wdata.to_event.expires);
 	tv_add_diff(&msg->wdata.to_event.expires, timeout);
-	
+
 	/*
 	 * Current fibril is inserted as waiting regardless of the
@@ -1801,22 +1801,22 @@
 	msg->wdata.active = false;
 	async_insert_timeout(&msg->wdata);
-	
+
 	/* Leave the async_futex locked when entering this function */
 	fibril_switch(FIBRIL_TO_MANAGER);
-	
+
 	/* Futex is up automatically after fibril_switch */
-	
+
 	if (!msg->done)
 		return ETIMEOUT;
-	
+
 done:
 	if (retval)
 		*retval = msg->retval;
-	
+
 	amsg_destroy(msg);
-	
+
 	return 0;
 }
- 
+
 /** Discard the message / reply on arrival.
  *
@@ -1830,11 +1830,11 @@
 {
 	amsg_t *msg = (amsg_t *) amsgid;
-	
+
 	assert(msg);
 	assert(!msg->forget);
 	assert(!msg->destroyed);
-	
+
 	futex_down(&async_futex);
-	
+
 	if (msg->done) {
 		amsg_destroy(msg);
@@ -1843,5 +1843,5 @@
 		msg->forget = true;
 	}
-	
+
 	futex_up(&async_futex);
 }
@@ -1858,17 +1858,17 @@
 	awaiter_t awaiter;
 	awaiter_initialize(&awaiter);
-	
+
 	awaiter.fid = fibril_get_id();
-	
+
 	getuptime(&awaiter.to_event.expires);
 	tv_add_diff(&awaiter.to_event.expires, timeout);
-	
+
 	futex_down(&async_futex);
-	
+
 	async_insert_timeout(&awaiter);
-	
+
 	/* Leave the async_futex locked when entering this function */
 	fibril_switch(FIBRIL_TO_MANAGER);
-	
+
 	/* Futex is up automatically after fibril_switch() */
 }
@@ -1921,27 +1921,27 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	ipc_call_t result;
 	aid_t aid = async_send_4(exch, imethod, arg1, arg2, arg3, arg4,
 	    &result);
-	
+
 	errno_t rc;
 	async_wait_for(aid, &rc);
-	
+
 	if (r1)
 		*r1 = IPC_GET_ARG1(result);
-	
+
 	if (r2)
 		*r2 = IPC_GET_ARG2(result);
-	
+
 	if (r3)
 		*r3 = IPC_GET_ARG3(result);
-	
+
 	if (r4)
 		*r4 = IPC_GET_ARG4(result);
-	
+
 	if (r5)
 		*r5 = IPC_GET_ARG5(result);
-	
+
 	return rc;
 }
@@ -1973,27 +1973,27 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	ipc_call_t result;
 	aid_t aid = async_send_5(exch, imethod, arg1, arg2, arg3, arg4, arg5,
 	    &result);
-	
+
 	errno_t rc;
 	async_wait_for(aid, &rc);
-	
+
 	if (r1)
 		*r1 = IPC_GET_ARG1(result);
-	
+
 	if (r2)
 		*r2 = IPC_GET_ARG2(result);
-	
+
 	if (r3)
 		*r3 = IPC_GET_ARG3(result);
-	
+
 	if (r4)
 		*r4 = IPC_GET_ARG4(result);
-	
+
 	if (r5)
 		*r5 = IPC_GET_ARG5(result);
-	
+
 	return rc;
 }
@@ -2081,5 +2081,5 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	return ipc_forward_fast(chandle, exch->phone, imethod, arg1, arg2, mode);
 }
@@ -2091,5 +2091,5 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	return ipc_forward_slow(chandle, exch->phone, imethod, arg1, arg2, arg3,
 	    arg4, arg5, mode);
@@ -2113,14 +2113,14 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	ipc_call_t answer;
 	aid_t req = async_send_3(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
 	    &answer);
-	
+
 	errno_t rc;
 	async_wait_for(req, &rc);
 	if (rc != EOK)
 		return (errno_t) rc;
-	
+
 	return EOK;
 }
@@ -2130,25 +2130,25 @@
 {
 	ipc_call_t result;
-	
+
 	// XXX: Workaround for GCC's inability to infer association between
 	// rc == EOK and *out_phone being assigned.
 	*out_phone = -1;
-	
+
 	amsg_t *msg = amsg_create();
 	if (!msg)
 		return ENOENT;
-	
+
 	msg->dataptr = &result;
 	msg->wdata.active = true;
-	
+
 	ipc_call_async_4(phone, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, arg4,
 	    msg, reply_received);
-	
+
 	errno_t rc;
 	async_wait_for((aid_t) msg, &rc);
-	
+
 	if (rc != EOK)
 		return rc;
-	
+
 	*out_phone = (int) IPC_GET_ARG5(result);
 	return EOK;
@@ -2175,5 +2175,5 @@
 		return NULL;
 	}
-	
+
 	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (sess == NULL) {
@@ -2181,5 +2181,5 @@
 		return NULL;
 	}
-	
+
 	int phone;
 	errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
@@ -2190,5 +2190,5 @@
 		return NULL;
 	}
-	
+
 	sess->iface = 0;
 	sess->mgmt = mgmt;
@@ -2197,12 +2197,12 @@
 	sess->arg2 = arg2;
 	sess->arg3 = arg3;
-	
+
 	fibril_mutex_initialize(&sess->remote_state_mtx);
 	sess->remote_state_data = NULL;
-	
+
 	list_initialize(&sess->exch_list);
 	fibril_mutex_initialize(&sess->mutex);
 	atomic_set(&sess->refcnt, 0);
-	
+
 	return sess;
 }
@@ -2228,5 +2228,5 @@
 		return NULL;
 	}
-	
+
 	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (sess == NULL) {
@@ -2234,5 +2234,5 @@
 		return NULL;
 	}
-	
+
 	int phone;
 	errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2,
@@ -2243,5 +2243,5 @@
 		return NULL;
 	}
-	
+
 	sess->iface = iface;
 	sess->phone = phone;
@@ -2249,12 +2249,12 @@
 	sess->arg2 = arg2;
 	sess->arg3 = arg3;
-	
+
 	fibril_mutex_initialize(&sess->remote_state_mtx);
 	sess->remote_state_data = NULL;
-	
+
 	list_initialize(&sess->exch_list);
 	fibril_mutex_initialize(&sess->mutex);
 	atomic_set(&sess->refcnt, 0);
-	
+
 	return sess;
 }
@@ -2299,5 +2299,5 @@
 		return NULL;
 	}
-	
+
 	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (sess == NULL) {
@@ -2305,9 +2305,9 @@
 		return NULL;
 	}
-	
+
 	int phone;
 	errno_t rc = async_connect_me_to_internal(exch->phone, arg1, arg2, arg3,
 	    IPC_FLAG_BLOCKING, &phone);
-	
+
 	if (rc != EOK) {
 		errno = rc;
@@ -2315,5 +2315,5 @@
 		return NULL;
 	}
-	
+
 	sess->iface = 0;
 	sess->mgmt = mgmt;
@@ -2322,12 +2322,12 @@
 	sess->arg2 = arg2;
 	sess->arg3 = arg3;
-	
+
 	fibril_mutex_initialize(&sess->remote_state_mtx);
 	sess->remote_state_data = NULL;
-	
+
 	list_initialize(&sess->exch_list);
 	fibril_mutex_initialize(&sess->mutex);
 	atomic_set(&sess->refcnt, 0);
-	
+
 	return sess;
 }
@@ -2353,5 +2353,5 @@
 		return NULL;
 	}
-	
+
 	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (sess == NULL) {
@@ -2359,5 +2359,5 @@
 		return NULL;
 	}
-	
+
 	int phone;
 	errno_t rc = async_connect_me_to_internal(exch->phone, iface, arg2,
@@ -2368,5 +2368,5 @@
 		return NULL;
 	}
-	
+
 	sess->iface = iface;
 	sess->phone = phone;
@@ -2374,12 +2374,12 @@
 	sess->arg2 = arg2;
 	sess->arg3 = arg3;
-	
+
 	fibril_mutex_initialize(&sess->remote_state_mtx);
 	sess->remote_state_data = NULL;
-	
+
 	list_initialize(&sess->exch_list);
 	fibril_mutex_initialize(&sess->mutex);
 	atomic_set(&sess->refcnt, 0);
-	
+
 	return sess;
 }
@@ -2395,5 +2395,5 @@
 		return NULL;
 	}
-	
+
 	cap_handle_t phone;
 	errno_t rc = ipc_connect_kbox(id, &phone);
@@ -2403,5 +2403,5 @@
 		return NULL;
 	}
-	
+
 	sess->iface = 0;
 	sess->mgmt = EXCHANGE_ATOMIC;
@@ -2410,12 +2410,12 @@
 	sess->arg2 = 0;
 	sess->arg3 = 0;
-	
+
 	fibril_mutex_initialize(&sess->remote_state_mtx);
 	sess->remote_state_data = NULL;
-	
+
 	list_initialize(&sess->exch_list);
 	fibril_mutex_initialize(&sess->mutex);
 	atomic_set(&sess->refcnt, 0);
-	
+
 	return sess;
 }
@@ -2436,19 +2436,19 @@
 {
 	async_exch_t *exch;
-	
+
 	assert(sess);
-	
+
 	if (atomic_get(&sess->refcnt) > 0)
 		return EBUSY;
-	
+
 	fibril_mutex_lock(&async_sess_mutex);
-	
+
 	errno_t rc = async_hangup_internal(sess->phone);
-	
+
 	while (!list_empty(&sess->exch_list)) {
 		exch = (async_exch_t *)
 		    list_get_instance(list_first(&sess->exch_list),
 		    async_exch_t, sess_link);
-		
+
 		list_remove(&exch->sess_link);
 		list_remove(&exch->global_link);
@@ -2458,7 +2458,7 @@
 
 	free(sess);
-	
+
 	fibril_mutex_unlock(&async_sess_mutex);
-	
+
 	return rc;
 }
@@ -2481,13 +2481,13 @@
 	if (sess == NULL)
 		return NULL;
-	
+
 	exch_mgmt_t mgmt = sess->mgmt;
 	if (sess->iface != 0)
 		mgmt = sess->iface & IFACE_EXCHANGE_MASK;
-	
+
 	async_exch_t *exch = NULL;
-	
+
 	fibril_mutex_lock(&async_sess_mutex);
-	
+
 	if (!list_empty(&sess->exch_list)) {
 		/*
@@ -2497,5 +2497,5 @@
 		    list_get_instance(list_first(&sess->exch_list),
 		    async_exch_t, sess_link);
-		
+
 		list_remove(&exch->sess_link);
 		list_remove(&exch->global_link);
@@ -2504,5 +2504,5 @@
 		 * There are no available exchanges in the session.
 		 */
-		
+
 		if ((mgmt == EXCHANGE_ATOMIC) ||
 		    (mgmt == EXCHANGE_SERIALIZE)) {
@@ -2517,5 +2517,5 @@
 			int phone;
 			errno_t rc;
-			
+
 		retry:
 			/*
@@ -2542,5 +2542,5 @@
 				    list_get_instance(list_first(&inactive_exch_list),
 				    async_exch_t, global_link);
-				
+
 				list_remove(&exch->sess_link);
 				list_remove(&exch->global_link);
@@ -2557,14 +2557,14 @@
 		}
 	}
-	
+
 	fibril_mutex_unlock(&async_sess_mutex);
-	
+
 	if (exch != NULL) {
 		atomic_inc(&sess->refcnt);
-		
+
 		if (mgmt == EXCHANGE_SERIALIZE)
 			fibril_mutex_lock(&sess->mutex);
 	}
-	
+
 	return exch;
 }
@@ -2579,23 +2579,23 @@
 	if (exch == NULL)
 		return;
-	
+
 	async_sess_t *sess = exch->sess;
 	assert(sess != NULL);
-	
+
 	exch_mgmt_t mgmt = sess->mgmt;
 	if (sess->iface != 0)
 		mgmt = sess->iface & IFACE_EXCHANGE_MASK;
-	
+
 	atomic_dec(&sess->refcnt);
-	
+
 	if (mgmt == EXCHANGE_SERIALIZE)
 		fibril_mutex_unlock(&sess->mutex);
-	
+
 	fibril_mutex_lock(&async_sess_mutex);
-	
+
 	list_append(&exch->sess_link, &sess->exch_list);
 	list_append(&exch->global_link, &inactive_exch_list);
 	fibril_condvar_signal(&avail_phone_cv);
-	
+
 	fibril_mutex_unlock(&async_sess_mutex);
 }
@@ -2618,13 +2618,13 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	sysarg_t _flags = 0;
 	sysarg_t _dst = (sysarg_t) -1;
 	errno_t res = async_req_2_4(exch, IPC_M_SHARE_IN, (sysarg_t) size,
 	    arg, NULL, &_flags, NULL, &_dst);
-	
+
 	if (flags)
 		*flags = (unsigned int) _flags;
-	
+
 	*dst = (void *) _dst;
 	return res;
@@ -2649,11 +2649,11 @@
 	assert(chandle);
 	assert(size);
-	
+
 	ipc_call_t data;
 	*chandle = async_get_call(&data);
-	
+
 	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_IN)
 		return false;
-	
+
 	*size = (size_t) IPC_GET_ARG1(data);
 	return true;
@@ -2692,5 +2692,5 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	return async_req_3_0(exch, IPC_M_SHARE_OUT, (sysarg_t) src, 0,
 	    (sysarg_t) flags);
@@ -2718,11 +2718,11 @@
 	assert(size);
 	assert(flags);
-	
+
 	ipc_call_t data;
 	*chandle = async_get_call(&data);
-	
+
 	if (IPC_GET_IMETHOD(data) != IPC_M_SHARE_OUT)
 		return false;
-	
+
 	*size = (size_t) IPC_GET_ARG2(data);
 	*flags = (unsigned int) IPC_GET_ARG3(data);
@@ -2778,5 +2778,5 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	return async_req_2_0(exch, IPC_M_DATA_READ, (sysarg_t) dst,
 	    (sysarg_t) size);
@@ -2822,13 +2822,13 @@
 	assert(chandle);
 	assert(data);
-	
+
 	*chandle = async_get_call(data);
-	
+
 	if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_READ)
 		return false;
-	
+
 	if (size)
 		*size = (size_t) IPC_GET_ARG2(*data);
-	
+
 	return true;
 }
@@ -2862,5 +2862,5 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	cap_handle_t chandle;
 	if (!async_data_read_receive(&chandle, NULL)) {
@@ -2868,5 +2868,5 @@
 		return EINVAL;
 	}
-	
+
 	aid_t msg = async_send_fast(exch, imethod, arg1, arg2, arg3, arg4,
 	    dataptr);
@@ -2875,5 +2875,5 @@
 		return EINVAL;
 	}
-	
+
 	errno_t retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
 	    IPC_FF_ROUTE_FROM_ME);
@@ -2883,8 +2883,8 @@
 		return retval;
 	}
-	
+
 	errno_t rc;
 	async_wait_for(msg, &rc);
-	
+
 	return (errno_t) rc;
 }
@@ -2903,5 +2903,5 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	return async_req_2_0(exch, IPC_M_DATA_WRITE, (sysarg_t) src,
 	    (sysarg_t) size);
@@ -2948,13 +2948,13 @@
 	assert(chandle);
 	assert(data);
-	
+
 	*chandle = async_get_call(data);
-	
+
 	if (IPC_GET_IMETHOD(*data) != IPC_M_DATA_WRITE)
 		return false;
-	
+
 	if (size)
 		*size = (size_t) IPC_GET_ARG2(*data);
-	
+
 	return true;
 }
@@ -3004,5 +3004,5 @@
 {
 	assert(data);
-	
+
 	cap_handle_t chandle;
 	size_t size;
@@ -3011,32 +3011,32 @@
 		return EINVAL;
 	}
-	
+
 	if (size < min_size) {
 		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
-	
+
 	if ((max_size > 0) && (size > max_size)) {
 		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
-	
+
 	if ((granularity > 0) && ((size % granularity) != 0)) {
 		ipc_answer_0(chandle, EINVAL);
 		return EINVAL;
 	}
-	
+
 	void *arg_data;
-	
+
 	if (nullterm)
 		arg_data = malloc(size + 1);
 	else
 		arg_data = malloc(size);
-	
+
 	if (arg_data == NULL) {
 		ipc_answer_0(chandle, ENOMEM);
 		return ENOMEM;
 	}
-	
+
 	errno_t rc = async_data_write_finalize(chandle, arg_data, size);
 	if (rc != EOK) {
@@ -3044,12 +3044,12 @@
 		return rc;
 	}
-	
+
 	if (nullterm)
 		((char *) arg_data)[size] = 0;
-	
+
 	*data = arg_data;
 	if (received != NULL)
 		*received = size;
-	
+
 	return EOK;
 }
@@ -3078,5 +3078,5 @@
 	if (exch == NULL)
 		return ENOENT;
-	
+
 	cap_handle_t chandle;
 	if (!async_data_write_receive(&chandle, NULL)) {
@@ -3084,5 +3084,5 @@
 		return EINVAL;
 	}
-	
+
 	aid_t msg = async_send_fast(exch, imethod, arg1, arg2, arg3, arg4,
 	    dataptr);
@@ -3091,5 +3091,5 @@
 		return EINVAL;
 	}
-	
+
 	errno_t retval = ipc_forward_fast(chandle, exch->phone, 0, 0, 0,
 	    IPC_FF_ROUTE_FROM_ME);
@@ -3099,8 +3099,8 @@
 		return retval;
 	}
-	
+
 	errno_t rc;
 	async_wait_for(msg, &rc);
-	
+
 	return (errno_t) rc;
 }
@@ -3123,10 +3123,10 @@
 	cap_handle_t chandle = async_get_call(&call);
 	cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(call);
-	
+
 	if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECT_TO_ME) || (phandle < 0)) {
 		async_answer_0(chandle, EINVAL);
 		return NULL;
 	}
-	
+
 	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (sess == NULL) {
@@ -3134,5 +3134,5 @@
 		return NULL;
 	}
-	
+
 	sess->iface = 0;
 	sess->mgmt = mgmt;
@@ -3141,15 +3141,15 @@
 	sess->arg2 = 0;
 	sess->arg3 = 0;
-	
+
 	fibril_mutex_initialize(&sess->remote_state_mtx);
 	sess->remote_state_data = NULL;
-	
+
 	list_initialize(&sess->exch_list);
 	fibril_mutex_initialize(&sess->mutex);
 	atomic_set(&sess->refcnt, 0);
-	
+
 	/* Acknowledge the connected phone */
 	async_answer_0(chandle, EOK);
-	
+
 	return sess;
 }
@@ -3172,12 +3172,12 @@
 {
 	cap_handle_t phandle = (cap_handle_t) IPC_GET_ARG5(*call);
-	
+
 	if ((IPC_GET_IMETHOD(*call) != IPC_M_CONNECT_TO_ME) || (phandle < 0))
 		return NULL;
-	
+
 	async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));
 	if (sess == NULL)
 		return NULL;
-	
+
 	sess->iface = 0;
 	sess->mgmt = mgmt;
@@ -3186,12 +3186,12 @@
 	sess->arg2 = 0;
 	sess->arg3 = 0;
-	
+
 	fibril_mutex_initialize(&sess->remote_state_mtx);
 	sess->remote_state_data = NULL;
-	
+
 	list_initialize(&sess->exch_list);
 	fibril_mutex_initialize(&sess->mutex);
 	atomic_set(&sess->refcnt, 0);
-	
+
 	return sess;
 }
@@ -3208,11 +3208,11 @@
 {
 	assert(chandle);
-	
+
 	ipc_call_t call;
 	*chandle = async_get_call(&call);
-	
+
 	if (IPC_GET_IMETHOD(call) != IPC_M_STATE_CHANGE_AUTHORIZE)
 		return false;
-	
+
 	if (arg1)
 		*arg1 = IPC_GET_ARG1(call);
@@ -3221,5 +3221,5 @@
 	if (arg3)
 		*arg3 = IPC_GET_ARG3(call);
-	
+
 	return true;
 }
@@ -3274,5 +3274,5 @@
 {
 	assert(fibril_mutex_is_locked(&sess->remote_state_mtx));
-	
+
 	fibril_mutex_unlock(&sess->remote_state_mtx);
 }
@@ -3292,8 +3292,8 @@
 	if (exch == NULL)
 		return;
-	
+
 	async_sess_t *sess = exch->sess;
 	assert(fibril_mutex_is_locked(&sess->remote_state_mtx));
-	
+
 	async_exchange_end(exch);
 	fibril_mutex_unlock(&sess->remote_state_mtx);
