Sha256: 72b2e722446bd46b65a8556dea2e30556b2d5ef34a4d7d1f830e4d7ae8e935f0

Contents?: true

Size: 1.23 KB

Versions: 28

Compression:

Stored size: 1.23 KB

Contents

#ifdef USE_INSTANT_OSX

#include "hitimes_interval.h"
#include <mach/mach.h>
#include <mach/mach_time.h>

/* All this OSX code is adapted from http://developer.apple.com/library/mac/#qa/qa1398/_index.html */

/*
 * returns the conversion factor, this value is used to convert
 * the value from hitimes_get_current_instant() into seconds
 */
long double hitimes_instant_conversion_factor()
{
    static mach_timebase_info_data_t  s_timebase_info;
    static long double                conversion_factor;
    static uint64_t                   nano_conversion;

    /**
     * If this is the first time we've run, get the timebase.
     * We can use denom == 0 to indicate that s_timebase_info is
     * uninitialised because it makes no sense to have a zero
     * denominator is a fraction.
     */

    if ( s_timebase_info.denom == 0 ) {
        mach_timebase_info(&s_timebase_info);
        nano_conversion   = s_timebase_info.numer / s_timebase_info.denom;
        conversion_factor = (long double) (nano_conversion) * (1e9l);
    }

    return conversion_factor;
}

/*
 * returns the mach absolute time, which has no meaning outside of a conversion
 * factor.
 */
hitimes_instant_t hitimes_get_current_instant()
{
    return mach_absolute_time();
}


#endif

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
hitimes-1.3.0-x64-mingw32 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.3.0-x86-mingw32 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.3.0-java ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.3.0 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.6-x86-mingw32 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.6-java ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.6 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.5-java ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.5-x86-mingw32 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.5 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.4-java ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.4-x86-mingw32 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.4 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.3-x86-mingw32 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.3-java ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.3 ext/hitimes/c/hitimes_instant_osx.c
scoot-0.0.4 .bundle/gems/ruby/2.2.0/gems/hitimes-1.2.2/ext/hitimes/c/hitimes_instant_osx.c
vagrant-cloudstack-1.1.0 vendor/bundle/gems/hitimes-1.2.2/ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.2-x86-mingw32 ext/hitimes/c/hitimes_instant_osx.c
hitimes-1.2.2-x86-mswin32-60 ext/hitimes/c/hitimes_instant_osx.c