[Pcre-svn] [924] code/trunk: Add alignment patch for m68k.

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [924] code/trunk: Add alignment patch for m68k.
Revision: 924
          http://www.exim.org/viewvc/pcre2?view=rev&revision=924
Author:   ph10
Date:     2018-02-27 17:19:51 +0000 (Tue, 27 Feb 2018)
Log Message:
-----------
Add alignment patch for m68k.


Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/src/pcre2_intmodedep.h


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2018-02-25 18:00:56 UTC (rev 923)
+++ code/trunk/ChangeLog    2018-02-27 17:19:51 UTC (rev 924)
@@ -32,7 +32,13 @@


7. Added --enable-jit=auto support to configure.ac.

+8. Added some dummy variables to the heapframe structure in 16-bit and 32-bit
+modes for the benefit of m68k, where pointers can be 16-bit aligned. The
+dummies force 32-bit alignment and this ensures that the structure is a
+multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other
+architectures, alignment requirements take care of this automatically.

+
Version 10.31 12-February-2018
------------------------------


Modified: code/trunk/src/pcre2_intmodedep.h
===================================================================
--- code/trunk/src/pcre2_intmodedep.h    2018-02-25 18:00:56 UTC (rev 923)
+++ code/trunk/src/pcre2_intmodedep.h    2018-02-27 17:19:51 UTC (rev 924)
@@ -793,12 +793,23 @@
   uint8_t return_id;         /* Where to go on in internal "return" */
   uint8_t op;                /* Processing opcode */


+  /* At this point, the structure is 16-bit aligned. On most architectures
+  the alignment requirement for a pointer will ensure that the eptr field below
+  is 32-bit or 64-bit aligned. However, on m68k it is fine to have a pointer
+  that is 16-bit aligned. We must therefore ensure that the occu vector is an
+  odd multiple of 16 bits so as to get back into 32-bit alignment. This happens
+  naturally when PCRE2_UCHAR is 8 bits wide, but needs fudges in the other
+  cases. Without these, this structure is no longer a multiple of PCRE2_SIZE
+  and the check below fails. */
+
 #if PCRE2_CODE_UNIT_WIDTH == 8
   PCRE2_UCHAR occu[6];       /* Used for other case code units */
 #elif PCRE2_CODE_UNIT_WIDTH == 16
   PCRE2_UCHAR occu[2];       /* Used for other case code units */
+  uint8_t unused[2];         /* Ensure 32-bit alignment (see above) */
 #else
   PCRE2_UCHAR occu[1];       /* Used for other case code units */
+  uint8_t unused[2];         /* Ensure 32-bit alignment (see above) */
 #endif


/* The rest have to be copied from the previous frame whenever a new frame
@@ -818,6 +829,9 @@
PCRE2_SIZE ovector[131072]; /* Must be last in the structure */
} heapframe;

+/* This typedef is a check that the size of the heapframe structure is a
+multiple of PCRE2_SIZE. See various comments above. */
+
typedef char check_heapframe_size[
((sizeof(heapframe) % sizeof(PCRE2_SIZE)) == 0)? (+1):(-1)];