gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10159 - in libmicrohttpd: . src/daemon


From: gnunet
Subject: [GNUnet-SVN] r10159 - in libmicrohttpd: . src/daemon
Date: Thu, 28 Jan 2010 21:14:18 +0100

Author: grothoff
Date: 2010-01-28 21:14:18 +0100 (Thu, 28 Jan 2010)
New Revision: 10159

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/daemon/daemon.c
   libmicrohttpd/src/daemon/memorypool.c
Log:
fixing alignment issue

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2010-01-28 16:30:22 UTC (rev 10158)
+++ libmicrohttpd/ChangeLog     2010-01-28 20:14:18 UTC (rev 10159)
@@ -1,3 +1,7 @@
+Thu Jan 28 20:35:48 CET 2010
+       Make sure addresses returned by memory pool are
+       aligned (fixes bus errors on Sparc). -CG
+       
 Thu Dec 17 20:26:52 CET 2009
        poll.h is not stricly required anymore. -ND
 

Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c   2010-01-28 16:30:22 UTC (rev 10158)
+++ libmicrohttpd/src/daemon/daemon.c   2010-01-28 20:14:18 UTC (rev 10159)
@@ -495,8 +495,8 @@
   struct timeval tv;
   unsigned int timeout;
   time_t now;
+#ifdef HAVE_POLL_H
   struct MHD_Pollfd mp;
-#ifdef HAVE_POLL_H
   struct pollfd p;
 #endif
 

Modified: libmicrohttpd/src/daemon/memorypool.c
===================================================================
--- libmicrohttpd/src/daemon/memorypool.c       2010-01-28 16:30:22 UTC (rev 
10158)
+++ libmicrohttpd/src/daemon/memorypool.c       2010-01-28 20:14:18 UTC (rev 
10159)
@@ -1,6 +1,6 @@
 /*
      This file is part of libmicrohttpd
-     (C) 2007, 2009 Daniel Pittman and Christian Grothoff
+     (C) 2007, 2009, 2010 Daniel Pittman and Christian Grothoff
 
      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,16 @@
 #define MAP_FAILED ((void*)-1)
 #endif
 
+/**
+ * Align to 2x word size (as GNU libc does).
+ */
+#define ALIGN_SIZE (2 * sizeof(void*))
 
+/**
+ * Round up 'n' to a multiple of ALIGN_SIZE.
+ */
+#define ROUND_TO_ALIGN(n) ((n+(ALIGN_SIZE-1)) & (~(ALIGN_SIZE-1)))
+
 struct MemoryPool
 {
 
@@ -127,6 +136,7 @@
 {
   void *ret;
 
+  size = ROUND_TO_ALIGN (size);
   if ((pool->pos + size > pool->end) || (pool->pos + size < pool->pos))
     return NULL;
   if (from_end == MHD_YES)
@@ -166,6 +176,7 @@
 {
   void *ret;
 
+  new_size = ROUND_TO_ALIGN (new_size);
   if ((pool->end < old_size) || (pool->end < new_size))
     return NULL;                /* unsatisfiable or bogus request */
 
@@ -211,6 +222,7 @@
                void *keep, 
                size_t size)
 {
+  size = ROUND_TO_ALIGN (size);
   if (keep != NULL)
     {
       if (keep != pool->memory)





reply via email to

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