From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
qemu-trivial@nongnu.org
Subject: Re: [PATCH-for-8.0] coroutine: Add missing <qemu/atomic.h> include
Date: Wed, 14 Dec 2022 15:11:01 +0100 [thread overview]
Message-ID: <87edt2gjnu.fsf@pond.sub.org> (raw)
In-Reply-To: <26516050-1599-7a66-ebff-d7844c128b5f@linaro.org> ("Philippe Mathieu-Daudé"'s message of "Wed, 14 Dec 2022 11:28:31 +0100")
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> On 14/12/22 08:58, Markus Armbruster wrote:
>> Philippe Mathieu-Daudé <philmd@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é <philmd@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-armbru@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.
prev parent reply other threads:[~2022-12-14 14:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-25 17:55 [PATCH-for-8.0] coroutine: Add missing <qemu/atomic.h> include Philippe Mathieu-Daudé
2022-12-14 7:27 ` Philippe Mathieu-Daudé
2022-12-14 7:58 ` Markus Armbruster
2022-12-14 10:28 ` Philippe Mathieu-Daudé
2022-12-14 14:11 ` Markus Armbruster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87edt2gjnu.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.