Fix deadlock in RTS when using allocation in native code

When marking a section of memory for allocation using requireAlloc, any
requests to the allocate function (which would generally happen from
native code, such as the SDL library) would try and acquire the same
allocation lock.

The fix makes this a reentrant lock.
Merge pull request #1016 from SimonJF/rts-deadlock-fix

Fix deadlock in RTS when using allocation in native code