Note that there are some explanatory texts on larger screens.

plurals
  1. POLinux SLAB_CTOR_VERIFY and cache undeclared
    primarykey
    data
    text
    <p>I try to compile a program, that serves as a example how storage allocation works.</p> <p>The compiler gives me a error, that 'cache' and 'SLAB_CTOR_VERIFY' is undeclared.</p> <p>I can not find the declaration in my whole Kernel project ( Linux Kernel 2.6.32 ).</p> <p>Maybe there are some replacements or something like that.</p> <p>I found nothing in the web about that, but maybe some of you can give me a clue.</p> <p>Here is the Sourcecode:</p> <pre><code>#include &lt;linux/module.h&gt; #include &lt;linux/completion.h&gt; #include &lt;linux/slab.h&gt; static int thread_id=0; static DECLARE_COMPLETION( on_exit ); static kmem_cache_t *cache; struct linobj { int dummy_i, dummy_j, dummy_k; char dummy_feld[250]; wait_queue_head_t wq; }; static void linobj_destructor(void *objp, kmem_cache_t *cache, unsigned long flags) { printk("linobj_destructor( %p )\n", objp); return; } static void linobj_constructor(void *objp, kmem_cache_t *cache, unsigned long flags) { struct linobj *ptr = (struct linobj *)objp; if( flags &amp; SLAB_CTOR_VERIFY ) return; printk("linobj_constructor( %p )\n", objp); init_waitqueue_head(&amp;ptr-&gt;wq); return; } static int thread_code( void *data ) { unsigned long timeout, retvalue; int i; struct linobj *obj; daemonize("linobj-test"); allow_signal( SIGTERM ); for( i=0; i&lt;5; i++ ) { obj = (struct linobj *)kmem_cache_alloc( cache, GFP_KERNEL ); printk("objadr=%p\n", obj ); timeout=HZ; retvalue=schedule_timeout_interruptible(timeout); kmem_cache_free( cache, obj ); if( retvalue ) break; } complete_and_exit( &amp;on_exit, 0 ); } static int __init slab_init(void) { cache = kmem_cache_create( "linobj", sizeof(struct linobj), 0, 0, linobj_constructor, linobj_destructor ); if( !cache ) return -EFAULT; thread_id=kernel_thread( thread_code, NULL, CLONE_KERNEL ); if( thread_id==0 ) { kmem_cache_destroy( cache ); return -EIO; } return 0; } static void __exit slab_exit(void) { kill_pid( find_vpid(thread_id), SIGTERM, 1 ); wait_for_completion( &amp;on_exit ); if( cache ) kmem_cache_destroy( cache ); } module_init( slab_init ); module_exit( slab_exit ); MODULE_LICENSE("GPL"); </code></pre> <p>Thanks in advance</p> <p>Peter</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload