vm: add macro for allocating and initialising C++ objects
This commit is contained in:
@@ -50,6 +50,7 @@ typedef enum vm_prot {
|
||||
} vm_prot_t;
|
||||
|
||||
typedef enum vm_flags {
|
||||
VM_NORMAL = 0x00u,
|
||||
VM_GET_DMA = 0x01u,
|
||||
} vm_flags_t;
|
||||
|
||||
@@ -294,4 +295,18 @@ extern size_t vm_page_get_pfn_sparse(vm_page_t *pg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
inline void *operator new(size_t count, void *p) { return p; }
|
||||
|
||||
#define kmalloc_object(objtype, flags, ...) \
|
||||
__extension__({ \
|
||||
void *p = kmalloc(sizeof(objtype), flags); \
|
||||
if (p) { \
|
||||
new (p) objtype(__VA_ARGS__); \
|
||||
} \
|
||||
(objtype *)p; \
|
||||
})
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user