MPS issue job003411

TitleMPS doesn't make use of __builtin_readcyclecounter on OS X
Assigned userRichard Brooksby
DescriptionClang provides a cross-platform builtin for a fast timer. We should use this on OS X to implement EVENT_CLOCK (but only if it is available, obviously).
AnalysisRB wrote the following code in clock.h:

    /* TODO: Clang supposedly provides a cross-platform builtin for a fast
     * timer, but it doesn't seem to be present on Mac OS X 10.8. We should
     * use it if it ever appears.
     * <> */
    #if defined(MPS_BUILD_LL)

    #if __has_builtin(__builtin_readcyclecounter)
    #error "__builtin_readcyclecounter is available but not used"
    #endif /* __has_builtin(__builtin_readcyclecounter) */


The upgrade to XCode 4.6 caused the #error to go off, so presumably this upgrade adds __builtin_readcyclecounter on OS X.

We need to:

1. Remove the #error so that the MPS can be built on OS X with XCode 4.6. [DONE]
2. Use this fast counter to implement EVENT_CLOCK.
How foundmanual_test
Observed in1.110.0
Created byGareth Rees
Created on2013-02-04 16:36:17
Last modified byGareth Rees
Last modified on2013-05-16 13:37:31
History2013-02-04 GDR Created.


Change Effect Date User Description
181858 closed 2013-05-16 13:37:31 Gareth Rees Use __builtin_readcyclecounter for EVENT_CLOCK if it's available.
180917 open 2013-02-06 17:03:17 Richard Brooksby Temporarily patching detection of __builtin_readcyclecounter so that we can continue to compile with Apple Clang 4.0.
180903 open 2013-02-04 16:40:28 Gareth Rees Don't #error if defined(MPS_BUILD_LL) and __has_builtin(__builtin_readcyclecounter). Put a TODO here instead, referencing job003411.