9 * Use this allocator if you have an object a child writes to that you want
10 * all other processes to see.
12 void * alloc_shared(unsigned int size
)
16 ret
= mmap(NULL
, size
, PROT_READ
| PROT_WRITE
, MAP_ANON
| MAP_SHARED
, -1, 0);
17 if (ret
== MAP_FAILED
) {
18 printf("mmap %u failure\n", size
);
24 void * __zmalloc(size_t size
, const char *func
)
30 printf("%s: malloc(%zu) failure.\n", func
, size
);
38 void sizeunit(unsigned long size
, char *buf
)
40 if (size
< 1024 * 1024) {
41 sprintf(buf
, "%lu bytes", size
);
45 if (size
< (1024 * 1024 * 1024)) {
46 sprintf(buf
, "%ldMB", (size
/ 1024) / 1024);
50 sprintf(buf
, "%ldGB", ((size
/ 1024) / 1024) / 1024);