LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-17-2020, 03:40 PM   #1
GreyGnome
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?


Hello,
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 https://elixir.bootlin.com/linux/v5....nel/smp.c#L234 (assume we're staying in x86-land for now), which says
Code:
DEFINE_IDTENTRY_SYSVEC(sysvec_call_function)
{
	ack_APIC_irq();
	trace_call_function_entry(CALL_FUNCTION_VECTOR);
	inc_irq_stat(irq_call_count);
	generic_smp_call_function_interrupt();
	trace_call_function_exit(CALL_FUNCTION_VECTOR);
}
. 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:

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

(at https://elixir.bootlin.com/linux/v5....dtentry.h#L239)

I think I might understand better if I could figure out what
Code:
__##func
means.

Can you help? Thanks.
 
Old 09-17-2020, 10:49 PM   #2
powerboat9
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.

Ex:

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

would be processed roughly as follows:


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

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

DEFINE_IDTENTRY_SYSVEC(my_cool_function)

into:

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
GreyGnome
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
powerboat9
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").
 
  


Reply

Tags
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

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

All times are GMT -5. The time now is 07:40 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