Skip to content
This repository was archived by the owner on Jun 18, 2023. It is now read-only.

Commit 876fa43

Browse files
authored
Fix compilation error, warnings and migrate to 2018 edition (#2)
* Fix compilation errors by using repr(u32) * Fix warnings * Remove unstable feature `untagged_unions` by deriving basic traits * Migrate crate and example to 2018 edition
1 parent 7be2a17 commit 876fa43

File tree

19 files changed

+116
-99
lines changed

19 files changed

+116
-99
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "psp2-sys"
33
version = "0.2.2"
44
authors = ["Martin Larralde <martin.larralde@ens-cachan.fr>"]
5+
edition = "2018"
56
license = "MIT"
67
description = "Unsafe Rust FFI bindings to the psp2 headers"
78
repository = "https://github.com/vita-rust/psp2-sys"
@@ -25,4 +26,3 @@ maintenance = { status = "actively-developed" }
2526
default = []
2627
unsafe = []
2728
dox = []
28-

examples/hello_rust_world/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "bare_metal_rust"
33
version = "0.1.0"
44
authors = ["Martin Larralde <martin.larralde@ens-cachan.fr>"]
5+
edition = "2018"
56

67
[lib]
78
crate-type = ["staticlib"]

examples/hello_rust_world/src/debug/screen.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use core::fmt::Write;
33
use core::mem::size_of;
44
use core::slice::from_raw_parts_mut;
55

6-
use psp2::display::sceDisplaySetFrameBuf;
7-
use psp2::display::SceDisplayFrameBuf;
8-
use psp2::display::SceDisplaySetBufSync::SCE_DISPLAY_SETBUF_NEXTFRAME;
9-
use psp2::kernel::sysmem::sceKernelAllocMemBlock;
10-
use psp2::kernel::sysmem::sceKernelGetMemBlockBase;
11-
use psp2::kernel::sysmem::SceKernelMemBlockType::SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW;
12-
use psp2::kernel::threadmgr::sceKernelCreateMutex;
13-
use psp2::kernel::threadmgr::sceKernelLockMutex;
14-
use psp2::kernel::threadmgr::sceKernelUnlockMutex;
15-
use psp2::types::SceUID;
16-
use psp2::void;
6+
use crate::psp2::display::sceDisplaySetFrameBuf;
7+
use crate::psp2::display::SceDisplayFrameBuf;
8+
use crate::psp2::display::SceDisplaySetBufSync::SCE_DISPLAY_SETBUF_NEXTFRAME;
9+
use crate::psp2::kernel::sysmem::sceKernelAllocMemBlock;
10+
use crate::psp2::kernel::sysmem::sceKernelGetMemBlockBase;
11+
use crate::psp2::kernel::sysmem::SceKernelMemBlockType::SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW;
12+
use crate::psp2::kernel::threadmgr::sceKernelCreateMutex;
13+
use crate::psp2::kernel::threadmgr::sceKernelLockMutex;
14+
use crate::psp2::kernel::threadmgr::sceKernelUnlockMutex;
15+
use crate::psp2::types::SceUID;
16+
use crate::psp2::void;
1717

1818
use super::font::DEBUG_FONT;
1919

@@ -136,7 +136,7 @@ impl<'a> DebugScreen<'a> {
136136
continue;
137137
}
138138

139-
let mut vram = &mut self.base[self.coord_x + self.coord_y * SCREEN_FB_WIDTH..];
139+
let vram = &mut self.base[self.coord_x + self.coord_y * SCREEN_FB_WIDTH..];
140140
let mut font =
141141
&DEBUG_FONT.glyphs[(chr - DEBUG_FONT.first) as usize * bytes_per_glyph..];
142142
let mut mask = 1 << 7;

examples/hello_rust_world/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(dead_code, unused_imports, unused_variables, unused_macros, unused_parens)]
2-
#![feature(lang_items, core_intrinsics, panic_handler, start, used, const_fn)]
2+
#![feature(lang_items, core_intrinsics, start)]
33
#![no_std]
44

55
extern crate psp2_sys as psp2;
@@ -17,15 +17,15 @@ pub extern "C" fn eh_personality() {}
1717
#[panic_handler]
1818
#[no_mangle]
1919
fn panic(_info: &PanicInfo) -> ! {
20-
unsafe { intrinsics::abort() }
20+
intrinsics::abort()
2121
}
2222

2323
#[no_mangle]
2424
pub unsafe fn main(_argc: isize, _argv: *const *const u8) -> isize {
2525
let mut screen = debug::screen::DebugScreen::new();
26-
write!(screen, "This bare-metal is starting to rust!\n");
26+
write!(screen, "This bare-metal is starting to rust!\n").ok();
2727
psp2::kernel::threadmgr::sceKernelDelayThread(1 * 1000000); // Wait for 1 second
28-
write!(screen, "See ? I told you !\n");
28+
write!(screen, "See ? I told you !\n").ok();
2929
psp2::kernel::threadmgr::sceKernelDelayThread(3 * 1000000);
3030
psp2::kernel::processmgr::sceKernelExitProcess(0);
3131
return 0;

src/ctrl.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
use crate::types::SceUChar8;
2-
use crate::types::SceUInt;
3-
use crate::types::SceUInt64;
4-
use crate::types::SceUInt8;
5-
6-
#[repr(C)]
1+
#[repr(u32)]
72
pub enum SceCtrlErrorCode {
83
SCE_CTRL_ERROR_INVALID_ARG = 0x80340001,
94
SCE_CTRL_ERROR_PRIV_REQUIRED = 0x80340002,

src/dialog/common.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use graphics::gxm::SceGxmColorFormat;
2-
use graphics::gxm::SceGxmColorSurfaceType;
3-
use graphics::gxm::SceGxmSyncObject;
4-
use system_param::SceSystemParamEnterButtonAssign;
5-
use system_param::SceSystemParamLang;
6-
use types::SceInt32;
7-
use types::ScePVoid;
8-
use types::SceUInt32;
9-
use types::SceUInt8;
1+
use crate::graphics::gxm::SceGxmColorFormat;
2+
use crate::graphics::gxm::SceGxmColorSurfaceType;
3+
use crate::graphics::gxm::SceGxmSyncObject;
4+
use crate::system_param::SceSystemParamEnterButtonAssign;
5+
use crate::system_param::SceSystemParamLang;
6+
use crate::types::SceInt32;
7+
use crate::types::ScePVoid;
8+
use crate::types::SceUInt32;
9+
use crate::types::SceUInt8;
1010

1111
#[repr(u32)]
1212
pub enum SceCommonDialogErrorCode {

src/dialog/message.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use types::SceChar8;
2-
use types::SceInt32;
3-
use types::SceUInt32;
1+
use crate::types::SceChar8;
2+
use crate::types::SceInt32;
3+
use crate::types::SceUInt32;
44

55
use super::common::SceCommonDialogParam;
66
use super::common::SceCommonDialogStatus;
77

8-
#[repr(C)]
8+
#[repr(u32)]
99
pub enum SceMsgDialogErrorCode {
1010
SCE_MSG_DIALOG_ERROR_PARAM = 0x80100A01, // Illegal parameter
1111
}

src/display.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use types::SceSize;
2-
use types::SceUID;
1+
use crate::types::SceSize;
2+
use crate::types::SceUID;
33

44
#[repr(u32)]
55
pub enum SceDisplayErrorCode {
@@ -29,12 +29,12 @@ pub enum SceDisplaySetBufSync {
2929

3030
#[repr(C)]
3131
pub struct SceDisplayFrameBuf {
32-
pub size: SceSize, // sizeof(SceDisplayFrameBuf)
33-
pub base: *mut ::void, // Pointer to framebuffer
34-
pub pitch: u32, // pitch pixels
35-
pub pixelformat: u32, // pixel format (one of ::SceDisplayPixelFormat)
36-
pub width: u32, // framebuffer width
37-
pub height: u32, // framebuffer height
32+
pub size: SceSize, // sizeof(SceDisplayFrameBuf)
33+
pub base: *mut crate::void, // Pointer to framebuffer
34+
pub pitch: u32, // pitch pixels
35+
pub pixelformat: u32, // pixel format (one of ::SceDisplayPixelFormat)
36+
pub width: u32, // framebuffer width
37+
pub height: u32, // framebuffer height
3838
}
3939

4040
#[cfg_attr(

src/io/devctl.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use types::SceOff;
2-
use types::SceSize;
3-
use types::SceUID;
1+
use crate::types::SceOff;
2+
use crate::types::SceSize;
3+
use crate::types::SceUID;
44

55
#[repr(C)]
66
pub struct SceIoDevInfo {
77
pub max_size: SceOff,
88
pub free_size: SceOff,
99
pub cluster_size: SceSize,
10-
pub unk: *mut ::void,
10+
pub unk: *mut crate::void,
1111
}
1212

1313
#[cfg_attr(
@@ -18,25 +18,25 @@ extern "C" {
1818
pub fn sceIoDevctl(
1919
dev: *const u8,
2020
cmd: u32,
21-
indata: *mut ::void,
21+
indata: *mut crate::void,
2222
inlen: i32,
23-
outdata: *mut ::void,
23+
outdata: *mut crate::void,
2424
outlen: i32,
2525
) -> i32;
2626
pub fn sceIoIoctl(
2727
fd: SceUID,
2828
cmd: u32,
29-
indata: *mut ::void,
29+
indata: *mut crate::void,
3030
inlen: i32,
31-
outdata: *mut ::void,
31+
outdata: *mut crate::void,
3232
outlen: i32,
3333
) -> i32;
3434
pub fn sceIoIoctlAsync(
3535
fd: SceUID,
3636
cmd: u32,
37-
indata: *mut ::void,
37+
indata: *mut crate::void,
3838
inlen: i32,
39-
outdata: *mut ::void,
39+
outdata: *mut crate::void,
4040
outlen: i32,
4141
) -> i32;
4242
}

src/io/dirent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use types::SceUID;
1+
use crate::types::SceUID;
22

33
use super::stat::SceIoStat;
44

55
#[repr(C)]
66
pub struct SceIoDirent {
77
pub d_stat: SceIoStat,
88
pub d_name: [u8; 256],
9-
pub d_private: *mut ::void,
9+
pub d_private: *mut crate::void,
1010
pub dummy: i32,
1111
}
1212

0 commit comments

Comments
 (0)