Ticket #364: pf_items.p4

File pf_items.p4, 2.8 KB (added by doughera, 5 years ago)
Line 
1diff -r -u parrot-current/include/parrot/packfile.h parrot-gcc64/include/parrot/packfile.h
2--- parrot-current/include/parrot/packfile.h    2009-03-11 07:42:34.000000000 -0400
3+++ parrot-gcc64/include/parrot/packfile.h      2009-03-11 08:28:05.000000000 -0400
4@@ -1031,7 +1031,7 @@
5 PARROT_WARN_UNUSED_RESULT
6 INTVAL PF_fetch_integer(
7     ARGIN_NULLOK(PackFile *pf),
8-    ARGIN(const opcode_t **stream))
9+    ARGIN(const char **stream))
10         __attribute__nonnull__(2);
11 
12 PARROT_WARN_UNUSED_RESULT
13diff -r -u parrot-current/src/packfile/pf_items.c parrot-gcc64/src/packfile/pf_items.c
14--- parrot-current/src/packfile/pf_items.c      2009-03-11 07:42:31.000000000 -0400
15+++ parrot-gcc64/src/packfile/pf_items.c        2009-03-11 12:20:16.000000000 -0400
16@@ -1098,24 +1098,24 @@
17 
18 PARROT_WARN_UNUSED_RESULT
19 INTVAL
20-PF_fetch_integer(ARGIN_NULLOK(PackFile *pf), ARGIN(const opcode_t **stream))
21+PF_fetch_integer(ARGIN_NULLOK(PackFile *pf), ARGIN(const char **stream))
22 {
23     ASSERT_ARGS(PF_fetch_integer)
24     INTVAL i;
25 
26-    if (!pf || pf->fetch_iv == NULL)
27-        return *(*stream)++;
28-    i = (pf->fetch_iv)(*((const unsigned char **)stream));
29-    TRACE_PRINTF_VAL(("  PF_fetch_integer: 0x%x (%d) at 0x%x\n", i, i,
30-                      OFFS(*stream)));
31-    /* XXX assume sizeof (opcode_t) == sizeof (INTVAL) on the
32-     * machine producing this PBC.
33-     *
34-     * TODO TT #364 on Sparc 64bit: On pbc wordsize=4 but native ptrsize=8 and
35-     * ptr_alignment=8 the advance by 4 will signal BUS (invalid address alignment)
36-     * in PF_fetch_integer and elsewhere.
37-     */
38-    *((const unsigned char **) (stream)) += pf->header->wordsize;
39+    if (!pf || pf->fetch_iv == NULL) {  /* Native transforms */
40+        memcpy(&i, *stream, sizeof (INTVAL));
41+        *stream += sizeof (INTVAL);
42+    }
43+    else {
44+        i = (pf->fetch_iv)(*((const unsigned char **)stream));
45+        TRACE_PRINTF_VAL(("  PF_fetch_integer: 0x%x (%d) at 0x%x\n", i, i,
46+                          OFFS(*stream)));
47+        /* XXX assume sizeof (opcode_t) == sizeof (INTVAL) on the
48+         * machine producing this PBC.
49+         */
50+        *stream += pf->header->wordsize;
51+    }
52     return i;
53 }
54 
55diff -r -u parrot-current/src/pmc_freeze.c parrot-gcc64/src/pmc_freeze.c
56--- parrot-current/src/pmc_freeze.c     2009-03-11 07:42:32.000000000 -0400
57+++ parrot-gcc64/src/pmc_freeze.c       2009-03-11 08:30:52.000000000 -0400
58@@ -872,7 +872,7 @@
59     const char * const   start  = (char *)io->image->strstart;
60     char               **opcode = &io->image->strstart;
61     const INTVAL i              = PF_fetch_integer(io->pf,
62-                                    (const opcode_t **)opcode);
63+                                    (const char **)opcode);
64 
65     io->image->bufused -= ((char *)io->image->strstart - start);
66     PARROT_ASSERT((int)io->image->bufused >= 0);