Author: chromatic
Date: Thu May 31 23:20:41 2007
New Revision: 18721

Modified:
   trunk/src/gc/register.c
   trunk/src/pmc/sub.pmc

Log:
[GC] Fixed a const cast warning with a const cast.

While I was at it, turned 'struct Parrot_Context' into just 'Parrot_Context'.  
Satisfying!

Modified: trunk/src/gc/register.c
==============================================================================
--- trunk/src/gc/register.c     (original)
+++ trunk/src/gc/register.c     Thu May 31 23:20:41 2007
@@ -72,7 +72,7 @@
 
 #define CTX_ALLOC_SIZE 0x20000
 
-#define ALIGNED_CTX_SIZE (((sizeof (struct Parrot_Context) + NUMVAL_SIZE - 1) \
+#define ALIGNED_CTX_SIZE (((sizeof (Parrot_Context) + NUMVAL_SIZE - 1) \
         / NUMVAL_SIZE) * NUMVAL_SIZE)
 
 /*
@@ -116,12 +116,12 @@
 destroy_context(Interp *interp)
 {
     int slot;
-    struct Parrot_Context *context;
+    Parrot_Context *context;
 
     /* clear active contexts all the way back to the initial context */
     context = CONTEXT(interp->ctx);
     while (context) {
-        struct Parrot_Context * prev = context->caller_ctx;
+        Parrot_Context * prev = context->caller_ctx;
         mem_sys_free(context);
         context = prev;
     }
@@ -281,11 +281,12 @@
     clear_regs(interp, ctx);
 }
 
-struct Parrot_Context *
-Parrot_dup_context(Interp *interp, const struct Parrot_Context *old)
+Parrot_Context *
+Parrot_dup_context(Interp *interp, const Parrot_Context *old)
 {
-    size_t diff;
-    struct Parrot_Context *ctx;
+    size_t          diff;
+    Parrot_Context *ctx;
+    DECL_CONST_CAST;
 
     const size_t reg_alloc = old->regs_mem_size;
     const int slot = CALCULATE_SLOT_NUM(reg_alloc);
@@ -297,11 +298,11 @@
     else {
         ptr = (void *)mem_sys_allocate(reg_alloc + ALIGNED_CTX_SIZE);
     }
-    CONTEXT(interp->ctx) = ctx = (struct Parrot_Context *)ptr;
+    CONTEXT(interp->ctx) = ctx = (Parrot_Context *)ptr;
 
     ctx->regs_mem_size   = reg_alloc;
     ctx->n_regs_used     = old->n_regs_used;
-    diff                 = (long*)ctx - (long*)old;
+    diff                 = (long *)ctx - (long *)const_cast(old);
 
     interp->ctx.bp.regs_i    += diff;
     interp->ctx.bp_ps.regs_s += diff;
@@ -309,11 +310,11 @@
     return ctx;
 }
 
-struct Parrot_Context *
+Parrot_Context *
 Parrot_push_context(Interp *interp, INTVAL *n_regs_used)
 {
-    struct Parrot_Context * const old = CONTEXT(interp->ctx);
-    struct Parrot_Context * const ctx =
+    Parrot_Context * const old = CONTEXT(interp->ctx);
+    Parrot_Context * const ctx =
         Parrot_alloc_context(interp, n_regs_used);
 
     ctx->caller_ctx = old;
@@ -325,8 +326,8 @@
 void
 Parrot_pop_context(Interp *interp)
 {
-    struct Parrot_Context * const ctx = CONTEXT(interp->ctx);
-    struct Parrot_Context * const old = ctx->caller_ctx;
+    Parrot_Context * const ctx = CONTEXT(interp->ctx);
+    Parrot_Context * const old = ctx->caller_ctx;
 
     Parrot_free_context(interp, ctx, 1);
     /* restore old, set cached interpreter base pointers */
@@ -336,10 +337,10 @@
 }
 
 
-struct Parrot_Context *
+Parrot_Context *
 Parrot_alloc_context(Interp *interp, INTVAL *n_regs_used)
 {
-    struct Parrot_Context *old, *ctx;
+    Parrot_Context *old, *ctx;
     void *ptr, *p;
 
     /*
@@ -404,7 +405,7 @@
     }
 #endif
 
-    CONTEXT(interp->ctx) = ctx = (struct Parrot_Context *)ptr;
+    CONTEXT(interp->ctx) = ctx = (Parrot_Context *)ptr;
 
     ctx->regs_mem_size   = reg_alloc;
     ctx->n_regs_used     = n_regs_used;

Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc       (original)
+++ trunk/src/pmc/sub.pmc       Thu May 31 23:20:41 2007
@@ -213,7 +213,7 @@
     opcode_t* invoke(void *next) {
         struct Parrot_sub     *sub = PMC_sub(SELF);
         parrot_context_t      *caller_ctx;
-        struct Parrot_Context *context;
+        Parrot_Context        *context;
         PMC                   *ccont;
         opcode_t              *pc;
 

Reply via email to