diff --git a/src/psp/audio.rs b/src/psp/audio.rs
index 4f892aaa33745f84e8520207b89d5552e7102a4a..579921523c76e91e976e7abce1634618e9d63ddb 100644
--- a/src/psp/audio.rs
+++ b/src/psp/audio.rs
@@ -46,30 +46,67 @@ pub enum AudioInputFrequency {
     Khz11_025 = 11025,
 }
 
-extern {
-    pub fn sceAudioChReserve(channel: i32, sample_count: i32, format: AudioFormat) -> i32;
+extern "C" {
+    pub fn sceAudioChReserve(
+        channel: i32,
+        sample_count: i32,
+        format: AudioFormat,
+    ) -> i32;
     pub fn sceAudioChRelease(channel: i32) -> i32;
     pub fn sceAudioOutput(channel: i32, vol: i32, buf: *mut c_void) -> i32;
-    pub fn sceAudioOutputBlocking(channel: i32, vol: i32, buf: *mut c_void) -> i32;
-    pub fn sceAudioOutputPanned(channel: i32, left_vol: i32, right_vol: i32, buf: *mut c_void) -> i32;
-    pub fn sceAudioOutputPannedBlocking(channel: i32, left_vol: i32, right_vol: i32, buf: *mut c_void) -> i32;
+    pub fn sceAudioOutputBlocking(
+        channel: i32,
+        vol: i32,
+        buf: *mut c_void,
+    ) -> i32;
+    pub fn sceAudioOutputPanned(
+        channel: i32,
+        left_vol: i32,
+        right_vol: i32,
+        buf: *mut c_void,
+    ) -> i32;
+    pub fn sceAudioOutputPannedBlocking(
+        channel: i32,
+        left_vol: i32,
+        right_vol: i32,
+        buf: *mut c_void,
+    ) -> i32;
     pub fn sceAudioGetChannelRestLen(channel: i32) -> i32;
     pub fn sceAudioGetChannelRestLength(channel: i32) -> i32;
     pub fn sceAudioSetChannelDataLen(channel: i32, sample_count: i32) -> i32;
-    pub fn sceAudioChangeChannelConfig(channel: i32, format: AudioFormat) -> i32;
-    pub fn sceAudioChangeChannelVolume(channel:i32, left_vol: i32, right_vol:i32) -> i32;
+    pub fn sceAudioChangeChannelConfig(
+        channel: i32,
+        format: AudioFormat,
+    ) -> i32;
+    pub fn sceAudioChangeChannelVolume(
+        channel: i32,
+        left_vol: i32,
+        right_vol: i32,
+    ) -> i32;
     pub fn sceAudioOutput2Reserve(sample_count: i32) -> i32;
     pub fn sceAudioOutput2Release() -> i32;
     pub fn sceAudioOutput2ChangeLength(sample_count: i32) -> i32;
     pub fn sceAudioOutput2OutputBlocking(vol: i32, buf: *mut c_void) -> i32;
     pub fn sceAudioOutput2GetRestSample() -> i32;
-    pub fn sceAudioSRCChReserve(sample_count: i32, freq: AudioOutputFrequency, channels: i32) -> i32;
+    pub fn sceAudioSRCChReserve(
+        sample_count: i32,
+        freq: AudioOutputFrequency,
+        channels: i32,
+    ) -> i32;
     pub fn sceAudioSRCChRelease() -> i32;
     pub fn sceAudioSRCOutputBlocking(vol: i32, buf: *mut c_void) -> i32;
     pub fn sceAudioInputInit(unknown1: i32, gain: i32, unknown2: i32) -> i32;
     pub fn sceAudioInputInitEx(params: *mut AudioInputParams) -> i32;
-    pub fn sceAudioInputBlocking(sample_count: i32, freq: AudioInputFrequency, buf: *mut c_void);
-    pub fn sceAudioInput(sample_count: i32, freq: AudioInputFrequency, buf: *mut c_void);
+    pub fn sceAudioInputBlocking(
+        sample_count: i32,
+        freq: AudioInputFrequency,
+        buf: *mut c_void,
+    );
+    pub fn sceAudioInput(
+        sample_count: i32,
+        freq: AudioInputFrequency,
+        buf: *mut c_void,
+    );
     pub fn sceAudioGetInputLength() -> i32;
     pub fn sceAudioWaitInputEnd() -> i32;
     pub fn sceAudioPollInputEnd() -> i32;
diff --git a/src/psp/ctrl.rs b/src/psp/ctrl.rs
index ebfa5ada6261b17ce044a834a3e63a5f14ae5168..045cc813af18adf29766c832d178e6dfa014be6c 100644
--- a/src/psp/ctrl.rs
+++ b/src/psp/ctrl.rs
@@ -24,7 +24,7 @@ pub const PSP_CTRL_MS: i32 = 0x2000000;
 #[repr(u32)]
 pub enum CtrlMode {
     Digital = 0,
-    Analaog
+    Analaog,
 }
 
 #[derive(Copy, Clone)]
@@ -34,8 +34,7 @@ pub struct SceCtrlData {
     pub buttons: i32,
     pub lx: u8,
     pub ly: u8,
-    pub rsrv: [u8;
-6],
+    pub rsrv: [u8; 6],
 }
 
 #[derive(Copy, Clone)]
@@ -47,17 +46,33 @@ pub struct SceCtrlLatch {
     pub ui_release: u32,
 }
 
-extern {
+extern "C" {
     pub fn sceCtrlSetSamplingCycle(cycle: i32) -> i32;
     pub fn sceCtrlGetSamplingCycle(pcycle: *mut i32) -> i32;
     pub fn sceCtrlSetSamplingMode(mode: CtrlMode) -> i32;
     pub fn sceCtrlGetSamplingMode(pmode: *mut i32) -> i32;
-    pub fn sceCtrlPeekBufferPositive(pad_data: *mut SceCtrlData, count: i32) -> i32;
-    pub fn sceCtrlPeekBufferNegative(pad_data: *mut SceCtrlData, count: i32) -> i32;
-    pub fn sceCtrlReadBufferPositive(pad_data: *mut SceCtrlData, count: i32) -> i32;
-    pub fn sceCtrlReadBufferNegative(pad_data: *mut SceCtrlData, count: i32) -> i32;
+    pub fn sceCtrlPeekBufferPositive(
+        pad_data: *mut SceCtrlData,
+        count: i32,
+    ) -> i32;
+    pub fn sceCtrlPeekBufferNegative(
+        pad_data: *mut SceCtrlData,
+        count: i32,
+    ) -> i32;
+    pub fn sceCtrlReadBufferPositive(
+        pad_data: *mut SceCtrlData,
+        count: i32,
+    ) -> i32;
+    pub fn sceCtrlReadBufferNegative(
+        pad_data: *mut SceCtrlData,
+        count: i32,
+    ) -> i32;
     pub fn sceCtrlPeekLatch(latch_data: *mut SceCtrlLatch) -> i32;
     pub fn sceCtrlReadLatch(latch_data: *mut SceCtrlLatch) -> i32;
-    pub fn sceCtrlSetIdleCancelThreshold(idlereset: i32, idleback: i32) -> i32;
-    pub fn sceCtrlGetIdleCancelThreshold(idlereset: *mut i32, idleback: *mut i32) -> i32;
+    pub fn sceCtrlSetIdleCancelThreshold(idlereset: i32, idleback: i32)
+        -> i32;
+    pub fn sceCtrlGetIdleCancelThreshold(
+        idlereset: *mut i32,
+        idleback: *mut i32,
+    ) -> i32;
 }
diff --git a/src/psp/display.rs b/src/psp/display.rs
index 6781e714cfb26274a95f801bfa81a8e6e05de754..2c2cd70fefb0bbb3f51b85d9ebffcea2f4e3e0e6 100644
--- a/src/psp/display.rs
+++ b/src/psp/display.rs
@@ -22,9 +22,17 @@ pub enum DisplaySetBufSync {
     NextFrame = 1,
 }
 
-extern {
-    pub fn sceDisplaySetMode(mode: DisplayMode, width: usize, height: usize) -> u32;
-    pub fn sceDisplayGetMode(pmode: *mut i32, pwidth: *mut i32, pheight: *mut i32) -> i32;
+extern "C" {
+    pub fn sceDisplaySetMode(
+        mode: DisplayMode,
+        width: usize,
+        height: usize,
+    ) -> u32;
+    pub fn sceDisplayGetMode(
+        pmode: *mut i32,
+        pwidth: *mut i32,
+        pheight: *mut i32,
+    ) -> i32;
     pub fn sceDisplaySetFrameBuf(
         top_addr: *const u8,
         buffer_width: usize,
diff --git a/src/psp/ge.rs b/src/psp/ge.rs
index 3bfd5c800b3bc56587d1b425e5abe4076063196e..2663565a6299854c84e7be587e7d054a7a73cd1d 100644
--- a/src/psp/ge.rs
+++ b/src/psp/ge.rs
@@ -9,15 +9,15 @@ pub struct GeContext {
 #[derive(Copy, Clone)]
 #[repr(C)]
 pub struct GeStack {
-    pub stack: [u32;8]
+    pub stack: [u32; 8],
 }
 
 #[derive(Copy, Clone)]
 #[repr(C)]
 pub struct GeCallbackData {
-    pub signal_func: Option<extern fn(id: i32, arg: *mut c_void)>,
+    pub signal_func: Option<extern "C" fn(id: i32, arg: *mut c_void)>,
     pub signal_arg: *mut c_void,
-    pub finish_func: Option<extern fn(id: i32, arg: *mut c_void)>,
+    pub finish_func: Option<extern "C" fn(id: i32, arg: *mut c_void)>,
     pub finish_arg: *mut c_void,
 }
 
@@ -33,7 +33,7 @@ pub struct GeListArgs {
 #[derive(Copy, Clone)]
 #[repr(C)]
 pub struct GeBreakParam {
-    pub buf: [u32;4]
+    pub buf: [u32; 4],
 }
 
 #[derive(Copy, Clone)]
@@ -325,7 +325,7 @@ pub enum GeCommand {
     NopFF = 0xff,
 }
 
-extern {
+extern "C" {
     pub fn sceGeEdramGetSize() -> u32;
     pub fn sceGeEdramGetAddr() -> *mut u8;
     pub fn sceGeEdramSetAddrTranslation(width: i32) -> i32;
@@ -335,12 +335,17 @@ extern {
     pub fn sceGeSaveContext(context: *mut GeContext) -> i32;
     pub fn sceGeRestoreContext(context: *const GeContext) -> i32;
     pub fn sceGeListEnQueue(
-       list: *const c_void,
-       stall: *mut c_void,
-       cbid: i32,
-       arg: *mut GeListArgs,
+        list: *const c_void,
+        stall: *mut c_void,
+        cbid: i32,
+        arg: *mut GeListArgs,
+    ) -> i32;
+    pub fn sceGeListEnQueueHead(
+        list: *const c_void,
+        stall: *mut c_void,
+        cbid: i32,
+        arg: *mut GeListArgs,
     ) -> i32;
-    pub fn sceGeListEnQueueHead(list: *const c_void, stall: *mut c_void, cbid: i32, arg: *mut GeListArgs) -> i32;
     pub fn sceGeListDeQueue(qid: i32) -> i32;
     pub fn sceGeListUpdateStallAddr(qid: i32, stall: *mut c_void) -> i32;
     pub fn sceGeListSync(qid: i32, sync_type: i32) -> GeListState;
diff --git a/src/psp/gu.rs b/src/psp/gu.rs
index 9a50b7767f26ce194eb446591703813eba5e1b46..c64eb020a0f0b46665c42524b7781268d28d1857 100644
--- a/src/psp/gu.rs
+++ b/src/psp/gu.rs
@@ -1,10 +1,12 @@
 use super::{
-    c_void,
-    ge::{GeContext, GeCommand, GeListState},
-    display::DisplayPixelFormat,
-    types::{ScePspFMatrix4, ScePspFVector3, ScePspIMatrix4},
+    c_void, DisplayPixelFormat, GeCommand, GeContext, GeListState,
+    ScePspFMatrix4, ScePspFVector3, ScePspIMatrix4,
 };
 
+pub type GuCallback = Option<extern "C" fn(id: i32, arg: *mut c_void)>;
+pub type GuSwapBuffersCallback =
+    Option<extern "C" fn(display: *mut *mut c_void, render: *mut *mut c_void)>;
+
 pub const GU_PI: f32 = 3.141593;
 
 #[repr(u32)]
@@ -411,14 +413,24 @@ pub enum ClutPixelFormat {
     Psm8888 = 3,
 }
 
-pub type GuCallback = Option<extern fn(id: i32, arg: *mut c_void)>;
-pub type GuSwapBuffersCallback = Option<extern fn(display: *mut *mut c_void, render: *mut *mut c_void)>;
-
-extern {
+extern "C" {
     pub fn sceGuDepthBuffer(zbp: *mut c_void, zbw: i32);
-    pub fn sceGuDispBuffer(width: i32, height: i32, dispbp: *mut c_void, dispbw: i32);
-    pub fn sceGuDrawBuffer(psm: DisplayPixelFormat, fbp: *mut c_void, fbw: i32);
-    pub fn sceGuDrawBufferList(psm: DisplayPixelFormat, fbp: *mut c_void, fbw: i32);
+    pub fn sceGuDispBuffer(
+        width: i32,
+        height: i32,
+        dispbp: *mut c_void,
+        dispbw: i32,
+    );
+    pub fn sceGuDrawBuffer(
+        psm: DisplayPixelFormat,
+        fbp: *mut c_void,
+        fbw: i32,
+    );
+    pub fn sceGuDrawBufferList(
+        psm: DisplayPixelFormat,
+        fbp: *mut c_void,
+        fbw: i32,
+    );
     pub fn sceGuDisplay(state: bool) -> bool;
     pub fn sceGuDepthFunc(function: DepthFunc);
     pub fn sceGuDepthMask(mask: i32);
@@ -446,9 +458,16 @@ extern {
     pub fn sceGuCallList(list: *const c_void);
     pub fn sceGuCallMode(mode: i32);
     pub fn sceGuCheckList() -> i32;
-    pub fn sceGuSendList(mode: GuQueueMode, list: *const c_void, context: *mut GeContext);
+    pub fn sceGuSendList(
+        mode: GuQueueMode,
+        list: *const c_void,
+        context: *mut GeContext,
+    );
     pub fn sceGuSwapBuffers() -> *mut c_void;
-    pub fn sceGuSync(mode: GuSyncMode, behavior: GuSyncBehavior) -> GeListState;
+    pub fn sceGuSync(
+        mode: GuSyncMode,
+        behavior: GuSyncBehavior,
+    ) -> GeListState;
     pub fn sceGuDrawArray(
         prim: GuPrimitive,
         vtype: i32,
@@ -478,7 +497,12 @@ extern {
     pub fn sceGuLightAtt(light: i32, atten0: f32, atten1: f32, atten2: f32);
     pub fn sceGuLightColor(light: i32, component: i32, color: u32);
     pub fn sceGuLightMode(mode: LightMode);
-    pub fn sceGuLightSpot(light: i32, direction: &ScePspFVector3, exponent: f32, cutoff: f32);
+    pub fn sceGuLightSpot(
+        light: i32,
+        direction: &ScePspFVector3,
+        exponent: f32,
+        cutoff: f32,
+    );
     pub fn sceGuClear(flags: i32);
     pub fn sceGuClearColor(color: u32);
     pub fn sceGuClearDepth(depth: u32);
@@ -500,7 +524,12 @@ extern {
         dest_fix: u32,
     );
     pub fn sceGuMaterial(components: i32, color: u32);
-    pub fn sceGuModelColor(emissive: u32, ambient: u32, diffuse: u32, specular: u32);
+    pub fn sceGuModelColor(
+        emissive: u32,
+        ambient: u32,
+        diffuse: u32,
+        specular: u32,
+    );
     pub fn sceGuStencilFunc(func: StencilFunc, ref_: i32, mask: i32);
     pub fn sceGuStencilOp(
         fail: StencilOperation,
@@ -529,10 +558,21 @@ extern {
     pub fn sceGuTexFilter(min: TextureFilter, mag: TextureFilter);
     pub fn sceGuTexFlush();
     pub fn sceGuTexFunc(tfx: TextureEffect, tcc: TextureColorComponent);
-    pub fn sceGuTexImage(mipmap: MipmapLevel, width: i32, height: i32, tbw: i32, tbp: *const c_void);
+    pub fn sceGuTexImage(
+        mipmap: MipmapLevel,
+        width: i32,
+        height: i32,
+        tbw: i32,
+        tbp: *const c_void,
+    );
     pub fn sceGuTexLevelMode(mode: TextureLevelMode, bias: f32);
     pub fn sceGuTexMapMode(mode: TextureMapMode, a1: u32, a2: u32);
-    pub fn sceGuTexMode(tpsm: TexturePixelFormat, maxmips: i32, a2: i32, swizzle: i32);
+    pub fn sceGuTexMode(
+        tpsm: TexturePixelFormat,
+        maxmips: i32,
+        a2: i32,
+        swizzle: i32,
+    );
     pub fn sceGuTexOffset(u: f32, v: f32);
     pub fn sceGuTexProjMapMode(mode: TextureProjectionMapMode);
     pub fn sceGuTexScale(u: f32, v: f32);
@@ -541,7 +581,12 @@ extern {
     pub fn sceGuTexSync();
     pub fn sceGuTexWrap(u: GuTexWrapMode, v: GuTexWrapMode);
     pub fn sceGuClutLoad(num_blocks: i32, cbp: *const c_void);
-    pub fn sceGuClutMode(cpsm: ClutPixelFormat, shift: u32, mask: u32, a3: u32);
+    pub fn sceGuClutMode(
+        cpsm: ClutPixelFormat,
+        shift: u32,
+        mask: u32,
+        a3: u32,
+    );
     pub fn sceGuOffset(x: u32, y: u32);
     pub fn sceGuScissor(x: i32, y: i32, w: i32, h: i32);
     pub fn sceGuViewport(cx: i32, cy: i32, width: i32, height: i32);
diff --git a/src/psp/gum.rs b/src/psp/gum.rs
index a9cfe498660e84af28b8329181b9f05b175fd634..044c7e092dcfed7e661020cbeb16dbec3e05a65c 100644
--- a/src/psp/gum.rs
+++ b/src/psp/gum.rs
@@ -1,6 +1,6 @@
-use super::{c_void, ScePspFMatrix4, ScePspFVector3, MatrixMode, GuPrimitive};
+use super::{c_void, GuPrimitive, MatrixMode, ScePspFMatrix4, ScePspFVector3};
 
-extern {
+extern "C" {
     pub fn sceGumDrawArray(
         prim: GuPrimitive,
         v_type: i32,
@@ -40,7 +40,11 @@ extern {
     pub fn sceGumFullInverse();
     pub fn sceGumLoadIdentity();
     pub fn sceGumLoadMatrix(m: &ScePspFMatrix4);
-    pub fn sceGumLookAt(eye: &ScePspFVector3, center: &ScePspFVector3, up: &ScePspFVector3);
+    pub fn sceGumLookAt(
+        eye: &ScePspFVector3,
+        center: &ScePspFVector3,
+        up: &ScePspFVector3,
+    );
     pub fn sceGumMatrixMode(mode: MatrixMode);
     pub fn sceGumMultMatrix(m: &ScePspFMatrix4);
     pub fn sceGumOrtho(
@@ -49,7 +53,7 @@ extern {
         bottom: f32,
         top: f32,
         near: f32,
-        far: f32
+        far: f32,
     );
     pub fn sceGumPerspective(fovy: f32, aspect: f32, near: f32, far: f32);
     pub fn sceGumPopMatrix();
diff --git a/src/psp/io.rs b/src/psp/io.rs
index 1b0a3c95357771b035ae5430a3f517af1299c66e..f9acaaa47b525695238f3bf3fb2838557060be26 100644
--- a/src/psp/io.rs
+++ b/src/psp/io.rs
@@ -1,4 +1,6 @@
-use super::{c_void, SceUid, ScePspDateTime};
+use super::{c_void, ScePspDateTime, SceUid};
+
+pub type IoPermissions = i32;
 
 #[repr(C)]
 #[derive(Copy, Clone)]
@@ -70,14 +72,16 @@ pub const PSP_O_TRUNC: i32 = 0x0400;
 pub const PSP_O_EXCL: i32 = 0x0800;
 pub const PSP_O_NO_WAIT: i32 = 0x8000;
 
-pub type IoPermissions = i32;
-
-extern {
-    pub fn sceIoOpen(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid;
+extern "C" {
+    pub fn sceIoOpen(
+        file: *const u8,
+        flags: i32,
+        permissions: IoPermissions,
+    ) -> SceUid;
     pub fn sceIoOpenAsync(
         file: *const u8,
         flags: i32,
-        permissions: IoPermissions
+        permissions: IoPermissions,
     ) -> SceUid;
     pub fn sceIoClose(fd: SceUid) -> i32;
     pub fn sceIoCloseAsync(fd: SceUid) -> i32;
@@ -88,7 +92,8 @@ extern {
     pub fn sceIoLseek(fd: SceUid, offset: i64, whence: IoWhence) -> i64;
     pub fn sceIoLseekAsync(fd: SceUid, offset: i64, whence: IoWhence) -> i32;
     pub fn sceIoLseek32(fd: SceUid, offset: i32, whence: IoWhence) -> i32;
-    pub fn sceIoLseek32Async(fd: SceUid, offset: i32, whence: IoWhence) -> i32;
+    pub fn sceIoLseek32Async(fd: SceUid, offset: i32, whence: IoWhence)
+        -> i32;
     pub fn sceIoRemove(file: *const u8) -> i32;
     pub fn sceIoMkdir(dir: *const u8, mode: IoPermissions) -> i32;
     pub fn sceIoRmdir(path: *const u8) -> i32;
@@ -103,7 +108,7 @@ extern {
         indata: *mut c_void,
         inlen: i32,
         outdata: *mut c_void,
-        outlen: i32
+        outlen: i32,
     ) -> i32;
     pub fn sceIoAssign(
         dev1: *const u8,
@@ -111,18 +116,22 @@ extern {
         dev3: *const u8,
         mode: IoAssignPerms,
         unk1: *mut c_void,
-        unk2: i32
+        unk2: i32,
     ) -> i32;
     pub fn sceIoUnassign(dev: *const u8) -> i32;
     pub fn sceIoGetstat(file: *const u8, stat: *mut SceIoStat) -> i32;
-    pub fn sceIoChstat(file: *const u8, stat: *mut SceIoStat, bits: i32) -> i32;
+    pub fn sceIoChstat(
+        file: *const u8,
+        stat: *mut SceIoStat,
+        bits: i32,
+    ) -> i32;
     pub fn sceIoIoctl(
         fd: SceUid,
         cmd: u32,
         indata: *mut c_void,
         inlen: i32,
         outdata: *mut c_void,
-        outlen: i32
+        outlen: i32,
     ) -> i32;
     pub fn sceIoIoctlAsync(
         fd: SceUid,
@@ -130,7 +139,7 @@ extern {
         indata: *mut c_void,
         inlen: i32,
         outdata: *mut c_void,
-        outlen: i32
+        outlen: i32,
     ) -> i32;
     pub fn sceIoSync(device: *const u8, unk: u32) -> i32;
     pub fn sceIoWaitAsync(fd: SceUid, res: *mut i64) -> i32;
@@ -143,6 +152,6 @@ extern {
     pub fn sceIoSetAsyncCallback(
         fd: SceUid,
         cb: SceUid,
-        argp: *mut c_void
+        argp: *mut c_void,
     ) -> i32;
 }
diff --git a/src/psp/kernel/mod.rs b/src/psp/kernel/mod.rs
index 7b65f0bfb822edd27998eecb7ac344341f9af9be..0209c5e97e861fbd3e0ecbf7cbcb81941ead65af 100644
--- a/src/psp/kernel/mod.rs
+++ b/src/psp/kernel/mod.rs
@@ -1,8 +1,5 @@
 use super::c_void;
 
-mod thread;
-pub use self::thread::*;
-
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SceKernelLoadExecParam {
@@ -12,7 +9,7 @@ pub struct SceKernelLoadExecParam {
     pub key: *const u8,
 }
 
-extern {
+extern "C" {
     pub fn sceKernelExitGame();
     pub fn sceKernelRegisterExitCallback(id: SceUid) -> i32;
     pub fn sceKernelLoadExec(
@@ -51,7 +48,7 @@ pub enum SceSysMemBlockTypes {
     Addr,
 }
 
-extern {
+extern "C" {
     pub fn sceKernelAllocPartitionMemory(
         partition: SceSysMemPartitionId,
         name: *const u8,
@@ -107,40 +104,38 @@ pub struct SceKernelUtilsMd5Context {
     pub buf: [u8; 64usize],
 }
 
-extern {
+extern "C" {
     pub fn sceKernelLibcTime(t: *mut i32) -> i32;
     pub fn sceKernelLibcClock() -> u32;
-    pub fn sceKernelLibcGettimeofday(tp: *mut timeval, tzp: *mut timezone) -> i32;
+    pub fn sceKernelLibcGettimeofday(
+        tp: *mut timeval,
+        tzp: *mut timezone,
+    ) -> i32;
     pub fn sceKernelDcacheWritebackAll();
     pub fn sceKernelDcacheWritebackInvalidateAll();
-    pub fn sceKernelDcacheWritebackRange(
-        p: *const c_void,
-        size: u32,
-    );
+    pub fn sceKernelDcacheWritebackRange(p: *const c_void, size: u32);
     pub fn sceKernelDcacheWritebackInvalidateRange(
         p: *const c_void,
         size: u32,
     );
-    pub fn sceKernelDcacheInvalidateRange(
-        p: *const c_void,
-        size: u32,
-    );
+    pub fn sceKernelDcacheInvalidateRange(p: *const c_void, size: u32);
     pub fn sceKernelIcacheInvalidateAll();
-    pub fn sceKernelIcacheInvalidateRange(
-        p: *const c_void,
-        size: u32,
-    );
+    pub fn sceKernelIcacheInvalidateRange(p: *const c_void, size: u32);
     pub fn sceKernelUtilsMt19937Init(
         ctx: *mut SceKernelUtilsMt19937Context,
         seed: u32,
     ) -> i32;
-    pub fn sceKernelUtilsMt19937UInt(ctx: *mut SceKernelUtilsMt19937Context) -> u32;
+    pub fn sceKernelUtilsMt19937UInt(
+        ctx: *mut SceKernelUtilsMt19937Context,
+    ) -> u32;
     pub fn sceKernelUtilsMd5Digest(
         data: *mut u8,
         size: u32,
         digest: *mut u8,
     ) -> i32;
-    pub fn sceKernelUtilsMd5BlockInit(ctx: *mut SceKernelUtilsMd5Context) -> i32;
+    pub fn sceKernelUtilsMd5BlockInit(
+        ctx: *mut SceKernelUtilsMd5Context,
+    ) -> i32;
     pub fn sceKernelUtilsMd5BlockUpdate(
         ctx: *mut SceKernelUtilsMd5Context,
         data: *mut u8,
@@ -232,25 +227,16 @@ pub enum SubInterrupt {
     Display = Interrupt::Vblank as u32,
 }
 
-extern {
+extern "C" {
     pub fn sceKernelRegisterSubIntrHandler(
         int_no: i32,
         no: i32,
         handler: *mut c_void,
         arg: *mut c_void,
     ) -> i32;
-    pub fn sceKernelReleaseSubIntrHandler(
-        int_no: i32,
-        no: i32,
-    ) -> i32;
-    pub fn sceKernelEnableSubIntr(
-        int_no: i32,
-        no: i32,
-    ) -> i32;
-    pub fn sceKernelDisableSubIntr(
-        int_no: i32,
-        no: i32,
-    ) -> i32;
+    pub fn sceKernelReleaseSubIntrHandler(int_no: i32, no: i32) -> i32;
+    pub fn sceKernelEnableSubIntr(int_no: i32, no: i32) -> i32;
+    pub fn sceKernelDisableSubIntr(int_no: i32, no: i32) -> i32;
     pub fn QueryIntrHandlerInfo(
         intr_code: SceUid,
         sub_intr_code: SceUid,
@@ -258,7 +244,7 @@ extern {
     ) -> i32;
 }
 
-extern {
+extern "C" {
     pub fn sceKernelCpuSuspendIntr() -> u32;
     pub fn sceKernelCpuResumeIntr(flags: u32);
     pub fn sceKernelCpuResumeIntrWithSync(flags: u32);
@@ -307,7 +293,7 @@ pub struct SceKernelModuleInfo {
     pub name: [u8; 28usize],
 }
 
-extern {
+extern "C" {
     pub fn sceKernelLoadModule(
         path: *const u8,
         flags: i32,
@@ -366,7 +352,7 @@ extern {
     ) -> i32;
 }
 
-extern {
+extern "C" {
     pub fn sceKernelVolatileMemLock(
         unk: i32,
         ptr: *mut *mut c_void,
@@ -380,8 +366,11 @@ extern {
     pub fn sceKernelVolatileMemUnlock(unk: i32) -> i32;
 }
 
-extern {
+extern "C" {
     pub fn sceKernelStdin() -> SceUid;
     pub fn sceKernelStdout() -> SceUid;
     pub fn sceKernelStderr() -> SceUid;
 }
+
+mod thread;
+pub use self::thread::*;
diff --git a/src/psp/kernel/thread.rs b/src/psp/kernel/thread.rs
index 1591dd16be76e8fc8e6ea2a62a1c50e6ec34c3d5..6b2c1a179c4336eb5d4327213439df61ab06b278 100644
--- a/src/psp/kernel/thread.rs
+++ b/src/psp/kernel/thread.rs
@@ -1,4 +1,27 @@
-use super::{SceUid, c_void};
+use super::{c_void, SceUid};
+
+pub type SceKernelVTimerHandler = unsafe extern "C" fn(
+    uid: SceUid,
+    arg1: *mut SceKernelSysClock,
+    arg2: *mut SceKernelSysClock,
+    arg3: *mut c_void,
+) -> u32;
+
+pub type SceKernelVTimerHandlerWide = unsafe extern "C" fn(
+    uid: SceUid,
+    arg1: i64,
+    arg2: i64,
+    arg3: *mut c_void,
+) -> u32;
+
+pub type SceKernelThreadEventHandler =
+    unsafe extern "C" fn(mask: i32, thid: SceUid, common: *mut c_void) -> i32;
+
+pub type SceKernelAlarmHandler =
+    unsafe extern "C" fn(common: *mut c_void) -> u32;
+
+pub type SceKernelCallbackFunction =
+    unsafe extern "C" fn(arg1: i32, arg2: i32, arg: *mut c_void) -> i32;
 
 #[repr(C)]
 #[derive(Copy, Clone)]
@@ -32,7 +55,8 @@ pub struct SceKernelSysClock {
     pub hi: u32,
 }
 
-pub type SceKernelThreadEntry = unsafe extern "C" fn(args: usize, argp: *mut c_void) -> i32;
+pub type SceKernelThreadEntry =
+    unsafe extern "C" fn(args: usize, argp: *mut c_void) -> i32;
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SceKernelThreadOptParam {
@@ -144,20 +168,6 @@ pub struct SceKernelMbxInfo {
     pub first_message: *mut c_void,
 }
 
-pub type SceKernelVTimerHandler = unsafe extern "C" fn(
-    uid: SceUid,
-    arg1: *mut SceKernelSysClock,
-    arg2: *mut SceKernelSysClock,
-    arg3: *mut c_void,
-) -> u32;
-
-pub type SceKernelVTimerHandlerWide = unsafe extern "C" fn(
-    uid: SceUid,
-    arg1: i64,
-    arg2: i64,
-    arg3: *mut c_void,
-) -> u32;
-
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SceKernelVTimerInfo {
@@ -171,12 +181,6 @@ pub struct SceKernelVTimerInfo {
     pub common: *mut c_void,
 }
 
-pub type SceKernelThreadEventHandler = unsafe extern "C" fn(
-    mask: i32,
-    thid: SceUid,
-    common: *mut c_void
-) -> i32;
-
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SceKernelThreadEventHandlerInfo {
@@ -188,8 +192,6 @@ pub struct SceKernelThreadEventHandlerInfo {
     pub common: *mut c_void,
 }
 
-pub type SceKernelAlarmHandler = unsafe extern "C" fn(common: *mut c_void) -> u32;
-
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SceKernelAlarmInfo {
@@ -283,12 +285,6 @@ pub struct SceKernelVTimerOptParam {
     pub size: usize,
 }
 
-pub type SceKernelCallbackFunction = unsafe extern "C" fn(
-    arg1: i32,
-    arg2: i32,
-    arg: *mut c_void,
-) -> i32;
-
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SceKernelCallbackInfo {
@@ -301,7 +297,7 @@ pub struct SceKernelCallbackInfo {
     pub notify_arg: i32,
 }
 
-extern {
+extern "C" {
     pub fn sceKernelGetThreadmanIdType(uid: SceUid) -> SceKernelIdListType;
     pub fn sceKernelCreateThread(
         name: *const u8,
@@ -334,18 +330,12 @@ extern {
     pub fn sceKernelDelayThread(delay: u32) -> i32;
     pub fn sceKernelDelayThreadCB(delay: u32) -> i32;
     pub fn sceKernelDelaySysClockThread(delay: *mut SceKernelSysClock) -> i32;
-    pub fn sceKernelDelaySysClockThreadCB(delay: *mut SceKernelSysClock) -> i32;
-    pub fn sceKernelChangeCurrentThreadAttr(
-        unknown: i32,
-        attr: i32,
-    ) -> i32;
-    pub fn sceKernelChangeThreadPriority(
-        thid: SceUid,
-        priority: i32,
-    ) -> i32;
-    pub fn sceKernelRotateThreadReadyQueue(
-        priority: i32,
+    pub fn sceKernelDelaySysClockThreadCB(
+        delay: *mut SceKernelSysClock,
     ) -> i32;
+    pub fn sceKernelChangeCurrentThreadAttr(unknown: i32, attr: i32) -> i32;
+    pub fn sceKernelChangeThreadPriority(thid: SceUid, priority: i32) -> i32;
+    pub fn sceKernelRotateThreadReadyQueue(priority: i32) -> i32;
     pub fn sceKernelReleaseWaitThread(thid: SceUid) -> i32;
     pub fn sceKernelGetThreadId() -> i32;
     pub fn sceKernelGetThreadCurrentPriority() -> i32;
@@ -368,10 +358,7 @@ extern {
         option: *mut SceKernelSemaOptParam,
     ) -> SceUid;
     pub fn sceKernelDeleteSema(sema_id: SceUid) -> i32;
-    pub fn sceKernelSignalSema(
-        sema_id: SceUid,
-        signal: i32,
-    ) -> i32;
+    pub fn sceKernelSignalSema(sema_id: SceUid, signal: i32) -> i32;
     pub fn sceKernelWaitSema(
         sema_id: SceUid,
         signal: i32,
@@ -382,10 +369,7 @@ extern {
         signal: i32,
         timeout: *mut u32,
     ) -> i32;
-    pub fn sceKernelPollSema(
-        sema_id: SceUid,
-        signal: i32,
-    ) -> i32;
+    pub fn sceKernelPollSema(sema_id: SceUid, signal: i32) -> i32;
     pub fn sceKernelReferSemaStatus(
         sema_id: SceUid,
         info: *mut SceKernelSemaInfo,
@@ -429,10 +413,7 @@ extern {
         option: *mut SceKernelMbxOptParam,
     ) -> SceUid;
     pub fn sceKernelDeleteMbx(mbx_id: SceUid) -> i32;
-    pub fn sceKernelSendMbx(
-        mbx_id: SceUid,
-        message: *mut c_void,
-    ) -> i32;
+    pub fn sceKernelSendMbx(mbx_id: SceUid, message: *mut c_void) -> i32;
     pub fn sceKernelReceiveMbx(
         mbx_id: SceUid,
         message: *mut *mut c_void,
@@ -443,14 +424,9 @@ extern {
         message: *mut *mut c_void,
         timeout: *mut u32,
     ) -> i32;
-    pub fn sceKernelPollMbx(
-        mbx_id: SceUid,
-        pmessage: *mut *mut c_void,
-    ) -> i32;
-    pub fn sceKernelCancelReceiveMbx(
-        mbx_id: SceUid,
-        num: *mut i32,
-    ) -> i32;
+    pub fn sceKernelPollMbx(mbx_id: SceUid, pmessage: *mut *mut c_void)
+        -> i32;
+    pub fn sceKernelCancelReceiveMbx(mbx_id: SceUid, num: *mut i32) -> i32;
     pub fn sceKernelReferMbxStatus(
         mbx_id: SceUid,
         info: *mut SceKernelMbxInfo,
@@ -480,10 +456,7 @@ extern {
         status: *mut SceKernelCallbackInfo,
     ) -> i32;
     pub fn sceKernelDeleteCallback(cb: SceUid) -> i32;
-    pub fn sceKernelNotifyCallback(
-        cb: SceUid,
-        arg2: i32,
-    ) -> i32;
+    pub fn sceKernelNotifyCallback(cb: SceUid, arg2: i32) -> i32;
     pub fn sceKernelCancelCallback(cb: SceUid) -> i32;
     pub fn sceKernelGetCallbackCount(cb: SceUid) -> i32;
     pub fn sceKernelCheckCallback() -> i32;
@@ -493,7 +466,9 @@ extern {
         read_buf_size: i32,
         id_count: *mut i32,
     ) -> i32;
-    pub fn sceKernelReferSystemStatus(status: *mut SceKernelSystemStatus) -> i32;
+    pub fn sceKernelReferSystemStatus(
+        status: *mut SceKernelSystemStatus,
+    ) -> i32;
     pub fn sceKernelCreateMsgPipe(
         name: *const u8,
         part: i32,
@@ -582,14 +557,8 @@ extern {
         size: u32,
         data: *mut *mut c_void,
     ) -> i32;
-    pub fn sceKernelFreeVpl(
-        uid: SceUid,
-        data: *mut c_void,
-    ) -> i32;
-    pub fn sceKernelCancelVpl(
-        uid: SceUid,
-        num: *mut i32,
-    ) -> i32;
+    pub fn sceKernelFreeVpl(uid: SceUid, data: *mut c_void) -> i32;
+    pub fn sceKernelCancelVpl(uid: SceUid, num: *mut i32) -> i32;
     pub fn sceKernelReferVplStatus(
         uid: SceUid,
         info: *mut SceKernelVplInfo,
@@ -613,18 +582,10 @@ extern {
         data: *mut *mut c_void,
         timeout: *mut u32,
     ) -> i32;
-    pub fn sceKernelTryAllocateFpl(
-        uid: SceUid,
-        data: *mut *mut c_void,
-    ) -> i32;
-    pub fn sceKernelFreeFpl(
-        uid: SceUid,
-        data: *mut c_void,
-    ) -> i32;
-    pub fn sceKernelCancelFpl(
-        uid: SceUid,
-        pnum: *mut i32,
-    ) -> i32;
+    pub fn sceKernelTryAllocateFpl(uid: SceUid, data: *mut *mut c_void)
+        -> i32;
+    pub fn sceKernelFreeFpl(uid: SceUid, data: *mut c_void) -> i32;
+    pub fn sceKernelCancelFpl(uid: SceUid, pnum: *mut i32) -> i32;
     pub fn sceKernelReferFplStatus(
         uid: SceUid,
         info: *mut SceKernelFplInfo,
diff --git a/src/psp/mpeg.rs b/src/psp/mpeg.rs
index 34e2232f8a399b1c7f5ed75c69ba83c3afc36b68..8ce889b3ab70279f8d072ef2b255f6fdd455ff6b 100644
--- a/src/psp/mpeg.rs
+++ b/src/psp/mpeg.rs
@@ -8,7 +8,11 @@ pub struct SceMpeg(*mut *mut c_void);
 #[derive(Copy, Clone)]
 pub struct SceMpegStream(*mut c_void);
 pub type SceMpegRingbufferCb = Option<
-    unsafe extern "C" fn(data: *mut c_void, num_packets: i32, param: *mut c_void) -> i32,
+    unsafe extern "C" fn(
+        data: *mut c_void,
+        num_packets: i32,
+        param: *mut c_void,
+    ) -> i32,
 >;
 
 #[repr(C)]
@@ -45,7 +49,7 @@ pub struct SceMpegAvcMode {
     pub pixel_format: super::DisplayPixelFormat,
 }
 
-extern {
+extern "C" {
     pub fn sceMpegInit() -> i32;
     pub fn sceMpegFinish();
     pub fn sceMpegRingbufferQueryMemSize(packets: i32) -> i32;
@@ -58,7 +62,9 @@ extern {
         cb_param: *mut c_void,
     ) -> i32;
     pub fn sceMpegRingbufferDestruct(ringbuffer: *mut SceMpegRingbuffer);
-    pub fn sceMpegRingbufferAvailableSize(ringbuffer: *mut SceMpegRingbuffer) -> i32;
+    pub fn sceMpegRingbufferAvailableSize(
+        ringbuffer: *mut SceMpegRingbuffer,
+    ) -> i32;
     pub fn sceMpegRingbufferPut(
         ringbuffer: *mut SceMpegRingbuffer,
         num_packets: i32,
@@ -95,14 +101,21 @@ extern {
         es_size: *mut i32,
         out_size: *mut i32,
     ) -> i32;
-    pub fn sceMpegInitAu(handle: SceMpeg, es_buffer: *mut c_void, au: *mut SceMpegAu) -> i32;
+    pub fn sceMpegInitAu(
+        handle: SceMpeg,
+        es_buffer: *mut c_void,
+        au: *mut SceMpegAu,
+    ) -> i32;
     pub fn sceMpegGetAvcAu(
         handle: SceMpeg,
         stream: SceMpegStream,
         au: *mut SceMpegAu,
         unk: *mut i32,
     ) -> i32;
-    pub fn sceMpegAvcDecodeMode(handle: SceMpeg, mode: *mut SceMpegAvcMode) -> i32;
+    pub fn sceMpegAvcDecodeMode(
+        handle: SceMpeg,
+        mode: *mut SceMpegAvcMode,
+    ) -> i32;
     pub fn sceMpegAvcDecode(
         handle: SceMpeg,
         au: *mut SceMpegAu,
@@ -161,7 +174,7 @@ pub struct SceMpegYCrCbBuffer {
     pub unknown3: [i32; 11usize],
 }
 
-extern {
+extern "C" {
     pub fn sceMpegBaseYCrCbCopyVme(
         yuv_buffer: *mut c_void,
         buffer: *mut i32,
diff --git a/src/psp/net.rs b/src/psp/net.rs
index 4b22512ce48beeec5afe4e57a84a65b2d3966d7e..da578d67a37f77967081d769e0ff21873f63a38a 100644
--- a/src/psp/net.rs
+++ b/src/psp/net.rs
@@ -1,5 +1,50 @@
 use super::c_void;
 
+pub type SceNetAdhocctlHandler =
+    Option<unsafe extern "C" fn(flag: i32, error: i32, unknown: *mut c_void)>;
+
+pub type AdhocMatchingCallback = Option<
+    unsafe extern "C" fn(
+        matching_id: i32,
+        event: i32,
+        mac: *mut u8,
+        opt_len: i32,
+        opt_data: *mut c_void,
+    ),
+>;
+
+pub type SceNetApctlHandler = Option<
+    unsafe extern "C" fn(
+        oldState: i32,
+        newState: i32,
+        event: i32,
+        error: i32,
+        pArg: *mut c_void,
+    ),
+>;
+
+pub type HttpMallocFunction =
+    Option<unsafe extern "C" fn(size: usize) -> *mut c_void>;
+pub type HttpReallocFunction =
+    Option<unsafe extern "C" fn(p: *mut c_void, size: usize) -> *mut c_void>;
+pub type HttpFreeFunction = Option<unsafe extern "C" fn(p: *mut c_void)>;
+pub type HttpPasswordCB = Option<
+    unsafe extern "C" fn(
+        request: i32,
+        auth_type: HttpAuthType,
+        realm: *const u8,
+        username: *mut u8,
+        password: *mut u8,
+        need_entity: i32,
+        entity_body: *mut *mut u8,
+        entity_size: *mut usize,
+        save: *mut i32,
+    ) -> i32,
+>;
+
+#[allow(non_camel_case_types)]
+pub type socklen_t = u32;
+
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SceNetMallocStat {
@@ -8,7 +53,7 @@ pub struct SceNetMallocStat {
     pub free: i32,
 }
 
-extern {
+extern "C" {
     pub fn sceNetInit(
         poolsize: i32,
         calloutprio: i32,
@@ -70,10 +115,7 @@ pub struct SceNetAdhocctlParams {
     pub nickname: [u8; 128usize],
 }
 
-pub type SceNetAdhocctlHandler =
-    Option<unsafe extern "C" fn(flag: i32, error: i32, unknown: *mut c_void)>;
-
-extern {
+extern "C" {
     pub fn sceNetAdhocctlInit(
         stacksize: i32,
         priority: i32,
@@ -123,16 +165,16 @@ extern {
         unknown: *mut c_void,
     ) -> i32;
     pub fn sceNetAdhocctlDelHandler(id: i32) -> i32;
-    pub fn sceNetAdhocctlGetNameByAddr(
-        mac: *mut u8,
-        nickname: *mut u8,
-    ) -> i32;
+    pub fn sceNetAdhocctlGetNameByAddr(mac: *mut u8, nickname: *mut u8)
+        -> i32;
     pub fn sceNetAdhocctlGetAddrByName(
         nickname: *mut u8,
         length: *mut i32,
         buf: *mut c_void,
     ) -> i32;
-    pub fn sceNetAdhocctlGetParameter(params: *mut SceNetAdhocctlParams) -> i32;
+    pub fn sceNetAdhocctlGetParameter(
+        params: *mut SceNetAdhocctlParams,
+    ) -> i32;
 }
 
 #[repr(C)]
@@ -169,7 +211,7 @@ pub struct SceNetAdhocPdpStat {
     pub rcvd_data: u32,
 }
 
-extern {
+extern "C" {
     pub fn sceNetAdhocInit() -> i32;
     pub fn sceNetAdhocTerm() -> i32;
     pub fn sceNetAdhocPdpCreate(
@@ -178,10 +220,7 @@ extern {
         buf_size: u32,
         unk1: i32,
     ) -> i32;
-    pub fn sceNetAdhocPdpDelete(
-        id: i32,
-        unk1: i32,
-    ) -> i32;
+    pub fn sceNetAdhocPdpDelete(id: i32, unk1: i32) -> i32;
     pub fn sceNetAdhocPdpSend(
         id: i32,
         dest_mac_addr: *mut u8,
@@ -214,10 +253,7 @@ extern {
         size: i32,
     ) -> i32;
     pub fn sceNetAdhocGameModeUpdateMaster() -> i32;
-    pub fn sceNetAdhocGameModeUpdateReplica(
-        id: i32,
-        unk1: i32,
-    ) -> i32;
+    pub fn sceNetAdhocGameModeUpdateReplica(id: i32, unk1: i32) -> i32;
     pub fn sceNetAdhocGameModeDeleteMaster() -> i32;
     pub fn sceNetAdhocGameModeDeleteReplica(id: i32) -> i32;
     pub fn sceNetAdhocPtpOpen(
@@ -230,11 +266,7 @@ extern {
         count: i32,
         unk1: i32,
     ) -> i32;
-    pub fn sceNetAdhocPtpConnect(
-        id: i32,
-        timeout: u32,
-        nonblock: i32,
-    ) -> i32;
+    pub fn sceNetAdhocPtpConnect(id: i32, timeout: u32, nonblock: i32) -> i32;
     pub fn sceNetAdhocPtpListen(
         srcmac: *mut u8,
         srcport: u16,
@@ -265,15 +297,8 @@ extern {
         timeout: u32,
         nonblock: i32,
     ) -> i32;
-    pub fn sceNetAdhocPtpFlush(
-        id: i32,
-        timeout: u32,
-        nonblock: i32,
-    ) -> i32;
-    pub fn sceNetAdhocPtpClose(
-        id: i32,
-        unk1: i32,
-    ) -> i32;
+    pub fn sceNetAdhocPtpFlush(id: i32, timeout: u32, nonblock: i32) -> i32;
+    pub fn sceNetAdhocPtpClose(id: i32, unk1: i32) -> i32;
     pub fn sceNetAdhocGetPtpStat(
         size: *mut i32,
         stat: *mut SceNetAdhocPtpStat,
@@ -288,16 +313,6 @@ pub struct AdhocPoolStat {
     pub freesize: i32,
 }
 
-pub type AdhocMatchingCallback = Option<
-    unsafe extern "C" fn(
-        matching_id: i32,
-        event: i32,
-        mac: *mut u8,
-        opt_len: i32,
-        opt_data: *mut c_void,
-    ),
->;
-
 #[repr(u32)]
 #[derive(Copy, Clone)]
 pub enum AdhocMatchingMode {
@@ -306,7 +321,7 @@ pub enum AdhocMatchingMode {
     Ptp,
 }
 
-extern {
+extern "C" {
     pub fn sceNetAdhocMatchingInit(memsize: i32) -> i32;
     pub fn sceNetAdhocMatchingTerm() -> i32;
     pub fn sceNetAdhocMatchingCreate(
@@ -373,7 +388,8 @@ extern {
         buf: *mut c_void,
     ) -> i32;
     pub fn sceNetAdhocMatchingGetPoolMaxAlloc() -> i32;
-    pub fn sceNetAdhocMatchingGetPoolStat(poolstat: *mut AdhocPoolStat) -> i32;
+    pub fn sceNetAdhocMatchingGetPoolStat(poolstat: *mut AdhocPoolStat)
+        -> i32;
 }
 
 #[repr(u32)]
@@ -460,15 +476,8 @@ pub union SceNetApctlInfo {
     pub wifisp: u32,
 }
 
-pub type SceNetApctlHandler = Option<
-    unsafe extern "C" fn(oldState: i32, newState: i32, event: i32, error: i32, pArg: *mut c_void),
->;
-
-extern {
-    pub fn sceNetApctlInit(
-        stack_size: i32,
-        init_priority: i32,
-    ) -> i32;
+extern "C" {
+    pub fn sceNetApctlInit(stack_size: i32, init_priority: i32) -> i32;
     pub fn sceNetApctlTerm() -> i32;
     pub fn sceNetApctlGetInfo(
         code: ApctlInfo,
@@ -484,14 +493,11 @@ extern {
     pub fn sceNetApctlGetState(pstate: *mut ApctlState) -> i32;
 }
 
-#[allow(non_camel_case_types)]
-pub type socklen_t = u32;
-
 #[derive(Copy, Clone)]
 #[repr(C)]
 pub struct sockaddr(pub u32);
 
-extern {
+extern "C" {
     pub fn sceNetInetInit() -> i32;
     pub fn sceNetInetTerm() -> i32;
     pub fn sceNetInetAccept(
@@ -516,10 +522,7 @@ extern {
         opt_val: *mut c_void,
         optl_en: *mut socklen_t,
     ) -> i32;
-    pub fn sceNetInetListen(
-        s: i32,
-        backlog: i32,
-    ) -> i32;
+    pub fn sceNetInetListen(s: i32, backlog: i32) -> i32;
     pub fn sceNetInetRecv(
         s: i32,
         buf: *mut c_void,
@@ -555,20 +558,13 @@ extern {
         opt_val: *const c_void,
         opt_len: socklen_t,
     ) -> i32;
-    pub fn sceNetInetShutdown(
-        s: i32,
-        how: i32,
-    ) -> i32;
-    pub fn sceNetInetSocket(
-        domain: i32,
-        type_: i32,
-        protocol: i32,
-    ) -> i32;
+    pub fn sceNetInetShutdown(s: i32, how: i32) -> i32;
+    pub fn sceNetInetSocket(domain: i32, type_: i32, protocol: i32) -> i32;
     pub fn sceNetInetClose(s: i32) -> i32;
     pub fn sceNetInetGetErrno() -> i32;
 }
 
-extern {
+extern "C" {
     pub fn sceSslInit(unknown1: i32) -> i32;
     pub fn sceSslEnd() -> i32;
     pub fn sceSslGetUsedMemoryMax(memory: *mut u32) -> i32;
@@ -590,26 +586,7 @@ pub enum HttpAuthType {
     Digest,
 }
 
-pub type HttpMallocFunction = Option<unsafe extern "C" fn(size: usize) -> *mut c_void>;
-pub type HttpReallocFunction =
-    Option<unsafe extern "C" fn(p: *mut c_void, size: usize) -> *mut c_void>;
-
-pub type HttpFreeFunction = Option<unsafe extern "C" fn(p: *mut c_void)>;
-pub type HttpPasswordCB = Option<
-    unsafe extern "C" fn(
-        request: i32,
-        auth_type: HttpAuthType,
-        realm: *const u8,
-        username: *mut u8,
-        password: *mut u8,
-        need_entity: i32,
-        entity_body: *mut *mut u8,
-        entity_size: *mut usize,
-        save: *mut i32,
-    ) -> i32,
->;
-
-extern {
+extern "C" {
     pub fn sceHttpInit(unknown1: u32) -> i32;
     pub fn sceHttpEnd() -> i32;
     pub fn sceHttpCreateTemplate(
@@ -659,30 +636,13 @@ extern {
         request_id: i32,
         content_length: *mut u64,
     ) -> i32;
-    pub fn sceHttpGetStatusCode(
-        request_id: i32,
-        status_code: *mut i32,
-    ) -> i32;
-    pub fn sceHttpSetResolveTimeOut(
-        id: i32,
-        timeout: u32,
-    ) -> i32;
-    pub fn sceHttpSetResolveRetry(
-        id: i32,
-        count: i32,
-    ) -> i32;
-    pub fn sceHttpSetConnectTimeOut(
-        id: i32,
-        timeout: u32,
-    ) -> i32;
-    pub fn sceHttpSetSendTimeOut(
-        id: i32,
-        timeout: u32,
-    ) -> i32;
-    pub fn sceHttpSetRecvTimeOut(
-        id: i32,
-        timeout: u32,
-    ) -> i32;
+    pub fn sceHttpGetStatusCode(request_id: i32, status_code: *mut i32)
+        -> i32;
+    pub fn sceHttpSetResolveTimeOut(id: i32, timeout: u32) -> i32;
+    pub fn sceHttpSetResolveRetry(id: i32, count: i32) -> i32;
+    pub fn sceHttpSetConnectTimeOut(id: i32, timeout: u32) -> i32;
+    pub fn sceHttpSetSendTimeOut(id: i32, timeout: u32) -> i32;
+    pub fn sceHttpSetRecvTimeOut(id: i32, timeout: u32) -> i32;
     pub fn sceHttpEnableKeepAlive(id: i32) -> i32;
     pub fn sceHttpDisableKeepAlive(id: i32) -> i32;
     pub fn sceHttpEnableRedirect(id: i32) -> i32;
@@ -697,10 +657,7 @@ extern {
         value: *mut u8,
         unknown1: i32,
     ) -> i32;
-    pub fn sceHttpDeleteHeader(
-        id: i32,
-        name: *const u8,
-    ) -> i32;
+    pub fn sceHttpDeleteHeader(id: i32, name: *const u8) -> i32;
     pub fn sceHttpsInit(
         unknown1: i32,
         unknown2: i32,
@@ -708,10 +665,7 @@ extern {
         unknown4: i32,
     ) -> i32;
     pub fn sceHttpsEnd() -> i32;
-    pub fn sceHttpsLoadDefaultCert(
-        unknown1: i32,
-        unknown2: i32,
-    ) -> i32;
+    pub fn sceHttpsLoadDefaultCert(unknown1: i32, unknown2: i32) -> i32;
     pub fn sceHttpDisableAuth(id: i32) -> i32;
     pub fn sceHttpDisableCache(id: i32) -> i32;
     pub fn sceHttpEnableAuth(id: i32) -> i32;
@@ -722,10 +676,7 @@ extern {
         header: *mut *mut u8,
         header_size: *mut u32,
     ) -> i32;
-    pub fn sceHttpGetNetworkErrno(
-        request: i32,
-        err_num: *mut i32,
-    ) -> i32;
+    pub fn sceHttpGetNetworkErrno(request: i32, err_num: *mut i32) -> i32;
     pub fn sceHttpGetProxy(
         id: i32,
         activate_flag: *mut i32,
@@ -735,10 +686,7 @@ extern {
         proxy_port: *mut u16,
     ) -> i32;
     pub fn sceHttpInitCache(max_size: usize) -> i32;
-    pub fn sceHttpSetAuthInfoCB(
-        id: i32,
-        cbfunc: HttpPasswordCB,
-    ) -> i32;
+    pub fn sceHttpSetAuthInfoCB(id: i32, cbfunc: HttpPasswordCB) -> i32;
     pub fn sceHttpSetProxy(
         id: i32,
         activate_flag: i32,
@@ -746,10 +694,7 @@ extern {
         new_proxy_host: *const u8,
         new_proxy_port: u16,
     ) -> i32;
-    pub fn sceHttpSetResHeaderMaxSize(
-        id: i32,
-        header_size: u32,
-    ) -> i32;
+    pub fn sceHttpSetResHeaderMaxSize(id: i32, header_size: u32) -> i32;
     pub fn sceHttpSetMallocFunction(
         malloc_func: HttpMallocFunction,
         free_func: HttpFreeFunction,
@@ -761,7 +706,7 @@ extern {
 #[repr(C)]
 pub struct in_addr(pub u32);
 
-extern {
+extern "C" {
     pub fn sceNetResolverInit() -> i32;
     pub fn sceNetResolverCreate(
         rid: *mut i32,
diff --git a/src/psp/power.rs b/src/psp/power.rs
index dfb21e590e053c434ec7869e67041218eae312b9..910cc1701b25a48a4b0ceb67397a4f75e04e20c1 100644
--- a/src/psp/power.rs
+++ b/src/psp/power.rs
@@ -1,5 +1,7 @@
 use super::SceUid;
 
+pub type PowerCallback = extern "C" fn(unknown: i32, power_info: i32);
+
 pub const POWER_INFO_POWER_SWITCH: i32 = 0x80000000;
 pub const POWER_INFO_HOLD_SWITCH: i32 = 0x40000000;
 pub const POWER_INFO_STANDBY: i32 = 0x00080000;
@@ -19,9 +21,7 @@ pub enum PowerTick {
     Display = 6,
 }
 
-pub type PowerCallback = extern fn (unknown: i32, power_info: i32);
-
-extern {
+extern "C" {
     pub fn scePowerRegisterCallback(slot: i32, cbid: SceUid) -> i32;
     pub fn scePowerUnregisterCallback(slot: i32) -> i32;
     pub fn scePowerIsPowerOnline() -> i32;
@@ -42,7 +42,11 @@ extern {
     pub fn scePowerGetBusClockFrequency() -> i32;
     pub fn scePowerGetBusClockFrequencyInt() -> i32;
     pub fn scePowerGetBusClockFrequencyFloat() -> f32;
-    pub fn scePowerSetClockFrequency(pllfreq: i32, cpufreq: i32, busfreq: i32) -> i32;
+    pub fn scePowerSetClockFrequency(
+        pllfreq: i32,
+        cpufreq: i32,
+        busfreq: i32,
+    ) -> i32;
     pub fn scePowerLock(unknown: i32) -> i32;
     pub fn scePowerUnlock(unknown: i32) -> i32;
     pub fn scePowerTick(t: PowerTick) -> i32;
diff --git a/src/psp/rtc.rs b/src/psp/rtc.rs
index 909452f6c70247d9c022e8dc4abffe0a694d4522..ac3295b2173b578a9c2431cf3ee6ad8b2de21eb5 100644
--- a/src/psp/rtc.rs
+++ b/src/psp/rtc.rs
@@ -22,13 +22,19 @@ pub enum RtcCheckValidError {
     InvalidMicroseconds = -7,
 }
 
-extern {
+extern "C" {
     pub fn sceRtcGetTickResolution() -> u32;
     pub fn sceRtcGetCurrentTick(tick: *mut u64) -> i32;
     pub fn sceRtcGetCurrentClock(tm: *mut ScePspDateTime, tz: i32) -> i32;
     pub fn sceRtcGetCurrentClockLocalTime(tm: *mut ScePspDateTime) -> i32;
-    pub fn sceRtcConvertUtcToLocalTime(tick_utc: *const u64, tick_local: *mut u64) -> i32;
-    pub fn sceRtcConvertLocalTimeToUTC(tick_local: *const u64, tick_utc: *mut u64) -> i32;
+    pub fn sceRtcConvertUtcToLocalTime(
+        tick_utc: *const u64,
+        tick_local: *mut u64,
+    ) -> i32;
+    pub fn sceRtcConvertLocalTimeToUTC(
+        tick_local: *const u64,
+        tick_utc: *mut u64,
+    ) -> i32;
     pub fn sceRtcIsLeapYear(year: i32) -> i32;
     pub fn sceRtcGetDaysInMonth(year: i32, month: i32) -> i32;
     pub fn sceRtcGetDayOfWeek(year: i32, month: i32, day: i32) -> i32;
@@ -36,25 +42,88 @@ extern {
     pub fn sceRtcSetTick(date: *mut ScePspDateTime, tick: *const u64) -> i32;
     pub fn sceRtcGetTick(date: *const ScePspDateTime, tick: *mut u64) -> i32;
     pub fn sceRtcCompareTick(tick1: *const u64, tick2: *const u64) -> i32;
-    pub fn sceRtcTickAddTicks(dest_tick: *mut u64, src_tick: *const u64, num_ticks: u64) -> i32;
-    pub fn sceRtcTickAddMicroseconds(dest_tick: *mut u64, src_tick: *const u64, num_ms: u64) -> i32;
-    pub fn sceRtcTickAddSeconds(dest_tick: *mut u64, src_tick: *const u64, num_seconds: u64) -> i32;
-    pub fn sceRtcTickAddMinutes(dest_tick: *mut u64, src_tick: *const u64, num_minutes: u64) -> i32;
-    pub fn sceRtcTickAddHours(dest_tick: *mut u64, src_tick: *const u64, num_hours: u64) -> i32;
-    pub fn sceRtcTickAddDays(dest_tick: *mut u64, src_tick: *const u64, num_days: u64) -> i32;
-    pub fn sceRtcTickAddWeeks(dest_tick: *mut u64, src_tick: *const u64, num_weeks: u64) -> i32;
-    pub fn sceRtcTickAddMonths(dest_tick: *mut u64, src_tick: *const u64, num_months: u64) -> i32;
-    pub fn sceRtcTickAddYears(dest_tick: *mut u64, src_tick: *const u64, num_years: u64) -> i32;
+    pub fn sceRtcTickAddTicks(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_ticks: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddMicroseconds(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_ms: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddSeconds(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_seconds: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddMinutes(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_minutes: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddHours(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_hours: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddDays(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_days: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddWeeks(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_weeks: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddMonths(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_months: u64,
+    ) -> i32;
+    pub fn sceRtcTickAddYears(
+        dest_tick: *mut u64,
+        src_tick: *const u64,
+        num_years: u64,
+    ) -> i32;
     pub fn sceRtcSetTime_t(date: *mut ScePspDateTime, time: i64) -> i32;
-    pub fn sceRtcGetTime_t(date: *const ScePspDateTime, time: *mut i64) -> i32;
+    pub fn sceRtcGetTime_t(date: *const ScePspDateTime, time: *mut i64)
+        -> i32;
     pub fn sceRtcSetDosTime(date: *mut ScePspDateTime, dos_time: u32) -> i32;
     pub fn sceRtcGetDosTime(date: *mut ScePspDateTime, dos_time: u32) -> i32;
-    pub fn sceRtcSetWin32FileTime(date: *mut ScePspDateTime, time: *mut u64) -> i32;
-    pub fn sceRtcGetWin32FileTime(date: *mut ScePspDateTime, time: *mut u64) -> i32;
-    pub fn sceRtcParseDateTime(dest_tick: *mut u64, date_string: *const u8) -> i32;
-    pub fn sceRtcFormatRFC3339(psz_date_time: *mut char, p_utc: *const u64, time_zone_minutes: i32) -> i32;
-    pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32;
-    pub fn sceRtcParseRFC3339(p_utc: *mut u64, psz_date_time: *const u8) -> i32;
-    pub fn sceRtcFormatRFC2822(psz_date_time: *mut char, p_utc: *const u64, time_zone_minutes: i32) -> i32;
-    pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut char, p_utc: *const u64) -> i32;
+    pub fn sceRtcSetWin32FileTime(
+        date: *mut ScePspDateTime,
+        time: *mut u64,
+    ) -> i32;
+    pub fn sceRtcGetWin32FileTime(
+        date: *mut ScePspDateTime,
+        time: *mut u64,
+    ) -> i32;
+    pub fn sceRtcParseDateTime(
+        dest_tick: *mut u64,
+        date_string: *const u8,
+    ) -> i32;
+    pub fn sceRtcFormatRFC3339(
+        psz_date_time: *mut char,
+        p_utc: *const u64,
+        time_zone_minutes: i32,
+    ) -> i32;
+    pub fn sceRtcFormatRFC3339LocalTime(
+        psz_date_time: *mut char,
+        p_utc: *const u64,
+    ) -> i32;
+    pub fn sceRtcParseRFC3339(
+        p_utc: *mut u64,
+        psz_date_time: *const u8,
+    ) -> i32;
+    pub fn sceRtcFormatRFC2822(
+        psz_date_time: *mut char,
+        p_utc: *const u64,
+        time_zone_minutes: i32,
+    ) -> i32;
+    pub fn sceRtcFormatRFC2822LocalTime(
+        psz_date_time: *mut char,
+        p_utc: *const u64,
+    ) -> i32;
 }
diff --git a/src/psp/sircs.rs b/src/psp/sircs.rs
index 26ce22141fc6521ec5879066ef3c66708323e363..b6f2b5c7989d26c6997a9ee2e716a9cdecb32db0 100644
--- a/src/psp/sircs.rs
+++ b/src/psp/sircs.rs
@@ -1,5 +1,3 @@
-
-
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct SircsData {
diff --git a/src/psp/umd.rs b/src/psp/umd.rs
index 94e954fef4854ea1f16f0b28bcee25961ebc31c5..5d23ec760d4b70701c3b84248a40f2b6915b5f5a 100644
--- a/src/psp/umd.rs
+++ b/src/psp/umd.rs
@@ -1,3 +1,5 @@
+pub type UmdCallback = fn(unknown: i32, event: i32) -> i32;
+
 #[repr(C)]
 #[derive(Copy, Clone)]
 pub struct UmdInfo {
@@ -20,8 +22,6 @@ pub const UMD_INITING: i32 = 0x08;
 pub const UMD_INITED: i32 = 0x10;
 pub const UMD_READY: i32 = 0x20;
 
-pub type UmdCallback = fn(unknown: i32, event: i32) -> i32;
-
 extern {
     pub fn sceUmdCheckMedium() -> i32;
     pub fn sceUmdGetDiscInfo(info: *mut UmdInfo) -> i32;
diff --git a/src/psp/usb.rs b/src/psp/usb.rs
index 27d2d13b134097197ccc7aa886768e930a0d292c..85ddbd95dcf165d70ce73619e97c57bea245ad91 100644
--- a/src/psp/usb.rs
+++ b/src/psp/usb.rs
@@ -11,6 +11,9 @@ pub const ACTIVATED: i32 = 0x200;
 pub const CONNECTED: i32 = 0x020;
 pub const ESTABLISHED: i32 = 0x002;
 
+pub const USB_CAM_FLIP: i32 = 1;
+pub const USB_CAM_MIRROR: i32 = 0x100;
+
 extern {
     pub fn sceUsbStart(
         driver_name: *const u8,
@@ -128,9 +131,6 @@ pub enum UsbCamResolutionEx {
     Px1280_960 = 8,
 }
 
-pub const USB_CAM_FLIP: i32 = 1;
-pub const USB_CAM_MIRROR: i32 = 0x100;
-
 #[repr(i32)]
 #[derive(Copy, Clone)]
 pub enum UsbCamDelay {
diff --git a/src/psp/utility.rs b/src/psp/utility.rs
index a4c816bf0451b02169600a79dd8c5a64e418c04f..19148e3665b8be443be1b3f5475a7fc382cf033c 100644
--- a/src/psp/utility.rs
+++ b/src/psp/utility.rs
@@ -492,7 +492,8 @@ pub const UTILITY_HTMLVIEWER_DISABLE_EXIT_DIALOG: i32 = 0x000004;
 pub const UTILITY_HTMLVIEWER_DISABLE_CURSOR: i32 = 0x000008;
 pub const UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_COMPLETE_DIALOG: i32 = 0x000010;
 pub const UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_START_DIALOG: i32 = 0x000020;
-pub const UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_DESTINATION_DIALOG: i32 = 0x000040;
+pub const UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_DESTINATION_DIALOG: i32 =
+    0x000040;
 pub const UTILITY_HTMLVIEWER_LOCK_DOWNLOAD_DESTINATION_DIALOG: i32 = 0x000080;
 pub const UTILITY_HTMLVIEWER_DISABLE_TAB_DISPLAY: i32 = 0x000100;
 pub const UTILITY_HTMLVIEWER_ENABLE_ANALOG_HOLD: i32 = 0x000200;
@@ -527,7 +528,7 @@ pub struct SceUtilityOskParams {
     pub unk_60: i32,
 }
 
-extern {
+extern "C" {
     pub fn sceUtilityMsgDialogInitStart(
         params: *mut UtilityMsgDialogParams,
     ) -> i32;
@@ -563,10 +564,7 @@ extern {
     pub fn sceUtilityHtmlViewerShutdownStart() -> i32;
     pub fn sceUtilityHtmlViewerUpdate(n: i32) -> i32;
     pub fn sceUtilityHtmlViewerGetStatus() -> i32;
-    pub fn sceUtilitySetSystemParamInt(
-        id: SystemParamId,
-        value: i32,
-    ) -> i32;
+    pub fn sceUtilitySetSystemParamInt(id: SystemParamId, value: i32) -> i32;
     pub fn sceUtilitySetSystemParamString(
         id: SystemParamId,
         str: *const u8,
@@ -594,15 +592,9 @@ extern {
     pub fn sceUtilityUnloadModule(module: Module) -> i32;
 }
 
-extern {
+extern "C" {
     pub fn sceUtilityCreateNetParam(conf: i32) -> i32;
-    pub fn sceUtilitySetNetParam(
-        param: NetParam,
-        val: *const c_void,
-    ) -> i32;
-    pub fn sceUtilityCopyNetParam(
-        src: i32,
-        dest: i32,
-    ) -> i32;
+    pub fn sceUtilitySetNetParam(param: NetParam, val: *const c_void) -> i32;
+    pub fn sceUtilityCopyNetParam(src: i32, dest: i32) -> i32;
     pub fn sceUtilityDeleteNetParam(conf: i32) -> i32;
 }