Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;/***
  2.  
  3. MenuetHeapInit = @@Menuet@_HeapInit$qpvt1t1
  4.  
  5. MenuetHeapAlloc = @@Menuet@Alloc$qui
  6.  
  7. MenuetHeapReAlloc = @@Menuet@ReAlloc$qpvui
  8.  
  9. MenuetHeapFree = @@Menuet@Free$qpv
  10.  
  11. MenuetHeapFreeAndThreadFinish = @Menuet@_FreeAndThreadFinish$qpvpi
  12.  
  13. define @Menuet@_SetUseMemory$qui
  14.   push ebx
  15.   mov  eax,64
  16.   mov  ebx,1
  17.   mov  ecx,[esp+8]
  18.   int  0x40
  19.   pop  ebx
  20.   test eax,eax
  21.   jnz  Menuet_set_use_memory_nomem
  22.   push ecx
  23.   push dword [@Menuet@_MenuetMemBlock]
  24.   call @@MemoryHeap@ResizeBlock$q20MemoryHeap@TMemBlockpv
  25.   add  esp,8
  26.   mov  al,1
  27.   ret
  28. Menuet_set_use_memory_nomem:
  29.   xor  al,al
  30.   ret
  31. enddef
  32.  
  33. define @Menuet@_RecalculateUseMemory$qui
  34.   mov  eax,dword [esp+4]
  35.   mov  ecx,(U_END + 3) and not 3
  36.   cmp  eax,ecx
  37.   jna  Menuet_recalculate_use_memory_min
  38.   push ebx
  39.   sub  eax,ecx
  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
  46.   pop  ebx
  47.   ret
  48. Menuet_recalculate_use_memory_min:
  49.   mov  eax,ecx
  50.   ret
  51. enddef
  52.  
  53. define @Menuet@_FreeAndThreadFinish$qpvpi
  54.   mov  ebx,1
  55.   mov  ecx,[esp+8]
  56.   jmp  Menuet_heap_free_tf_wait
  57. Menuet_heap_free_tf_wait_loop:
  58.   mov  eax,5
  59.   int  0x40
  60.   shl  ebx,1
  61.   cmp  ebx,MENUET_MUTEX_MAX_TIME_WAIT
  62.   jna  Menuet_heap_free_tf_wait
  63.   mov  ebx,MENUET_MUTEX_MAX_TIME_WAIT
  64. Menuet_heap_free_tf_wait:
  65.   cmp  dword [ecx],0
  66.   jnz  @Menuet@ExitProcess$qv
  67.   lock bts dword [@Menuet@_MemHeapMutex],0
  68.   jc   Menuet_heap_free_tf_wait_loop
  69.   push dword [esp+4]
  70.   push @Menuet@_MenuetFreeSpace
  71.   call @@MemoryHeap@Free$qr21MemoryHeap@TFreeSpacepv
  72.   add  esp,8
  73.   mov  byte [@Menuet@_MemHeapMutex],0x40
  74.   or   eax,-1
  75.   int  0x40
  76. enddef
  77.  
  78. macro call func
  79. {
  80.   if func eq @MemoryHeap@_FirstNotZeroBit$qui
  81.     bsf  eax,[esp]
  82.   else if func eq @MemoryHeap@_CopyMemItemArray$quiuiui
  83.     xchg edi,[esp]
  84.     xchg esi,[esp+4]
  85.     mov  ecx,[esp+8]
  86.     cld
  87.     sub  ecx,esi
  88.     shr  ecx,2
  89.     rep movs dword [edi],[esi]
  90.     xchg edi,[esp]
  91.     xchg esi,[esp+4]
  92.   else
  93.     call func
  94.   end if
  95. }
  96.  
  97. ;/**/
  98.