-
- if (alloc_size > smalloc_pool_size)
- pool->size = alloc_size;
- else
- pool->size = smalloc_pool_size;
-
- if (ftruncate(fd, pool->size) < 0)
- goto out_unlink;
+ alloc_size += sizeof(struct block_hdr);
+ if (alloc_size < INITIAL_SIZE)
+ alloc_size = INITIAL_SIZE;
+
+ /* round up to nearest full number of blocks */
+ alloc_size = (alloc_size + SMALLOC_BPL - 1) & ~(SMALLOC_BPL - 1);
+ bitmap_blocks = alloc_size / SMALLOC_BPL;
+ alloc_size += bitmap_blocks * sizeof(unsigned int);
+ pool->mmap_size = alloc_size;
+
+ pool->nr_blocks = bitmap_blocks;
+ pool->free_blocks = bitmap_blocks * SMALLOC_BPB;
+
+ mmap_flags = OS_MAP_ANON;
+#ifdef CONFIG_ESX
+ mmap_flags |= MAP_PRIVATE;
+#else
+ mmap_flags |= MAP_SHARED;
+#endif
+ ptr = mmap(NULL, alloc_size, PROT_READ|PROT_WRITE, mmap_flags, -1, 0);