Skip to content

Commit 89fc5b8

Browse files
authored
Fix unmap logic
1 parent 7fd12a5 commit 89fc5b8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

driver/others/memory.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7676
#ifndef likely
7777
#ifdef __GNUC__
7878
#define likely(x) __builtin_expect(!!(x), 1)
79+
#define unlikely(x) __builtin_expect(!!(x), 0)
7980
#else
8081
#define likely(x) (x)
82+
#define unlikely(x) (x)
8183
#endif
8284
#endif
8385

@@ -3097,7 +3099,7 @@ void blas_memory_free(void *free_area){
30973099
if (memory[position].addr != free_area) goto error;
30983100
printf(" Position : %d\n", position);
30993101
#endif
3100-
if (memory_overflowed) {
3102+
if (unlikely(memory_overflowed && position >= NUM_BUFFERS)) {
31013103
while ((position < NUM_BUFFERS+512) && (newmemory[position-NUM_BUFFERS].addr != free_area))
31023104
position++;
31033105
// arm: ensure all writes are finished before other thread takes this memory

0 commit comments

Comments
 (0)