mirror of https://github.com/ARMmbed/mbed-os.git
Fix duplicate symbols for malloc lock and unlock
When the malloc lock and unlock functions are inside a library they conflict with the standard libraries weak version of these functions. This is because of the way weak references are handled by the linker. This patch renames the lock and unlock functions defined inside RTX so they do not conflict. A thunk inside retarget.cpp then calls the RTX functions. This problem does not occur with retarget.cpp since it is always build into an object file rather than a library file.pull/1907/head
parent
3db2c030d2
commit
d0b7b3b497
|
@ -636,6 +636,35 @@ extern "C" WEAK void __iar_file_Mtxinit(__iar_Rmtx *mutex) {}
|
|||
extern "C" WEAK void __iar_file_Mtxdst(__iar_Rmtx *mutex) {}
|
||||
extern "C" WEAK void __iar_file_Mtxlock(__iar_Rmtx *mutex) {}
|
||||
extern "C" WEAK void __iar_file_Mtxunlock(__iar_Rmtx *mutex) {}
|
||||
#elif defined(__CC_ARM)
|
||||
// Do nothing
|
||||
#elif defined (__GNUC__)
|
||||
struct _reent;
|
||||
// Stub out locks when an rtos is not present
|
||||
extern "C" WEAK void __rtos_malloc_lock( struct _reent *_r ) {}
|
||||
extern "C" WEAK void __rtos_malloc_unlock( struct _reent *_r ) {}
|
||||
extern "C" WEAK void __rtos_env_lock( struct _reent *_r ) {}
|
||||
extern "C" WEAK void __rtos_env_unlock( struct _reent *_r ) {}
|
||||
|
||||
void __malloc_lock( struct _reent *_r )
|
||||
{
|
||||
__rtos_malloc_lock(_r);
|
||||
}
|
||||
|
||||
void __malloc_unlock( struct _reent *_r )
|
||||
{
|
||||
__rtos_malloc_unlock(_r);
|
||||
}
|
||||
|
||||
void __env_lock( struct _reent *_r )
|
||||
{
|
||||
__rtos_env_lock(_r);
|
||||
}
|
||||
|
||||
void __env_unlock( struct _reent *_r )
|
||||
{
|
||||
__rtos_env_unlock(_r);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -684,22 +684,22 @@ __attribute__((naked)) void software_init_hook_rtos (void) {
|
|||
// Opaque declaration of _reent structure
|
||||
struct _reent;
|
||||
|
||||
void __malloc_lock( struct _reent *_r )
|
||||
void __rtos_malloc_lock( struct _reent *_r )
|
||||
{
|
||||
osMutexWait(malloc_mutex_id, osWaitForever);
|
||||
}
|
||||
|
||||
void __malloc_unlock( struct _reent *_r )
|
||||
void __rtos_malloc_unlock( struct _reent *_r )
|
||||
{
|
||||
osMutexRelease(malloc_mutex_id);
|
||||
}
|
||||
|
||||
void __env_lock( struct _reent *_r )
|
||||
void __rtos_env_lock( struct _reent *_r )
|
||||
{
|
||||
osMutexWait(env_mutex_id, osWaitForever);
|
||||
}
|
||||
|
||||
void __env_unlock( struct _reent *_r )
|
||||
void __rtos_env_unlock( struct _reent *_r )
|
||||
{
|
||||
osMutexRelease(env_mutex_id);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue