@@ -233,6 +233,64 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
233233 this. write_null ( dest) ?;
234234 }
235235
236+ // Synchronization primitives
237+ "pthread_mutexattr_init" => {
238+ let result = this. pthread_mutexattr_init ( args[ 0 ] ) ?;
239+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
240+ }
241+ "pthread_mutexattr_settype" => {
242+ let result = this. pthread_mutexattr_settype ( args[ 0 ] , args[ 1 ] ) ?;
243+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
244+ }
245+ "pthread_mutexattr_destroy" => {
246+ let result = this. pthread_mutexattr_destroy ( args[ 0 ] ) ?;
247+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
248+ }
249+ "pthread_mutex_init" => {
250+ let result = this. pthread_mutex_init ( args[ 0 ] , args[ 1 ] ) ?;
251+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
252+ }
253+ "pthread_mutex_lock" => {
254+ let result = this. pthread_mutex_lock ( args[ 0 ] ) ?;
255+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
256+ }
257+ "pthread_mutex_trylock" => {
258+ let result = this. pthread_mutex_trylock ( args[ 0 ] ) ?;
259+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
260+ }
261+ "pthread_mutex_unlock" => {
262+ let result = this. pthread_mutex_unlock ( args[ 0 ] ) ?;
263+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
264+ }
265+ "pthread_mutex_destroy" => {
266+ let result = this. pthread_mutex_destroy ( args[ 0 ] ) ?;
267+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
268+ }
269+ "pthread_rwlock_rdlock" => {
270+ let result = this. pthread_rwlock_rdlock ( args[ 0 ] ) ?;
271+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
272+ }
273+ "pthread_rwlock_tryrdlock" => {
274+ let result = this. pthread_rwlock_tryrdlock ( args[ 0 ] ) ?;
275+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
276+ }
277+ "pthread_rwlock_wrlock" => {
278+ let result = this. pthread_rwlock_wrlock ( args[ 0 ] ) ?;
279+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
280+ }
281+ "pthread_rwlock_trywrlock" => {
282+ let result = this. pthread_rwlock_trywrlock ( args[ 0 ] ) ?;
283+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
284+ }
285+ "pthread_rwlock_unlock" => {
286+ let result = this. pthread_rwlock_unlock ( args[ 0 ] ) ?;
287+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
288+ }
289+ "pthread_rwlock_destroy" => {
290+ let result = this. pthread_rwlock_destroy ( args[ 0 ] ) ?;
291+ this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
292+ }
293+
236294 // Better error for attempts to create a thread
237295 "pthread_create" => {
238296 throw_unsup_format ! ( "Miri does not support threading" ) ;
@@ -255,25 +313,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
255313 this. write_null ( dest) ?;
256314 }
257315
258- // Incomplete shims that we "stub out" just to get pre-main initialziation code to work.
316+ // Incomplete shims that we "stub out" just to get pre-main initialization code to work.
259317 // These shims are enabled only when the caller is in the standard library.
260318 | "pthread_attr_init"
261319 | "pthread_attr_destroy"
262320 | "pthread_self"
263- | "pthread_attr_setstacksize" if this. frame ( ) . instance . to_string ( ) . starts_with ( "std::sys::unix::" ) => {
264- this. write_null ( dest) ?;
265- }
266- | "pthread_mutexattr_init"
267- | "pthread_mutexattr_settype"
268- | "pthread_mutex_init"
269- | "pthread_mutexattr_destroy"
270- | "pthread_mutex_lock"
271- | "pthread_mutex_unlock"
272- | "pthread_mutex_destroy"
273- | "pthread_rwlock_rdlock"
274- | "pthread_rwlock_unlock"
275- | "pthread_rwlock_wrlock"
276- | "pthread_rwlock_destroy"
321+ | "pthread_attr_setstacksize"
277322 | "pthread_condattr_init"
278323 | "pthread_condattr_setclock"
279324 | "pthread_cond_init"
@@ -282,6 +327,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
282327 => {
283328 this. write_null ( dest) ?;
284329 }
330+
285331 | "signal"
286332 | "sigaction"
287333 | "sigaltstack"
0 commit comments