| Summary: | SDL sys timer Mac OS update proposal | ||
|---|---|---|---|
| Product: | SDL | Reporter: | David Carlier <devnexen> |
| Component: | timer | Assignee: | Ryan C. Gordon <icculus> |
| Status: | WAITING --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | amaranth72, icculus, sezeroz |
| Version: | HG 2.1 | ||
| Hardware: | All | ||
| OS: | Mac OS X (All) | ||
| Attachments: |
patch
patch 2 patch 3 patch 4 better check for clock_gettime_nsec_np() better check for clock_gettime_nsec_np() better check for clock_gettime_nsec_np() - v6 |
||
As far as I can see, this breaks macOS < 10.12 (In reply to Ozkan Sezer from comment #1) > As far as I can see, this breaks macOS < 10.12 Fwiw, mach_absolute_time() is apparently deprecated as of 11.0, so we'll probably have to wrap this in preprocessor check in any case. :/ --ryan. Ah older still supported. I can try detection at config time in both autoconf/Cmake fashions. Created attachment 4668 [details]
patch 2
Created attachment 4671 [details]
patch 3
The second patch didn't apply, I regenerated it by guess-work:
Please confirm that it matches your intention.
Yes sorry I m not comfortable with mercurial really much better with git :-) but the diff looks good indeed, except maybe those two lines removal ` -#else -#define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC ` Created attachment 4672 [details] patch 4 (In reply to David Carlier from comment #6) > but the diff looks good indeed, except maybe those two lines removal Attached v4 patch. +1 Is there any benefit for using the newer API? If it's performance, can you attach your test and the timing results you got? Not that much (no more init but that s once) but more reliability, less error prone and easier to use. It s usually advised to move on to this newer api when possible (ideally I would have prefered removing the ancient one but depends on support wanted). Patch added, thanks! https://hg.libsdl.org/SDL/rev/8cad7d7ec50c Created attachment 4697 [details]
better check for clock_gettime_nsec_np()
(In reply to Ozkan Sezer from comment #12) > Created attachment 4697 [details] > better check for clock_gettime_nsec_np() The attached patch makes sure that the build is targeting macOS >= 10.12 for clock_gettime_nsec_np() availability. It also adds missing HAVE_xxx to SDL_config_macosx.h. Please review. Notes: I do NOT know how to check IOS version requirements. time.h from 10.12 SDK says: __IOS_AVAILABLE(10.0) __TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0) If these are already the minimum requirements from SDL, then I can add the availability unconditionally: Tell me what to do for it and I will complete the patch and push to hg. > I do NOT know how to check IOS version requirements
I do not know if that answers your question but the attribute available can
as :
if (@available(iOS 10, *)) // It is variadic to be able to check tvOs and so on
(In reply to David Carlier from comment #14) > I do not know if that answers your question but the attribute available can > > as : > > if (@available(iOS 10, *)) // It is variadic to be able to check tvOs and so on I believe that's for detection at run time. We need something for compile-time. ah right I think you have constants such as : - __IPHONE_OS_VERSION_MIN_REQUIRED - more broadly __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_10_0) from the top of my head. otherwise there are these in case : - __WATCHOS_AVAILABLE(<version>) and __TVOS_AVAILABLE(<version>) Created attachment 4700 [details]
better check for clock_gettime_nsec_np()
-- patch rebased to current hg
Created attachment 4701 [details]
better check for clock_gettime_nsec_np() - v6
Updated patch, v6:
- Unconditionally defines HAVE_CLOCK_GETTIME_NSEC_NP for iOS / TVOS
assuming iOS >= 10.0.
This is similar to SDL_JOYSTICK_MFI being defined for iOS or TVOS
which depend on GameController framework which require iOS >=10.0
at the least.
Comments? OK to apply?
Seems ok to me Latest patch looks good to me. --ryan. (In reply to David Carlier from comment #20) > Seems ok to me (In reply to Ryan C. Gordon from comment #21) > Latest patch looks good to me. > > --ryan. OK, applied the latest patch as https://hg.libsdl.org/SDL/rev/d01593bd58d9 Re-closing as fixed. SDL_GetTicks() was broken, so I backed this out: https://hg.libsdl.org/SDL/rev/88c79c6a8457 Ah surprising but understood... Sorry for this. It may make sense to use clock_gettime_nsec_np() for the performance timer and leave the original code for SDL_GetTicks(). Thoughts? Could work out indeed. Is there any advantage in performance or resolution? Performance not really, resolution most likely and more consistent across architectures. As far as I know there's no benefit to using clock_gettime_nsec_np versus the current code aside from mach_absolute_time being marked as deprecated. I suspect Apple only marked it as deprecated in the first place because other code (not SDL) was using it wrong on macOS in a way that will produce correct results on x64 but not Apple Silicon CPUs. |
Created attachment 4666 [details] patch Change of api from 2016 which reduce code complexity a bit.