Skip to content

Commit 1dab93f

Browse files
committed
Add inline attribute to segment functions
Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
1 parent 3c3ac3c commit 1dab93f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/instructions/segmentation.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use core::arch::asm;
1010

1111
macro_rules! get_reg_impl {
1212
($name:literal) => {
13+
#[inline]
1314
fn get_reg() -> SegmentSelector {
1415
let segment: u16;
1516
unsafe {
@@ -25,6 +26,7 @@ macro_rules! segment_impl {
2526
impl Segment for $type {
2627
get_reg_impl!($name);
2728

29+
#[inline]
2830
unsafe fn set_reg(sel: SegmentSelector) {
2931
unsafe {
3032
asm!(concat!("mov ", $name, ", {0:x}"), in(reg) sel.0, options(nostack, preserves_flags));
@@ -38,6 +40,7 @@ macro_rules! segment64_impl {
3840
($type:ty, $name:literal, $base:ty) => {
3941
impl Segment64 for $type {
4042
const BASE: Msr = <$base>::MSR;
43+
#[inline]
4144
fn read_base() -> VirtAddr {
4245
unsafe {
4346
let val: u64;
@@ -46,6 +49,7 @@ macro_rules! segment64_impl {
4649
}
4750
}
4851

52+
#[inline]
4953
unsafe fn write_base(base: VirtAddr) {
5054
unsafe{
5155
asm!(concat!("wr", $name, "base {}"), in(reg) base.as_u64(), options(nostack, preserves_flags));
@@ -66,6 +70,7 @@ impl Segment for CS {
6670
/// Note we cannot use a "far call" (`lcall`) or "far jmp" (`ljmp`) to do this because then we
6771
/// would only be able to jump to 32-bit instruction pointers. Only Intel implements support
6872
/// for 64-bit far calls/jumps in long-mode, AMD does not.
73+
#[inline]
6974
unsafe fn set_reg(sel: SegmentSelector) {
7075
unsafe {
7176
asm!(
@@ -97,6 +102,7 @@ impl GS {
97102
///
98103
/// This function is unsafe because the caller must ensure that the
99104
/// swap operation cannot lead to undefined behavior.
105+
#[inline]
100106
pub unsafe fn swap() {
101107
unsafe {
102108
asm!("swapgs", options(nostack, preserves_flags));

0 commit comments

Comments
 (0)