Commit 44a2cbc9 authored by Pekka Pessi's avatar Pekka Pessi

su/su_devpoll_port.c: fixed whitespace

darcs-hash:20081127130637-db55f-0cb42fdea5506379e342c28417e02c8c4493c124.gz
parent 73725c10
......@@ -58,7 +58,7 @@
#define POLL2EPOLL_NEEDED \
(POLLIN != EPOLLIN || POLLOUT != EPOLLOUT || POLLPRI != EPOLLPRI || \
POLLERR != EPOLLERR || POLLHUP != EPOLLHUP)
#define POLL2EPOLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
#define EPOLL2POLL(e) (e & (POLLIN|POLLOUT|POLLPRI|POLLERR|POLLHUP))
......@@ -71,8 +71,8 @@ struct su_devpoll_port_s {
int sup_devpoll;
unsigned sup_multishot; /**< Multishot operation? */
unsigned sup_registers; /** Counter incremented by
su_port_register() or
unsigned sup_registers; /** Counter incremented by
su_port_register() or
su_port_unregister()
*/
int sup_n_registrations;
......@@ -82,9 +82,9 @@ struct su_devpoll_port_s {
/** Structure containing registration data */
struct su_devpoll {
struct su_devpoll *ser_next; /* Next in free list */
su_wakeup_f ser_cb;
su_wakeup_arg_t*ser_arg;
su_root_t *ser_root;
su_wakeup_f ser_cb;
su_wakeup_arg_t*ser_arg;
su_root_t *ser_root;
int ser_id; /** registration identifier */
su_wait_t ser_wait[1];
} **sup_indices;
......@@ -99,19 +99,19 @@ static void su_devpoll_port_decref(su_port_t *self,
int blocking,
char const *who);
static int su_devpoll_port_register(su_port_t *self,
su_root_t *root,
su_wait_t *wait,
su_root_t *root,
su_wait_t *wait,
su_wakeup_f callback,
su_wakeup_arg_t *arg,
int priority);
static int su_devpoll_port_unregister(su_port_t *port,
su_root_t *root,
su_wait_t *wait,
su_wakeup_f callback,
su_root_t *root,
su_wait_t *wait,
su_wakeup_f callback,
su_wakeup_arg_t *arg);
static int su_devpoll_port_deregister(su_port_t *self, int i);
static int su_devpoll_port_unregister_all(su_port_t *self, su_root_t *root);
static int su_devpoll_port_eventmask(su_port_t *self,
static int su_devpoll_port_eventmask(su_port_t *self,
int index,
int socket,
int events);
......@@ -182,22 +182,22 @@ static void su_devpoll_port_deinit(void *arg)
*
* Please note if identical wait objects are inserted, only first one is
* ever signalled.
*
*
* @param self pointer to port
* @param root pointer to root object
* @param waits pointer to wait object
* @param callback callback function pointer
* @param arg argument given to callback function when it is invoked
* @param priority relative priority of the wait object
* @param priority relative priority of the wait object
* (0 is normal, 1 important, 2 realtime)
*
*
* @return
* Positive index of the wait object,
* Positive index of the wait object,
* or -1 upon an error.
*/
int su_devpoll_port_register(su_port_t *self,
su_root_t *root,
su_wait_t *wait,
su_root_t *root,
su_wait_t *wait,
su_wakeup_f callback,
su_wakeup_arg_t *arg,
int priority)
......@@ -223,7 +223,7 @@ int su_devpoll_port_register(su_port_t *self,
if (!ser) {
i = self->sup_max_index, j = i == 0 ? 15 : i + 16;
if (j >= self->sup_size_indices) {
/* Reallocate index table */
n = n < 1024 ? 2 * n : n + 1024;
......@@ -255,17 +255,17 @@ int su_devpoll_port_register(su_port_t *self,
if ((size_t)wait->fd >= self->sup_n_devpoll_by_socket) {
size_t n_devpoll_by_socket = ((size_t)wait->fd + 32) / 32 * 32;
devpoll_by_socket = su_realloc(h, devpoll_by_socket,
n_devpoll_by_socket *
devpoll_by_socket = su_realloc(h, devpoll_by_socket,
n_devpoll_by_socket *
(sizeof devpoll_by_socket[0]));
if (devpoll_by_socket == NULL)
return -1;
memset(&devpoll_by_socket[self->sup_n_devpoll_by_socket],
0,
(char *)&devpoll_by_socket[n_devpoll_by_socket] -
(char *)&devpoll_by_socket[n_devpoll_by_socket] -
(char *)&devpoll_by_socket[self->sup_n_devpoll_by_socket]);
self->sup_devpoll_by_socket = devpoll_by_socket;
self->sup_n_devpoll_by_socket = n_devpoll_by_socket;
}
......@@ -273,7 +273,7 @@ int su_devpoll_port_register(su_port_t *self,
if (devpoll_by_socket[wait->fd])
/* XXX - we should lift this limitation with epoll, too */
return errno = EEXIST, -1;
return errno = EEXIST, -1;
i = ser->ser_id;
......@@ -282,7 +282,7 @@ int su_devpoll_port_register(su_port_t *self,
pollfd->revents = 0;
if (write(self->sup_devpoll, pollfd, (sizeof pollfd)) != (sizeof pollfd)) {
return errno = EIO, -1;
return errno = EIO, -1;
}
indices[0] = ser->ser_next;
......@@ -327,7 +327,7 @@ static int su_devpoll_port_deregister0(su_port_t *self, int i, int destroy_wait)
if (destroy_wait)
su_wait_destroy(ser->ser_wait);
memset(ser, 0, sizeof *ser);
ser->ser_id = i;
ser->ser_next = indices[0], indices[0] = ser;
......@@ -341,25 +341,25 @@ static int su_devpoll_port_deregister0(su_port_t *self, int i, int destroy_wait)
/** Unregister a su_wait_t object.
*
*
* The function su_devpoll_port_unregister() unregisters a su_wait_t object. The
* wait object, a callback function and a argument are removed from the
* port object.
*
*
* @param self - pointer to port object
* @param root - pointer to root object
* @param wait - pointer to wait object
* @param callback - callback function pointer (may be NULL)
* @param arg - argument given to callback function when it is invoked
* @param arg - argument given to callback function when it is invoked
* (may be NULL)
*
* @deprecated Use su_devpoll_port_deregister() instead.
* @deprecated Use su_devpoll_port_deregister() instead.
*
* @return Nonzero index of the wait object, or -1 upon an error.
*/
int su_devpoll_port_unregister(su_port_t *self,
su_root_t *root,
su_wait_t *wait,
su_root_t *root,
su_wait_t *wait,
su_wakeup_f callback, /* XXX - ignored */
su_wakeup_arg_t *arg)
{
......@@ -387,14 +387,14 @@ int su_devpoll_port_unregister(su_port_t *self,
}
/** Deregister a su_wait_t object.
*
*
* Deregisters a registration by index. The wait object, a callback
* function and a argument are removed from the port object. The wait
* object is destroyed.
*
*
* @param self - pointer to port object
* @param i - registration index
*
*
* @return Index of the wait object, or -1 upon an error.
*/
int su_devpoll_port_deregister(su_port_t *self, int i)
......@@ -417,10 +417,10 @@ int su_devpoll_port_deregister(su_port_t *self, int i)
*
* The function su_devpoll_port_unregister_all() unregisters all su_wait_t
* objects associated with given root object.
*
*
* @param self - pointer to port object
* @param root - pointer to root object
*
*
* @return Number of wait objects removed.
*/
int su_devpoll_port_unregister_all(su_port_t *self, su_root_t *root)
......@@ -479,7 +479,7 @@ int su_devpoll_port_eventmask(su_port_t *self, int index, int socket, int events
w[1].revents = 0;
if (write(self->sup_devpoll, w, (sizeof w)) == -1) {
SU_DEBUG_1(("su_devpoll_port_eventmask(%p): %d: %s\n", (void *)self,
SU_DEBUG_1(("su_devpoll_port_eventmask(%p): %d: %s\n", (void *)self,
socket, su_strerror(su_errno())));
return -1;
}
......@@ -496,7 +496,7 @@ int su_devpoll_port_eventmask(su_port_t *self, int index, int socket, int events
*
* @param self pointer to port object
* @param multishot multishot mode (0 => disables, 1 => enables, -1 => query)
*
*
* @retval 0 multishot mode is disabled
* @retval 1 multishot mode is enabled
* @retval -1 an error occurred
......@@ -508,7 +508,7 @@ int su_devpoll_port_multishot(su_port_t *self, int multishot)
return self->sup_multishot;
else if (multishot == 0 || multishot == 1)
return self->sup_multishot = multishot;
else
else
return (errno = EINVAL), -1;
}
......@@ -546,7 +546,7 @@ int su_devpoll_port_wait_events(su_port_t *self, su_duration_t tout)
if (socket < 0 || self->sup_n_devpoll_by_socket <= socket)
continue;
ser = self->sup_devpoll_by_socket[socket]; assert(ser);
magic = ser->ser_root ? su_root_magic(ser->ser_root) : NULL;
ser->ser_wait->revents = ev[j].revents;
ser->ser_cb(magic, ser->ser_wait, ser->ser_arg);
......@@ -554,7 +554,7 @@ int su_devpoll_port_wait_events(su_port_t *self, su_duration_t tout)
if (version != self->sup_registers)
/* Callback function used su_register()/su_deregister() */
break;
}
}
return events;
}
......@@ -568,7 +568,7 @@ su_port_t *su_devpoll_port_create(void)
if (devpoll == -1) {
/* Fallback to poll() */
SU_DEBUG_3(("%s(): open(\"%s\") => %u: %s\n",
SU_DEBUG_3(("%s(): open(\"%s\") => %u: %s\n",
"su_devpoll_port_create", "/dev/poll",
errno, strerror(errno)));
return su_poll_port_create();
......@@ -581,9 +581,9 @@ su_port_t *su_devpoll_port_create(void)
}
if (su_home_destructor(su_port_home(self), su_devpoll_port_deinit) < 0 ||
!(self->sup_indices =
!(self->sup_indices =
su_zalloc(su_port_home(self),
(sizeof self->sup_indices[0]) *
(sizeof self->sup_indices[0]) *
(self->sup_size_indices = 64)))) {
su_home_unref(su_port_home(self));
close(devpoll);
......@@ -608,7 +608,7 @@ int su_devpoll_clone_start(su_root_t *parent,
su_root_init_f init,
su_root_deinit_f deinit)
{
return su_pthreaded_port_start(su_devpoll_port_create,
return su_pthreaded_port_start(su_devpoll_port_create,
parent, return_clone, magic, init, deinit);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment