The comma expression in linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. I recently read the Linux kernel code and see the following definition in the interrupted section:
Extern irq_cpustat_t irq_stat [];/* defined in asm/hardirq. h */
The two rough sentences above are about multi-CPU and single-CPU. The former is easy to understand, and the latter is a bit confusing, however, here the Linux kernel should use a comma expression in the C language syntax, because this syntax is rarely used, so it is not easy to understand at first glance, let's look at an example:
If (softirq_pending (cpu ))
Do_softirq ();
This syntax uses commas to connect N multiple expressions. The value of the entire comma expression is the last value of the expression, as shown in the following
Int a = 0;
Int B = 0;
Int c = 0;
Int d = a + 1, B + 100, c + 10000;
What is the value of d? In fact, the value of d is c + 1000. write it down, but there is a bit of doubt why the second rough statement is not defined as follows: # define _ IRQ_STAT (cpu, member) (irq_stat [0]. member)
Isn't it more direct? Are there any differences between the two?
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service