=== modified file 'boot/Makefile.common'
--- boot/Makefile.common	2011-10-07 22:22:34 +0000
+++ boot/Makefile.common	2011-11-15 09:06:52 +0000
@@ -160,6 +160,7 @@
 	$(USPACE_PATH)/app/ext2info/ext2info \
 	$(USPACE_PATH)/app/kill/kill \
 	$(USPACE_PATH)/app/killall/killall \
+	$(USPACE_PATH)/app/memalign/memalign \
 	$(USPACE_PATH)/app/locinfo/locinfo \
 	$(USPACE_PATH)/app/mkfat/mkfat \
 	$(USPACE_PATH)/app/mkmfs/mkmfs \

=== modified file 'uspace/Makefile'
--- uspace/Makefile	2011-10-18 20:41:25 +0000
+++ uspace/Makefile	2011-11-15 09:06:12 +0000
@@ -46,6 +46,7 @@
 	app/klog \
 	app/locinfo \
 	app/lsusb \
+	app/memalign \
 	app/mkfat \
 	app/mkmfs \
 	app/redir \

=== added directory 'uspace/app/memalign'
=== added file 'uspace/app/memalign/Makefile'
--- uspace/app/memalign/Makefile	1970-01-01 00:00:00 +0000
+++ uspace/app/memalign/Makefile	2011-11-15 09:06:12 +0000
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2011 Vojtech Horky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+USPACE_PREFIX = ../..
+LIBS =
+EXTRA_CFLAGS =
+BINARY = memalign
+
+SOURCES = \
+	memalign.c
+
+include $(USPACE_PREFIX)/Makefile.common

=== added file 'uspace/app/memalign/memalign.c'
--- uspace/app/memalign/memalign.c	1970-01-01 00:00:00 +0000
+++ uspace/app/memalign/memalign.c	2011-11-15 09:06:12 +0000
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2011 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <malloc.h>
+
+#define ALLOC_ORDER_MAX 30
+
+static void touch_buffer(uint8_t *buffer, size_t size)
+{
+	while (size > 0) {
+		*buffer = 0xAA;
+		buffer++;
+		size--;
+	}
+}
+
+static int try_malloc(size_t size)
+{
+	void *ptr = malloc(size);
+	if (ptr == NULL) {
+		return 0;
+	}
+	touch_buffer((uint8_t *) ptr, size);
+	free(ptr);
+	return 1;
+}
+
+static int try_memalign(size_t align, size_t size)
+{
+	void *ptr = memalign(align, size);
+	if (ptr == NULL) {
+		return 0;
+	}
+	touch_buffer((uint8_t *) ptr, size);
+	free(ptr);
+	return 1;
+}
+
+static void run_malloc(void)
+{
+	printf("malloc:  ");
+	for (size_t i = 0; i < ALLOC_ORDER_MAX; i++) {
+		int ok = try_malloc(1 << i);
+		if (ok) {
+			printf(" %2zu", i);
+		} else {
+			printf("  -");
+		}
+	}
+	printf("\n");
+}
+
+static void run_memalign(void)
+{
+	printf("memalign:");
+	for (size_t i = 0; i < ALLOC_ORDER_MAX; i++) {
+		int ok = try_memalign(1 << i, 32);
+		if (ok) {
+			printf(" %2zu", i);
+		} else {
+			printf("  -");
+		}
+	}
+	printf("\n");
+}
+
+int main(int argc, char *argv[])
+{
+	setvbuf(stdout, NULL, _IONBF, 0);
+
+	run_memalign();
+	run_malloc();
+	run_malloc();
+	run_memalign();
+	run_memalign();
+	run_memalign();
+	run_memalign();
+	run_memalign();
+	run_memalign();
+	run_memalign();
+	run_memalign();
+	run_malloc();
+
+	return 0;
+}
+
+/** @}
+ */

