@@ -702,163 +702,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
702
702
this. write_null ( dest) ?;
703
703
}
704
704
705
- // macOS API stubs.
706
- | "pthread_attr_get_np"
707
- | "pthread_getattr_np"
708
- => {
709
- this. write_null ( dest) ?;
710
- }
711
- "pthread_get_stackaddr_np" => {
712
- let stack_addr = Scalar :: from_uint ( STACK_ADDR , dest. layout . size ) ;
713
- this. write_scalar ( stack_addr, dest) ?;
714
- }
715
- "pthread_get_stacksize_np" => {
716
- let stack_size = Scalar :: from_uint ( STACK_SIZE , dest. layout . size ) ;
717
- this. write_scalar ( stack_size, dest) ?;
718
- }
719
- "_tlv_atexit" => {
720
- // FIXME: register the destructor.
721
- }
722
- "_NSGetArgc" => {
723
- this. write_scalar ( this. machine . argc . expect ( "machine must be initialized" ) , dest) ?;
724
- }
725
- "_NSGetArgv" => {
726
- this. write_scalar ( this. machine . argv . expect ( "machine must be initialized" ) , dest) ?;
727
- }
728
- "SecRandomCopyBytes" => {
729
- let len = this. read_scalar ( args[ 1 ] ) ?. to_machine_usize ( this) ?;
730
- let ptr = this. read_scalar ( args[ 2 ] ) ?. not_undef ( ) ?;
731
- this. gen_random ( ptr, len as usize ) ?;
732
- this. write_null ( dest) ?;
733
- }
734
-
735
- // Windows API stubs.
736
- // HANDLE = isize
737
- // DWORD = ULONG = u32
738
- // BOOL = i32
739
- "GetProcessHeap" => {
740
- // Just fake a HANDLE
741
- this. write_scalar ( Scalar :: from_int ( 1 , this. pointer_size ( ) ) , dest) ?;
742
- }
743
- "HeapAlloc" => {
744
- let _handle = this. read_scalar ( args[ 0 ] ) ?. to_machine_isize ( this) ?;
745
- let flags = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
746
- let size = this. read_scalar ( args[ 2 ] ) ?. to_machine_usize ( this) ?;
747
- let zero_init = ( flags & 0x00000008 ) != 0 ; // HEAP_ZERO_MEMORY
748
- let res = this. malloc ( size, zero_init, MiriMemoryKind :: WinHeap ) ;
749
- this. write_scalar ( res, dest) ?;
750
- }
751
- "HeapFree" => {
752
- let _handle = this. read_scalar ( args[ 0 ] ) ?. to_machine_isize ( this) ?;
753
- let _flags = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
754
- let ptr = this. read_scalar ( args[ 2 ] ) ?. not_undef ( ) ?;
755
- this. free ( ptr, MiriMemoryKind :: WinHeap ) ?;
756
- this. write_scalar ( Scalar :: from_int ( 1 , Size :: from_bytes ( 4 ) ) , dest) ?;
757
- }
758
- "HeapReAlloc" => {
759
- let _handle = this. read_scalar ( args[ 0 ] ) ?. to_machine_isize ( this) ?;
760
- let _flags = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
761
- let ptr = this. read_scalar ( args[ 2 ] ) ?. not_undef ( ) ?;
762
- let size = this. read_scalar ( args[ 3 ] ) ?. to_machine_usize ( this) ?;
763
- let res = this. realloc ( ptr, size, MiriMemoryKind :: WinHeap ) ?;
764
- this. write_scalar ( res, dest) ?;
765
- }
766
-
767
- "SetLastError" => {
768
- this. set_last_error ( this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?) ?;
769
- }
770
- "GetLastError" => {
771
- let last_error = this. get_last_error ( ) ?;
772
- this. write_scalar ( last_error, dest) ?;
773
- }
774
-
775
- "AddVectoredExceptionHandler" => {
776
- // Any non zero value works for the stdlib. This is just used for stack overflows anyway.
777
- this. write_scalar ( Scalar :: from_int ( 1 , dest. layout . size ) , dest) ?;
778
- }
779
-
780
- | "InitializeCriticalSection"
781
- | "EnterCriticalSection"
782
- | "LeaveCriticalSection"
783
- | "DeleteCriticalSection"
784
- => {
785
- // Nothing to do, not even a return value.
786
- }
787
-
788
- | "GetModuleHandleW"
789
- | "GetProcAddress"
790
- | "TryEnterCriticalSection"
791
- | "GetConsoleScreenBufferInfo"
792
- | "SetConsoleTextAttribute"
793
- => {
794
- // Pretend these do not exist / nothing happened, by returning zero.
795
- this. write_null ( dest) ?;
796
- }
797
-
798
- "GetSystemInfo" => {
799
- let system_info = this. deref_operand ( args[ 0 ] ) ?;
800
- // Initialize with `0`.
801
- this. memory . write_bytes (
802
- system_info. ptr ,
803
- iter:: repeat ( 0u8 ) . take ( system_info. layout . size . bytes ( ) as usize ) ,
804
- ) ?;
805
- // Set number of processors.
806
- let dword_size = Size :: from_bytes ( 4 ) ;
807
- let num_cpus = this. mplace_field ( system_info, 6 ) ?;
808
- this. write_scalar ( Scalar :: from_int ( NUM_CPUS , dword_size) , num_cpus. into ( ) ) ?;
809
- }
810
-
811
- "TlsAlloc" => {
812
- // This just creates a key; Windows does not natively support TLS destructors.
813
-
814
- // Create key and return it.
815
- let key = this. machine . tls . create_tls_key ( None ) as u128 ;
816
-
817
- // Figure out how large a TLS key actually is. This is `c::DWORD`.
818
- if dest. layout . size . bits ( ) < 128
819
- && key >= ( 1u128 << dest. layout . size . bits ( ) as u128 )
820
- {
821
- throw_unsup ! ( OutOfTls ) ;
822
- }
823
- this. write_scalar ( Scalar :: from_uint ( key, dest. layout . size ) , dest) ?;
824
- }
825
- "TlsGetValue" => {
826
- let key = this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ? as u128 ;
827
- let ptr = this. machine . tls . load_tls ( key, tcx) ?;
828
- this. write_scalar ( ptr, dest) ?;
829
- }
830
- "TlsSetValue" => {
831
- let key = this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ? as u128 ;
832
- let new_ptr = this. read_scalar ( args[ 1 ] ) ?. not_undef ( ) ?;
833
- this. machine . tls . store_tls ( key, this. test_null ( new_ptr) ?) ?;
834
-
835
- // Return success (`1`).
836
- this. write_scalar ( Scalar :: from_int ( 1 , dest. layout . size ) , dest) ?;
837
- }
838
- "GetStdHandle" => {
839
- let which = this. read_scalar ( args[ 0 ] ) ?. to_i32 ( ) ?;
840
- // We just make this the identity function, so we know later in `WriteFile`
841
- // which one it is.
842
- this. write_scalar ( Scalar :: from_int ( which, this. pointer_size ( ) ) , dest) ?;
843
- }
844
- "GetConsoleMode" => {
845
- // Everything is a pipe.
846
- this. write_null ( dest) ?;
847
- }
848
- "GetCommandLineW" => {
849
- this. write_scalar (
850
- this. machine . cmd_line . expect ( "machine must be initialized" ) ,
851
- dest,
852
- ) ?;
853
- }
854
- // The actual name of 'RtlGenRandom'
855
- "SystemFunction036" => {
856
- let ptr = this. read_scalar ( args[ 0 ] ) ?. not_undef ( ) ?;
857
- let len = this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?;
858
- this. gen_random ( ptr, len as usize ) ?;
859
- this. write_scalar ( Scalar :: from_bool ( true ) , dest) ?;
860
- }
861
-
862
705
_ => match this. tcx . sess . target . target . target_os . to_lowercase ( ) . as_str ( ) {
863
706
"linux" | "macos" => posix:: EvalContextExt :: emulate_foreign_item_by_name ( this, link_name, args, dest) ?,
864
707
"windows" => windows:: EvalContextExt :: emulate_foreign_item_by_name ( this, link_name, args, dest) ?,
0 commit comments