@@ -68,11 +68,20 @@ fn mutexattr_set_kind<'mir, 'tcx: 'mir>(
68
68
// (the kind has to be at this particular offset for compatibility with Linux's static initializer
69
69
// macros, e.g. PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP.)
70
70
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
+
71
76
fn mutex_get_id < ' mir , ' tcx : ' mir > (
72
77
ecx : & mut MiriInterpCx < ' mir , ' tcx > ,
73
78
mutex_op : & OpTy < ' tcx , Provenance > ,
74
79
) -> 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
+ )
76
85
}
77
86
78
87
fn mutex_reset_id < ' mir , ' tcx : ' mir > (
@@ -81,7 +90,7 @@ fn mutex_reset_id<'mir, 'tcx: 'mir>(
81
90
) -> InterpResult < ' tcx , ( ) > {
82
91
ecx. deref_pointer_and_write (
83
92
mutex_op,
84
- 4 ,
93
+ mutex_id_offset ( ecx ) ,
85
94
Scalar :: from_i32 ( 0 ) ,
86
95
ecx. libc_ty_layout ( "pthread_mutex_t" ) ,
87
96
ecx. machine . layouts . u32 ,
@@ -124,13 +133,20 @@ fn mutex_set_kind<'mir, 'tcx: 'mir>(
124
133
// (need to avoid this because it is set by static initializer macros)
125
134
// bytes 4-7: rwlock id as u32 or 0 if id is not assigned yet.
126
135
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
+ }
128
140
129
141
fn rwlock_get_id < ' mir , ' tcx : ' mir > (
130
142
ecx : & mut MiriInterpCx < ' mir , ' tcx > ,
131
143
rwlock_op : & OpTy < ' tcx , Provenance > ,
132
144
) -> 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
+ )
134
150
}
135
151
136
152
// pthread_condattr_t
@@ -177,14 +193,18 @@ fn condattr_set_clock_id<'mir, 'tcx: 'mir>(
177
193
// bytes 4-7: the conditional variable id as u32 or 0 if id is not assigned yet.
178
194
// bytes 8-11: the clock id constant as i32
179
195
180
- const CONDVAR_ID_OFFSET : u64 = 4 ;
181
196
const CONDVAR_CLOCK_OFFSET : u64 = 8 ;
182
197
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
+
183
203
fn cond_get_id < ' mir , ' tcx : ' mir > (
184
204
ecx : & mut MiriInterpCx < ' mir , ' tcx > ,
185
205
cond_op : & OpTy < ' tcx , Provenance > ,
186
206
) -> 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 ) )
188
208
}
189
209
190
210
fn cond_reset_id < ' mir , ' tcx : ' mir > (
@@ -193,7 +213,7 @@ fn cond_reset_id<'mir, 'tcx: 'mir>(
193
213
) -> InterpResult < ' tcx , ( ) > {
194
214
ecx. deref_pointer_and_write (
195
215
cond_op,
196
- CONDVAR_ID_OFFSET ,
216
+ cond_id_offset ( ecx ) ,
197
217
Scalar :: from_i32 ( 0 ) ,
198
218
ecx. libc_ty_layout ( "pthread_cond_t" ) ,
199
219
ecx. machine . layouts . u32 ,
@@ -287,7 +307,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
287
307
) -> InterpResult < ' tcx , i32 > {
288
308
let this = self . eval_context_mut ( ) ;
289
309
290
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
310
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
291
311
throw_unsup_format ! (
292
312
"`pthread_mutexattr_init` is not supported on {}" ,
293
313
this. tcx. sess. target. os
@@ -376,7 +396,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
376
396
) -> InterpResult < ' tcx , i32 > {
377
397
let this = self . eval_context_mut ( ) ;
378
398
379
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
399
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
380
400
throw_unsup_format ! (
381
401
"`pthread_mutex_init` is not supported on {}" ,
382
402
this. tcx. sess. target. os
@@ -537,7 +557,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
537
557
) -> InterpResult < ' tcx , i32 > {
538
558
let this = self . eval_context_mut ( ) ;
539
559
540
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
560
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
541
561
throw_unsup_format ! (
542
562
"`pthread_rwlock_rdlock` is not supported on {}" ,
543
563
this. tcx. sess. target. os
@@ -562,7 +582,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
562
582
) -> InterpResult < ' tcx , i32 > {
563
583
let this = self . eval_context_mut ( ) ;
564
584
565
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
585
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
566
586
throw_unsup_format ! (
567
587
"`pthread_rwlock_tryrdlock` is not supported on {}" ,
568
588
this. tcx. sess. target. os
@@ -586,7 +606,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
586
606
) -> InterpResult < ' tcx , i32 > {
587
607
let this = self . eval_context_mut ( ) ;
588
608
589
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
609
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
590
610
throw_unsup_format ! (
591
611
"`pthread_rwlock_wrlock` is not supported on {}" ,
592
612
this. tcx. sess. target. os
@@ -623,7 +643,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
623
643
) -> InterpResult < ' tcx , i32 > {
624
644
let this = self . eval_context_mut ( ) ;
625
645
626
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
646
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
627
647
throw_unsup_format ! (
628
648
"`pthread_rwlock_trywrlock` is not supported on {}" ,
629
649
this. tcx. sess. target. os
@@ -647,7 +667,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
647
667
) -> InterpResult < ' tcx , i32 > {
648
668
let this = self . eval_context_mut ( ) ;
649
669
650
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
670
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
651
671
throw_unsup_format ! (
652
672
"`pthread_rwlock_unlock` is not supported on {}" ,
653
673
this. tcx. sess. target. os
@@ -673,7 +693,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
673
693
) -> InterpResult < ' tcx , i32 > {
674
694
let this = self . eval_context_mut ( ) ;
675
695
676
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
696
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
677
697
throw_unsup_format ! (
678
698
"`pthread_rwlock_destroy` is not supported on {}" ,
679
699
this. tcx. sess. target. os
@@ -704,7 +724,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
704
724
) -> InterpResult < ' tcx , i32 > {
705
725
let this = self . eval_context_mut ( ) ;
706
726
707
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
727
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
708
728
throw_unsup_format ! (
709
729
"`pthread_condattr_init` is not supported on {}" ,
710
730
this. tcx. sess. target. os
@@ -728,9 +748,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
728
748
let this = self . eval_context_mut ( ) ;
729
749
730
750
// 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" ) {
732
752
throw_unsup_format ! (
733
- "`pthread_condattr_init ` is not supported on {}" ,
753
+ "`pthread_condattr_setclock ` is not supported on {}" ,
734
754
this. tcx. sess. target. os
735
755
) ;
736
756
}
@@ -756,9 +776,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
756
776
let this = self . eval_context_mut ( ) ;
757
777
758
778
// 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" ) {
760
780
throw_unsup_format ! (
761
- "`pthread_condattr_init ` is not supported on {}" ,
781
+ "`pthread_condattr_getclock ` is not supported on {}" ,
762
782
this. tcx. sess. target. os
763
783
) ;
764
784
}
@@ -793,7 +813,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
793
813
) -> InterpResult < ' tcx , i32 > {
794
814
let this = self . eval_context_mut ( ) ;
795
815
796
- if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" ) {
816
+ if !matches ! ( & * this. tcx. sess. target. os, "linux" | "macos" | "solaris" | "illumos" ) {
797
817
throw_unsup_format ! (
798
818
"`pthread_cond_init` is not supported on {}" ,
799
819
this. tcx. sess. target. os
0 commit comments