Skip to content
Snippets Groups Projects
Select Git revision
  • d3e25d39d764a0804d289187c819b8c74ea4ba49
  • master default
  • anders.blomdell
  • typeref
  • pragma
  • compiler-refactoring
  • labcomm2013
  • v2014.1
  • v2014.0
  • v2013.0
10 results

labcomm_compat_osx.h

Blame
  • Forked from Anders Blomdell / LabComm
    297 commits behind the upstream repository.
    labcomm_compat_osx.h 601 B
    #ifndef __APPLE__
    #error "__APPLE__" not defined
    #endif
    
    #ifndef LABCOMM_COMPAT_OSX
    #define LABCOMM_COMPAT_OSX
    
    #include <machine/endian.h>
    #include <stdio.h>
    #include <time.h>
    
    #include <mach/clock.h>
    #include <mach/mach.h>
    
    #define CLOCK_REALTIME 0
    static inline void clock_gettime(int garbage, struct timespec *ts)
    {
      (void) garbage;
      clock_serv_t cclock;
      mach_timespec_t mts;
      host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
      clock_get_time(cclock, &mts);
      mach_port_deallocate(mach_task_self(), cclock);
      ts->tv_sec = mts.tv_sec;
      ts->tv_nsec = mts.tv_nsec;
    }
    
    #endif