* TODO: Can the code span more than one page? If yes, we need to make two
* pages executable!
*/
-static rtsBool
+static void
execPage (void* addr, pageMode mode)
{
#if defined(i386_TARGET_ARCH) && defined(_WIN32) && 0
sInfo.dwPageSize,
( mode == pageExecuteReadWrite ? PAGE_EXECUTE_READWRITE : PAGE_EXECUTE_READ),
&dwOldProtect) == 0 ) {
-# if 1
DWORD rc = GetLastError();
- prog_belch("execPage: failed to protect 0x%p; error=%lu; old protection: %lu\n", addr, rc, dwOldProtect);
-# endif
- return rtsFalse;
+ barf("execPage: failed to protect 0x%p; error=%lu; old protection: %lu\n", addr, rc, dwOldProtect);
}
- return rtsTrue;
#else
(void)addr; (void)mode; /* keep gcc -Wall happy */
- return rtsTrue;
#endif
}
<c>: ff e0 jmp %eax # and jump to it.
# the callee cleans up the stack
*/
- if ((adjustor = stgMallocBytes(14, "createAdjustor")) != NULL) {
+ adjustor = stgMallocBytes(14, "createAdjustor");
+ {
unsigned char *const adj_code = (unsigned char *)adjustor;
adj_code[0x00] = (unsigned char)0x58; /* popl %eax */
That's (thankfully) the case here with the restricted set of
return types that we support.
*/
- if ((adjustor = stgMallocBytes(17, "createAdjustor")) != NULL) {
+ adjustor = stgMallocBytes(17, "createAdjustor");
+ {
unsigned char *const adj_code = (unsigned char *)adjustor;
adj_code[0x00] = (unsigned char)0x68; /* pushl hptr (which is a dword immediate ) */
similarly, and local variables should be accessed via %fp, not %sp. In a
nutshell: This should work! (Famous last words! :-)
*/
- if ((adjustor = stgMallocBytes(4*(11+1), "createAdjustor")) != NULL) {
+ adjustor = stgMallocBytes(4*(11+1), "createAdjustor");
+ {
unsigned long *const adj_code = (unsigned long *)adjustor;
adj_code[ 0] = 0x9C23A008UL; /* sub %sp, 8, %sp */
4 bytes (getting rid of the nop), hence saving memory. [ccshan]
*/
ASSERT(((StgWord64)wptr & 3) == 0);
- if ((adjustor = stgMallocBytes(48, "createAdjustor")) != NULL) {
+ adjustor = stgMallocBytes(48, "createAdjustor");
+ {
StgWord64 *const code = (StgWord64 *)adjustor;
code[0] = 0x4610041246520414L;
this code, it only works for up to 6 arguments (when floating point arguments
are involved, this may be more or less, depending on the exact situation).
*/
- if ((adjustor = stgMallocBytes(4*13, "createAdjustor")) != NULL) {
+ adjustor = stgMallocBytes(4*13, "createAdjustor");
+ {
unsigned long *const adj_code = (unsigned long *)adjustor;
// make room for extra arguments
#if defined(i386_TARGET_ARCH)
if ( *(unsigned char*)ptr != 0x68 &&
*(unsigned char*)ptr != 0x58 ) {
- prog_belch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
+ errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
return;
}
}
#elif defined(sparc_TARGET_ARCH)
if ( *(unsigned long*)ptr != 0x9C23A008UL ) {
- prog_belch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
+ errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
return;
}
freeStablePtr(*((StgStablePtr*)((unsigned long*)ptr + 11)));
#elif defined(alpha_TARGET_ARCH)
if ( *(StgWord64*)ptr != 0xa77b0018a61b0010L ) {
- prog_belch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
+ errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
return;
}
freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 0x10)));
#elif defined(powerpc_TARGET_ARCH)
if ( *(StgWord*)ptr != 0x7d0a4378 ) {
- prog_belch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
+ errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
return;
}
freeStablePtr(*((StgStablePtr*)((unsigned char*)ptr + 4*12)));
StgWord64 *code = (StgWord64 *)(fdesc+1);
if (fdesc->ip != (StgWord64)code) {
- prog_belch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
+ errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
return;
}
freeStablePtr((StgStablePtr)code[16]);
*
* Perform initialisation of adjustor thunk layer (if needed.)
*/
-rtsBool
+void
initAdjustor(void)
{
#if defined(i386_TARGET_ARCH)
execPage(obscure_ccall_ret_code, pageExecuteRead);
#endif
- return rtsTrue;
}