@@ -6,7 +6,7 @@ use std::{convert::TryInto, iter};
6
6
use rustc_hir:: def_id:: DefId ;
7
7
use rustc:: mir;
8
8
use rustc:: ty;
9
- use rustc:: ty:: layout:: { Align , LayoutOf , Size } ;
9
+ use rustc:: ty:: layout:: { Align , Size } ;
10
10
use rustc_apfloat:: Float ;
11
11
use rustc_span:: symbol:: sym;
12
12
use syntax:: attr;
@@ -192,7 +192,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
192
192
dest : PlaceTy < ' tcx , Tag > ,
193
193
) -> InterpResult < ' tcx > {
194
194
let this = self . eval_context_mut ( ) ;
195
- let tcx = & { this. tcx . tcx } ;
196
195
197
196
match link_name {
198
197
"malloc" => {
@@ -487,115 +486,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
487
486
this. write_null ( dest) ?;
488
487
}
489
488
490
- // Hook pthread calls that go to the thread-local storage memory subsystem.
491
- "pthread_key_create" => {
492
- let key_place = this. deref_operand ( args[ 0 ] ) ?;
493
-
494
- // Extract the function type out of the signature (that seems easier than constructing it ourselves).
495
- let dtor = match this. test_null ( this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?) ? {
496
- Some ( dtor_ptr) => Some ( this. memory . get_fn ( dtor_ptr) ?. as_instance ( ) ?) ,
497
- None => None ,
498
- } ;
499
-
500
- // Figure out how large a pthread TLS key actually is.
501
- // This is `libc::pthread_key_t`.
502
- let key_type = args[ 0 ] . layout . ty
503
- . builtin_deref ( true )
504
- . ok_or_else ( || err_ub_format ! (
505
- "wrong signature used for `pthread_key_create`: first argument must be a raw pointer."
506
- ) ) ?
507
- . ty ;
508
- let key_layout = this. layout_of ( key_type) ?;
509
-
510
- // Create key and write it into the memory where `key_ptr` wants it.
511
- let key = this. machine . tls . create_tls_key ( dtor) as u128 ;
512
- if key_layout. size . bits ( ) < 128 && key >= ( 1u128 << key_layout. size . bits ( ) as u128 )
513
- {
514
- throw_unsup ! ( OutOfTls ) ;
515
- }
516
-
517
- this. write_scalar ( Scalar :: from_uint ( key, key_layout. size ) , key_place. into ( ) ) ?;
518
-
519
- // Return success (`0`).
520
- this. write_null ( dest) ?;
521
- }
522
- "pthread_key_delete" => {
523
- let key = this. read_scalar ( args[ 0 ] ) ?. to_bits ( args[ 0 ] . layout . size ) ?;
524
- this. machine . tls . delete_tls_key ( key) ?;
525
- // Return success (0)
526
- this. write_null ( dest) ?;
527
- }
528
- "pthread_getspecific" => {
529
- let key = this. read_scalar ( args[ 0 ] ) ?. to_bits ( args[ 0 ] . layout . size ) ?;
530
- let ptr = this. machine . tls . load_tls ( key, tcx) ?;
531
- this. write_scalar ( ptr, dest) ?;
532
- }
533
- "pthread_setspecific" => {
534
- let key = this. read_scalar ( args[ 0 ] ) ?. to_bits ( args[ 0 ] . layout . size ) ?;
535
- let new_ptr = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
536
- this. machine . tls . store_tls ( key, this. test_null ( new_ptr) ?) ?;
537
-
538
- // Return success (`0`).
539
- this. write_null ( dest) ?;
540
- }
541
-
542
- // Stack size/address stuff.
543
- | "pthread_attr_init"
544
- | "pthread_attr_destroy"
545
- | "pthread_self"
546
- | "pthread_attr_setstacksize" => {
547
- this. write_null ( dest) ?;
548
- }
549
- "pthread_attr_getstack" => {
550
- let addr_place = this. deref_operand ( args[ 1 ] ) ?;
551
- let size_place = this. deref_operand ( args[ 2 ] ) ?;
552
-
553
- this. write_scalar (
554
- Scalar :: from_uint ( STACK_ADDR , addr_place. layout . size ) ,
555
- addr_place. into ( ) ,
556
- ) ?;
557
- this. write_scalar (
558
- Scalar :: from_uint ( STACK_SIZE , size_place. layout . size ) ,
559
- size_place. into ( ) ,
560
- ) ?;
561
-
562
- // Return success (`0`).
563
- this. write_null ( dest) ?;
564
- }
565
-
566
- // We don't support threading. (Also for Windows.)
567
- | "pthread_create"
568
- | "CreateThread"
569
- => {
570
- throw_unsup_format ! ( "Miri does not support threading" ) ;
571
- }
572
-
573
- // Stub out calls for condvar, mutex and rwlock, to just return `0`.
574
- | "pthread_mutexattr_init"
575
- | "pthread_mutexattr_settype"
576
- | "pthread_mutex_init"
577
- | "pthread_mutexattr_destroy"
578
- | "pthread_mutex_lock"
579
- | "pthread_mutex_unlock"
580
- | "pthread_mutex_destroy"
581
- | "pthread_rwlock_rdlock"
582
- | "pthread_rwlock_unlock"
583
- | "pthread_rwlock_wrlock"
584
- | "pthread_rwlock_destroy"
585
- | "pthread_condattr_init"
586
- | "pthread_condattr_setclock"
587
- | "pthread_cond_init"
588
- | "pthread_condattr_destroy"
589
- | "pthread_cond_destroy"
590
- => {
591
- this. write_null ( dest) ?;
592
- }
593
-
594
- // We don't support fork so we don't have to do anything for atfork.
595
- "pthread_atfork" => {
596
- this. write_null ( dest) ?;
597
- }
598
-
599
489
"posix_fadvise" => {
600
490
// fadvise is only informational, we can ignore it.
601
491
this. write_null ( dest) ?;
0 commit comments