qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@gmail.com>
To: Christian Schoenebeck <qemu_oss@crudebyte.com>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	qemu-block@nongnu.org, "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Cameron Esfahani" <dirty@apple.com>,
	"Roman Bolshakov" <r.bolshakov@yadro.com>,
	"Alexander Graf" <agraf@csgraf.de>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [RFC PATCH v2 2/6] audio/coreaudio: Remove a deprecation warning on macOS 12
Date: Tue, 11 Jan 2022 04:01:40 +0900	[thread overview]
Message-ID: <524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com> (raw)
In-Reply-To: <2798332.tR5H1UBy9i@silver>

On 2022/01/11 3:46, Christian Schoenebeck wrote:
> On Montag, 10. Januar 2022 19:20:15 CET Akihiko Odaki wrote:
>> On 2022/01/10 22:22, Peter Maydell wrote:
>>> On Mon, 10 Jan 2022 at 13:14, Christian Schoenebeck
>>>
>>> <qemu_oss@crudebyte.com> wrote:
>>>> I'd suggest to use:
>>>>
>>>> #if !defined(MAC_OS_VERSION_12_0) ||
>>>>
>>>>       (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_VERSION_12_0)
>>>>
>>>> #define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster
>>>> #endif
>>>
>>> This is also how we do this for existing checks of this sort,
>>> like the one in osdep.h for qemu_thread_jit_execute().
>>>
>>> -- PMM
>>
>> If I understand correctly, Many macOS-specific codes already no longer
>> complies with GCC because they depend on modern features GCC doesn't
>> provide. The most problematic construction is block; it is extensively
>> used by Apple's ABI and API and you cannot avoid using it even if you try.
> 
> You mean Obj-C blocks? That's working with GCC for decades. I am not aware
> about any recent changes to Obj-C block mechanisms by Apple.
> 
>> Also, note that MAC_OS_X_VERSION_MAX_ALLOWED defines the upper bound of
>> the supported version. The lower bound should be preferred here because
>> the usage of the new identifier is applied regardless of the version of
>> the host system. It is in contrary to the usage of
>> MAC_OS_X_VERSION_MAX_ALLOWED in osdep.h where the new interfaces are
>> used only for the newer versions. The lower bound is defined as
>> MAC_OS_X_VERSION_MIN_REQUIRED. Practically there is no difference of the
>> two macros because they have the same value in QEMU and
>> kAudioObjectPropertyElementMain is a constant resolved compile-time, but
>> it is still nice to have the code semantically correct.
> 
> For this particular enum: no, MAC_OS_X_VERSION_MAX_ALLOWED is the correct one.
> This is about whether enum kAudioObjectPropertyElementMain is defined in the
> SDK header files. That's all. And the new enum kAudioObjectPropertyElementMain
> is pure refactoring of the enum's old name due to social reasons ("Master").
> The actual reflected numeric value and semantic of the enum is unchanged and
> the resulting binary and behaviour are identical.


There are a few problems with the usage of MAC_OS_X_VERSION_MAX_ALLOWED:
- The deprecation warning is designed to work with 
MAC_OS_X_VERSION_MIN_REQUIRED. You may verify that with:
cc -mmacosx-version-min=12.0 -x c - <<EOF
#include <CoreAudio/CoreAudio.h>

int main()
{
    int k = kAudioObjectPropertyElementMaster;
}
EOF
- The programmer must be aware whether it is constant or not.
- The macro tells about the runtime and not the SDK. There is no way to 
tell the SDK version and that is why I suggested __is_identifier at the 
first place. However, now I'm convinced that 
MAC_OS_X_VERSION_MIN_REQUIRED is the better option because of the above 
reasons.

> 
> There are other cases where MAC_OS_X_VERSION_MIN_REQUIRED (a.k.a. "minimum
> deployment target") would be used instead: macOS APIs that might be available
> to only some, but not to the entire macOS version range officially supported
> by the rolled out binary. Did you see any particular case where this is
> incorrectly used in QEMU?
> 
> Best regards,
> Christian Schoenebeck
> 
> 
Assuming the correctness of the use MAC_OS_X_VERSION_MAX_ALLOWED is 
irrelevant with the nature of the identifier (constant or not), the same 
problem is in ui/cocoa.m:
#ifndef MAC_OS_X_VERSION_10_13
#define MAC_OS_X_VERSION_10_13 101300
#endif

/* 10.14 deprecates NSOnState and NSOffState in favor of
  * NSControlStateValueOn/Off, which were introduced in 10.13.
  * Define for older versions
  */
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
#define NSControlStateValueOn NSOnState
#define NSControlStateValueOff NSOffState
#endif

Regards,
Akihiko Odaki


  reply	other threads:[~2022-01-10 19:08 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 17:06 [RFC PATCH v2 0/6] host: Support macOS 12 Philippe Mathieu-Daudé
2022-01-09 17:06 ` [PATCH v2 1/6] configure: Allow passing extra Objective C compiler flags Philippe Mathieu-Daudé
2022-01-09 17:06 ` [RFC PATCH v2 2/6] audio/coreaudio: Remove a deprecation warning on macOS 12 Philippe Mathieu-Daudé
2022-01-10  8:17   ` Akihiko Odaki
2022-01-10  8:44     ` Philippe Mathieu-Daudé
2022-01-10 12:24       ` Philippe Mathieu-Daudé
2022-01-10 13:07         ` Christian Schoenebeck
2022-01-10 13:14           ` Philippe Mathieu-Daudé
2022-01-10 13:22           ` Peter Maydell
2022-01-10 18:20             ` Akihiko Odaki
2022-01-10 18:46               ` Christian Schoenebeck
2022-01-10 19:01                 ` Akihiko Odaki [this message]
2022-01-10 19:07                   ` Peter Maydell
2022-01-10 20:22                   ` Christian Schoenebeck
2022-01-10 20:39                     ` Akihiko Odaki
2022-01-10 21:05                       ` Christian Schoenebeck
2022-01-10 21:38                         ` Akihiko Odaki
2022-01-11 12:35                         ` Christian Schoenebeck
2022-01-11 12:51                           ` Christian Schoenebeck
2022-01-09 17:06 ` [RFC PATCH v2 3/6] block/file-posix: " Philippe Mathieu-Daudé
2022-01-09 17:06 ` [RFC PATCH v2 4/6] hvf: Make hvf_get_segments() / hvf_put_segments() local Philippe Mathieu-Daudé
2022-01-09 17:06 ` [RFC PATCH v2 5/6] hvf: Remove deprecated hv_vcpu_flush() calls Philippe Mathieu-Daudé
2022-01-09 17:06 ` [PATCH v2 6/6] gitlab-ci: Support macOS 12 via cirrus-run Philippe Mathieu-Daudé
2022-01-10  8:50   ` Akihiko Odaki
2022-01-10  9:14   ` Daniel P. Berrangé

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=524515d6-2fb5-15c1-0aaf-bcda3684cd00@gmail.com \
    --to=akihiko.odaki@gmail.com \
    --cc=agraf@csgraf.de \
    --cc=alex.bennee@linaro.org \
    --cc=dirty@apple.com \
    --cc=f4bug@amsat.org \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=r.bolshakov@yadro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).