[project @ 2004-08-22 16:40:38 by panne]
[ghc-hetmet.git] / ghc / rts / Adjustor.c
index ea91d90..44fbcf2 100644 (file)
@@ -61,7 +61,7 @@ typedef enum {
  * 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
@@ -75,16 +75,11 @@ execPage (void* addr, pageMode mode)
                          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
 }
 
@@ -153,7 +148,8 @@ createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr)
      <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  */
 
@@ -199,7 +195,8 @@ createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr)
     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 ) */
@@ -246,7 +243,8 @@ createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr)
      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         */
@@ -322,7 +320,8 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for
       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;
@@ -359,7 +358,8 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for
        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
@@ -558,7 +558,7 @@ freeHaskellFunctionPtr(void* ptr)
  *
  * Perform initialisation of adjustor thunk layer (if needed.)
  */
-rtsBool
+void
 initAdjustor(void)
 {
 #if defined(i386_TARGET_ARCH)
@@ -589,5 +589,4 @@ initAdjustor(void)
 
   execPage(obscure_ccall_ret_code, pageExecuteRead);
 #endif
-  return rtsTrue;
 }