source: libcfa/src/concurrency/kernel/fwd.hfa @ e660761

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since e660761 was e660761, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

First attempt at reducing complation time by restructuring the code.
Notably, starting the runtime has been moved to kernel/startup.cfa

  • Property mode set to 100644
File size: 2.5 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2020 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// kernel/fwd.hfa --
8//
9// Author           : Thierry Delisle
10// Created On       : Thu Jul 30 16:46:41 2020
11// Last Modified By :
12// Last Modified On :
13// Update Count     :
14//
15
16#include "bits/defs.hfa"
17#include "bits/debug.hfa"
18
19#if !defined(__cforall_thread__)
20#error non-thread source file includes kernel/fwd.hfa
21#endif
22
23struct $thread;
24struct processor;
25struct cluster;
26
27#ifdef __cforall
28extern "C" {
29      extern "Cforall" {
30                extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
31                        struct $thread    * volatile this_thread;
32                        struct processor  * volatile this_processor;
33                        struct __stats_t  * volatile this_stats;
34
35                        struct {
36                                volatile unsigned short disable_count;
37                                volatile bool enabled;
38                                volatile bool in_progress;
39                        } preemption_state;
40
41                        #if defined(__SIZEOF_INT128__)
42                                __uint128_t rand_seed;
43                        #else
44                                uint64_t rand_seed;
45                        #endif
46                } kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
47        }
48
49      #ifdef __ARM_ARCH
50            // function prototypes are only really used by these macros on ARM
51            void disable_global_interrupts();
52            void enable_global_interrupts();
53
54            #define TL_GET( member ) ( { __typeof__( kernelTLS.member ) target; \
55                  disable_global_interrupts(); \
56                  target = kernelTLS.member; \
57                  enable_global_interrupts(); \
58                  target; } )
59            #define TL_SET( member, value ) disable_global_interrupts(); \
60                  kernelTLS.member = value; \
61                  enable_global_interrupts();
62      #else
63            #define TL_GET( member ) kernelTLS.member
64            #define TL_SET( member, value ) kernelTLS.member = value;
65      #endif
66
67      extern void disable_interrupts();
68      extern void enable_interrupts_noPoll();
69        extern void enable_interrupts( __cfaabi_dbg_ctx_param );
70
71        enum __Preemption_Reason { __NO_PREEMPTION, __ALARM_PREEMPTION, __POLL_PREEMPTION, __MANUAL_PREEMPTION };
72
73      extern "Cforall" {
74            extern void park( __cfaabi_dbg_ctx_param );
75            extern void unpark( struct $thread * this __cfaabi_dbg_ctx_param2 );
76            static inline struct $thread * active_thread () { return TL_GET( this_thread ); }
77
78            extern bool force_yield( enum __Preemption_Reason );
79      }
80}
81#endif
Note: See TracBrowser for help on using the repository browser.