ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since d035cf7 was
d035cf7,
checked in by Thierry Delisle <tdelisle@…>, 3 years ago
|
Added first attempt at libfibre implementation
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | #pragma once |
---|
2 | |
---|
3 | #include <cassert> |
---|
4 | #include <libfibre/cfibre.h> |
---|
5 | |
---|
6 | #if defined(__cforall) || defined(__cpluplus) |
---|
7 | extern "C" { |
---|
8 | #endif |
---|
9 | //-------------------- |
---|
10 | // Basic types |
---|
11 | typedef cfibre_t thread_t; |
---|
12 | |
---|
13 | void * fibre_runner(void * arg) { |
---|
14 | auto the_main = (void (*)( thread_t ))arg; |
---|
15 | the_main( cfibre_self() ); |
---|
16 | return nullptr; |
---|
17 | } |
---|
18 | |
---|
19 | //-------------------- |
---|
20 | // Basic thread support |
---|
21 | thread_t thrdlib_create( void (*the_main)( thread_t ) ) { |
---|
22 | thread_t fibre; |
---|
23 | cfibre_create( &fibre, nullptr, fibre_runner, (void*)the_main ); |
---|
24 | return fibre; |
---|
25 | } |
---|
26 | |
---|
27 | void thrdlib_join( thread_t handle ) { |
---|
28 | cfibre_join( handle, nullptr ); |
---|
29 | } |
---|
30 | |
---|
31 | void thrdlib_park( thread_t handle ) { |
---|
32 | assert( handle == cfibre_self() ); |
---|
33 | cfibre_park(); |
---|
34 | } |
---|
35 | |
---|
36 | void thrdlib_unpark( thread_t handle ) { |
---|
37 | cfibre_unpark( handle ); |
---|
38 | } |
---|
39 | |
---|
40 | void thrdlib_yield( void ) { |
---|
41 | cfibre_yield(); |
---|
42 | } |
---|
43 | |
---|
44 | //-------------------- |
---|
45 | // Basic kernel features |
---|
46 | void thrdlib_init( int procs ) { |
---|
47 | cfibre_init_n(1, procs ); |
---|
48 | } |
---|
49 | |
---|
50 | void thrdlib_clean( void ) { |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | |
---|
55 | #if defined(__cforall) || defined(__cpluplus) |
---|
56 | } |
---|
57 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.