source: libcfa/src/bits/defs.hfa @ d685cb0

arm-ehjacob/cs343-translationnew-ast-unique-expr
Last change on this file since d685cb0 was d685cb0, checked in by Peter A. Buhr <pabuhr@…>, 16 months ago

add ARM equivalent for x86 rdtsc

  • Property mode set to 100644
File size: 1.8 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// defs.hfa --
8//
9// Author           : Thierry Delisle
10// Created On       : Thu Nov  9 13:24:10 2017
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Aug 13 22:00:23 2020
13// Update Count     : 19
14//
15
16#pragma once
17
18#include <stdint.h>
19#include <assert.h>
20
21#define likely(x)   __builtin_expect(!!(x), 1)
22#define unlikely(x) __builtin_expect(!!(x), 0)
23#define thread_local _Thread_local
24
25typedef void (*fptr_t)();
26typedef int_fast16_t __lock_size_t;
27
28#ifdef __cforall
29#define __cfa_anonymous_object(x) inline struct x
30#else
31#define __cfa_anonymous_object(x) x __cfa_anonymous_object
32#endif
33
34#ifdef __cforall
35void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
36void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
37extern "C" {
38#endif
39void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
40#ifdef __cforall
41}
42#endif
43
44#if defined(__cforall_thread__)
45#define OPTIONAL_THREAD
46#else
47#define OPTIONAL_THREAD __attribute__((weak))
48#endif
49
50static inline long long int rdtscl(void) {
51        #if defined( __aarch64__ )
52        // https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116
53        long long int virtual_timer_value;
54        asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
55        return virtual_timer_value;
56        #else
57        unsigned int lo, hi;
58        __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
59        return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
60        #endif // __ARM_ARCH
61}
Note: See TracBrowser for help on using the repository browser.