osxcross/patches/compiler-rt_clock-gettime.patch
Thomas Pöchtrager 68bdbd9452 New:
* Added support for TAPIv3 stubs (including "zippering" target)
* Added support for MacOSX SDKs up to 10.14
* Added new SDK packaging script for SDKs that end with ".xip" (tools/gen_sdk_package_pbzx.sh <xcode.xip>) (tested up to Xcode 10.2.1)
* Updated cctools to 921 and ld64 to 409.12

Fixed:
* Implemented fix for https://github.com/tpoechtrager/osxcross/issues/171
* Implemented fix for https://github.com/tpoechtrager/osxcross/issues/178
* Implemented fix for https://github.com/tpoechtrager/osxcross/issues/182

Changed:
* cctools, ld64, apple-libtapi and xar are now "git clone"'d and no longer come with OSXCross.

Removed:
* Support for Cygwin and *BSD (besides FreeBSD)
* Support for building OSXCross with GCC
2019-06-01 19:57:44 +02:00

31 lines
1.0 KiB
Diff

diff -crB --new-file /home/thomas/tmp/compiler-rt/include/time.h compiler-rt/include/time.h
*** /home/thomas/tmp/compiler-rt/include/time.h 1970-01-01 01:00:00.000000000 +0100
--- compiler-rt/include/time.h 2019-06-01 15:42:13.006343150 +0200
***************
*** 0 ****
--- 1,24 ----
+ #ifndef __TIME_H_INCLUDE_HACK__
+ #define __TIME_H_INCLUDE_HACK__
+ #ifdef __MACH__
+ /* https://stackoverflow.com/a/17112198/1392778 */
+ #include_next <time.h>
+ #include <mach/mach_time.h>
+ #define CLOCK_REALTIME 0
+ #define CLOCK_MONOTONIC 0
+ typedef int clockid_t;
+ static int clock_gettime(clockid_t clk_id, struct timespec *t){
+ mach_timebase_info_data_t timebase;
+ mach_timebase_info(&timebase);
+ uint64_t time;
+ time = mach_absolute_time();
+ double nseconds = ((double)time * (double)timebase.numer)/((double)timebase.denom);
+ double seconds = ((double)time * (double)timebase.numer)/((double)timebase.denom * 1e9);
+ t->tv_sec = seconds;
+ t->tv_nsec = nseconds;
+ return 0;
+ }
+ #else
+ #include_next <time.h>
+ #endif
+ #endif