Sometimes the compiler accepts `(struct sockaddr_in *)` and
`(struct sockaddr_in6 *)` to be passed in to `(struct sockaddr *)`
without a cast. But not all compilers agree with that. Building with
clang 13.0.1 yields the following errors:
io_uring-udp.c:134:18: error: incompatible pointer types passing \
'struct sockaddr_in6 *' to parameter of type 'const struct sockaddr *' \
[-Werror,-Wincompatible-pointer-types
io_uring-udp.c:142:18: error: incompatible pointer types passing \
'struct sockaddr_in *' to parameter of type 'const struct sockaddr *' \
[-Werror,-Wincompatible-pointer-types]
Explicitly cast the pointer to (struct sockaddr *) to avoid this error.
Cc: Dylan Yudaken <dylany@fb.com>
Cc: Facebook Kernel Team <kernel-team@fb.com>
Fixes: 12d7e7cf8f ("add an example for a UDP server")
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Link: https://lore.kernel.org/r/20220726164310.266060-1-ammar.faizi@intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Silences the following:
* Error due to no definition for `mode_t` in `liburing.h`
* Warning due to use of non-portable `#include <sys/poll.h>` and `#include <sys/signal.h>`
* Warning due to incorrect `printf` format specifier in `test/io_uring_register.c`
* Error due to missing declaration for `strcpy` in `test/sendmsg_fs_cve.c`
* Error due to missing declaration for `strerror` in `test/shutdown.c`
Signed-off-by: Mahdi Rakhshandehroo <mahdi.rakhshandehroo@gmail.com>
Several things go wrong with this Makefile:
1) Using `test_srcs` to generate `test_objs`.
2) `test_objs` is an unused variable. So (1) is pointless.
3) `make clean` does not remove `ucontext-cp` binary.
I assume (1) and (2) were blindly copied from the test Makefile.
For 3, the `make clean` removes $(all_targets) and $(test_objs). But
`ucontext-cp` only exists in $(all_targets) if we have
`CONFIG_HAVE_UCONTEXT`. When the target goal is `clean`, we will not
have any of `CONFIG_*` variables. Thus, `ucontext-cp` is not removed.
Clean them up!
Signed-off-by: Ammar Faizi <ammar.faizi@students.amikom.ac.id>
Link: https://lore.kernel.org/r/20211030114858.320116-2-ammar.faizi@intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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 <guillem@hadrons.org>
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 <hjl.tools@gmail.com>
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 <hjl.tools@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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 <axboe@kernel.dk>
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 <simon@bl4ckb0ne.ca>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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 <guillem@hadrons.org>
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 <axboe@kernel.dk>
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 <liuyun01@kylinos.cn>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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: 李通洲 <carter.li@eoitek.com>
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.
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 <stefanha@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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 <bvanassche@acm.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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 <sbates@raithlin.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
In case malloc fails, the fix returns NULL to avoid NULL pointer
dereference.
Signed-off-by: zhangliguang <zhangliguang@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
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 <axboe@kernel.dk>
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 <axboe@kernel.dk>