path: root/examples
AgeCommit message (Collapse)Author
2021-09-15examples: Fix warnings for comparison of integers with different signednessGuillem Jover
Warned-by: gcc -Wsign-compare Signed-off-by: Guillem Jover <>
2021-09-13build: Fix build flags supportGuillem Jover
The usual convention is that the various *FLAGS are user controllable, and can be overridden, so anything that is essential for the build should be passed respecting that. The other usual convention is that CPPFLAGS only contain pre-processor options, CFLAGS and CXXFLAGS only contain compilation options and LDFLAGS only contain linker flags, where all of these are honored in all build rules. Switch to set optional flags conditionally into the *FLAGS variables if they are not set, and then unconditionally append any required flags. And pass the various *FLAGS to the rules as expected. Signed-off-by: Guillem Jover <>
2021-09-02build: add -D_GNU_SOURCE to all CPPFLAGS/CFLAGS.Uman Shahzad
Needed for e.g. musl libc which only includes entities like cpu_set_t if this is defined. Signed-off-by: Uman Shahzad <>
2021-04-20examples/link-cp: fix a couple of strerror negationsDavid Disseldorp
Signed-off-by: David Disseldorp <>
2021-04-13examples/ucontext-cp.c: cope with variable SIGSTKSZStefan Hajnoczi
The size of C arrays at file scope must be constant. The following compiler error occurs with recent upstream glibc (2.33.9000): CC ucontext-cp ucontext-cp.c:31:23: error: variably modified ‘stack_buf’ at file scope 31 | unsigned char stack_buf[SIGSTKSZ]; | ^~~~~~~~~ make[1]: *** [Makefile:26: ucontext-cp] Error 1 The following glibc commit changed SIGSTKSZ from a constant value to a variable: commit 6c57d320484988e87e446e2e60ce42816bf51d53 Author: H.J. Lu <> Date: Mon Feb 1 11:00:38 2021 -0800 sysconf: Add _SC_MINSIGSTKSZ/_SC_SIGSTKSZ [BZ #20305] ... +# define SIGSTKSZ sysconf (_SC_SIGSTKSZ) Allocate the stack buffer explicitly to avoid declaring an array at file scope. Cc: H.J. Lu <> Signed-off-by: Stefan Hajnoczi <> Signed-off-by: Jens Axboe <>
2021-03-26examples/io_uring-cp: wait for pending writes before exit copy loopJens Axboe
We could be ending the loop with all reads done, but with pending writes that we haven't waited for yet. Ensure that we do so. Signed-off-by: Jens Axboe <>
2020-10-28examples: disable ucontext-cp if ucontext.h is not availableSimon Zeni
The header file `ucontext.h` is not available on musl based distros. The example `ucontext-cp` is not built if `configure` fails to locate the header. Signed-off-by: Simon Zeni <> Signed-off-by: Jens Axboe <>
2020-09-20Fix build flag settingsGuillem Jover
Split preprocessor flags into CPPFLAGS to be passed to rules involving code compilation, instead of link-only rules. This also guarantees we always use the user set CPPFLAGS which are expected to be honored by most build systems. Move build system required C++ flags into an override for CXXFLAGS to follow the same pattern as the other flags. Signed-off-by: Guillem Jover <>
2020-08-20examples/io_uring-test: don't error on shorter filesJens Axboe
The example currently assumes the file is at least 4*4096 bytes, and errors when we get 0 reads on EOF. Fix this up. Signed-off-by: Jens Axboe <>
2020-06-10examples/ucontext-cp.c: use IORING_OP_TIMEOUTCarter Li
2020-02-11Add SPDX license identifiersJens Axboe
Signed-off-by: Jens Axboe <>
2019-12-23configure: allow to set host CCJens Axboe
Use ./configure --cc=whatever to set the compiler. Signed-off-by: Jens Axboe <>
2019-12-23Makefile: quiet down rmJens Axboe
Signed-off-by: Jens Axboe <>
2019-11-19Avoid redefined warning of "SIGSTKSZ"Jackie Liu
ucontext-cp.c:24:0: warning: "SIGSTKSZ" redefined #define SIGSTKSZ 8192 In file included from /usr/include/signal.h:316:0, from ucontext-cp.c:13: /usr/include/aarch64-linux-gnu/bits/sigstack.h:30:0: note: this is the location of the previous definition #define SIGSTKSZ 16384 Signed-off-by: Jackie Liu <> Signed-off-by: Jens Axboe <>
2019-10-01examples/ucontext-cp.c: get rid of c99 style declarationsJens Axboe
Signed-off-by: Jens Axboe <>
2019-09-22Makefile: handle quiet AR/RANLIBJens Axboe
Also unify across subdirs. Signed-off-by: Jens Axboe <>
2019-09-21Makefile: add pretty/quiet CC/LN outputJens Axboe
Signed-off-by: Jens Axboe <>
2019-09-22examples/ucontext-cp: more complex example to show how ucontext works李通洲
Allow multiple files being copied in one command, and print more logs Also add timeout to indicate that different coroutines run in parallel actually Signed-off-by: 李通洲 <>
2019-09-21Generalize Makefiles for examples and test.James Rouzier
Signed-off-by: James Rouzier <>
2019-09-20examples/ucontext-cp: style fixupsJens Axboe
No functional changes. Signed-off-by: Jens Axboe <>
2019-09-20examples/ucontext-cp: use ucontext with liburing李通洲
Coroutines are often used to simplify async programming, and work great with liburing. `ucontext` doesn't perform very good, but it's enough for an example.
2019-08-30examples/io_uring-cp: handle io_uring_peek_cqe() -EAGAINJens Axboe
Signed-off-by: Jens Axboe <>
2019-07-24src/Makefile: keep private headers in <liburing/*.h>Stefan Hajnoczi
It is not possible to install barrier.h and compat.h into the top-level /usr/include directly since they are likely to conflict with other software. io_uring.h could be confused with the system's kernel header file. Put liburing headers into <liburing/*.h> so there is no chance of conflicts or confusion. Existing applications continue to build successfully since the location of <liburing.h> is unchanged. In-tree examples and tests require modification because src/liburing.h is moved to src/include/liburing.h. Signed-off-by: Stefan Hajnoczi <> Signed-off-by: Jens Axboe <>
2019-07-08Makefiles: Support specifying CFLAGS on the command lineBart Van Assche
This patch makes the liburing build work as expected for e.g. the following command: make CFLAGS=-m32 and avoids that the build fails as follows for the above command: make[1]: Entering directory 'liburing/test' cc -m32 -o poll poll.c -luring /usr/bin/ld: cannot find -luring collect2: error: ld returned 1 exit status Makefile:18: recipe for target 'poll' failed make[1]: *** [poll] Error 1 make[1]: Leaving directory 'software/liburing/test' Makefile:12: recipe for target 'all' failed make: *** [all] Error 2 Signed-off-by: Bart Van Assche <> Signed-off-by: Jens Axboe <>
2019-06-13example/io_uring-test.c: Fix iovecs incrementStephen Bates
This example misses an increment though the iovecs array. This causes the same buffer to be filled from the block device every time. It would be good to fix this since it is one of the first examples a new-comer to io_uring is exposed too. Signed-off-by: Stephen Bates <> Signed-off-by: Jens Axboe <>
2019-05-22examples/io_uring-cp: fix a NULL pointer dereferencezhangliguang
In case malloc fails, the fix returns NULL to avoid NULL pointer dereference. Signed-off-by: zhangliguang <> Signed-off-by: Jens Axboe <>
2019-05-15examples/link-cp: improve memory useJens Axboe
Put the data at the end so we don't have to offset the actual buffer. Signed-off-by: Jens Axboe <>
2019-05-15examples/link-cp: improvementsJens Axboe
Add short read requeue and abort on error. Signed-off-by: Jens Axboe <>
2019-05-14examples/link-cp: fix a few issuesJens Axboe
Still need to handle broken chains, must resubmit those. Signed-off-by: Jens Axboe <>
2019-05-14Add chain failure handling test caseJens Axboe
Signed-off-by: Jens Axboe <>
2019-05-13Add link SQE supportJens Axboe
Just a basic test case that does various forms of linked nops, and a sample bare bones copy program using linked reads and writes. Signed-off-by: Jens Axboe <>
2019-04-18Rename completion helpersJens Axboe
We have io_uring_get_sqe() on the submission side, yet the completion side is named _completion. Rename as follows: io_uring_get_completion() io_uring_peek_cqe() iO_uring_wait_completion() io_uring_wait_cqe() This better tells the user what the _get variant does by calling it _peek instead, and we move to using _cqe() as the postfix instead of _completion. Signed-off-by: Jens Axboe <>
2019-04-17Separate test cases from examplesJens Axboe
Also adds a runtests makefile target.