* of the GNU Lesser General Public License.
*/
-#include "ucw/lib.h"
+#include <ucw/lib.h>
#include <sys/mman.h>
#include <string.h>
void *
page_alloc(u64 len)
{
+ if (!len)
+ return NULL;
if (len > SIZE_MAX)
die("page_alloc: Size %llu is too large for the current architecture", (long long) len);
ASSERT(!(len & (CPU_PAGE_SIZE-1)));
u64 l = big_round(len);
if (l > SIZE_MAX - 2*CPU_PAGE_SIZE)
die("big_alloc: Size %llu is too large for the current architecture", (long long) len);
-#ifdef CONFIG_DEBUG
+#ifdef CONFIG_UCW_DEBUG
l += 2*CPU_PAGE_SIZE;
#endif
byte *p = page_alloc(l);
-#ifdef CONFIG_DEBUG
+#ifdef CONFIG_UCW_DEBUG
*(u64*)p = len;
mprotect(p, CPU_PAGE_SIZE, PROT_NONE);
mprotect(p+l-CPU_PAGE_SIZE, CPU_PAGE_SIZE, PROT_NONE);
{
byte *p = start;
u64 l = big_round(len);
-#ifdef CONFIG_DEBUG
+#ifdef CONFIG_UCW_DEBUG
p -= CPU_PAGE_SIZE;
mprotect(p, CPU_PAGE_SIZE, PROT_READ);
ASSERT(*(u64*)p == len);