Syncing net branch with trunk.
git-svn-id: svn://kolibrios.org@3187 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -47,18 +47,18 @@ run_test1:
|
||||
ret
|
||||
|
||||
run_test2:
|
||||
ret
|
||||
|
||||
run_test3:
|
||||
; 1024000 times run random operation.
|
||||
; Randomly select malloc(random size from 1 to 1023)
|
||||
; or free(random of previously allocated areas)
|
||||
mov edi, 0x12345678
|
||||
xor esi, esi ; 0 areas allocated
|
||||
mov ebx, 1024000
|
||||
.loop:
|
||||
imul edi, 1103515245
|
||||
add edi, 12345
|
||||
ret
|
||||
|
||||
run_test3:
|
||||
; 1024 times run random operation.
|
||||
; Randomly select malloc(random size from 1 to 1023)
|
||||
; or free(random of previously allocated areas)
|
||||
mov edi, 0x12345678
|
||||
xor esi, esi ; 0 areas allocated
|
||||
mov ebx, 1024
|
||||
.loop:
|
||||
imul edi, 1103515245
|
||||
add edi, 12345
|
||||
mov eax, edi
|
||||
shr eax, 16
|
||||
test ebx, 64
|
||||
@@ -75,13 +75,17 @@ run_test3:
|
||||
and eax, 1023
|
||||
jz .loop
|
||||
push ebx
|
||||
push eax
|
||||
; mov ecx, [saved_state_num]
|
||||
; mov [saved_state+ecx*8], eax
|
||||
call malloc_with_test
|
||||
; mov ecx, [saved_state_num]
|
||||
; mov [saved_state+ecx*8+4], eax
|
||||
; inc [saved_state_num]
|
||||
push eax
|
||||
; mov ecx, [saved_state_num]
|
||||
; mov [saved_state+ecx*8], eax
|
||||
push edi
|
||||
call malloc_with_test
|
||||
pop ecx
|
||||
cmp ecx, edi
|
||||
jnz edi_destroyed
|
||||
; mov ecx, [saved_state_num]
|
||||
; mov [saved_state+ecx*8+4], eax
|
||||
; inc [saved_state_num]
|
||||
pop ecx
|
||||
pop ebx
|
||||
inc esi
|
||||
@@ -110,13 +114,17 @@ run_test3:
|
||||
mov edi, eax
|
||||
mov al, [edi]
|
||||
repz scasb
|
||||
jnz memory_destroyed
|
||||
pop eax edi
|
||||
push ebx edx
|
||||
call free
|
||||
pop edx ebx
|
||||
dec esi
|
||||
pop eax ecx
|
||||
jnz memory_destroyed
|
||||
pop eax edi
|
||||
push ebx edx
|
||||
push edi
|
||||
call free
|
||||
pop ecx
|
||||
cmp ecx, edi
|
||||
jnz edi_destroyed
|
||||
pop edx ebx
|
||||
dec esi
|
||||
pop eax ecx
|
||||
push edi
|
||||
lea edi, [esp+4]
|
||||
@@:
|
||||
@@ -147,15 +155,21 @@ malloc_with_test:
|
||||
jz generic_malloc_fail
|
||||
call check_mutex
|
||||
call check_range
|
||||
ret
|
||||
|
||||
; Stubs for kernel procedures used by heap code
|
||||
wait_mutex:
|
||||
inc dword [ebx]
|
||||
ret
|
||||
|
||||
kernel_alloc:
|
||||
cmp dword [esp+4], bufsize
|
||||
ret
|
||||
|
||||
; Stubs for kernel procedures used by heap code
|
||||
mutex_init:
|
||||
and dword [ecx], 0
|
||||
ret
|
||||
mutex_lock:
|
||||
inc dword [ecx]
|
||||
ret
|
||||
mutex_unlock:
|
||||
dec dword [ecx]
|
||||
ret
|
||||
|
||||
kernel_alloc:
|
||||
cmp dword [esp+4], bufsize
|
||||
jnz error1
|
||||
mov eax, buffer
|
||||
ret 4
|
||||
@@ -171,13 +185,13 @@ error1:
|
||||
|
||||
generic_malloc_fail:
|
||||
mov eax, 2
|
||||
jmp error_with_code
|
||||
|
||||
check_mutex:
|
||||
cmp [mst.mutex], 0
|
||||
jnz @f
|
||||
ret
|
||||
@@:
|
||||
jmp error_with_code
|
||||
|
||||
check_mutex:
|
||||
cmp dword [mst.mutex], 0
|
||||
jnz @f
|
||||
ret
|
||||
@@:
|
||||
mov eax, 3
|
||||
jmp error_with_code
|
||||
|
||||
@@ -192,12 +206,16 @@ check_range:
|
||||
jmp error_with_code
|
||||
|
||||
memory_destroyed:
|
||||
mov eax, 5
|
||||
jmp error_with_code
|
||||
|
||||
error_with_code:
|
||||
mov edx, saved_state_num
|
||||
; eax = error code
|
||||
mov eax, 5
|
||||
jmp error_with_code
|
||||
|
||||
edi_destroyed:
|
||||
mov eax, 6
|
||||
jmp error_with_code
|
||||
|
||||
error_with_code:
|
||||
mov edx, saved_state_num
|
||||
; eax = error code
|
||||
; 1 signals error in testing code (wrong bufsize)
|
||||
; 2 = malloc() returned NULL
|
||||
; 3 = mutex not released
|
||||
@@ -205,12 +223,13 @@ error_with_code:
|
||||
; 5 = memory destroyed by malloc() or free()
|
||||
int3 ; simplest way to report error
|
||||
jmp $-1 ; just in case
|
||||
|
||||
; Include main heap code
|
||||
include '../proc32.inc'
|
||||
include '../const.inc'
|
||||
include 'malloc.inc'
|
||||
|
||||
|
||||
; Include main heap code
|
||||
include '../proc32.inc'
|
||||
include '../struct.inc'
|
||||
include '../const.inc'
|
||||
include 'malloc.inc'
|
||||
|
||||
i_end:
|
||||
|
||||
align 4
|
||||
|
Reference in New Issue
Block a user