Date: Wed, 28 Jul 2021 16:03:10 +0530 From: Shamsher singh <meetshamsher@gmail.com> To: freebsd-questions@freebsd.org Subject: Re: Regarding MALLOC_DEFINE related issues in kernel code usage Message-ID: <9E45B3A6-451E-4F92-ACC6-8B63750F9BE4@gmail.com> In-Reply-To: <F31346C7-0C8A-4643-8C7C-049DBD980882@gmail.com> References: <F31346C7-0C8A-4643-8C7C-049DBD980882@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi,
Please ignore this mail. It’s done and working fine.
Thanks & regards
Shamsher
> On 28-Jul-2021, at 12:32 PM, Shamsher singh <meetshamsher@gmail.com> wrote:
>
> Hi,
> I am using below test.c file (shown as example) in freebsd13 and getting below issues:
>
> For #include <sys/systm.h> and #include <sys/malloc.h>
>
> # cat test.c
> #define _KERNEL
> #include <sys/types.h>
> #include <sys/module.h>
> #include <sys/systm.h>
> #include <sys/param.h>
> #include <sys/kernel.h>
> #include <sys/malloc.h>
> #include <sys/kthread.h>
> #include <sys/unistd.h>
> #include <stdlib.h>
> #include <sys/param.h>
> #include <sys/kernel.h>
> #include <sys/types.h>
>
> MALLOC_DEFINE(M_NODE, "NODE1", "test Node");
> int main() {
> int *ptr;
> ptr = (int*)malloc(sizeof(int), M_NODE ,M_WAITOK)
> printf("ptr=%p\n",ptr);
> return 0;
> }
> [root@FreeBSD_build_machine1 ~/iproot/freebsd/mods/drivers/dell_bios]# cc test.c
> In file included from test.c:4:
> In file included from /usr/include/sys/systm.h:179:
> /usr/include/sys/kpilite.h:33:10: fatal error: 'offset.inc' file not found
> #include "offset.inc"
> ^~~~~~~~~~~~
> 1 error generated.
>
> If commenting above header then getting issues like:
> In file included from /usr/include/sys/malloc.h:43:
> In file included from /usr/include/sys/systm.h:179:
> /usr/include/sys/kpilite.h:33:10: fatal error: 'offset.inc' file not found
> #include “offset.inc"
>
>
>
> The MALLOC_DEFINE is defined in malloc.h with macros _KERNEL.
> So can’t avoid these above header files.
>
> Can you please suggest me what am I missing here ?
>
> Note: This similar issues I am facing for smbios.
>
> Thanks & regards
> Shamsher Singh
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9E45B3A6-451E-4F92-ACC6-8B63750F9BE4>
