![]() |
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) 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) \ (at https://elixir.bootlin.com/linux/v5....dtentry.h#L239) I think I might understand better if I could figure out what Code:
__##func Can you help? Thanks. |
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. |
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? |
Yeah, sorry. I was using square brackets to show identifier tokens ([abc] was an identifier token named "abc").
|
All times are GMT -5. The time now is 08:56 AM. |