mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-28 21:08:45 +00:00
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:
1 parent
1f9558059a
commit
cbd962c5b6
2 files changed
+10
-9
No files matched your search
@@ -22,7 +22,7 @@
|
|||||||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# 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 = $(shell git tag -l | tail -1)
|
||||||
VERSION ?= 1.1.0
|
VERSION ?= 1.1.0
|
||||||
@@ -106,9 +106,9 @@ strip: $(TARGET)
|
|||||||
@$(STRIP) --strip-unneeded $(TARGET)
|
@$(STRIP) --strip-unneeded $(TARGET)
|
||||||
@size $(TARGET)
|
@size $(TARGET)
|
||||||
|
|
||||||
bench: Makefile bench.o $(STATICLIB)
|
bench: Makefile $(STATICLIB)
|
||||||
@printf " BENCH %s\n" $(STATICLIB)
|
@printf " RUN %s\n" $@
|
||||||
@$(CC) $(CPPFLAGS) -g -o bench bench.c $(STATICLIB) && ./bench
|
@$(CC) $(CPPFLAGS) -D_GNU_SOURCE -g -o bench bench.c $(STATICLIB) && ./bench
|
||||||
|
|
||||||
examples: all
|
examples: all
|
||||||
@$(MAKE) -C examples
|
@$(MAKE) -C examples
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ static int *pipes;
|
|||||||
static uev_t *evio;
|
static uev_t *evio;
|
||||||
static uev_t *evto;
|
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;
|
int idx, widx;
|
||||||
u_char ch;
|
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 */
|
/* nop */
|
||||||
}
|
}
|
||||||
@@ -208,16 +208,17 @@ int main(int argc, char **argv)
|
|||||||
if (timers)
|
if (timers)
|
||||||
uev_timer_init(&ctx, &evto[i], timer_cb, NULL, 0, 0);
|
uev_timer_init(&ctx, &evto[i], timer_cb, NULL, 0, 0);
|
||||||
args[i].index = i;
|
args[i].index = i;
|
||||||
uev_io_init(&ctx, &evio[i], read_cb, &args[i], -1, UEV_READ);
|
|
||||||
|
|
||||||
#ifdef USE_PIPES
|
#ifdef USE_PIPES
|
||||||
if (pipe(cp) == -1) {
|
if (pipe2(cp, O_NONBLOCK) == -1) {
|
||||||
#else
|
#else
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, 0, cp) == -1) {
|
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, cp) == -1) {
|
||||||
#endif
|
#endif
|
||||||
perror("pipe");
|
perror("pipe");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uev_io_init(&ctx, &evio[i], read_cb, &args[i], cp[0], UEV_READ);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
|
|||||||
Reference in new issue
Block a user