From 368aa725c073a03c2c8999c372c4d1108f19b357 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Thu, 15 Jun 2023 21:48:08 +0800 Subject: [PATCH 1/3] liburing: 2.3 -> 2.4 --- ...-Add-custom-error-function-for-tests.patch | 66 ----- ...Use-t_error-instead-of-glibc-s-error.patch | 109 --------- ...Use-t_error-instead-of-glibc-s-error.patch | 226 ------------------ .../libraries/liburing/default.nix | 21 +- 4 files changed, 3 insertions(+), 419 deletions(-) delete mode 100644 pkgs/development/libraries/liburing/0001-Add-custom-error-function-for-tests.patch delete mode 100644 pkgs/development/libraries/liburing/0002-test-Use-t_error-instead-of-glibc-s-error.patch delete mode 100644 pkgs/development/libraries/liburing/0003-examples-Use-t_error-instead-of-glibc-s-error.patch diff --git a/pkgs/development/libraries/liburing/0001-Add-custom-error-function-for-tests.patch b/pkgs/development/libraries/liburing/0001-Add-custom-error-function-for-tests.patch deleted file mode 100644 index 191f6ae8cd5a..000000000000 --- a/pkgs/development/libraries/liburing/0001-Add-custom-error-function-for-tests.patch +++ /dev/null @@ -1,66 +0,0 @@ -From d4714fd7aac9c5f499c406703bc437dc6cf72ef3 Mon Sep 17 00:00:00 2001 -From: Steffen -Date: Mon, 13 Feb 2023 17:32:16 +0100 -Subject: [PATCH 1/3] Add custom error function for tests. - -On musl systems, liburing cannot build examples and tests due to -it's usage of error.h. t_error calls fprintf(stderr, ...) and -exits. - -Closes: #786 - -Signed-off-by: Steffen Winter ---- - test/helpers.c | 18 ++++++++++++++++++ - test/helpers.h | 2 ++ - 2 files changed, 20 insertions(+) - -diff --git a/test/helpers.c b/test/helpers.c -index 8fb32b8..caa887e 100644 ---- a/test/helpers.c -+++ b/test/helpers.c -@@ -8,6 +8,7 @@ - #include - #include - #include -+#include - #include - - #include -@@ -266,3 +267,20 @@ bool t_probe_defer_taskrun(void) - io_uring_queue_exit(&ring); - return true; - } -+ -+/* -+ * Implementation of error(3), prints an error message and exits. -+ */ -+void t_error(int status, int errnum, const char *format, ...) -+{ -+ va_list args; -+ va_start(args, format); -+ -+ vfprintf(stderr, format, args); -+ if (errnum) -+ fprintf(stderr, ": %s", strerror(errnum)); -+ -+ fprintf(stderr, "\n"); -+ va_end(args); -+ exit(status); -+} -diff --git a/test/helpers.h b/test/helpers.h -index 4375a9e..33b82cf 100644 ---- a/test/helpers.h -+++ b/test/helpers.h -@@ -87,6 +87,8 @@ bool t_probe_defer_taskrun(void); - - #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - -+void t_error(int status, int errnum, const char *format, ...); -+ - #ifdef __cplusplus - } - #endif --- -2.39.1 - diff --git a/pkgs/development/libraries/liburing/0002-test-Use-t_error-instead-of-glibc-s-error.patch b/pkgs/development/libraries/liburing/0002-test-Use-t_error-instead-of-glibc-s-error.patch deleted file mode 100644 index 676b006482c4..000000000000 --- a/pkgs/development/libraries/liburing/0002-test-Use-t_error-instead-of-glibc-s-error.patch +++ /dev/null @@ -1,109 +0,0 @@ -From e84f40ca872f0bce72b5686c95a11739d9c89494 Mon Sep 17 00:00:00 2001 -From: Steffen -Date: Mon, 13 Feb 2023 17:56:03 +0100 -Subject: [PATCH 2/3] test: Use t_error instead of glibc's error. - -On musl systems, liburing cannot build examples and tests due to -it's usage of error.h. Replacing calls to error() with t_error(). - -Closes: #786 - -Signed-off-by: Steffen Winter ---- - test/defer-taskrun.c | 1 - - test/send-zerocopy.c | 1 - - test/single-issuer.c | 15 +++++++-------- - 3 files changed, 7 insertions(+), 10 deletions(-) - -diff --git a/test/defer-taskrun.c b/test/defer-taskrun.c -index 9283f28..87cd256 100644 ---- a/test/defer-taskrun.c -+++ b/test/defer-taskrun.c -@@ -4,7 +4,6 @@ - #include - #include - #include --#include - #include - #include - #include -diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c -index 4db102b..be33094 100644 ---- a/test/send-zerocopy.c -+++ b/test/send-zerocopy.c -@@ -4,7 +4,6 @@ - #include - #include - #include --#include - #include - #include - #include -diff --git a/test/single-issuer.c b/test/single-issuer.c -index 1d13f47..d71cd74 100644 ---- a/test/single-issuer.c -+++ b/test/single-issuer.c -@@ -5,7 +5,6 @@ - #include - #include - #include --#include - #include - #include - -@@ -56,13 +55,13 @@ static int try_submit(struct io_uring *ring) - return ret; - - if (ret != 1) -- error(1, ret, "submit %i", ret); -+ t_error(1, ret, "submit %i", ret); - ret = io_uring_wait_cqe(ring, &cqe); - if (ret) -- error(1, ret, "wait fail %i", ret); -+ t_error(1, ret, "wait fail %i", ret); - - if (cqe->res || cqe->user_data != 42) -- error(1, ret, "invalid cqe"); -+ t_error(1, ret, "invalid cqe"); - - io_uring_cqe_seen(ring, cqe); - return 0; -@@ -106,7 +105,7 @@ int main(int argc, char *argv[]) - ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER | - IORING_SETUP_R_DISABLED); - if (ret) -- error(1, ret, "ring init (2) %i", ret); -+ t_error(1, ret, "ring init (2) %i", ret); - - if (!fork_t()) { - io_uring_enable_rings(&ring); -@@ -122,7 +121,7 @@ int main(int argc, char *argv[]) - ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER | - IORING_SETUP_R_DISABLED); - if (ret) -- error(1, ret, "ring init (3) %i", ret); -+ t_error(1, ret, "ring init (3) %i", ret); - - io_uring_enable_rings(&ring); - if (!fork_t()) { -@@ -137,7 +136,7 @@ int main(int argc, char *argv[]) - /* test that anyone can submit to a SQPOLL|SINGLE_ISSUER ring */ - ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_SQPOLL); - if (ret) -- error(1, ret, "ring init (4) %i", ret); -+ t_error(1, ret, "ring init (4) %i", ret); - - ret = try_submit(&ring); - if (ret) { -@@ -157,7 +156,7 @@ int main(int argc, char *argv[]) - /* test that IORING_ENTER_REGISTERED_RING doesn't break anything */ - ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER); - if (ret) -- error(1, ret, "ring init (5) %i", ret); -+ t_error(1, ret, "ring init (5) %i", ret); - - if (!fork_t()) { - ret = try_submit(&ring); --- -2.39.1 - diff --git a/pkgs/development/libraries/liburing/0003-examples-Use-t_error-instead-of-glibc-s-error.patch b/pkgs/development/libraries/liburing/0003-examples-Use-t_error-instead-of-glibc-s-error.patch deleted file mode 100644 index ce92f16dcb18..000000000000 --- a/pkgs/development/libraries/liburing/0003-examples-Use-t_error-instead-of-glibc-s-error.patch +++ /dev/null @@ -1,226 +0,0 @@ -From 23704bbd1416ed1a051b32d5d44e46dd654b8ffe Mon Sep 17 00:00:00 2001 -From: Steffen -Date: Mon, 13 Feb 2023 18:23:44 +0100 -Subject: [PATCH 3/3] examples: Use t_error instead of glibc's error. - -On musl systems, liburing cannot build examples and tests due to -it's usage of error.h. t_error copied from test/helpers.c. -Replacing calls to error() with t_error(). - -Closes: #786 - -Signed-off-by: Steffen Winter ---- - examples/send-zerocopy.c | 61 +++++++++++++++++++++++++--------------- - 1 file changed, 39 insertions(+), 22 deletions(-) - -diff --git a/examples/send-zerocopy.c b/examples/send-zerocopy.c -index 7f5f2b1..6092af9 100644 ---- a/examples/send-zerocopy.c -+++ b/examples/send-zerocopy.c -@@ -5,11 +5,11 @@ - #include - #include - #include --#include - #include - #include - #include - #include -+#include - #include - - #include -@@ -57,6 +57,23 @@ static struct sockaddr_storage cfg_dst_addr; - - static char payload[IP_MAXPACKET] __attribute__((aligned(4096))); - -+/* -+ * Implementation of error(3), prints an error message and exits. -+ */ -+static void t_error(int status, int errnum, const char *format, ...) -+{ -+ va_list args; -+ va_start(args, format); -+ -+ vfprintf(stderr, format, args); -+ if (errnum) -+ fprintf(stderr, ": %s", strerror(errnum)); -+ -+ fprintf(stderr, "\n"); -+ va_end(args); -+ exit(status); -+} -+ - static unsigned long gettimeofday_ms(void) - { - struct timeval tv; -@@ -68,7 +85,7 @@ static unsigned long gettimeofday_ms(void) - static void do_setsockopt(int fd, int level, int optname, int val) - { - if (setsockopt(fd, level, optname, &val, sizeof(val))) -- error(1, errno, "setsockopt %d.%d: %d", level, optname, val); -+ t_error(1, errno, "setsockopt %d.%d: %d", level, optname, val); - } - - static void setup_sockaddr(int domain, const char *str_addr, -@@ -84,7 +101,7 @@ static void setup_sockaddr(int domain, const char *str_addr, - addr4->sin_port = htons(cfg_port); - if (str_addr && - inet_pton(AF_INET, str_addr, &(addr4->sin_addr)) != 1) -- error(1, 0, "ipv4 parse error: %s", str_addr); -+ t_error(1, 0, "ipv4 parse error: %s", str_addr); - break; - case PF_INET6: - memset(addr6, 0, sizeof(*addr6)); -@@ -92,10 +109,10 @@ static void setup_sockaddr(int domain, const char *str_addr, - addr6->sin6_port = htons(cfg_port); - if (str_addr && - inet_pton(AF_INET6, str_addr, &(addr6->sin6_addr)) != 1) -- error(1, 0, "ipv6 parse error: %s", str_addr); -+ t_error(1, 0, "ipv6 parse error: %s", str_addr); - break; - default: -- error(1, 0, "illegal domain"); -+ t_error(1, 0, "illegal domain"); - } - } - -@@ -105,12 +122,12 @@ static int do_setup_tx(int domain, int type, int protocol) - - fd = socket(domain, type, protocol); - if (fd == -1) -- error(1, errno, "socket t"); -+ t_error(1, errno, "socket t"); - - do_setsockopt(fd, SOL_SOCKET, SO_SNDBUF, 1 << 21); - - if (connect(fd, (void *) &cfg_dst_addr, cfg_alen)) -- error(1, errno, "connect"); -+ t_error(1, errno, "connect"); - return fd; - } - -@@ -125,7 +142,7 @@ static inline struct io_uring_cqe *wait_cqe_fast(struct io_uring *ring) - - ret = io_uring_wait_cqe(ring, &cqe); - if (ret) -- error(1, ret, "wait cqe"); -+ t_error(1, ret, "wait cqe"); - return cqe; - } - -@@ -143,17 +160,17 @@ static void do_tx(int domain, int type, int protocol) - - ret = io_uring_queue_init(512, &ring, IORING_SETUP_COOP_TASKRUN); - if (ret) -- error(1, ret, "io_uring: queue init"); -+ t_error(1, ret, "io_uring: queue init"); - - if (cfg_fixed_files) { - ret = io_uring_register_files(&ring, &fd, 1); - if (ret < 0) -- error(1, ret, "io_uring: files registration"); -+ t_error(1, ret, "io_uring: files registration"); - } - if (cfg_reg_ringfd) { - ret = io_uring_register_ring_fd(&ring); - if (ret < 0) -- error(1, ret, "io_uring: io_uring_register_ring_fd"); -+ t_error(1, ret, "io_uring: io_uring_register_ring_fd"); - } - - iov.iov_base = payload; -@@ -161,7 +178,7 @@ static void do_tx(int domain, int type, int protocol) - - ret = io_uring_register_buffers(&ring, &iov, 1); - if (ret) -- error(1, ret, "io_uring: buffer registration"); -+ t_error(1, ret, "io_uring: buffer registration"); - - tstop = gettimeofday_ms() + cfg_runtime_ms; - do { -@@ -193,14 +210,14 @@ static void do_tx(int domain, int type, int protocol) - - ret = io_uring_submit(&ring); - if (ret != cfg_nr_reqs) -- error(1, ret, "submit"); -+ t_error(1, ret, "submit"); - - for (i = 0; i < cfg_nr_reqs; i++) { - cqe = wait_cqe_fast(&ring); - - if (cqe->flags & IORING_CQE_F_NOTIF) { - if (cqe->flags & IORING_CQE_F_MORE) -- error(1, -EINVAL, "F_MORE notif"); -+ t_error(1, -EINVAL, "F_MORE notif"); - compl_cqes--; - i--; - io_uring_cqe_seen(&ring, cqe); -@@ -217,7 +234,7 @@ static void do_tx(int domain, int type, int protocol) - fprintf(stderr, "Connection failure"); - goto out_fail; - } else if (cqe->res != -EAGAIN) { -- error(1, cqe->res, "send failed"); -+ t_error(1, cqe->res, "send failed"); - } - io_uring_cqe_seen(&ring, cqe); - } -@@ -226,7 +243,7 @@ static void do_tx(int domain, int type, int protocol) - out_fail: - shutdown(fd, SHUT_RDWR); - if (close(fd)) -- error(1, errno, "close"); -+ t_error(1, errno, "close"); - - fprintf(stderr, "tx=%lu (MB=%lu), tx/s=%lu (MB/s=%lu)\n", - packets, bytes >> 20, -@@ -254,7 +271,7 @@ static void do_test(int domain, int type, int protocol) - - static void usage(const char *filepath) - { -- error(1, 0, "Usage: %s [-n] [-z] [-s] " -+ t_error(1, 0, "Usage: %s [-n] [-z] [-s] " - "(-4|-6) [-t