Skip to content

Commit 828b7b8

Browse files
authored
Merge pull request #79 from GUIpsp/use-pointer-wrapping-add
Use pointer wrapping add
2 parents f1dc84e + 269fd90 commit 828b7b8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generate/block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ pub fn render(opts: &super::Options, ir: &IR, b: &Block, path: &str) -> Result<T
4949
#[inline(always)]
5050
pub const fn #name(self, n: usize) -> #ty {
5151
assert!(n < #len);
52-
unsafe { #common_path::Reg::from_ptr(self.ptr.add(#offset + #offs_expr) as _) }
52+
unsafe { #common_path::Reg::from_ptr(self.ptr.wrapping_add(#offset + #offs_expr) as _) }
5353
}
5454
));
5555
} else {
5656
items.extend(quote!(
5757
#doc
5858
#[inline(always)]
5959
pub const fn #name(self) -> #ty {
60-
unsafe { #common_path::Reg::from_ptr(self.ptr.add(#offset) as _) }
60+
unsafe { #common_path::Reg::from_ptr(self.ptr.wrapping_add(#offset) as _) }
6161
}
6262
));
6363
}
@@ -74,15 +74,15 @@ pub fn render(opts: &super::Options, ir: &IR, b: &Block, path: &str) -> Result<T
7474
#[inline(always)]
7575
pub const fn #name(self, n: usize) -> #ty {
7676
assert!(n < #len);
77-
unsafe { #ty::from_ptr(self.ptr.add(#offset + #offs_expr) as _) }
77+
unsafe { #ty::from_ptr(self.ptr.wrapping_add(#offset + #offs_expr) as _) }
7878
}
7979
));
8080
} else {
8181
items.extend(quote!(
8282
#doc
8383
#[inline(always)]
8484
pub const fn #name(self) -> #ty {
85-
unsafe { #ty::from_ptr(self.ptr.add(#offset) as _) }
85+
unsafe { #ty::from_ptr(self.ptr.wrapping_add(#offset) as _) }
8686
}
8787
));
8888
}

0 commit comments

Comments
 (0)