Skip to content

Commit 847548a

Browse files
committed
sim: Put "C" on externs
Many of these extern functions are missing the "C". It doesn't seem to matter on any of our targets, but this does make the code more correct, and might be a problem in the future. Signed-off-by: David Brown <[email protected]>
1 parent 1b1d495 commit 847548a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sim/mcuboot-sys/src/api.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,42 +189,42 @@ pub fn clear_flash(dev_id: u8) {
189189
// This isn't meant to call directly, but by a wrapper.
190190

191191
#[no_mangle]
192-
pub extern fn sim_get_flash_areas() -> *const CAreaDesc {
192+
pub extern "C" fn sim_get_flash_areas() -> *const CAreaDesc {
193193
THREAD_CTX.with(|ctx| {
194194
ctx.borrow().flash_areas.ptr
195195
})
196196
}
197197

198198
#[no_mangle]
199-
pub extern fn sim_set_flash_areas(areas: *const CAreaDesc) {
199+
pub extern "C" fn sim_set_flash_areas(areas: *const CAreaDesc) {
200200
THREAD_CTX.with(|ctx| {
201201
ctx.borrow_mut().flash_areas.ptr = areas;
202202
});
203203
}
204204

205205
#[no_mangle]
206-
pub extern fn sim_reset_flash_areas() {
206+
pub extern "C" fn sim_reset_flash_areas() {
207207
THREAD_CTX.with(|ctx| {
208208
ctx.borrow_mut().flash_areas.ptr = ptr::null();
209209
});
210210
}
211211

212212
#[no_mangle]
213-
pub extern fn sim_get_context() -> *const CSimContext {
213+
pub extern "C" fn sim_get_context() -> *const CSimContext {
214214
SIM_CTX.with(|ctx| {
215215
ctx.borrow().ptr
216216
})
217217
}
218218

219219
#[no_mangle]
220-
pub extern fn sim_set_context(ptr: *const CSimContext) {
220+
pub extern "C" fn sim_set_context(ptr: *const CSimContext) {
221221
SIM_CTX.with(|ctx| {
222222
ctx.borrow_mut().ptr = ptr;
223223
});
224224
}
225225

226226
#[no_mangle]
227-
pub extern fn sim_reset_context() {
227+
pub extern "C" fn sim_reset_context() {
228228
SIM_CTX.with(|ctx| {
229229
ctx.borrow_mut().ptr = ptr::null();
230230
});
@@ -257,7 +257,7 @@ pub fn clear_ram_info() {
257257
}
258258

259259
#[no_mangle]
260-
pub extern fn sim_flash_erase(dev_id: u8, offset: u32, size: u32) -> libc::c_int {
260+
pub extern "C" fn sim_flash_erase(dev_id: u8, offset: u32, size: u32) -> libc::c_int {
261261
let mut rc: libc::c_int = -19;
262262
THREAD_CTX.with(|ctx| {
263263
if let Some(flash) = ctx.borrow().flash_map.get(&dev_id) {
@@ -269,7 +269,7 @@ pub extern fn sim_flash_erase(dev_id: u8, offset: u32, size: u32) -> libc::c_int
269269
}
270270

271271
#[no_mangle]
272-
pub extern fn sim_flash_read(dev_id: u8, offset: u32, dest: *mut u8, size: u32) -> libc::c_int {
272+
pub extern "C" fn sim_flash_read(dev_id: u8, offset: u32, dest: *mut u8, size: u32) -> libc::c_int {
273273
let mut rc: libc::c_int = -19;
274274
THREAD_CTX.with(|ctx| {
275275
if let Some(flash) = ctx.borrow().flash_map.get(&dev_id) {
@@ -282,7 +282,7 @@ pub extern fn sim_flash_read(dev_id: u8, offset: u32, dest: *mut u8, size: u32)
282282
}
283283

284284
#[no_mangle]
285-
pub extern fn sim_flash_write(dev_id: u8, offset: u32, src: *const u8, size: u32) -> libc::c_int {
285+
pub extern "C" fn sim_flash_write(dev_id: u8, offset: u32, src: *const u8, size: u32) -> libc::c_int {
286286
let mut rc: libc::c_int = -19;
287287
THREAD_CTX.with(|ctx| {
288288
if let Some(flash) = ctx.borrow().flash_map.get(&dev_id) {
@@ -295,14 +295,14 @@ pub extern fn sim_flash_write(dev_id: u8, offset: u32, src: *const u8, size: u32
295295
}
296296

297297
#[no_mangle]
298-
pub extern fn sim_flash_align(id: u8) -> u32 {
298+
pub extern "C" fn sim_flash_align(id: u8) -> u32 {
299299
THREAD_CTX.with(|ctx| {
300300
ctx.borrow().flash_params.get(&id).unwrap().align
301301
})
302302
}
303303

304304
#[no_mangle]
305-
pub extern fn sim_flash_erased_val(id: u8) -> u8 {
305+
pub extern "C" fn sim_flash_erased_val(id: u8) -> u8 {
306306
THREAD_CTX.with(|ctx| {
307307
ctx.borrow().flash_params.get(&id).unwrap().erased_val
308308
})
@@ -325,7 +325,7 @@ fn map_err(err: Result<()>) -> libc::c_int {
325325
/// or
326326
/// RUST_LOG=bootsim=info cargo run --release runall
327327
#[no_mangle]
328-
pub extern fn sim_log_enabled(level: libc::c_int) -> libc::c_int {
328+
pub extern "C" fn sim_log_enabled(level: libc::c_int) -> libc::c_int {
329329
let res = match level {
330330
1 => log_enabled!(Level::Error),
331331
2 => log_enabled!(Level::Warn),

0 commit comments

Comments
 (0)