mm: Restore the return type of mm_lock from bool to int
Fix the issue reported here better: https://github.com/apache/incubator-nuttx/pull/6995 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
4cc13c19c6
commit
b567e09c3c
|
@ -240,7 +240,7 @@ typedef CODE void (*mmchunk_handler_t)(FAR struct mm_allocnode_s *node,
|
|||
|
||||
/* Functions contained in mm_lock.c *****************************************/
|
||||
|
||||
bool mm_lock(FAR struct mm_heap_s *heap);
|
||||
int mm_lock(FAR struct mm_heap_s *heap);
|
||||
void mm_unlock(FAR struct mm_heap_s *heap);
|
||||
|
||||
/* Functions contained in mm_shrinkchunk.c **********************************/
|
||||
|
|
|
@ -68,7 +68,7 @@ void mm_foreach(FAR struct mm_heap_s *heap, mmchunk_handler_t handler,
|
|||
* Retake the mutex for each region to reduce latencies
|
||||
*/
|
||||
|
||||
if (!mm_lock(heap))
|
||||
if (mm_lock(heap) < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ void mm_free(FAR struct mm_heap_s *heap, FAR void *mem)
|
|||
return;
|
||||
}
|
||||
|
||||
if (mm_lock(heap) == false)
|
||||
if (mm_lock(heap) < 0)
|
||||
{
|
||||
/* Meet -ESRCH return, which means we are in situations
|
||||
* during context switching(See mm_lock() & getpid()).
|
||||
|
|
|
@ -51,11 +51,11 @@
|
|||
* heap - heap instance want to take mutex
|
||||
*
|
||||
* Returned Value:
|
||||
* true if the lock can be taken, otherwise false.
|
||||
* 0 if the lock can be taken, otherwise negative errno.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
bool mm_lock(FAR struct mm_heap_s *heap)
|
||||
int mm_lock(FAR struct mm_heap_s *heap)
|
||||
{
|
||||
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
|
||||
/* Check current environment */
|
||||
|
@ -67,11 +67,11 @@ bool mm_lock(FAR struct mm_heap_s *heap)
|
|||
* Or, touch the heap internal data directly.
|
||||
*/
|
||||
|
||||
return !nxmutex_is_locked(&heap->mm_lock);
|
||||
return nxmutex_is_locked(&heap->mm_lock) ? -EAGAIN : 0;
|
||||
#else
|
||||
/* Can't take mutex in SMP interrupt handler */
|
||||
|
||||
return false;
|
||||
return -EAGAIN;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -89,11 +89,11 @@ bool mm_lock(FAR struct mm_heap_s *heap)
|
|||
|
||||
if (getpid() < 0)
|
||||
{
|
||||
return false;
|
||||
return -ESRCH;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nxmutex_lock(&heap->mm_lock) >= 0;
|
||||
return nxmutex_lock(&heap->mm_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue