From: Roman Bolshakov <roman@roolebo.dev>
To: Akihiko Odaki <akihiko.odaki@gmail.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Vladislav Yaroshchuk" <yaroshchuk2000@gmail.com>,
phillip.ennen@gmail.com, "Jason Wang" <jasowang@redhat.com>,
"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
"qemu Developers" <qemu-devel@nongnu.org>,
"Cameron Esfahani" <dirty@apple.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Roman Bolshakov" <r.bolshakov@yadro.com>,
"Alexander Graf" <agraf@csgraf.de>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Howard Spoelstra" <hsp.cat7@gmail.com>,
"Alessio Dionisi" <hello@adns.io>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Eric Blake" <eblake@redhat.com>,
"Phillip Tennen" <phillip@axleos.com>
Subject: Re: [PATCH v13 2/7] net/vmnet: add vmnet backends to qapi/net
Date: Sun, 30 Jan 2022 00:03:36 +0300 [thread overview]
Message-ID: <YfWrqNWcqmtPUlb5@roolebo.dev> (raw)
In-Reply-To: <CAMVc7JXyFoUCkrGLKhCct_DatwU6Xu+L2XSK5y0YMV8xDHZC+g@mail.gmail.com>
On Tue, Jan 25, 2022 at 01:14:27PM +0900, Akihiko Odaki wrote:
> On Tue, Jan 25, 2022 at 8:00 AM Roman Bolshakov <roman@roolebo.dev> wrote:
> >
> > On Mon, Jan 24, 2022 at 08:14:31PM +0000, Peter Maydell wrote:
> > > On Mon, 24 Jan 2022 at 17:49, Roman Bolshakov <roman@roolebo.dev> wrote:
> > > > I'm not sure why blocks are Objective-C specific. All the data I have
> > > > shows the opposite [3][4][5]. They're just extensively used in Apple APIs.
> > >
> > > This is true, but for the purposes of our build machinery it is
> > > simpler to have three types of source files that it deals
> > > with (C, C++, ObjC) rather than four (C, C++, ObjC, C-that-uses-blocks).
> > > So unless there's a clear benefit from adding the extra category
> > > I think we should do the simple thing and keep these files named
> > > with a ".m" extension.
> > >
> >
> > Fine by me as long as majority finds it's simpler :) Perhaps it's just a
> > matter of personal preference.
> >
> > I've used to the fact that platform-specific code uses platform-specific
> > extensions or some sort of weird "GCC attributes". Therefore C with an
> > extension is easier to reason for me than Objective-C with ARC and other
> > kinds of implicit behaviour without an actual Objective-C code.
> >
>
> Being technically pedantic, actually this vmnet implementation uses
> Objective-C and there is a file with .c which uses blocks.
> If a file is named .m, dispatch_retain(o) will be redefined as [o
> retain], and effectively makes it Objective-C code. Therefore, vmnet
> involves Objective-C as long as its files are named .m. It will be C
> with blocks if they are named .c.
> Speaking of use of blocks, actually audio/coreaudio.c involves blocks
> in header files; Core Audio has functions which accept blocks.
>
Right, dispatch_retain()/dispatch_release() is just one example of the
implicit behaviour I'm talking about.
> I'm neutral about the decision.
> I think QEMU should avoid using Objective-C code except for
> interactions with Apple's APIs, and .c is superior in terms of that as
> it would prevent accidental introduction of Objective-C code.
That was exactly my point :)
> On the other hand, naming them .m will allow the
> introduction of Automatic Reference Counting to manage dispatch queue
> objects.
As of now ARC doesn't work automatically for .m files in QEMU. It
happens because QEMU doesn't enable it via -fobjc-arc.
If you try to enable it, Cocoa UI won't compile at all because of many
errors like this one and similar ones:
../ui/cocoa.m:1186:12: error: ARC forbids explicit message send of
'dealloc'
[super dealloc];
~~~~~ ^
> In fact, I have found a few memory leaks in vmnet in the last
> review and ui/cocoa.m has a suspicious construction of the object
> management (Particularly it has asynchronous dispatches wrapped with
> NSAutoreleasePool, which does not make sense).
> Introduction of Automatic Reference Counting would greatly help
> addressing those issues, but that would require significant rewriting
> of ui/cocoa.m.
Agreed.
Thanks,
Roman
P.S. I still think that given the mentioned facts and implicitness
introduced by Objective-C it would be more natural to have C code in
macOS-related device backends like vmnet and coreaudio unless
Objective-C is essential and required (like in UI code).
> Personally I'm concerned with ui/cocoa.m and do want to do that
> rewriting, but I'm being busy so it would not happen anytime soon.
>
> Regards,
> Akihiko Odaki
next prev parent reply other threads:[~2022-01-29 21:06 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 17:22 [PATCH v13 0/7] Add vmnet.framework based network backend Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 1/7] net/vmnet: add vmnet dependency and customizable option Vladislav Yaroshchuk
2022-01-20 7:14 ` Roman Bolshakov
2022-01-21 11:58 ` Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 2/7] net/vmnet: add vmnet backends to qapi/net Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-15 13:00 ` Vladislav Yaroshchuk
2022-01-18 15:00 ` Markus Armbruster
2022-01-18 16:16 ` Vladislav Yaroshchuk
2022-01-18 16:26 ` Markus Armbruster
2022-01-18 16:46 ` Vladislav Yaroshchuk
2022-01-20 8:32 ` Roman Bolshakov
2022-01-21 12:19 ` Vladislav Yaroshchuk
2022-01-21 13:03 ` Akihiko Odaki
2022-01-28 14:29 ` Vladislav Yaroshchuk
2022-01-28 23:00 ` Akihiko Odaki
2022-01-24 9:56 ` Roman Bolshakov
2022-01-24 11:27 ` Christian Schoenebeck
2022-01-24 17:49 ` Roman Bolshakov
2022-01-24 20:00 ` Christian Schoenebeck
2022-01-24 20:14 ` Peter Maydell
2022-01-24 23:00 ` Roman Bolshakov
2022-01-25 4:14 ` Akihiko Odaki
2022-01-25 10:32 ` Peter Maydell
2022-01-25 11:08 ` Akihiko Odaki
2022-01-25 17:30 ` Christian Schoenebeck
2022-01-29 21:03 ` Roman Bolshakov [this message]
2022-01-13 17:22 ` [PATCH v13 3/7] net/vmnet: implement shared mode (vmnet-shared) Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 4/7] net/vmnet: implement host mode (vmnet-host) Vladislav Yaroshchuk
2022-01-13 17:22 ` [PATCH v13 5/7] net/vmnet: implement bridged mode (vmnet-bridged) Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 6/7] net/vmnet: update qemu-options.hx Vladislav Yaroshchuk
2022-01-14 8:43 ` Akihiko Odaki
2022-01-13 17:22 ` [PATCH v13 7/7] net/vmnet: update MAINTAINERS list Vladislav Yaroshchuk
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=YfWrqNWcqmtPUlb5@roolebo.dev \
--to=roman@roolebo.dev \
--cc=agraf@csgraf.de \
--cc=akihiko.odaki@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=dirty@apple.com \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--cc=hello@adns.io \
--cc=hsp.cat7@gmail.com \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=phillip.ennen@gmail.com \
--cc=phillip@axleos.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
--cc=r.bolshakov@yadro.com \
--cc=yaroshchuk2000@gmail.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.