Fix inline procs

This commit is contained in:
Joey Yakimowich-Payne 2018-07-05 20:05:37 +09:00
commit f9f2facc08

View file

@ -81,6 +81,7 @@ elif defined(genode):
include genode/alloc # osAllocPages, osTryAllocPages, osDeallocPages include genode/alloc # osAllocPages, osTryAllocPages, osDeallocPages
elif defined(nintendoswitch): elif defined(nintendoswitch):
import nintendoswitch/switch_memory import nintendoswitch/switch_memory
type type
@ -94,7 +95,7 @@ elif defined(nintendoswitch):
heap: pointer # pointer to main heap alloc heap: pointer # pointer to main heap alloc
heapMirror: pointer # pointer to virtmem mapped heap heapMirror: pointer # pointer to virtmem mapped heap
proc alignSize(size: int): int = proc alignSize(size: int): int {.inline.} =
## Align a size integer to be in multiples of PageSize ## Align a size integer to be in multiples of PageSize
## The nintendo switch will not allocate memory that is not ## The nintendo switch will not allocate memory that is not
## aligned to 0x1000 bytes and will just crash. ## aligned to 0x1000 bytes and will just crash.
@ -120,7 +121,7 @@ elif defined(nintendoswitch):
nswitchBlock.heapMirror, nswitchBlock.heap, nswitchBlock.realSize nswitchBlock.heapMirror, nswitchBlock.heap, nswitchBlock.realSize
) )
proc storeHeapData(address, heapMirror, heap: pointer, size: int) = proc storeHeapData(address, heapMirror, heap: pointer, size: int) {.inline.} =
## Store data in the heap for deallocation purposes later ## Store data in the heap for deallocation purposes later
# the position of our heap pointer data. Since we allocated PageSize extra # the position of our heap pointer data. Since we allocated PageSize extra
@ -138,7 +139,7 @@ elif defined(nintendoswitch):
nswitchBlock.heap = heap nswitchBlock.heap = heap
nswitchBlock.heapMirror = heapMirror nswitchBlock.heapMirror = heapMirror
proc getOriginalHeapPosition(address: pointer, difference: int): pointer = proc getOriginalHeapPosition(address: pointer, difference: int): pointer {.inline.} =
## This function sets the heap back to the originally requested ## This function sets the heap back to the originally requested
## size ## size
let let
@ -175,11 +176,11 @@ elif defined(nintendoswitch):
allocPages(size): allocPages(size):
raiseOutOfMem() raiseOutOfMem()
proc osTryAllocPages(size: int): pointer {.inline.} = proc osTryAllocPages(size: int): pointer =
allocPages(size): allocPages(size):
return nil return nil
proc osDeallocPages(p: pointer, size: int) {.inline.} = proc osDeallocPages(p: pointer, size: int) =
# Note that in order for the Switch not to crash, a call to # Note that in order for the Switch not to crash, a call to
# deallocHeap(runFinalizers = true, allowGcAfterwards = false) # deallocHeap(runFinalizers = true, allowGcAfterwards = false)
# must be run before gfxExit(). The Switch requires all memory # must be run before gfxExit(). The Switch requires all memory