rkmem.h

Go to the documentation of this file.
00001 /*************************************************** */
00002 /* Rule Set Based Access Control                     */
00003 /* Author and (c) 1999-2005: Amon Ott <ao@rsbac.org> */
00004 /* Memory allocation                                 */
00005 /* Last modified: 08/Jun/2005                        */
00006 /*************************************************** */
00007 
00008 #ifndef __RSBAC_RKMEM_H
00009 #define __RSBAC_RKMEM_H
00010 
00011 #include <linux/init.h>
00012 #include <linux/slab.h>
00013 #include <linux/vmalloc.h>
00014 #include <linux/timer.h>
00015 
00016 #ifdef CONFIG_RSBAC_INIT_DELAY
00017 void rsbac_kmem_cache_sizes_init(void);
00018 #else
00019 void __init rsbac_kmem_cache_sizes_init(void);
00020 #endif
00021 
00022 /* if you might need more than this in 2.4, use rsbac_vkmalloc! */
00023 /* In 2.6, this is the maximum to allocate, more will fail! */
00024 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
00025 
00026 #ifdef CONFIG_MMU
00027 #define RSBAC_MAX_KMALLOC 131072
00028 #else
00029 #ifndef CONFIG_LARGE_ALLOCS
00030 #define RSBAC_MAX_KMALLOC 1048576
00031 #else
00032 #define RSBAC_MAX_KMALLOC 33554432
00033 #endif
00034 #endif
00035 
00036 #define rsbac_vmalloc(x) kmalloc(x, GFP_ATOMIC)
00037 #define rsbac_vfree(x) kfree(x)
00038 
00039 /* < 2.6 */
00040 #else
00041 #define RSBAC_MAX_KMALLOC 8192
00042 #define rsbac_vmalloc(x) vmalloc(x)
00043 #define rsbac_vfree(x) vfree(x)
00044 #endif
00045 
00046 struct rsbac_delayed_kfree_t
00047   {
00048     struct timer_list timer;
00049     void * objp;
00050   };
00051 
00052 extern void * rsbac_kmalloc (size_t size);
00053 
00054 /* Allocate memory. This function decides which alloc type (kmalloc or vmalloc) */
00055 /* to use and returns the decision as boolean value (TRUE = vmalloc), */
00056 /* if vmalloc_used_p is not NULL (what it should rather be...) */
00057 extern void * rsbac_vkmalloc (size_t size, rsbac_boolean_t * vmalloc_used_p);
00058 
00059 extern void rsbac_kfree (const void *objp);
00060 
00061 extern void rsbac_delayed_kfree(void *objp, rsbac_time_t delay);
00062 
00063 /* Free the allocated mem. Needs old returned mem type value, */
00064 /* or FALSE, if no type stored (kmalloc type assumed) */
00065 extern void rsbac_vkfree (void *objp, rsbac_boolean_t vmalloc_used);
00066 
00067 #endif

Generated on Sun May 21 14:30:49 2006 for RSBAC by  doxygen 1.4.2