diff options
author | Sergey Fedorov <vital.had@gmail.com> | 2022-10-19 18:49:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 23:49:45 +1300 |
commit | 567725ed303b6738493c80efaf93dc4c1e65a9c9 (patch) | |
tree | 75f141047050eee63c05d613491595a7a9380afa /gc.c | |
parent | fc3137ef54562c3c3290245c0f62e0bb193c3145 (diff) |
Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975)
Notes
Notes:
Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1359,6 +1359,27 @@ tick(void) return val; } +/* Implementation for macOS PPC by @nobu + * See: https://github.com/ruby/ruby/pull/5975#discussion_r890045558 + */ +#elif defined(__POWERPC__) && defined(__APPLE__) +typedef unsigned long long tick_t; +#define PRItick "llu" + +static __inline__ tick_t +tick(void) +{ + unsigned long int upper, lower, tmp; + # define mftbu(r) __asm__ volatile("mftbu %0" : "=r"(r)) + # define mftb(r) __asm__ volatile("mftb %0" : "=r"(r)) + do { + mftbu(upper); + mftb(lower); + mftbu(tmp); + } while (tmp != upper); + return ((tick_t)upper << 32) | lower; +} + #elif defined(__aarch64__) && defined(__GNUC__) typedef unsigned long tick_t; #define PRItick "lu" |