digarok / gsplus

Modern cross-platform Apple IIgs emulator and tools based on KEGS
http://apple2.gs/plus
GNU General Public License v2.0
151 stars 45 forks source link

Add posix timing as clock ticks for non x86 systems #98

Open julianaito opened 4 years ago

julianaito commented 4 years ago

Hi,

This is what happens when i try to build gsplus on my OpenBSD/macppc box:

/usr/obj/ports/gsplus-20190816/gsplus-480572054518112647c8fae5d7ea7046a6d6ecfb/src/engine_c.c:905:10: error: use of unknown builtin '__builtin_ppc_mftb' [-Wimplicit-function-declaration]
  return __rdtsc();

OpenBSD uses clang on powerpc, __builtin_ppc_mftb() is a gcc-ism. As such i'm proposing to add posix timings on systems that support it, not only this is more portable, but would allow more architectures to use it; this is how retroarch does it for example.

It can't be extended as-is to x86 because __rtsdc() is a native builtin, the #define should be renamed to do so, which would require a more intrusive patch.

cc @rapenne-s