Restore the "GPL licensing not permitted" in GLUT license headers.
[haiku.git] / src / libs / compat / freebsd_network / compat_cpp.cpp
bloba9ae740755dc944869d47184bf3adf7f9c7c7422
1 /*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "compat_cpp.h"
9 #include <stdio.h>
10 #include <string.h>
12 #include <kernel/vm/vm.h>
15 void*
16 _kernel_contigmalloc_cpp(const char* file, int line, size_t size,
17 phys_addr_t low, phys_addr_t high, phys_size_t alignment,
18 phys_size_t boundary, bool zero, bool dontWait)
20 size = ROUNDUP(size, B_PAGE_SIZE);
22 uint32 creationFlags = (zero ? 0 : CREATE_AREA_DONT_CLEAR)
23 | (dontWait ? CREATE_AREA_DONT_WAIT : 0);
25 char name[B_OS_NAME_LENGTH];
26 const char* baseName = strrchr(file, '/');
27 baseName = baseName != NULL ? baseName + 1 : file;
28 snprintf(name, sizeof(name), "contig:%s:%d", baseName, line);
30 virtual_address_restrictions virtualRestrictions = {};
32 physical_address_restrictions physicalRestrictions = {};
33 physicalRestrictions.low_address = low;
34 physicalRestrictions.high_address = high;
35 physicalRestrictions.alignment = alignment;
36 physicalRestrictions.boundary = boundary;
38 void* address;
39 area_id area = create_area_etc(B_SYSTEM_TEAM, name, size, B_CONTIGUOUS,
40 B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA, creationFlags, 0,
41 &virtualRestrictions, &physicalRestrictions, &address);
42 if (area < 0)
43 return NULL;
45 return address;