Fix bench.c so it actually reads from the pipe/socket, update callback API

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2015-06-09 13:14:49 +02:00
parent 1f9558059a
commit cbd962c5b6
2 changed files with 10 additions and 9 deletions
+4 -4
View File
@@ -22,7 +22,7 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
.PHONY: all test clean joystick test examples
.PHONY: all test clean joystick test examples bench
#VERSION = $(shell git tag -l | tail -1)
VERSION ?= 1.1.0
@@ -106,9 +106,9 @@ strip: $(TARGET)
@$(STRIP) --strip-unneeded $(TARGET)
@size $(TARGET)
bench: Makefile bench.o $(STATICLIB)
@printf " BENCH %s\n" $(STATICLIB)
@$(CC) $(CPPFLAGS) -g -o bench bench.c $(STATICLIB) && ./bench
bench: Makefile $(STATICLIB)
@printf " RUN %s\n" $@
@$(CC) $(CPPFLAGS) -D_GNU_SOURCE -g -o bench bench.c $(STATICLIB) && ./bench
examples: all
@$(MAKE) -C examples
+6 -5
View File
@@ -70,7 +70,7 @@ static int *pipes;
static uev_t *evio;
static uev_t *evto;
static void read_cb(uev_ctx_t *UNUSED(ctx), uev_t *w, void *arg, int UNUSED(events))
static void read_cb(uev_t *w, void *arg, int UNUSED(events))
{
int idx, widx;
u_char ch;
@@ -96,7 +96,7 @@ static void read_cb(uev_ctx_t *UNUSED(ctx), uev_t *w, void *arg, int UNUSED(even
}
}
static void timer_cb(uev_ctx_t UNUSED(*ctx), uev_t UNUSED(*w), void UNUSED(*arg), int UNUSED(events))
static void timer_cb(uev_t UNUSED(*w), void UNUSED(*arg), int UNUSED(events))
{
/* nop */
}
@@ -208,16 +208,17 @@ int main(int argc, char **argv)
if (timers)
uev_timer_init(&ctx, &evto[i], timer_cb, NULL, 0, 0);
args[i].index = i;
uev_io_init(&ctx, &evio[i], read_cb, &args[i], -1, UEV_READ);
#ifdef USE_PIPES
if (pipe(cp) == -1) {
if (pipe2(cp, O_NONBLOCK) == -1) {
#else
if (socketpair(AF_UNIX, SOCK_STREAM, 0, cp) == -1) {
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, cp) == -1) {
#endif
perror("pipe");
exit(1);
}
uev_io_init(&ctx, &evio[i], read_cb, &args[i], cp[0], UEV_READ);
}
for (i = 0; i < 2; i++)