liburing.h: Support C++20 module export feature
Having "static inline" functions in liburing header file results in
compilation errors when using the new C++20 module export feature:
In file included from src/work.cpp:3:
./include/liburing.h:343:20: error: \
‘void io_uring_cq_advance(io_uring*, unsigned int)’ \
exposes TU-local entity ‘void io_uring_smp_store_release(T*, T) [with T = unsigned int]’
343 | IOURINGINLINE void io_uring_cq_advance(struct io_uring *ring, unsigned nr)
| ^~~~~~~~~~~~~~~~~~~
In file included from ./include/liburing.h:20:
./include/liburing/barrier.h:42:20: note: \
‘void io_uring_smp_store_release(T*, T) [with T = unsigned int]’ is a \
specialization of TU-local template \
‘template<class T> void io_uring_smp_store_release(T*, T)’
42 | static inline void io_uring_smp_store_release(T *p, T v)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
./include/liburing/barrier.h:42:20: note: \
‘template<class T> void io_uring_smp_store_release(T*, T)’ declared with internal linkage
Introduce a new macro _LOCAL_INLINE, which will expand to "inline"
instead of "static inline" if compiled using C++20 or later. Also, make
IOURINGINLINE behave the same way in the same condition.
No functional change is expected for C and older C++ versions.
Closes: https://github.com/axboe/liburing/issues/1457
Reported-by: @xiaosa-zhz # A GitHub user
Fixes: 3d74c677c45e ("Make the liburing header files again compatible with C++")
Fixes: f2b6fb85b79b ("liburing: Don't use `IOURINGINLINE` on private helpers")
Cc: dr.xiaosa@gmail.com
Cc: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/io-uring/e0559c10-104d-4da8-9f7f-d2ffd73d8df3@acm.org
Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2 files changed