Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 09-17-2020, 03:40 PM   #1
LQ Newbie
Registered: Oct 2010
Location: Oak Park, IL
Distribution: RHEL 5.3, Fedora
Posts: 5

Rep: Reputation: 0
Linux Kernel source code: What does static void __##func mean?

I am trying to find out what the CAL interrupt in /proc/interrupts is all about. I understand it's "Function Call interrupts" but there seems to be a dearth of information about what a Function Call interrupt really is. I can presume it means "an interrupt generated whenever you call a system call", but I'm not so sure about that. "Prove it," I says to myself.

So I did some digging and uncovered (assume we're staying in x86-land for now), which says
. This is where the CAL counter gets incremented (it's irq_call_count). Perfect!

But I can't figure out how DEFINE_IDTENTRY_SYSVEC(sysvec_call_function) is called. What is a "sysvec_call_function"? That's not defined anywhere. And DEFINE_IDTENTRY_SYSVEC has a definition that I don't understand:

#define DEFINE_IDTENTRY_SYSVEC(func)					\
static void __##func(struct pt_regs *regs);


I think I might understand better if I could figure out what

Can you help? Thanks.
Old 09-17-2020, 10:49 PM   #2
LQ Newbie
Registered: Dec 2019
Posts: 3

Rep: Reputation: Disabled
While I'm not sure about the details of what you're working on, it looks like that's a token concatenation. Macros in c are based on tokens, not pieces of text like it may at first appear.


#define FOO(x, y) x##y
FOO(abc, def)

would be processed roughly as follows:

[FOO] ( [abc] , [def] )

The "##" acts to concatenate the two identifier tokens into a single identifier token. Essentially, the macro would turn something like:



static void [__my_cool_function] ( struct [pt_regs] * [regs] ) ;

instead of:

static void [__] [my_cool_function] ( struct [pt_regs] * [regs] ) ;

which would produce a compiler error.
1 members found this post helpful.
Old 09-18-2020, 06:35 PM   #3
LQ Newbie
Registered: Oct 2010
Location: Oak Park, IL
Distribution: RHEL 5.3, Fedora
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks. I understand, from your example, that the square brackets are not inserted by the macro preprocessor? In other words, technically it would be

static void __my_cool_function ( struct pt_regs *regs ) ;

and not

static void [__my_cool_function] ( struct [pt_regs] * [regs] ) ;

...Or do I misunderstand?
Old 09-19-2020, 10:17 AM   #4
LQ Newbie
Registered: Dec 2019
Posts: 3

Rep: Reputation: Disabled
Yeah, sorry. I was using square brackets to show identifier tokens ([abc] was an identifier token named "abc").


source code

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
Void Linux is... void black-clover Linux - Networking 8 11-23-2017 09:04 PM
pthread giving error: invalid conversion from ‘void* (*)(int*)’ to ‘void* (*)(void*)’ knobby67 Programming 4 05-05-2017 11:54 AM
difference between function declaration: func() and func(void) koyi Programming 4 11-19-2005 11:19 AM
how to find datatype of i in func(void *i,...) kapsikum Programming 2 03-09-2005 10:07 AM
void foo(void) and void foo() lackluster Programming 9 02-15-2003 11:57 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:40 PM.

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