Use own implementation instead of ROM functions, re-add memchr ROM function
This commit is contained in:
parent
1f929af377
commit
932c785f08
@ -16,5 +16,5 @@ PROVIDE ( strchr = 0x4000c53c );
|
||||
PROVIDE ( strlcpy = 0x4000c584 );
|
||||
PROVIDE ( strstr = 0x4000c674 );
|
||||
PROVIDE ( strcasecmp = 0x400011cc );
|
||||
PROVIDE ( strdup = 0x4000143c );
|
||||
PROVIDE ( atoi = 0x400566c4 );
|
||||
|
||||
PROVIDE ( memchr = 0x4000c244 );
|
||||
|
||||
@ -13,5 +13,3 @@ PROVIDE ( strchr = 0x40000514 );
|
||||
PROVIDE ( strlcpy = 0x40000524 );
|
||||
PROVIDE ( strstr = 0x400004ac );
|
||||
PROVIDE ( strcasecmp = 0x40000504 );
|
||||
PROVIDE ( strdup = 0x40000510 );
|
||||
PROVIDE ( atoi = 0x40000580 );
|
||||
|
||||
@ -17,5 +17,5 @@ PROVIDE( strchr = 0x400003e0 );
|
||||
PROVIDE( strlcpy = 0x400003f0 );
|
||||
PROVIDE( strstr = 0x40000378 );
|
||||
PROVIDE( strcasecmp = 0x400003d0 );
|
||||
PROVIDE( strdup = 0x400003dc );
|
||||
PROVIDE( atoi = 0x4000044c );
|
||||
|
||||
PROVIDE( memchr = 0x400003c8 );
|
||||
|
||||
@ -15,5 +15,3 @@ PROVIDE(strchr = 0x40000534);
|
||||
PROVIDE(strlcpy = 0x40000544);
|
||||
PROVIDE(strstr = 0x400004cc);
|
||||
PROVIDE(strcasecmp = 0x40000524);
|
||||
PROVIDE(strdup = 0x40000530);
|
||||
PROVIDE(atoi = 0x400005a0);
|
||||
|
||||
@ -15,5 +15,5 @@ PROVIDE( strchr = 0x4000052c );
|
||||
PROVIDE( strlcpy = 0x4000053c );
|
||||
PROVIDE( strstr = 0x400004c4 );
|
||||
PROVIDE( strcasecmp = 0x4000051c );
|
||||
PROVIDE( strdup = 0x40000528 );
|
||||
PROVIDE( atoi = 0x40000598 );
|
||||
|
||||
PROVIDE( memchr = 0x40000514 );
|
||||
|
||||
@ -17,4 +17,3 @@ PROVIDE ( strchr = 0x4001adb0 );
|
||||
PROVIDE ( strlcpy = 0x4001adf8 );
|
||||
PROVIDE ( strstr = 0x4001aee8 );
|
||||
PROVIDE ( strcasecmp = 0x40007b38 );
|
||||
PROVIDE ( strdup = 0x40007d84 );
|
||||
|
||||
@ -19,5 +19,3 @@ PROVIDE( strchr = 0x4000138c );
|
||||
PROVIDE( strlcpy = 0x400013bc );
|
||||
PROVIDE( strstr = 0x40001254 );
|
||||
PROVIDE( strcasecmp = 0x4000135c );
|
||||
PROVIDE( strdup = 0x40001380 );
|
||||
PROVIDE( atoi = 0x400014d0 );
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// these are not called but needed for linking
|
||||
use crate::compat::malloc::malloc;
|
||||
|
||||
// these are not called but needed for linking
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn fwrite(ptr: *const (), size: usize, count: usize, stream: *const ()) -> usize {
|
||||
todo!("fwrite {:?} {} {} {:?}", ptr, size, count, stream)
|
||||
@ -20,8 +21,26 @@ unsafe extern "C" fn fclose(stream: *const ()) -> i32 {
|
||||
todo!("fclose {:?}", stream);
|
||||
}
|
||||
|
||||
// not available in ROM on ESP32-S2
|
||||
#[cfg(feature = "esp32s2")]
|
||||
// We cannot just use the ROM function since it needs to allocate memory
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn strdup(str: *const i8) -> *const u8 {
|
||||
trace!("strdup {:?}", str);
|
||||
|
||||
unsafe {
|
||||
let s = core::ffi::CStr::from_ptr(str);
|
||||
let s = s.to_str().unwrap();
|
||||
|
||||
let p = malloc(s.len() + 1);
|
||||
core::ptr::copy_nonoverlapping(str, p as *mut i8, s.len() + 1);
|
||||
p as *const u8
|
||||
}
|
||||
}
|
||||
|
||||
// We cannot just use the ROM function since it calls `__getreent`
|
||||
//
|
||||
// From docs: The __getreent() function returns a per-task pointer to struct
|
||||
// _reent in newlib libc. This structure is allocated on the TCB of each task.
|
||||
// i.e. it assumes a FreeRTOS task calling it.
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn atoi(str: *const i8) -> i32 {
|
||||
trace!("atoi {:?}", str);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user