Sha256: 0f264c40c4bad874a12783a1e3ef1d95bdd2490ea6ca847ba38251ba2a5bca71

Contents?: true

Size: 1.96 KB

Versions: 26

Compression:

Stored size: 1.96 KB

Contents

/* SPDX-License-Identifier: MIT */
/*
 * Description: test use of eventfds with multiple rings
 *
 */
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/eventfd.h>

#include "liburing.h"
#include "helpers.h"

int main(int argc, char *argv[])
{
	struct io_uring_params p = {};
	struct io_uring ring1, ring2;
	struct io_uring_sqe *sqe;
	int ret, evfd1, evfd2;

	if (argc > 1)
		return T_EXIT_SKIP;

	ret = io_uring_queue_init_params(8, &ring1, &p);
	if (ret) {
		fprintf(stderr, "ring setup failed: %d\n", ret);
		return T_EXIT_FAIL;
	}
	if (!(p.features & IORING_FEAT_CUR_PERSONALITY)) {
		fprintf(stdout, "Skipping\n");
		return T_EXIT_SKIP;
	}
	ret = io_uring_queue_init(8, &ring2, 0);
	if (ret) {
		fprintf(stderr, "ring setup failed: %d\n", ret);
		return T_EXIT_FAIL;
	}

	evfd1 = eventfd(0, EFD_CLOEXEC);
	if (evfd1 < 0) {
		perror("eventfd");
		return T_EXIT_FAIL;
	}

	evfd2 = eventfd(0, EFD_CLOEXEC);
	if (evfd2 < 0) {
		perror("eventfd");
		return T_EXIT_FAIL;
	}

	ret = io_uring_register_eventfd(&ring1, evfd1);
	if (ret) {
		fprintf(stderr, "failed to register evfd: %d\n", ret);
		return T_EXIT_FAIL;
	}

	ret = io_uring_register_eventfd(&ring2, evfd2);
	if (ret) {
		fprintf(stderr, "failed to register evfd: %d\n", ret);
		return T_EXIT_FAIL;
	}

	sqe = io_uring_get_sqe(&ring1);
	io_uring_prep_poll_add(sqe, evfd2, POLLIN);
	sqe->user_data = 1;

	sqe = io_uring_get_sqe(&ring2);
	io_uring_prep_poll_add(sqe, evfd1, POLLIN);
	sqe->user_data = 1;

	ret = io_uring_submit(&ring1);
	if (ret != 1) {
		fprintf(stderr, "submit: %d\n", ret);
		return T_EXIT_FAIL;
	}

	ret = io_uring_submit(&ring2);
	if (ret != 1) {
		fprintf(stderr, "submit: %d\n", ret);
		return T_EXIT_FAIL;
	}

	sqe = io_uring_get_sqe(&ring1);
	io_uring_prep_nop(sqe);
	sqe->user_data = 3;

	ret = io_uring_submit(&ring1);
	if (ret != 1) {
		fprintf(stderr, "submit: %d\n", ret);
		return T_EXIT_FAIL;
	}

	return T_EXIT_PASS;
}

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
uringmachine-0.5.1 vendor/liburing/test/eventfd-ring.c
uringmachine-0.5 vendor/liburing/test/eventfd-ring.c
uringmachine-0.4 vendor/liburing/test/eventfd-ring.c
uringmachine-0.3 vendor/liburing/test/eventfd-ring.c
uringmachine-0.2 vendor/liburing/test/eventfd-ring.c
uringmachine-0.1 vendor/liburing/test/eventfd-ring.c
iou-0.2 vendor/liburing/test/eventfd-ring.c
iou-0.1 vendor/liburing/test/eventfd-ring.c
polyphony-1.6 vendor/liburing/test/eventfd-ring.c
polyphony-1.5 vendor/liburing/test/eventfd-ring.c
polyphony-1.4 vendor/liburing/test/eventfd-ring.c
polyphony-1.3 vendor/liburing/test/eventfd-ring.c
polyphony-1.2.1 vendor/liburing/test/eventfd-ring.c
polyphony-1.2 vendor/liburing/test/eventfd-ring.c
polyphony-1.1.1 vendor/liburing/test/eventfd-ring.c
polyphony-1.1 vendor/liburing/test/eventfd-ring.c
polyphony-1.0.2 vendor/liburing/test/eventfd-ring.c
polyphony-1.0.1 vendor/liburing/test/eventfd-ring.c
polyphony-1.0 vendor/liburing/test/eventfd-ring.c
polyphony-0.99.6 vendor/liburing/test/eventfd-ring.c