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

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since b0b89a8 was 82f4063, checked in by caparsons <caparson@…>, 3 years ago

switched unified locking to use dlist

  • Property mode set to 100644
File size: 2.5 KB
RevLine 
[3d5f2ef1]1//
[ea7d2b0]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.
[3d5f2ef1]6//
[454f478]7// defs.hfa -- Commen macros, functions and typedefs
8// Most files depend on them and they are always useful to have.
9//
10//  *** Must not contain code specific to libcfathread ***
[3d5f2ef1]11//
[ea7d2b0]12// Author           : Thierry Delisle
[490d9972]13// Created On       : Thu Nov  9 13:24:10 2017
14// Last Modified By : Peter A. Buhr
[c1076a2f]15// Last Modified On : Sat Oct 24 10:53:15 2020
16// Update Count     : 21
[3d5f2ef1]17//
[ea7d2b0]18
19#pragma once
20
21#include <stdint.h>
[d685cb0]22#include <assert.h>
[ea7d2b0]23
[490d9972]24#define likely(x)   __builtin_expect(!!(x), 1)
25#define unlikely(x) __builtin_expect(!!(x), 0)
[0cf5b79]26#define thread_local _Thread_local
27
28typedef void (*fptr_t)();
29typedef int_fast16_t __lock_size_t;
30
31#ifdef __cforall
[b1672e1]32#define __cfa_anonymous_object(x) inline struct x
[82f4063]33#define __cfa_dlink(x) inline dlink(x)
[0cf5b79]34#else
[8b73526]35#define __cfa_anonymous_object(x) struct x __cfa_anonymous_object
[82f4063]36#define __cfa_dlink(x) struct { struct x * next; struct x * back; } __dlink_substitute
[c2b9f21]37#endif
38
39#ifdef __cforall
[8a13c47]40void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
41void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
[c2b9f21]42extern "C" {
43#endif
[169d944]44void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
[c2b9f21]45#ifdef __cforall
46}
[490d9972]47#endif
[2026bb6]48
49#if defined(__cforall_thread__)
50#define OPTIONAL_THREAD
51#else
52#define OPTIONAL_THREAD __attribute__((weak))
53#endif
[21184e3]54
[d685cb0]55static inline long long int rdtscl(void) {
[98cf828]56        #if defined( __i386 ) || defined( __x86_64 )
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        #elif defined( __aarch64__ ) || defined( __arm__ )
[d685cb0]61        // https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116
62        long long int virtual_timer_value;
63        asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
64        return virtual_timer_value;
65        #else
[98cf828]66                #error unsupported hardware architecture
[c1076a2f]67        #endif
[21184e3]68}
[454f478]69
70// pause to prevent excess processor bus usage
71#if defined( __i386 ) || defined( __x86_64 )
72        #define Pause() __asm__ __volatile__ ( "pause" : : : )
73#elif defined( __ARM_ARCH )
74        #define Pause() __asm__ __volatile__ ( "YIELD" : : : )
75#else
76        #error unsupported architecture
77#endif
[dddb3dd0]78
79#define CFA_IO_LAZY (1_l64u << 32_l64u)
Note: See TracBrowser for help on using the repository browser.