| 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 -- 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 ***
|
|---|
| 11 | //
|
|---|
| 12 | // Author : Thierry Delisle
|
|---|
| 13 | // Created On : Thu Nov 9 13:24:10 2017
|
|---|
| 14 | // Last Modified By : Peter A. Buhr
|
|---|
| 15 | // Last Modified On : Sat Jul 4 15:04:20 2026
|
|---|
| 16 | // Update Count : 26
|
|---|
| 17 | //
|
|---|
| 18 |
|
|---|
| 19 | #pragma once
|
|---|
| 20 |
|
|---|
| 21 | #include <stdint.h>
|
|---|
| 22 | #include <assert.h>
|
|---|
| 23 |
|
|---|
| 24 | #define likely(x) __builtin_expect(!!(x), 1)
|
|---|
| 25 | #define unlikely(x) __builtin_expect(!!(x), 0)
|
|---|
| 26 |
|
|---|
| 27 | typedef void (* fptr_t)();
|
|---|
| 28 | typedef int_fast16_t __lock_size_t;
|
|---|
| 29 |
|
|---|
| 30 | #ifdef __cforall
|
|---|
| 31 | #define __cfa_anonymous_object(x) inline struct x
|
|---|
| 32 | #else
|
|---|
| 33 | #define __cfa_anonymous_object(x) struct x __cfa_anonymous_object
|
|---|
| 34 | #endif
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | #if defined(__has_attribute)
|
|---|
| 38 | #if !__has_attribute(__noclone__)
|
|---|
| 39 | #define ATTRIBUTE_NOCLONE
|
|---|
| 40 | #endif
|
|---|
| 41 | #endif
|
|---|
| 42 | #ifndef ATTRIBUTE_NOCLONE
|
|---|
| 43 | #define ATTRIBUTE_NOCLONE __attribute__((__noclone__))
|
|---|
| 44 | #endif
|
|---|
| 45 |
|
|---|
| 46 | #define libcfa_public __attribute__((visibility("default")))
|
|---|
| 47 | #define libcfa_nopreempt __attribute__((section("cfatext_nopreempt"))) __attribute__((__noinline__)) ATTRIBUTE_NOCLONE
|
|---|
| 48 |
|
|---|
| 49 | struct __cfa_nopreempt_region {
|
|---|
| 50 | void * start;
|
|---|
| 51 | void * stop;
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | #ifdef __cforall
|
|---|
| 55 | void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
|
|---|
| 56 | void abort( bool signalAbort, const char fmt[], ... ) __attribute__ (( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
|
|---|
| 57 | extern "C" {
|
|---|
| 58 | #endif
|
|---|
| 59 | void __cabi_abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
|
|---|
| 60 | #ifdef __cforall
|
|---|
| 61 | }
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | #if defined(__cforall_thread__)
|
|---|
| 65 | #define OPTIONAL_THREAD
|
|---|
| 66 | #else
|
|---|
| 67 | #define OPTIONAL_THREAD __attribute__((weak))
|
|---|
| 68 | #endif
|
|---|
| 69 |
|
|---|
| 70 | #define CFA_IO_LAZY (1_l64u << 32_l64u)
|
|---|