changeset 1939:def7b9c64935

* alloc.c (make_pure_float): Assure that PUREBEG + pureptr is aligned, not pureptr itself.
author Jim Blandy <jimb@redhat.com>
date Tue, 23 Feb 1993 11:49:39 +0000
parents 1045deef809f
children 0fe3520eb87b
files src/alloc.c
diffstat 1 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/alloc.c	Tue Feb 23 07:27:39 1993 +0000
+++ b/src/alloc.c	Tue Feb 23 11:49:39 1993 +0000
@@ -991,22 +991,27 @@
      double num;
 {
   register Lisp_Object new;
-  int alignment;
 
-  /* Make sure that pureptr is aligned on at least a sizeof (double)
-     boundary.  Some architectures (like the sparc) require this, and
-     I suspect that floats are rare enough that it's no tragedy for
-     those that do.  */
+  /* Make sure that PUREBEG + pureptr is aligned on at least a sizeof
+     (double) boundary.  Some architectures (like the sparc) require
+     this, and I suspect that floats are rare enough that it's no
+     tragedy for those that do.  */
+  {
+    int alignment;
+    char *p = PUREBEG + pureptr;
+
 #ifdef __GNUC__
 #if __GNUC__ >= 2
-  alignment = __alignof (struct Lisp_Float);
+    alignment = __alignof (struct Lisp_Float);
 #else
-  alignment = sizeof (struct Lisp_Float);
+    alignment = sizeof (struct Lisp_Float);
 #endif
 #else
-  alignment = sizeof (struct Lisp_Float);
+    alignment = sizeof (struct Lisp_Float);
 #endif  
-  pureptr = (pureptr + alignment - 1) & - alignment;
+    p = (char *) (((unsigned long) p + alignment - 1) & - alignment);
+    pureptr = p - PUREBEG;
+  }
 
   if (pureptr + sizeof (struct Lisp_Float) > PURESIZE)
     error ("Pure Lisp storage exhausted");