LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-22-2010, 03:29 AM   #1
kevinsk
LQ Newbie
 
Registered: Jun 2010
Posts: 4

Rep: Reputation: 0
Question magic macro in module.h what ((struct module*)0) is ?


Hi all
I am Newbie to linux kernel but try to trace and understand it .
when I look at usb related code in linux kernel . I found one interesting macro in module.h as following .

#ifdef MODULE
#define MODULE_GENERIC_TABLE(gtype,name) \
extern const struct gtype##_id __mod_##gtype##_table \
__attribute__ ((unused, alias(__stringify(name))))

extern struct module __this_module;
#define THIS_MODULE (&__this_module)
#else /* !MODULE */
#define MODULE_GENERIC_TABLE(gtype,name)
#define THIS_MODULE ((struct module *)0)
#endif

if I define MODULE , I can find __this_module some where in ohci-hcd.mod.c or ehci-hcd.mod.c else .
my question is what ((struct module*)0) is if I do not define MODULE ?
have never seen ((struct module*)0) before . hard to image about it .
Thanks

Kevin ...
 
Old 11-22-2010, 05:21 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
Blog Entries: 54

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
It is simply a null pointer. The cast is placed there so that the null will be forced to be a particular pointer type (in this case a pointer to struct module), so that there will be type checking at the point where THIS_MODULE is used.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile and load kernel module automatically after boot? (Intel NIC module) touser Linux - Newbie 3 08-29-2009 08:45 PM
A question about MODULE macro smoking81 Linux - Kernel 1 10-05-2008 10:36 AM
error: -1 Invalid module format when using insmod with module cross-compiled for arm AndrewShanks Linux - Embedded & Single-board computer 4 10-15-2007 03:50 AM
Use of MODULE macro while compiling a module fssengg Linux - Newbie 0 03-31-2006 07:13 AM
kcmshell module, Background&Screensaver Module can't be launch (but works @LookNFeeL) bobbyjoe Linux - Software 0 01-08-2005 04:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration