Mercurial > emacs
comparison src/alloc.c @ 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 | 82bbf90208d4 |
children | 54c8c66cd9ac |
comparison
equal
deleted
inserted
replaced
1938:1045deef809f | 1939:def7b9c64935 |
---|---|
989 Lisp_Object | 989 Lisp_Object |
990 make_pure_float (num) | 990 make_pure_float (num) |
991 double num; | 991 double num; |
992 { | 992 { |
993 register Lisp_Object new; | 993 register Lisp_Object new; |
994 int alignment; | 994 |
995 | 995 /* Make sure that PUREBEG + pureptr is aligned on at least a sizeof |
996 /* Make sure that pureptr is aligned on at least a sizeof (double) | 996 (double) boundary. Some architectures (like the sparc) require |
997 boundary. Some architectures (like the sparc) require this, and | 997 this, and I suspect that floats are rare enough that it's no |
998 I suspect that floats are rare enough that it's no tragedy for | 998 tragedy for those that do. */ |
999 those that do. */ | 999 { |
1000 int alignment; | |
1001 char *p = PUREBEG + pureptr; | |
1002 | |
1000 #ifdef __GNUC__ | 1003 #ifdef __GNUC__ |
1001 #if __GNUC__ >= 2 | 1004 #if __GNUC__ >= 2 |
1002 alignment = __alignof (struct Lisp_Float); | 1005 alignment = __alignof (struct Lisp_Float); |
1003 #else | 1006 #else |
1004 alignment = sizeof (struct Lisp_Float); | 1007 alignment = sizeof (struct Lisp_Float); |
1005 #endif | 1008 #endif |
1006 #else | 1009 #else |
1007 alignment = sizeof (struct Lisp_Float); | 1010 alignment = sizeof (struct Lisp_Float); |
1008 #endif | 1011 #endif |
1009 pureptr = (pureptr + alignment - 1) & - alignment; | 1012 p = (char *) (((unsigned long) p + alignment - 1) & - alignment); |
1013 pureptr = p - PUREBEG; | |
1014 } | |
1010 | 1015 |
1011 if (pureptr + sizeof (struct Lisp_Float) > PURESIZE) | 1016 if (pureptr + sizeof (struct Lisp_Float) > PURESIZE) |
1012 error ("Pure Lisp storage exhausted"); | 1017 error ("Pure Lisp storage exhausted"); |
1013 XSET (new, Lisp_Float, PUREBEG + pureptr); | 1018 XSET (new, Lisp_Float, PUREBEG + pureptr); |
1014 pureptr += sizeof (struct Lisp_Float); | 1019 pureptr += sizeof (struct Lisp_Float); |