@@ -68,11 +68,20 @@ fn mutexattr_set_kind<'mir, 'tcx: 'mir>(
6868// (the kind has to be at this particular offset for compatibility with Linux's static initializer
6969// macros, e.g. PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP.)
7070
71+ #[ inline]
72+ fn mutex_id_offset < ' mir , ' tcx : ' mir > ( ecx : & MiriInterpCx < ' mir , ' tcx > ) -> u64 {
73+ if matches ! ( & * ecx. tcx. sess. target. os, "macos" ) { 4 } else { 0 }
74+ }
75+
7176fn mutex_get_id < ' mir , ' tcx : ' mir > (
7277 ecx : & mut MiriInterpCx < ' mir , ' tcx > ,
7378 mutex_op : & OpTy < ' tcx , Provenance > ,
7479) -> InterpResult < ' tcx , MutexId > {
75- ecx. mutex_get_or_create_id ( mutex_op, ecx. libc_ty_layout ( "pthread_mutex_t" ) , 4 )
80+ ecx. mutex_get_or_create_id (
81+ mutex_op,
82+ ecx. libc_ty_layout ( "pthread_mutex_t" ) ,
83+ mutex_id_offset ( ecx) ,
84+ )
7685}
7786
7887fn mutex_reset_id < ' mir , ' tcx : ' mir > (
@@ -81,7 +90,7 @@ fn mutex_reset_id<'mir, 'tcx: 'mir>(
8190) -> InterpResult < ' tcx , ( ) > {
8291 ecx. deref_pointer_and_write (
8392 mutex_op,
84- 4 ,
93+ mutex_id_offset ( ecx ) ,
8594 Scalar :: from_i32 ( 0 ) ,
8695 ecx. libc_ty_layout ( "pthread_mutex_t" ) ,
8796 ecx. machine . layouts . u32 ,
@@ -124,13 +133,20 @@ fn mutex_set_kind<'mir, 'tcx: 'mir>(
124133// (need to avoid this because it is set by static initializer macros)
125134// bytes 4-7: rwlock id as u32 or 0 if id is not assigned yet.
126135
127- const RWLOCK_ID_OFFSET : u64 = 4 ;
136+ #[ inline]
137+ fn rwlock_id_offset < ' mir , ' tcx : ' mir > ( ecx : & MiriInterpCx < ' mir , ' tcx > ) -> u64 {
138+ if matches ! ( & * ecx. tcx. sess. target. os, "macos" ) { 4 } else { 0 }
139+ }
128140
129141fn rwlock_get_id < ' mir , ' tcx : ' mir > (
130142 ecx : & mut MiriInterpCx < ' mir , ' tcx > ,
131143 rwlock_op : & OpTy < ' tcx , Provenance > ,
132144) -> InterpResult < ' tcx , RwLockId > {
133- ecx. rwlock_get_or_create_id ( rwlock_op, ecx. libc_ty_layout ( "pthread_rwlock_t" ) , RWLOCK_ID_OFFSET )
145+ ecx. rwlock_get_or_create_id (
146+ rwlock_op,
147+ ecx. libc_ty_layout ( "pthread_rwlock_t" ) ,
148+ rwlock_id_offset ( ecx) ,
149+ )
134150}
135151
136152// pthread_condattr_t
@@ -177,14 +193,18 @@ fn condattr_set_clock_id<'mir, 'tcx: 'mir>(
177193// bytes 4-7: the conditional variable id as u32 or 0 if id is not assigned yet.
178194// bytes 8-11: the clock id constant as i32
179195
180- const CONDVAR_ID_OFFSET : u64 = 4 ;
181196const CONDVAR_CLOCK_OFFSET : u64 = 8 ;
182197
198+ #[ inline]
199+ fn cond_id_offset < ' mir , ' tcx : ' mir > ( ecx : & MiriInterpCx < ' mir , ' tcx > ) -> u64 {
200+ if matches ! ( & * ecx. tcx. sess. target. os, "macos" ) { 4 } else { 0 }
201+ }
202+
183203fn cond_get_id < ' mir , ' tcx : ' mir > (
184204 ecx : & mut MiriInterpCx < ' mir , ' tcx > ,
185205 cond_op : & OpTy < ' tcx , Provenance > ,
186206) -> InterpResult < ' tcx , CondvarId > {
187- ecx. condvar_get_or_create_id ( cond_op, ecx. libc_ty_layout ( "pthread_cond_t" ) , CONDVAR_ID_OFFSET )
207+ ecx. condvar_get_or_create_id ( cond_op, ecx. libc_ty_layout ( "pthread_cond_t" ) , cond_id_offset ( ecx ) )
188208}
189209
190210fn cond_reset_id < ' mir , ' tcx : ' mir > (
@@ -193,7 +213,7 @@ fn cond_reset_id<'mir, 'tcx: 'mir>(
193213) -> InterpResult < ' tcx , ( ) > {
194214 ecx. deref_pointer_and_write (
195215 cond_op,
196- CONDVAR_ID_OFFSET ,
216+ cond_id_offset ( ecx ) ,
197217 Scalar :: from_i32 ( 0 ) ,
198218 ecx. libc_ty_layout ( "pthread_cond_t" ) ,
199219 ecx. machine . layouts . u32 ,
@@ -287,7 +307,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
287307 ) -> InterpResult < ' tcx , i32 > {
288308 let this = self . eval_context_mut ( ) ;
289309
290- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
310+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
291311 throw_unsup_format ! (
292312 "`pthread_mutexattr_init` is not supported on {}" ,
293313 this. tcx. sess. target. os
@@ -376,7 +396,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
376396 ) -> InterpResult < ' tcx , i32 > {
377397 let this = self . eval_context_mut ( ) ;
378398
379- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
399+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
380400 throw_unsup_format ! (
381401 "`pthread_mutex_init` is not supported on {}" ,
382402 this. tcx. sess. target. os
@@ -537,7 +557,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
537557 ) -> InterpResult < ' tcx , i32 > {
538558 let this = self . eval_context_mut ( ) ;
539559
540- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
560+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
541561 throw_unsup_format ! (
542562 "`pthread_rwlock_rdlock` is not supported on {}" ,
543563 this. tcx. sess. target. os
@@ -562,7 +582,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
562582 ) -> InterpResult < ' tcx , i32 > {
563583 let this = self . eval_context_mut ( ) ;
564584
565- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
585+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
566586 throw_unsup_format ! (
567587 "`pthread_rwlock_tryrdlock` is not supported on {}" ,
568588 this. tcx. sess. target. os
@@ -586,7 +606,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
586606 ) -> InterpResult < ' tcx , i32 > {
587607 let this = self . eval_context_mut ( ) ;
588608
589- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
609+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
590610 throw_unsup_format ! (
591611 "`pthread_rwlock_wrlock` is not supported on {}" ,
592612 this. tcx. sess. target. os
@@ -623,7 +643,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
623643 ) -> InterpResult < ' tcx , i32 > {
624644 let this = self . eval_context_mut ( ) ;
625645
626- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
646+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
627647 throw_unsup_format ! (
628648 "`pthread_rwlock_trywrlock` is not supported on {}" ,
629649 this. tcx. sess. target. os
@@ -647,7 +667,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
647667 ) -> InterpResult < ' tcx , i32 > {
648668 let this = self . eval_context_mut ( ) ;
649669
650- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
670+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
651671 throw_unsup_format ! (
652672 "`pthread_rwlock_unlock` is not supported on {}" ,
653673 this. tcx. sess. target. os
@@ -673,7 +693,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
673693 ) -> InterpResult < ' tcx , i32 > {
674694 let this = self . eval_context_mut ( ) ;
675695
676- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
696+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
677697 throw_unsup_format ! (
678698 "`pthread_rwlock_destroy` is not supported on {}" ,
679699 this. tcx. sess. target. os
@@ -704,7 +724,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
704724 ) -> InterpResult < ' tcx , i32 > {
705725 let this = self . eval_context_mut ( ) ;
706726
707- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
727+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
708728 throw_unsup_format ! (
709729 "`pthread_condattr_init` is not supported on {}" ,
710730 this. tcx. sess. target. os
@@ -728,9 +748,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
728748 let this = self . eval_context_mut ( ) ;
729749
730750 // Does not exist on macOS!
731- if !matches ! ( & * this. tcx. sess. target. os, "linux" ) {
751+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "solaris" | "illumos" ) {
732752 throw_unsup_format ! (
733- "`pthread_condattr_init ` is not supported on {}" ,
753+ "`pthread_condattr_setclock ` is not supported on {}" ,
734754 this. tcx. sess. target. os
735755 ) ;
736756 }
@@ -756,9 +776,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
756776 let this = self . eval_context_mut ( ) ;
757777
758778 // Does not exist on macOS!
759- if !matches ! ( & * this. tcx. sess. target. os, "linux" ) {
779+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "solaris" | "illumos" ) {
760780 throw_unsup_format ! (
761- "`pthread_condattr_init ` is not supported on {}" ,
781+ "`pthread_condattr_getclock ` is not supported on {}" ,
762782 this. tcx. sess. target. os
763783 ) ;
764784 }
@@ -793,7 +813,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
793813 ) -> InterpResult < ' tcx , i32 > {
794814 let this = self . eval_context_mut ( ) ;
795815
796- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
816+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
797817 throw_unsup_format ! (
798818 "`pthread_cond_init` is not supported on {}" ,
799819 this. tcx. sess. target. os
0 commit comments