Rev 8170 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8170 | Rev 8184 | ||
---|---|---|---|
1 | ;/*** |
1 | ;/*** |
2 | 2 | ||
3 | KolibriHeapInit = @@Kolibri@_HeapInit$qpvt1t1 |
3 | KolibriHeapInit = @@Kolibri@_HeapInit$qv |
4 | 4 | ||
5 | KolibriHeapAlloc = @@Kolibri@Alloc$qui |
5 | KolibriHeapAlloc = @@Kolibri@Alloc$qui |
6 | 6 | ||
7 | KolibriHeapReAlloc = @@Kolibri@ReAlloc$qpvui |
7 | KolibriHeapReAlloc = @@Kolibri@ReAlloc$qpvui |
8 | 8 | ||
9 | KolibriHeapFree = @@Kolibri@Free$qpv |
9 | KolibriHeapFree = @@Kolibri@Free$qpv |
10 | - | ||
11 | KolibriHeapFreeAndThreadFinish = @Kolibri@_FreeAndThreadFinish$qpvpi |
- | |
12 | 10 | ||
13 | proc @Kolibri@_SetUseMemory$qui |
- | |
14 | push ebx |
11 | proc @MemoryHeap@mem_Init$qv uses ebx |
15 | mov eax,64 |
- | |
16 | mov ebx,1 |
12 | mov eax,SF_SYS_MISC |
17 | mov ecx,[esp+8] |
13 | mov ebx,SSF_HEAP_INIT |
18 | int 0x40 |
- | |
19 | pop ebx |
- | |
20 | test eax,eax |
- | |
21 | jnz .set_use_memory_nomem |
- | |
22 | push ecx |
- | |
23 | push dword [@Kolibri@_KolibriMemBlock] |
- | |
24 | call @@MemoryHeap@ResizeBlock$q20MemoryHeap@TMemBlockpv |
- | |
25 | add esp,8 |
- | |
26 | mov al,1 |
- | |
27 | ret |
- | |
28 | .set_use_memory_nomem: |
- | |
29 | xor al,al |
14 | int 0x40 |
30 | ret |
15 | ret |
31 | endp |
16 | endp |
32 | 17 | ||
33 | proc @Kolibri@_RecalculateUseMemory$qui |
18 | proc @MemoryHeap@mem_Alloc$qul uses ebx |
34 | mov eax,dword [esp+4] |
- | |
35 | mov ecx,(U_END + 3) and not 3 |
- | |
36 | cmp eax,ecx |
- | |
37 | jna .recalculate_use_memory_min |
- | |
38 | push ebx |
- | |
39 | sub eax,ecx |
19 | mov eax,SF_SYS_MISC |
40 | mov ebx,6 |
- | |
41 | mul ebx |
- | |
42 | dec ebx |
- | |
43 | div ebx |
- | |
44 | add eax,((U_END + 3) and not 3) + 3 |
- | |
45 | and eax,not 3 |
20 | mov ebx,SSF_MEM_ALLOC |
46 | pop ebx |
- | |
47 | ret |
- | |
48 | .recalculate_use_memory_min: |
- | |
49 | mov eax,ecx |
21 | int 0x40 |
50 | ret |
22 | ret |
51 | endp |
23 | endp |
52 | 24 | ||
53 | proc @Kolibri@_FreeAndThreadFinish$qpvpi |
25 | proc @MemoryHeap@mem_ReAlloc$qulpv uses ebx |
- | 26 | mov eax,SF_SYS_MISC |
|
54 | mov ebx,1 |
27 | mov ebx,SSF_MEM_REALLOC |
55 | mov ecx,[esp+8] |
- | |
56 | jmp .heap_free_tf_wait |
- | |
57 | .heap_free_tf_wait_loop: |
28 | mov ecx,[esp+8] |
58 | mov eax,5 |
- | |
59 | int 0x40 |
- | |
60 | shl ebx,1 |
- | |
61 | cmp ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
- | |
62 | jna .heap_free_tf_wait |
- | |
63 | mov ebx,KOLIBRI_MUTEX_MAX_TIME_WAIT |
- | |
64 | .heap_free_tf_wait: |
- | |
65 | cmp dword [ecx],0 |
- | |
66 | jnz @Kolibri@ExitProcess$qv |
- | |
67 | lock bts dword [@Kolibri@_MemHeapMutex],0 |
- | |
68 | jc .heap_free_tf_wait_loop |
- | |
69 | push dword [esp+4] |
- | |
70 | push @Kolibri@_KolibriFreeSpace |
- | |
71 | call @@MemoryHeap@Free$qr21MemoryHeap@TFreeSpacepv |
- | |
72 | add esp,8 |
- | |
73 | mov byte [@Kolibri@_MemHeapMutex],0x40 |
- | |
74 | or eax,-1 |
29 | mov edx,[esp+12] |
- | 30 | int 0x40 |
|
75 | int 0x40 |
31 | ret |
76 | endp |
- | |
77 | - | ||
78 | macro call func |
32 | endp |
79 | { |
33 | |
80 | if func eq @MemoryHeap@_FirstNotZeroBit$qui |
- | |
81 | bsf eax,[esp] |
34 | proc @MemoryHeap@mem_Free$qpv uses ebx |
82 | else if func eq @MemoryHeap@_CopyMemItemArray$quiuiui |
- | |
83 | xchg edi,[esp] |
35 | mov eax,SF_SYS_MISC |
84 | xchg esi,[esp+4] |
- | |
85 | mov ecx,[esp+8] |
- | |
86 | cld |
36 | mov ebx,SSF_MEM_FREE |
87 | sub ecx,esi |
- | |
88 | shr ecx,2 |
- | |
89 | rep movs dword [edi],[esi] |
- | |
90 | xchg edi,[esp] |
37 | mov ecx,[esp+8] |
91 | xchg esi,[esp+4] |
- | |
92 | else |
38 | int 0x40 |
93 | call func |
- | |
94 | end if |
39 | ret |
95 | } |
40 | endp |
96 | 41 | ||
97 | ;/**/ |
42 | ;/**/ |