Skip to content

Commit 2752d1b

Browse files
committed
Auto merge of #1167 - christianpoveda:shims-refactor, r=RalfJung
Reorganize shims by platform Fixes #1161. I am currently testing which shims belong to which platform. If you are reading this and know the answer for any of those please write me :P Edit: this is a list of the shims I haven't been able to figure out to which platform they belong: -~~`malloc`~~ -~~`calloc`~~ -~~`posix_memalign`~~ -~~`free`~~ -~~`realloc`~~ -~~`__rust_alloc`~~ -~~`__rust_alloc_zeroed`~~ -~~`__rust_dealloc`~~ -~~`__rust_realloc`~~ -~~`__rust_maybe_catch_panic`~~ -~~`syscall`~~ -~~`getrandom`~~ -~~`dlsym`~~ -~~`memcmp`~~ -~~`memrchr`~~ -~~`memchr`~~ -~~`strlen`~~ -~~`signal`~~ -~~`sigaction`~~ -~~`sigaltstack`~~ -~~`sysconf`~~ -~~`sched_getaffinity`~~ -~~`isatty`~~ -~~`pthread_key_create`~~ -~~`pthread_key_delete`~~ -~~`pthread_getspecific`~~ -~~`pthread_setspecific`~~ -~~`pthread_attr_init`~~ -~~`pthread_attr_destroy`~~ -~~`pthread_self`~~ -~~`pthread_attr_setstacksize`~~ -~~`pthread_attr_getstack`~~ -~~`pthread_create`~~ -~~`pthread_mutexattr_init`~~ -~~`pthread_mutexattr_settype`~~ -~~`pthread_mutex_init`~~ -~~`pthread_mutexattr_destroy`~~ -~~`pthread_mutex_lock`~~ -~~`pthread_mutex_unlock`~~ -~~`pthread_mutex_destroy`~~ -~~`pthread_rwlock_rdlock`~~ -~~`pthread_rwlock_unlock`~~ -~~`pthread_rwlock_wrlock`~~ -~~`pthread_rwlock_destroy`~~ -~~`pthread_condattr_init`~~ -~~`pthread_condattr_setclock`~~ -~~`pthread_cond_init`~~ -~~`pthread_condattr_destroy`~~ -~~`pthread_cond_destroy`~~ -~~`pthread_atfork`~~ -~~`posix_fadvise`~~ -~~`mmap`~~ -~~`mprotect`~~
2 parents c40a31e + 2086658 commit 2752d1b

File tree

7 files changed

+807
-635
lines changed

7 files changed

+807
-635
lines changed

src/helpers.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
368368
}
369369
Ok(())
370370
}
371+
/// Helper function used inside the shims of foreign functions to assert that the target
372+
/// platform is `platform`. It panics showing a message with the `name` of the foreign function
373+
/// if this is not the case.
374+
fn assert_platform(&mut self, platform: &str, name: &str) {
375+
assert_eq!(
376+
self.eval_context_mut().tcx.sess.target.target.target_os.to_lowercase(),
377+
platform,
378+
"`{}` is only available on the `{}` platform",
379+
name,
380+
platform
381+
)
382+
}
371383

372384
/// Sets the last error variable.
373385
fn set_last_error(&mut self, scalar: Scalar<Tag>) -> InterpResult<'tcx> {

0 commit comments

Comments
 (0)