source: libcfa/src/bits/defs.hfa @ 0b84b15

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 0b84b15 was 98cf828, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

update ARM architecture code

  • Property mode set to 100644
File size: 1.9 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 : Wed Aug 26 16:22:32 2020
13// Update Count     : 20
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( __i386 ) || defined( __x86_64 )
52        unsigned int lo, hi;
53        __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
54        return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
55        #elif defined( __aarch64__ ) || defined( __arm__ )
56        // https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116
57        long long int virtual_timer_value;
58        asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
59        return virtual_timer_value;
60        #else
61                #error unsupported hardware architecture
62        #endif // __ARM_ARCH
63}
Note: See TracBrowser for help on using the repository browser.