diff options
author | 2016-05-25 19:16:01 +0200 | |
---|---|---|
committer | 2016-05-27 01:17:39 +0200 | |
commit | 111c5a3dc080a4d454dbcadb6c211ccf2c749da7 (patch) | |
tree | 8a9ce93270d003414d398a0c8d7dd55882feae1f /src/lib/netlist/plib/pconfig.h | |
parent | 0522e44d2f0aa36e7225e44cfd63a8371019c31b (diff) |
Remove dependency on osd_ticks. Converted palloc and friends into
templates. First effort on a separate plib namespace. (nw)
Diffstat (limited to 'src/lib/netlist/plib/pconfig.h')
-rw-r--r-- | src/lib/netlist/plib/pconfig.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/netlist/plib/pconfig.h b/src/lib/netlist/plib/pconfig.h index 82c71c2f2a8..787bcede422 100644 --- a/src/lib/netlist/plib/pconfig.h +++ b/src/lib/netlist/plib/pconfig.h @@ -9,6 +9,8 @@ #define PCONFIG_H_ #include <cstdint> +#include <thread> +#include <chrono> #ifndef PSTANDALONE #define PSTANDALONE (0) @@ -25,6 +27,8 @@ typedef __uint128_t UINT128; typedef __int128_t INT128; #endif +#define PLIB_NAMESPACE_START() namespace plib { +#define PLIB_NAMESPACE_END() } #if !(PSTANDALONE) #include "osdcomm.h" @@ -135,6 +139,29 @@ typedef int64_t INT64; #endif +using pticks_t = INT64; + +inline pticks_t pticks() +{ + return std::chrono::high_resolution_clock::now().time_since_epoch().count(); +} +inline pticks_t pticks_per_second() +{ + return std::chrono::high_resolution_clock::period::den / std::chrono::high_resolution_clock::period::num; +} + +#if 1 && defined(__x86_64__) + +static inline pticks_t pprofile_ticks() +{ + unsigned hi, lo; + __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); + return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); +} +#else +inline pticks_t pprofile_ticks() { return pticks(); } +#endif + /* * The following class was derived from the MAME delegate.h code. * It derives a pointer to a member function. |