mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-21 20:01:58 +00:00
Reindent bench.c to Linux coding style
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
f7e93f9d43
commit
d9f078a119
1 file changed
+23
-29
@@ -64,7 +64,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <event.h>
|
#include <event.h>
|
||||||
|
|
||||||
|
|
||||||
static int count, writes, fired;
|
static int count, writes, fired;
|
||||||
static int *pipes;
|
static int *pipes;
|
||||||
static int num_pipes, num_active, num_writes;
|
static int num_pipes, num_active, num_writes;
|
||||||
@@ -73,27 +72,20 @@ static int timers, native;
|
|||||||
static struct ev_io *evio;
|
static struct ev_io *evio;
|
||||||
static struct ev_timer *evto;
|
static struct ev_timer *evto;
|
||||||
|
|
||||||
|
void read_cb(int fd, short which, void *arg)
|
||||||
|
|
||||||
void
|
|
||||||
read_cb(int fd, short which, void *arg)
|
|
||||||
{
|
{
|
||||||
int idx = (int)arg, widx = idx + 1;
|
int idx = (int)arg, widx = idx + 1;
|
||||||
u_char ch;
|
u_char ch;
|
||||||
|
|
||||||
if (timers)
|
if (timers) {
|
||||||
{
|
if (native) {
|
||||||
if (native)
|
|
||||||
{
|
|
||||||
#if NATIVE
|
#if NATIVE
|
||||||
evto[idx].repeat = 10. + drand48();
|
evto[idx].repeat = 10. + drand48();
|
||||||
ev_timer_again(&evto[idx]);
|
ev_timer_again(&evto[idx]);
|
||||||
#else
|
#else
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
event_del(&events[idx]);
|
event_del(&events[idx]);
|
||||||
tv.tv_sec = 10;
|
tv.tv_sec = 10;
|
||||||
@@ -113,29 +105,25 @@ read_cb(int fd, short which, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if NATIVE
|
#if NATIVE
|
||||||
void
|
void read_thunk(struct ev_io *w, int revents)
|
||||||
read_thunk(struct ev_io *w, int revents)
|
|
||||||
{
|
{
|
||||||
read_cb(w->fd, revents, w->data);
|
read_cb(w->fd, revents, w->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void timer_cb(struct ev_timer *w, int revents)
|
||||||
timer_cb (struct ev_timer *w, int revents)
|
|
||||||
{
|
{
|
||||||
/* nop */
|
/* nop */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct timeval *
|
struct timeval *run_once(void)
|
||||||
run_once(void)
|
|
||||||
{
|
{
|
||||||
int *cp, i, space;
|
int *cp, i, space;
|
||||||
static struct timeval ta, ts, te, tv;
|
static struct timeval ta, ts, te, tv;
|
||||||
|
|
||||||
gettimeofday(&ta, NULL);
|
gettimeofday(&ta, NULL);
|
||||||
for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) {
|
for (cp = pipes, i = 0; i < num_pipes; i++, cp += 2) {
|
||||||
if (native)
|
if (native) {
|
||||||
{
|
|
||||||
#if NATIVE
|
#if NATIVE
|
||||||
if (ev_is_active(&evio[i]))
|
if (ev_is_active(&evio[i]))
|
||||||
ev_io_stop(&evio[i]);
|
ev_io_stop(&evio[i]);
|
||||||
@@ -148,11 +136,10 @@ run_once(void)
|
|||||||
#else
|
#else
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
event_del(&events[i]);
|
event_del(&events[i]);
|
||||||
event_set(&events[i], cp[0], EV_READ | EV_PERSIST, read_cb, (void *) i);
|
event_set(&events[i], cp[0], EV_READ | EV_PERSIST,
|
||||||
|
read_cb, (void *)i);
|
||||||
tv.tv_sec = 10.;
|
tv.tv_sec = 10.;
|
||||||
tv.tv_usec = drand48() * 1e6;
|
tv.tv_usec = drand48() * 1e6;
|
||||||
event_add(&events[i], timers ? &tv : 0);
|
event_add(&events[i], timers ? &tv : 0);
|
||||||
@@ -169,7 +156,8 @@ run_once(void)
|
|||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
writes = num_writes;
|
writes = num_writes;
|
||||||
{ int xcount = 0;
|
{
|
||||||
|
int xcount = 0;
|
||||||
gettimeofday(&ts, NULL);
|
gettimeofday(&ts, NULL);
|
||||||
do {
|
do {
|
||||||
event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK);
|
event_loop(EVLOOP_ONCE | EVLOOP_NONBLOCK);
|
||||||
@@ -184,14 +172,12 @@ run_once(void)
|
|||||||
timersub(&te, &ts, &ts);
|
timersub(&te, &ts, &ts);
|
||||||
fprintf(stdout, "%8ld %8ld\n",
|
fprintf(stdout, "%8ld %8ld\n",
|
||||||
ta.tv_sec * 1000000L + ta.tv_usec,
|
ta.tv_sec * 1000000L + ta.tv_usec,
|
||||||
ts.tv_sec * 1000000L + ts.tv_usec
|
ts.tv_sec * 1000000L + ts.tv_usec);
|
||||||
);
|
|
||||||
|
|
||||||
return (&te);
|
return (&te);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int main(int argc, char **argv)
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
{
|
||||||
struct rlimit rl;
|
struct rlimit rl;
|
||||||
int i, c;
|
int i, c;
|
||||||
@@ -269,3 +255,11 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Local Variables:
|
||||||
|
* version-control: t
|
||||||
|
* indent-tabs-mode: t
|
||||||
|
* c-file-style: "linux"
|
||||||
|
* End:
|
||||||
|
*/
|
||||||
Reference in new issue
Block a user