Ejemplo n.º 1
0
static void *
vmem_mmap_alloc(vmem_t *src, size_t size, int vmflags)
{
	void *ret;
	int old_errno = errno;

	ret = vmem_alloc(src, size, vmflags);
#ifndef _WIN32
	if (ret != NULL) {
	    if (mmap(ret, size, ALLOC_PROT, ALLOC_FLAGS | MAP_FIXED, -1, 0) ==
		    MAP_FAILED) {
		raise_mmap();
		if (mmap(ret, size, ALLOC_PROT, ALLOC_FLAGS | MAP_FIXED, -1, 0) ==
			MAP_FAILED) {
		    syslog(LOG_WARNING,
			    "vmem_mmap_alloc: mmap still failing after raise_mmap");
		    vmem_free(src, ret, size);
		    vmem_reap();

		    ASSERT((vmflags & VM_NOSLEEP) == VM_NOSLEEP);
		    errno = old_errno;
		    return (NULL);
		}
	    }
	}
#endif

	errno = old_errno;
	return (ret);
}
Ejemplo n.º 2
0
static void *
vmem_mmap_alloc(vmem_t *src, size_t size, int vmflags)
{
	void *ret;
	int old_errno = errno;

	ret = vmem_alloc(src, size, vmflags);
#ifndef _WIN32
	if (ret != NULL &&
	    mmap(ret, size, ALLOC_PROT, ALLOC_FLAGS | MAP_FIXED, -1, 0) ==
	    MAP_FAILED) {
		vmem_free(src, ret, size);
		vmem_reap();

		ASSERT((vmflags & VM_NOSLEEP) == VM_NOSLEEP);
		errno = old_errno;
		return (NULL);
	}
#endif

	errno = old_errno;
	return (ret);
}