Philippe Mathieu-Daudé <phi...@linaro.org> writes: > On 14/12/22 08:58, Markus Armbruster wrote: >> Philippe Mathieu-Daudé <phi...@linaro.org> writes: >> >>> qemu_co_mutex_assert_locked() calls qatomic_read(), which >>> is declared in <qemu/atomic.h>. This fixes when refactoring: >>> >>> In file included from include/qemu/osdep.h:113, >>> from ../../util/error-report.c:13: >>> include/qemu/coroutine.h: In function 'qemu_co_mutex_assert_locked': >>> include/qemu/coroutine.h:182:12: error: implicit declaration of function >>> 'qatomic_read' [-Werror=implicit-function-declaration] >>> 182 | assert(qatomic_read(&mutex->locked) && >>> | ^~~~~~~~~~~~ >>> >>> Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> >>> --- >>> include/qemu/coroutine.h | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h >>> index 89650a2d7f..1750c30d8e 100644 >>> --- a/include/qemu/coroutine.h >>> +++ b/include/qemu/coroutine.h >>> @@ -17,6 +17,7 @@ >>> #include "qemu/queue.h" >>> #include "qemu/timer.h" >>> +#include "qemu/atomic.h" >>> /** >>> * Coroutines are a mechanism for stack switching and can be used for >> I think this papers over the actual problem. >> Compiling qemu/coroutine.h by itself succeeds for me. Printing headers >> with -H shows: >> [osdep.h and everything it includes elided...] >> . ../include/qemu/coroutine.h >> .. /work/armbru/qemu/include/qemu/queue.h >> .. /work/armbru/qemu/include/qemu/timer.h >> ... /work/armbru/qemu/include/qemu/bitops.h >> .... /work/armbru/qemu/include/qemu/host-utils.h >> ..... /work/armbru/qemu/include/qemu/bswap.h >> ...... /usr/include/byteswap.h >> ....... /usr/include/bits/byteswap.h >> ..... /work/armbru/qemu/include/qemu/int128.h >> .... /work/armbru/qemu/include/qemu/atomic.h >> [more...] >> So, qemu/coroutine.h *already* includes qemu/atomic.h, via qemu/timer.h >> and qemu/bitops.h. > > Well I'm not sure this implicit dependency is correct, since "coroutine.h" > explicitly access a function declared in "atomic.h"; > if I want to modify "qemu/timer.h" or "qemu/bitops.h" I'm back to > this very patch.
We have a rule "every header should include everything it needs". We don't have a rule "every header should include everything it needs directly". Yes, this means that when you drop includes from a header, you may have to add them back elsewhere. >> I suspect the actual problem is an inclusion loop: qemu/coroutine.h and >> qemu/lockable.h include each other. See my >> Subject: [PATCH 4/4] coroutine: Break inclusion loop >> Message-Id: <20221208142306.2642640-5-arm...@redhat.com> >> and Paolo's review. > > So I guess I'll wait your series to get merged and see what happens > when I rebase my work on yours. Makes sense to me.