Commit 842aedc3 authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Danilo Krummrich
Browse files

rust: Add cpu_relax() helper

parent 44d454fc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include "pid_namespace.c"
#include "platform.c"
#include "poll.c"
#include "processor.c"
#include "property.c"
#include "rbtree.c"
#include "rcu.c"
+8 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

#include <linux/processor.h>

void rust_helper_cpu_relax(void)
{
	cpu_relax();
}
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@
pub mod platform;
pub mod prelude;
pub mod print;
pub mod processor;
pub mod rbtree;
pub mod regulator;
pub mod revocable;
+14 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0

//! Processor related primitives.
//!
//! C header: [`include/linux/processor.h`](srctree/include/linux/processor.h)

/// Lower CPU power consumption or yield to a hyperthreaded twin processor.
///
/// It also happens to serve as a compiler barrier.
#[inline]
pub fn cpu_relax() {
    // SAFETY: Always safe to call.
    unsafe { bindings::cpu_relax() }
}