calling kernel space malloc get error

###Here is the errors I am getting. Below the error is the code I wrote, any help would be incredibly appreciated.!! Thanks!
Can someone explained by I am getting implicit warning for malloc and Malloc_Define, I included the header files. I also would like to know how to fix the errors . Thanks.!

Code:
intkmod.c:20:23: error: expected identifier
MALLOC_DEFINE(M_NODE, "New NODE", "Container Node");
                      ^
intkmod.c:20:1: warning: type specifier missing, defaults to 'int'
      [-Wimplicit-int]
MALLOC_DEFINE(M_NODE, "New NODE", "Container Node");
^
intkmod.c:28:17: warning: implicitly declaring library function 'malloc' with
      type 'void (unsigned long)' [-Wimplicit-function-declaration]
    ptr = (int)malloc(sizeof(int), M_NODE ,M_WAITOK)
                ^
intkmod.c:28:17: note: include the header <stdlib.h> or explicitly provide a
      declaration for 'malloc'
intkmod.c:28:37: error: use of undeclared identifier 'M_NODE'
    ptr = (int*)malloc(sizeof(int), M_NODE ,M_WAITOK)
                                    ^
2 warnings and 2 errors generated.


####Here is the code for my file which I include some kernel space files.

C:
typedef unsigned long uintfptr_t;

typedef unsigned long intrmask_t;

#include <sys/types.h>
#include <sys/module.h>
#include <sys/systm.h>  /* uprintf /
#include <sys/param.h>  / defines used in kernel.h /
#include <sys/kernel.h> / types used in module initialization /
#include <sys/conf.h>   / cdevsw struct /
#include <sys/uio.h>    / uio struct /
#include <sys/malloc.h>
#include <sys/kthread.h>
#include <sys/unistd.h>//int start();

MALLOC_DEFINE(M_NODE, "New NODE", "Container Node")
int main() {

    int ptr;
    ptr = (int*)malloc(sizeof(int), M_NODE ,M_WAITOK)

    printf("Hello world!\n");
    return 0;
}
 
Back
Top