mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-02 05:42:36 +07:00
The __attribute__ ((unused)) is useful sometimes to declare variables as intended to be unused, e.g. in callback functions. However, they tend to clutter up the code making hard to read. We therefore remove all uses of it and instead set -Wno-unused-parameter. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
46 lines
714 B
C
46 lines
714 B
C
#include "check.h"
|
|
#include <time.h>
|
|
#include <sys/time.h>
|
|
|
|
#define TIMEOUT 2 /* 2 sec */
|
|
|
|
int result = -1;
|
|
struct timeval start;
|
|
|
|
static void cb(uev_t *w, void *arg, int events)
|
|
{
|
|
struct timeval now;
|
|
|
|
if (UEV_ERROR == events)
|
|
fprintf(stderr, "timer watcher failed, ignoring ...\n");
|
|
|
|
gettimeofday(&now, NULL);
|
|
fail_unless(now.tv_sec == start.tv_sec + TIMEOUT);
|
|
|
|
result = 0;
|
|
uev_exit(w->ctx);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int rc;
|
|
uev_t w;
|
|
uev_ctx_t ctx;
|
|
|
|
uev_init(&ctx);
|
|
uev_timer_init(&ctx, &w, cb, NULL, TIMEOUT * 1000, 0);
|
|
gettimeofday(&start, NULL);
|
|
|
|
rc = uev_run(&ctx, 0);
|
|
fail_unless(result == 0);
|
|
|
|
return rc;
|
|
}
|
|
|
|
/**
|
|
* Local Variables:
|
|
* indent-tabs-mode: t
|
|
* c-file-style: "linux"
|
|
* End:
|
|
*/
|