Skip to content

Commit 1b29c7a

Browse files
committed
Merge pull request #284 from eagleflo/correct-integer-types
Correct integer types
2 parents f2b3893 + 887586e commit 1b29c7a

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

src/sdl2/cpuinfo.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
pub use sys::cpuinfo as ll;
22

3-
pub const CACHELINESIZE: isize = 128;
3+
pub const CACHELINESIZE: u8 = 128;
44

5-
pub fn get_cpu_count() -> isize {
6-
unsafe { ll::SDL_GetCPUCount() as isize }
5+
pub fn get_cpu_count() -> i32 {
6+
unsafe { ll::SDL_GetCPUCount() }
77
}
88

9-
pub fn get_cpu_cache_line_size() -> isize {
10-
unsafe { ll::SDL_GetCPUCacheLineSize() as isize}
9+
pub fn get_cpu_cache_line_size() -> i32 {
10+
unsafe { ll::SDL_GetCPUCacheLineSize() }
1111
}
1212

1313
pub fn has_rdtsc() -> bool {
@@ -50,6 +50,6 @@ pub fn has_avx() -> bool {
5050
unsafe { ll::SDL_HasAVX() == 1 }
5151
}
5252

53-
pub fn get_system_ram() -> isize {
54-
unsafe { ll::SDL_GetSystemRAM() as isize }
53+
pub fn get_system_ram() -> i32 {
54+
unsafe { ll::SDL_GetSystemRAM() }
5555
}

src/sdl2/timer.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use libc::{uint32_t, c_void};
22

33
pub use sys::timer as ll;
44

5-
pub fn get_ticks() -> usize {
6-
unsafe { ll::SDL_GetTicks() as usize }
5+
pub fn get_ticks() -> u32 {
6+
unsafe { ll::SDL_GetTicks() }
77
}
88

99
pub fn get_performance_counter() -> u64 {
@@ -14,8 +14,8 @@ pub fn get_performance_frequency() -> u64 {
1414
unsafe { ll::SDL_GetPerformanceFrequency() }
1515
}
1616

17-
pub fn delay(ms: usize) {
18-
unsafe { ll::SDL_Delay(ms as u32) }
17+
pub fn delay(ms: u32) {
18+
unsafe { ll::SDL_Delay(ms) }
1919
}
2020

2121
pub type TimerCallback = extern "C" fn (interval: uint32_t, param: *const c_void) -> u32;

src/sdl2/touch.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ pub use sys::touch as ll;
55
pub type Finger = ll::Finger;
66
pub type TouchDevice = ll::TouchDevice;
77

8-
pub fn get_num_touch_devices() -> isize {
9-
unsafe { ll::SDL_GetNumTouchDevices() as isize }
8+
pub fn get_num_touch_devices() -> i32 {
9+
unsafe { ll::SDL_GetNumTouchDevices() }
1010
}
1111

12-
pub fn get_touch_device(index: isize) -> TouchDevice {
13-
unsafe { ll::SDL_GetTouchDevice(index as i32) }
12+
pub fn get_touch_device(index: i32) -> TouchDevice {
13+
unsafe { ll::SDL_GetTouchDevice(index) }
1414
}
1515

16-
pub fn get_num_touch_fingers(touch: TouchDevice) -> isize {
17-
unsafe { ll::SDL_GetNumTouchFingers(touch) as isize }
16+
pub fn get_num_touch_fingers(touch: TouchDevice) -> i32 {
17+
unsafe { ll::SDL_GetNumTouchFingers(touch) }
1818
}
1919

20-
pub fn get_touch_finger(touch: TouchDevice, index: isize) -> Option<Finger> {
21-
let raw = unsafe { ll::SDL_GetTouchFinger(touch, index as i32) };
20+
pub fn get_touch_finger(touch: TouchDevice, index: i32) -> Option<Finger> {
21+
let raw = unsafe { ll::SDL_GetTouchFinger(touch, index) };
2222

2323
if raw == ptr::null() {
2424
None

src/sdl2/version.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ pub use sys::version as ll;
1111
#[derive(PartialEq, Copy, Clone)]
1212
pub struct Version {
1313
/// major version
14-
pub major: isize,
14+
pub major: u8,
1515
/// minor version
16-
pub minor: isize,
16+
pub minor: u8,
1717
/// update version (patchlevel)
18-
pub patch: isize,
18+
pub patch: u8,
1919
}
2020

2121
impl Version {
2222
/// Convert a raw *SDL_version to Version.
2323
pub fn from_ll(sv: *const ll::SDL_version) -> Version {
2424
unsafe {
2525
let ref v = *sv;
26-
Version{ major: v.major as isize, minor: v.minor as isize, patch: v.patch as isize }
26+
Version{ major: v.major, minor: v.minor, patch: v.patch }
2727
}
2828
}
2929
}
@@ -52,8 +52,8 @@ pub fn get_revision() -> String {
5252
}
5353

5454
/// Get the revision number of SDL that is linked against your program.
55-
pub fn get_revision_number() -> isize {
55+
pub fn get_revision_number() -> i32 {
5656
unsafe {
57-
ll::SDL_GetRevisionNumber() as isize
57+
ll::SDL_GetRevisionNumber()
5858
}
5959
}

0 commit comments

Comments
 (0)