 src/core/ipv4/ip_frag.c           |  2 +-
 src/core/mem.c                    |  2 +-
 src/core/memp.c                   |  2 +-
 src/include/lwip/mem.h            | 13 +++++++++++--
 src/include/lwip/memp.h           |  4 ++--
 src/include/lwip/opt.h            | 10 +++++++++-
 src/include/lwip/priv/memp_priv.h |  4 ++--
 7 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/core/ipv4/ip_frag.c b/src/core/ipv4/ip_frag.c
index a647433..af6a4cd 100644
--- a/src/core/ipv4/ip_frag.c
+++ b/src/core/ipv4/ip_frag.c
@@ -640,7 +640,7 @@ nullreturn:
 
 #if IP_FRAG
 #if IP_FRAG_USES_STATIC_BUF
-static u8_t buf[LWIP_MEM_ALIGN_SIZE(IP_FRAG_MAX_MTU + MEM_ALIGNMENT - 1)];
+static MEM_ALIGN_T buf[LWIP_MEM_ALIGN_BUFFER(MEM_ALIGN_T, IP_FRAG_MAX_MTU)];
 #else /* IP_FRAG_USES_STATIC_BUF */
 
 #if !LWIP_NETIF_TX_SINGLE_PBUF
diff --git a/src/core/mem.c b/src/core/mem.c
index 9ca9e3c..3256874 100644
--- a/src/core/mem.c
+++ b/src/core/mem.c
@@ -202,7 +202,7 @@ struct mem {
  * how that space is calculated). */
 #ifndef LWIP_RAM_HEAP_POINTER
 /** the heap. we need one struct mem at the end and some room for alignment */
-u8_t ram_heap[MEM_SIZE_ALIGNED + (2U*SIZEOF_STRUCT_MEM) + MEM_ALIGNMENT];
+MEM_ALIGN_T ram_heap[LWIP_MEM_ALIGN_BUFFER(MEM_ALIGN_T, MEM_SIZE_ALIGNED + SIZEOF_STRUCT_MEM)];
 #define LWIP_RAM_HEAP_POINTER ram_heap
 #endif /* LWIP_RAM_HEAP_POINTER */
 
diff --git a/src/core/memp.c b/src/core/memp.c
index 8a8a4e2..31aa8f0 100644
--- a/src/core/memp.c
+++ b/src/core/memp.c
@@ -204,7 +204,7 @@ memp_init_pool(const struct memp_desc *desc)
 {
   int i;
   struct memp *memp;
-  
+
   *desc->tab = NULL;
   memp = (struct memp*)LWIP_MEM_ALIGN(desc->base);
   /* create a linked list of memp elements */
diff --git a/src/include/lwip/mem.h b/src/include/lwip/mem.h
index 66537a9..9247559 100644
--- a/src/include/lwip/mem.h
+++ b/src/include/lwip/mem.h
@@ -108,10 +108,12 @@ void  mem_free(void *mem);
 
 /** Calculate safe memory size for an aligned buffer when using an unaligned
  * type as storage. This includes a safety-margin on (MEM_ALIGNMENT - 1) at the
- * start (e.g. if buffer is u8_t[] and actual data will be u32_t*)
+ * start (e.g. if buffer is u8_t[] and actual data will be u32_t*), where
+ * 'type' is the array type used to allocate the buffer and
+ * 'size' is the required buffer size in bytes
  */
 #ifndef LWIP_MEM_ALIGN_BUFFER
-#define LWIP_MEM_ALIGN_BUFFER(size) (((size) + MEM_ALIGNMENT - 1U))
+#define LWIP_MEM_ALIGN_BUFFER(type, size) (((size) + (MEM_ALIGNMENT - 1U))/sizeof(type))
 #endif
 
 /** Align a memory pointer to the alignment defined by MEM_ALIGNMENT
@@ -121,6 +123,13 @@ void  mem_free(void *mem);
 #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
 #endif
 
+/** Calculates the size of a statically allocated buffer allocated as MEM_ALIGN_T
+ * so that it meets the requirement set by MEM_ALIGNMENT
+ */
+#ifndef LWIP_MEM_ALIGNED_ARRAYSIZE
+#define LWIP_MEM_ALIGNED_ARRAYSIZE(size)
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/include/lwip/memp.h b/src/include/lwip/memp.h
index d6c2965..2cb7a54 100644
--- a/src/include/lwip/memp.h
+++ b/src/include/lwip/memp.h
@@ -90,8 +90,8 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
 
 #else /* MEMP_MEM_MALLOC */
 
-#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) u8_t memp_memory_ ## name ## _base \
-    [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size))) + (MEM_ALIGNMENT-1)]; \
+#define LWIP_MEMPOOL_DECLARE(name,num,size,desc) MEM_ALIGN_T memp_memory_ ## name ## _base \
+    [LWIP_MEM_ALIGN_BUFFER(MEM_ALIGN_T, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size))))]; \
     \
   static struct memp *memp_tab_ ## name; \
     \
diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h
index 9ff31a4..fdd740b 100644
--- a/src/include/lwip/opt.h
+++ b/src/include/lwip/opt.h
@@ -125,13 +125,21 @@
 #define MEMP_MEM_MALLOC                 0
 #endif
 
+/** MEM_ALIGN_T: A type for which 'sizeof(type)' is your alignment requirement.
+ * This type is used for static buffer allocation, its size MUST be smaller than
+ * MEM_ALIGNMENT (if you manually specify the latter).
+ */
+#ifndef MEM_ALIGN_T
+#define MEM_ALIGN_T                     u8_t
+#endif
+
 /**
  * MEM_ALIGNMENT: should be set to the alignment of the CPU
  *    4 byte alignment -> \#define MEM_ALIGNMENT 4
  *    2 byte alignment -> \#define MEM_ALIGNMENT 2
  */
 #ifndef MEM_ALIGNMENT
-#define MEM_ALIGNMENT                   1
+#define MEM_ALIGNMENT                   sizeof(MEM_ALIGN_T)
 #endif
 
 /**
diff --git a/src/include/lwip/priv/memp_priv.h b/src/include/lwip/priv/memp_priv.h
index d6f63b0..e368936 100644
--- a/src/include/lwip/priv/memp_priv.h
+++ b/src/include/lwip/priv/memp_priv.h
@@ -43,7 +43,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-    
+
 #include "lwip/mem.h"
 
 #if MEMP_OVERFLOW_CHECK
@@ -138,7 +138,7 @@ struct memp_desc {
 #endif /* LWIP_DEBUG || MEMP_OVERFLOW_CHECK */
 
   /** Base */
-  u8_t *base;  
+  MEM_ALIGN_T *base;
 
   /** First free element of each pool. Elements form a linked list. */
   struct memp **tab;
