clear-cache

Crates.ioclear-cache
lib.rsclear-cache
version0.1.1
sourcesrc
created_at2024-08-09 07:40:35.791227
updated_at2024-11-27 10:26:07.93096
descriptionA native implementation of `__builtin___clear_cache` without dependency of GCC/Clang.
homepagehttps://github.com/Evian-Zhang/clear-cache
repositoryhttps://github.com/Evian-Zhang/clear-cache
max_upload_size
id1330520
size23,216
EvianZhang (Evian-Zhang)

documentation

https://docs.rs/clear-cache

README

clear-cache

A native implementation of __builtin___clear_cache without dependency of GCC/Clang.

From GCC documentation:

This function is used to flush the processor’s instruction cache for the region of memory between begin inclusive and end exclusive. Some targets require that the instruction cache be flushed, after modifying memory containing code, in order to obtain deterministic behavior.

If the target does not require instruction cache flushes, __builtin___clear_cache has no effect. Otherwise either instructions are emitted in-line to clear the instruction cache or a call to the __clear_cache function in libgcc is made.

From LLVM documentation:

The llvm.clear_cache intrinsic ensures visibility of modifications in the specified range to the execution unit of the processor. On targets with non-unified instruction and data cache, the implementation flushes the instruction cache.

On platforms with coherent instruction and data caches (e.g. x86), this intrinsic is a nop. On platforms with non-coherent instruction and data cache (e.g. ARM, MIPS), the intrinsic is lowered either to appropriate instructions or a system call, if cache flushing requires special privileges.

The default behavior is to emit a call to __clear_cache from the run time library.

This intrinsic does not empty the instruction pipeline. Modifications of the current function are outside the scope of the intrinsic.

Current implementation is taken from LLVM's implementation

Current CI-tested platforms:

  • Linux

    • x86_64-unknown-linux-gnu
    • x86_64-unknown-linux-musl
    • i686-unknown-linux-gnu
    • aarch64-unknown-linux-gnu
    • riscv64gc-unknown-linux-gnu
    • loongarch64-unknown-linux-gnu
  • macOS

    • aarch64-apple-darwin
  • Windows

    • x86_64-pc-windows-msvc
    • i686-pc-windows-msvc
Commit count: 7

cargo fmt