-/* Copyright (c) 2009 The Regents of the University of California.
- * See the COPYRIGHT files at the top of this source tree for full
+/* Copyright (c) 2009 The Regents of the University of California.
+ * See the COPYRIGHT files at the top of this source tree for full
* license information.
- *
- * Kevin Klues <klueska@cs.berkeley.edu>
+ *
+ * Kevin Klues <klueska@cs.berkeley.edu>
*/
-#ifndef ROS_KERN_KMALLOC_H
-#define ROS_KERN_KMALLOC_H
+#pragma once
#include <ros/common.h>
#include <kref.h>
#define KMALLOC_LARGEST KMALLOC_SMALLEST << NUM_KMALLOC_CACHES
void kmalloc_init(void);
-void* (DALLOC(size) kmalloc)(size_t size, int flags);
-void* (DALLOC(size) kzmalloc)(size_t size, int flags);
+void *kmalloc(size_t size, int flags);
+void *kmalloc_array(size_t nmemb, size_t size, int flags);
+void *kzmalloc(size_t size, int flags);
void *kmalloc_align(size_t size, int flags, size_t align);
void *kzmalloc_align(size_t size, int flags, size_t align);
void *krealloc(void *buf, size_t size, int flags);
+void *kreallocarray(void *buf, size_t nmemb, size_t size, int flags);
int kmalloc_refcnt(void *buf);
void kmalloc_incref(void *buf);
void kfree(void *buf);
void kmalloc_canary_check(char *str);
void *debug_canary;
-/* Flags to pass to kmalloc */
-/* Not implemented yet. Block until it is available. */
-#define KMALLOC_WAIT 4
+#define MEM_ATOMIC (1 << 1)
+#define MEM_WAIT (1 << 2)
+#define MEM_ERROR (1 << 3)
/* Kmalloc tag flags looks like this:
*
* struct, and that it is not padded. */
struct kmalloc_tag {
union {
- struct kmem_cache *my_cache WHEN(flags == KMALLOC_TAG_CACHE);
- size_t num_pages WHEN(flags == KMALLOC_TAG_PAGES);
+ struct kmem_cache *my_cache;
+ size_t num_pages;
uint64_t unused_force_align;
};
struct kref kref;
uint32_t canary;
int flags;
};
-
-#endif //ROS_KERN_KMALLOC_H
-