libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] [PATCH 04/57] Workaround non-power-of-two i386 sizeof(


From: Tommi Rantala
Subject: [Libunwind-devel] [PATCH 04/57] Workaround non-power-of-two i386 sizeof(long double) in src/mi/mempool.c
Date: Fri, 21 Sep 2012 14:11:05 +0300

To ensure that we return properly aligned pointers from sos_alloc(),
MAX_ALIGN must be a power-of-two. On i386 the power-of-two assumption
fails as sizeof(long double) = 12. Fix this by rounding up to 16.
---
 src/mi/mempool.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mi/mempool.c b/src/mi/mempool.c
index b49202b..66cb099 100644
--- a/src/mi/mempool.c
+++ b/src/mi/mempool.c
@@ -31,7 +31,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.  */
 #ifdef __BIGGEST_ALIGNMENT__
 # define MAX_ALIGN     __BIGGEST_ALIGNMENT__
 #else
-# define MAX_ALIGN     (sizeof (long double))
+/* Crude hack to check that MAX_ALIGN is power-of-two.
+ * sizeof(long double) = 12 on i386. */
+# define MAX_ALIGN_(n) (n < 8 ? 8 : \
+                        n < 16 ? 16 : n)
+# define MAX_ALIGN     MAX_ALIGN_(sizeof (long double))
 #endif
 
 static char sos_memory[SOS_MEMORY_SIZE];
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]