about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-07 15:19:40 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-07 15:19:40 +0000
commita28b98650ffc7681aa388011055761c64eb5f3c9 (patch)
tree57def473e56e9f0b17e381d9bcf38c9db0b0dd9c
parentadf0f419832a0b337c592d13eff0362f0757272b (diff)
downloadrust-a28b98650ffc7681aa388011055761c64eb5f3c9.tar.gz
rust-a28b98650ffc7681aa388011055761c64eb5f3c9.zip
Remove a couple of obsolete tests
mod_bench is basically useless as test and hasn't been used as benchmark
for a long time. alloc_example doesn't test anything that isn't
already tested by std_example.
-rw-r--r--build_system/tests.rs3
-rw-r--r--config.txt3
-rw-r--r--example/alloc_example.rs44
-rw-r--r--example/alloc_system.rs124
-rw-r--r--example/mod_bench.rs37
5 files changed, 0 insertions, 211 deletions
diff --git a/build_system/tests.rs b/build_system/tests.rs
index 08736db8ba0..8de419a0c4e 100644
--- a/build_system/tests.rs
+++ b/build_system/tests.rs
@@ -73,8 +73,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
         "example/arbitrary_self_types_pointers_and_wrappers.rs",
         &[],
     ),
-    TestCase::build_lib("build.alloc_system", "example/alloc_system.rs", "lib"),
-    TestCase::build_bin_and_run("aot.alloc_example", "example/alloc_example.rs", &[]),
     TestCase::jit_bin("jit.std_example", "example/std_example.rs", "arg"),
     TestCase::build_bin_and_run("aot.std_example", "example/std_example.rs", &["arg"]),
     TestCase::build_bin_and_run("aot.dst_field_align", "example/dst-field-align.rs", &[]),
@@ -89,7 +87,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
         &[],
     ),
     TestCase::build_bin_and_run("aot.float-minmax-pass", "example/float-minmax-pass.rs", &[]),
-    TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
     TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
     TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
     TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
diff --git a/config.txt b/config.txt
index 9808ad624e1..f578cbef35e 100644
--- a/config.txt
+++ b/config.txt
@@ -21,15 +21,12 @@ aot.mini_core_hello_world
 testsuite.base_sysroot
 aot.arbitrary_self_types_pointers_and_wrappers
 aot.issue_91827_extern_types
-build.alloc_system
-aot.alloc_example
 jit.std_example
 aot.std_example
 aot.dst_field_align
 aot.subslice-patterns-const-eval
 aot.track-caller-attribute
 aot.float-minmax-pass
-aot.mod_bench
 aot.issue-72793
 aot.issue-59326
 aot.neon
diff --git a/example/alloc_example.rs b/example/alloc_example.rs
deleted file mode 100644
index da70ca79439..00000000000
--- a/example/alloc_example.rs
+++ /dev/null
@@ -1,44 +0,0 @@
-#![feature(start, core_intrinsics, alloc_error_handler, lang_items)]
-#![allow(internal_features)]
-#![no_std]
-
-extern crate alloc;
-extern crate alloc_system;
-
-use alloc::boxed::Box;
-
-use alloc_system::System;
-
-#[global_allocator]
-static ALLOC: System = System;
-
-#[cfg_attr(unix, link(name = "c"))]
-#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
-extern "C" {
-    fn puts(s: *const u8) -> i32;
-}
-
-#[panic_handler]
-fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! {
-    core::intrinsics::abort();
-}
-
-#[alloc_error_handler]
-fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
-    core::intrinsics::abort();
-}
-
-#[lang = "eh_personality"]
-fn eh_personality() -> ! {
-    loop {}
-}
-
-#[start]
-fn main(_argc: isize, _argv: *const *const u8) -> isize {
-    let world: Box<&str> = Box::new("Hello World!\0");
-    unsafe {
-        puts(*world as *const str as *const u8);
-    }
-
-    0
-}
diff --git a/example/alloc_system.rs b/example/alloc_system.rs
deleted file mode 100644
index 2884c9c32ae..00000000000
--- a/example/alloc_system.rs
+++ /dev/null
@@ -1,124 +0,0 @@
-// SPDX-License-Identifier: MIT OR Apache-2.0
-// SPDX-FileCopyrightText: The Rust Project Developers (see https://thanks.rust-lang.org)
-
-#![no_std]
-
-pub struct System;
-
-#[cfg(any(windows, unix, target_os = "redox"))]
-mod realloc_fallback {
-    use core::alloc::{GlobalAlloc, Layout};
-    use core::{cmp, ptr};
-    impl super::System {
-        pub(crate) unsafe fn realloc_fallback(
-            &self,
-            ptr: *mut u8,
-            old_layout: Layout,
-            new_size: usize,
-        ) -> *mut u8 {
-            // Docs for GlobalAlloc::realloc require this to be valid:
-            let new_layout = Layout::from_size_align_unchecked(new_size, old_layout.align());
-            let new_ptr = GlobalAlloc::alloc(self, new_layout);
-            if !new_ptr.is_null() {
-                let size = cmp::min(old_layout.size(), new_size);
-                ptr::copy_nonoverlapping(ptr, new_ptr, size);
-                GlobalAlloc::dealloc(self, ptr, old_layout);
-            }
-            new_ptr
-        }
-    }
-}
-#[cfg(any(unix, target_os = "redox"))]
-mod platform {
-    use core::alloc::{GlobalAlloc, Layout};
-    use core::ffi::c_void;
-    use core::ptr;
-
-    use System;
-    extern "C" {
-        fn posix_memalign(memptr: *mut *mut c_void, align: usize, size: usize) -> i32;
-        fn free(p: *mut c_void);
-    }
-    unsafe impl GlobalAlloc for System {
-        #[inline]
-        unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
-            aligned_malloc(&layout)
-        }
-        #[inline]
-        unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
-            let ptr = self.alloc(layout.clone());
-            if !ptr.is_null() {
-                ptr::write_bytes(ptr, 0, layout.size());
-            }
-            ptr
-        }
-        #[inline]
-        unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
-            free(ptr as *mut c_void)
-        }
-        #[inline]
-        unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
-            self.realloc_fallback(ptr, layout, new_size)
-        }
-    }
-    unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
-        let mut out = ptr::null_mut();
-        let ret = posix_memalign(&mut out, layout.align(), layout.size());
-        if ret != 0 { ptr::null_mut() } else { out as *mut u8 }
-    }
-}
-#[cfg(windows)]
-#[allow(nonstandard_style)]
-mod platform {
-    use core::alloc::{GlobalAlloc, Layout};
-
-    use System;
-    type LPVOID = *mut u8;
-    type HANDLE = LPVOID;
-    type SIZE_T = usize;
-    type DWORD = u32;
-    type BOOL = i32;
-    extern "system" {
-        fn GetProcessHeap() -> HANDLE;
-        fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
-        fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
-        fn GetLastError() -> DWORD;
-    }
-    #[repr(C)]
-    struct Header(*mut u8);
-    const HEAP_ZERO_MEMORY: DWORD = 0x00000008;
-    unsafe fn get_header<'a>(ptr: *mut u8) -> &'a mut Header {
-        &mut *(ptr as *mut Header).sub(1)
-    }
-    unsafe fn align_ptr(ptr: *mut u8, align: usize) -> *mut u8 {
-        let aligned = ptr.add(align - (ptr as usize & (align - 1)));
-        *get_header(aligned) = Header(ptr);
-        aligned
-    }
-    #[inline]
-    unsafe fn allocate_with_flags(layout: Layout, flags: DWORD) -> *mut u8 {
-        let size = layout.size() + layout.align();
-        let ptr = HeapAlloc(GetProcessHeap(), flags, size);
-        (if ptr.is_null() { ptr } else { align_ptr(ptr, layout.align()) }) as *mut u8
-    }
-    unsafe impl GlobalAlloc for System {
-        #[inline]
-        unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
-            allocate_with_flags(layout, 0)
-        }
-        #[inline]
-        unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
-            allocate_with_flags(layout, HEAP_ZERO_MEMORY)
-        }
-        #[inline]
-        unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
-            let header = get_header(ptr);
-            let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
-            debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
-        }
-        #[inline]
-        unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
-            self.realloc_fallback(ptr, layout, new_size)
-        }
-    }
-}
diff --git a/example/mod_bench.rs b/example/mod_bench.rs
deleted file mode 100644
index 11a3e8fc72d..00000000000
--- a/example/mod_bench.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#![feature(start, core_intrinsics, lang_items)]
-#![allow(internal_features)]
-#![no_std]
-
-#[cfg_attr(unix, link(name = "c"))]
-#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
-extern "C" {}
-
-#[panic_handler]
-fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! {
-    core::intrinsics::abort();
-}
-
-#[lang = "eh_personality"]
-fn eh_personality() {}
-
-// Required for rustc_codegen_llvm
-#[no_mangle]
-unsafe extern "C" fn _Unwind_Resume() {
-    core::intrinsics::unreachable();
-}
-
-#[start]
-fn main(_argc: isize, _argv: *const *const u8) -> isize {
-    for i in 2..10_000_000 {
-        black_box((i + 1) % i);
-    }
-
-    0
-}
-
-#[inline(never)]
-fn black_box(i: u32) {
-    if i != 1 {
-        core::intrinsics::abort();
-    }
-}