1
1
/* Native builtins. */
2
2
3
3
#include " rust_internal.h"
4
- #include " rust_task_thread .h"
4
+ #include " rust_sched_loop .h"
5
5
#include " rust_task.h"
6
6
#include " rust_util.h"
7
7
#include " rust_scheduler.h"
@@ -22,7 +22,7 @@ extern char **environ;
22
22
23
23
extern " C" CDECL rust_str*
24
24
last_os_error () {
25
- rust_task *task = rust_task_thread ::get_task ();
25
+ rust_task *task = rust_sched_loop ::get_task ();
26
26
27
27
LOG (task, task, " last_os_error()" );
28
28
@@ -65,7 +65,7 @@ last_os_error() {
65
65
66
66
extern " C" CDECL rust_str *
67
67
rust_getcwd () {
68
- rust_task *task = rust_task_thread ::get_task ();
68
+ rust_task *task = rust_sched_loop ::get_task ();
69
69
LOG (task, task, " rust_getcwd()" );
70
70
71
71
char cbuf[BUF_BYTES];
@@ -85,7 +85,7 @@ rust_getcwd() {
85
85
#if defined(__WIN32__)
86
86
extern " C" CDECL rust_vec *
87
87
rust_env_pairs () {
88
- rust_task *task = rust_task_thread ::get_task ();
88
+ rust_task *task = rust_sched_loop ::get_task ();
89
89
size_t envc = 0 ;
90
90
LPTCH ch = GetEnvironmentStringsA ();
91
91
LPTCH c;
@@ -111,7 +111,7 @@ rust_env_pairs() {
111
111
#else
112
112
extern " C" CDECL rust_vec *
113
113
rust_env_pairs () {
114
- rust_task *task = rust_task_thread ::get_task ();
114
+ rust_task *task = rust_sched_loop ::get_task ();
115
115
#ifdef __APPLE__
116
116
char **environ = *_NSGetEnviron ();
117
117
#endif
@@ -133,21 +133,21 @@ refcount(intptr_t *v) {
133
133
134
134
extern " C" CDECL void
135
135
unsupervise () {
136
- rust_task *task = rust_task_thread ::get_task ();
136
+ rust_task *task = rust_sched_loop ::get_task ();
137
137
task->unsupervise ();
138
138
}
139
139
140
140
extern " C" CDECL void
141
141
vec_reserve_shared (type_desc* ty, rust_vec** vp,
142
142
size_t n_elts) {
143
- rust_task *task = rust_task_thread ::get_task ();
143
+ rust_task *task = rust_sched_loop ::get_task ();
144
144
reserve_vec_exact (task, vp, n_elts * ty->size );
145
145
}
146
146
147
147
extern " C" CDECL void
148
148
str_reserve_shared (rust_vec** sp,
149
149
size_t n_elts) {
150
- rust_task *task = rust_task_thread ::get_task ();
150
+ rust_task *task = rust_sched_loop ::get_task ();
151
151
reserve_vec_exact (task, sp, n_elts + 1 );
152
152
}
153
153
@@ -157,7 +157,7 @@ str_reserve_shared(rust_vec** sp,
157
157
*/
158
158
extern " C" CDECL rust_vec*
159
159
vec_from_buf_shared (type_desc *ty, void *ptr, size_t count) {
160
- rust_task *task = rust_task_thread ::get_task ();
160
+ rust_task *task = rust_sched_loop ::get_task ();
161
161
size_t fill = ty->size * count;
162
162
rust_vec* v = (rust_vec*)task->kernel ->malloc (fill + sizeof (rust_vec),
163
163
" vec_from_buf" );
@@ -168,7 +168,7 @@ vec_from_buf_shared(type_desc *ty, void *ptr, size_t count) {
168
168
169
169
extern " C" CDECL void
170
170
rust_str_push (rust_vec** sp, uint8_t byte) {
171
- rust_task *task = rust_task_thread ::get_task ();
171
+ rust_task *task = rust_sched_loop ::get_task ();
172
172
size_t fill = (*sp)->fill ;
173
173
reserve_vec (task, sp, fill + 1 );
174
174
(*sp)->data [fill-1 ] = byte;
@@ -178,8 +178,8 @@ rust_str_push(rust_vec** sp, uint8_t byte) {
178
178
179
179
extern " C" CDECL void *
180
180
rand_new () {
181
- rust_task *task = rust_task_thread ::get_task ();
182
- rust_task_thread *thread = task->thread ;
181
+ rust_task *task = rust_sched_loop ::get_task ();
182
+ rust_sched_loop *thread = task->sched_loop ;
183
183
randctx *rctx = (randctx *) task->malloc (sizeof (randctx), " randctx" );
184
184
if (!rctx) {
185
185
task->fail ();
@@ -196,7 +196,7 @@ rand_next(randctx *rctx) {
196
196
197
197
extern " C" CDECL void
198
198
rand_free (randctx *rctx) {
199
- rust_task *task = rust_task_thread ::get_task ();
199
+ rust_task *task = rust_sched_loop ::get_task ();
200
200
task->free (rctx);
201
201
}
202
202
@@ -242,22 +242,22 @@ debug_abi_2(floats f) {
242
242
static void
243
243
debug_tydesc_helper (type_desc *t)
244
244
{
245
- rust_task *task = rust_task_thread ::get_task ();
245
+ rust_task *task = rust_sched_loop ::get_task ();
246
246
LOG (task, stdlib, " size %" PRIdPTR " , align %" PRIdPTR
247
247
" , first_param 0x%" PRIxPTR,
248
248
t->size , t->align , t->first_param );
249
249
}
250
250
251
251
extern " C" CDECL void
252
252
debug_tydesc (type_desc *t) {
253
- rust_task *task = rust_task_thread ::get_task ();
253
+ rust_task *task = rust_sched_loop ::get_task ();
254
254
LOG (task, stdlib, " debug_tydesc" );
255
255
debug_tydesc_helper (t);
256
256
}
257
257
258
258
extern " C" CDECL void
259
259
debug_opaque (type_desc *t, uint8_t *front) {
260
- rust_task *task = rust_task_thread ::get_task ();
260
+ rust_task *task = rust_sched_loop ::get_task ();
261
261
LOG (task, stdlib, " debug_opaque" );
262
262
debug_tydesc_helper (t);
263
263
// FIXME may want to actually account for alignment. `front` may not
@@ -277,7 +277,7 @@ struct rust_box {
277
277
278
278
extern " C" CDECL void
279
279
debug_box (type_desc *t, rust_box *box) {
280
- rust_task *task = rust_task_thread ::get_task ();
280
+ rust_task *task = rust_sched_loop ::get_task ();
281
281
LOG (task, stdlib, " debug_box(0x%" PRIxPTR " )" , box);
282
282
debug_tydesc_helper (t);
283
283
LOG (task, stdlib, " refcount %" PRIdPTR,
@@ -294,7 +294,7 @@ struct rust_tag {
294
294
295
295
extern " C" CDECL void
296
296
debug_tag (type_desc *t, rust_tag *tag) {
297
- rust_task *task = rust_task_thread ::get_task ();
297
+ rust_task *task = rust_sched_loop ::get_task ();
298
298
299
299
LOG (task, stdlib, " debug_tag" );
300
300
debug_tydesc_helper (t);
@@ -312,7 +312,7 @@ struct rust_fn {
312
312
313
313
extern " C" CDECL void
314
314
debug_fn (type_desc *t, rust_fn *fn) {
315
- rust_task *task = rust_task_thread ::get_task ();
315
+ rust_task *task = rust_sched_loop ::get_task ();
316
316
LOG (task, stdlib, " debug_fn" );
317
317
debug_tydesc_helper (t);
318
318
LOG (task, stdlib, " thunk at 0x%" PRIxPTR, fn->thunk );
@@ -326,7 +326,7 @@ extern "C" CDECL void *
326
326
debug_ptrcast (type_desc *from_ty,
327
327
type_desc *to_ty,
328
328
void *ptr) {
329
- rust_task *task = rust_task_thread ::get_task ();
329
+ rust_task *task = rust_sched_loop ::get_task ();
330
330
LOG (task, stdlib, " debug_ptrcast from" );
331
331
debug_tydesc_helper (from_ty);
332
332
LOG (task, stdlib, " to" );
@@ -336,13 +336,13 @@ debug_ptrcast(type_desc *from_ty,
336
336
337
337
extern " C" CDECL void *
338
338
debug_get_stk_seg () {
339
- rust_task *task = rust_task_thread ::get_task ();
339
+ rust_task *task = rust_sched_loop ::get_task ();
340
340
return task->stk ;
341
341
}
342
342
343
343
extern " C" CDECL rust_vec*
344
344
rust_list_files (rust_str *path) {
345
- rust_task *task = rust_task_thread ::get_task ();
345
+ rust_task *task = rust_sched_loop ::get_task ();
346
346
array_list<rust_str*> strings;
347
347
#if defined(__WIN32__)
348
348
WIN32_FIND_DATA FindFileData;
@@ -443,21 +443,21 @@ precise_time_ns(uint64_t *ns) {
443
443
444
444
extern " C" CDECL rust_sched_id
445
445
rust_get_sched_id () {
446
- rust_task *task = rust_task_thread ::get_task ();
446
+ rust_task *task = rust_sched_loop ::get_task ();
447
447
return task->sched ->get_id ();
448
448
}
449
449
450
450
extern " C" CDECL rust_sched_id
451
451
rust_new_sched (uintptr_t threads) {
452
- rust_task *task = rust_task_thread ::get_task ();
453
- A (task->thread , threads > 0 ,
452
+ rust_task *task = rust_sched_loop ::get_task ();
453
+ A (task->sched_loop , threads > 0 ,
454
454
" Can't create a scheduler with no threads, silly!" );
455
455
return task->kernel ->create_scheduler (threads);
456
456
}
457
457
458
458
extern " C" CDECL rust_task_id
459
459
get_task_id () {
460
- rust_task *task = rust_task_thread ::get_task ();
460
+ rust_task *task = rust_sched_loop ::get_task ();
461
461
return task->id ;
462
462
}
463
463
@@ -468,13 +468,13 @@ new_task_common(rust_scheduler *sched, rust_task *parent) {
468
468
469
469
extern " C" CDECL rust_task*
470
470
new_task () {
471
- rust_task *task = rust_task_thread ::get_task ();
471
+ rust_task *task = rust_sched_loop ::get_task ();
472
472
return new_task_common (task->sched , task);
473
473
}
474
474
475
475
extern " C" CDECL rust_task*
476
476
rust_new_task_in_sched (rust_sched_id id) {
477
- rust_task *task = rust_task_thread ::get_task ();
477
+ rust_task *task = rust_sched_loop ::get_task ();
478
478
rust_scheduler *sched = task->kernel ->get_scheduler_by_id (id);
479
479
// FIXME: What if we didn't get the scheduler?
480
480
return new_task_common (sched, task);
@@ -487,7 +487,7 @@ rust_task_config_notify(rust_task *target, rust_port_id *port) {
487
487
488
488
extern " C" rust_task *
489
489
rust_get_task () {
490
- return rust_task_thread ::get_task ();
490
+ return rust_sched_loop ::get_task ();
491
491
}
492
492
493
493
extern " C" CDECL void
@@ -497,13 +497,13 @@ start_task(rust_task *target, fn_env_pair *f) {
497
497
498
498
extern " C" CDECL int
499
499
sched_threads () {
500
- rust_task *task = rust_task_thread ::get_task ();
500
+ rust_task *task = rust_sched_loop ::get_task ();
501
501
return task->sched ->number_of_threads ();
502
502
}
503
503
504
504
extern " C" CDECL rust_port*
505
505
new_port (size_t unit_sz) {
506
- rust_task *task = rust_task_thread ::get_task ();
506
+ rust_task *task = rust_sched_loop ::get_task ();
507
507
LOG (task, comm, " new_port(task=0x%" PRIxPTR " (%s), unit_sz=%d)" ,
508
508
(uintptr_t ) task, task->name , unit_sz);
509
509
// port starts with refcount == 1
@@ -512,7 +512,7 @@ new_port(size_t unit_sz) {
512
512
513
513
extern " C" CDECL void
514
514
rust_port_begin_detach (rust_port *port, uintptr_t *yield) {
515
- rust_task *task = rust_task_thread ::get_task ();
515
+ rust_task *task = rust_sched_loop ::get_task ();
516
516
LOG (task, comm, " rust_port_detach(0x%" PRIxPTR " )" , (uintptr_t ) port);
517
517
port->begin_detach (yield);
518
518
}
@@ -524,7 +524,7 @@ rust_port_end_detach(rust_port *port) {
524
524
525
525
extern " C" CDECL void
526
526
del_port (rust_port *port) {
527
- rust_task *task = rust_task_thread ::get_task ();
527
+ rust_task *task = rust_sched_loop ::get_task ();
528
528
LOG (task, comm, " del_port(0x%" PRIxPTR " )" , (uintptr_t ) port);
529
529
delete port;
530
530
}
@@ -542,7 +542,7 @@ get_port_id(rust_port *port) {
542
542
extern " C" CDECL uintptr_t
543
543
rust_port_id_send (type_desc *t, rust_port_id target_port_id, void *sptr) {
544
544
bool sent = false ;
545
- rust_task *task = rust_task_thread ::get_task ();
545
+ rust_task *task = rust_sched_loop ::get_task ();
546
546
547
547
LOG (task, comm, " rust_port_id*_send port: 0x%" PRIxPTR,
548
548
(uintptr_t ) target_port_id);
@@ -573,14 +573,14 @@ port_recv(uintptr_t *dptr, rust_port *port, uintptr_t *yield) {
573
573
extern " C" CDECL void
574
574
rust_port_select (rust_port **dptr, rust_port **ports,
575
575
size_t n_ports, uintptr_t *yield) {
576
- rust_task *task = rust_task_thread ::get_task ();
576
+ rust_task *task = rust_sched_loop ::get_task ();
577
577
rust_port_selector *selector = task->get_port_selector ();
578
578
selector->select (task, dptr, ports, n_ports, yield);
579
579
}
580
580
581
581
extern " C" CDECL void
582
582
rust_set_exit_status (intptr_t code) {
583
- rust_task *task = rust_task_thread ::get_task ();
583
+ rust_task *task = rust_sched_loop ::get_task ();
584
584
task->kernel ->set_exit_status ((int )code);
585
585
}
586
586
@@ -595,7 +595,7 @@ extern void log_console_off(rust_env *env);
595
595
596
596
extern " C" CDECL void
597
597
rust_log_console_off () {
598
- rust_task *task = rust_task_thread ::get_task ();
598
+ rust_task *task = rust_sched_loop ::get_task ();
599
599
log_console_off (task->kernel ->env );
600
600
}
601
601
@@ -606,36 +606,36 @@ rust_dbg_lock_create() {
606
606
607
607
extern " C" CDECL void
608
608
rust_dbg_lock_destroy (lock_and_signal *lock) {
609
- rust_task *task = rust_task_thread ::get_task ();
610
- I (task->thread , lock);
609
+ rust_task *task = rust_sched_loop ::get_task ();
610
+ I (task->sched_loop , lock);
611
611
delete lock;
612
612
}
613
613
614
614
extern " C" CDECL void
615
615
rust_dbg_lock_lock (lock_and_signal *lock) {
616
- rust_task *task = rust_task_thread ::get_task ();
617
- I (task->thread , lock);
616
+ rust_task *task = rust_sched_loop ::get_task ();
617
+ I (task->sched_loop , lock);
618
618
lock->lock ();
619
619
}
620
620
621
621
extern " C" CDECL void
622
622
rust_dbg_lock_unlock (lock_and_signal *lock) {
623
- rust_task *task = rust_task_thread ::get_task ();
624
- I (task->thread , lock);
623
+ rust_task *task = rust_sched_loop ::get_task ();
624
+ I (task->sched_loop , lock);
625
625
lock->unlock ();
626
626
}
627
627
628
628
extern " C" CDECL void
629
629
rust_dbg_lock_wait (lock_and_signal *lock) {
630
- rust_task *task = rust_task_thread ::get_task ();
631
- I (task->thread , lock);
630
+ rust_task *task = rust_sched_loop ::get_task ();
631
+ I (task->sched_loop , lock);
632
632
lock->wait ();
633
633
}
634
634
635
635
extern " C" CDECL void
636
636
rust_dbg_lock_signal (lock_and_signal *lock) {
637
- rust_task *task = rust_task_thread ::get_task ();
638
- I (task->thread , lock);
637
+ rust_task *task = rust_sched_loop ::get_task ();
638
+ I (task->sched_loop , lock);
639
639
lock->signal ();
640
640
}
641
641
0 commit comments