473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Elipsis with array

Hello folks,

I investigating kernel sources I coincided with this part:

struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS-1] = {
.status = IRQ_DISABLED,
.chip = &no_irq_chip,
.handle_irq = handle_bad_irq,
.depth = 1,
.lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
#ifdef CONFIG_SMP
.affinity = CPU_MASK_ALL
#endif
}
};

Q1- What is this part "[0 ... NR_IRQS-1]" ?
Q2- Elipsis using with arrays ?

Regards.
Oct 13 '08 #1
6 2267
On 13 Oct 2008 at 10:23, berte wrote:
struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS-1] = {
.status = IRQ_DISABLED,
[snip]
>
Q1- What is this part "[0 ... NR_IRQS-1]" ?
Q2- Elipsis using with arrays ?
This is a GNU extension. See
<http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html>

Oct 13 '08 #2
On 13 Oct 2008 at 10:23, berte wrote:
struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS-1] = {
.status = IRQ_DISABLED,
[snip]
>
Q1- What is this part "[0 ... NR_IRQS-1]" ?
Q2- Elipsis using with arrays ?
This is a GNU extension. See
<http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html>

Oct 13 '08 #3
berte wrote:
Hello folks,

I investigating kernel sources I coincided with this part:

struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp =
{ [0 ... NR_IRQS-1] = {
.status = IRQ_DISABLED,
.chip = &no_irq_chip,
.handle_irq = handle_bad_irq,
.depth = 1,
.lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
#ifdef CONFIG_SMP
.affinity = CPU_MASK_ALL
#endif
}
};

Q1- What is this part "[0 ... NR_IRQS-1]" ?
Q2- Elipsis using with arrays ?
Those are GNU extensions to the GCC, to ease the static
initialization of structures. You find them to be used
throughout large parts of the Linux kernel sources and their use
is highly encouraged to enhance readability.

See the documentation here:
http://gcc.gnu.org/onlinedocs/gcc-4....signated-Inits

Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber.org, ICQ: 134682867

Oct 13 '08 #4
On Mon, 13 Oct 2008 03:23:31 -0700 (PDT),
berte <be********@gmail.comwrote:
Hello folks,

I investigating kernel sources I coincided with this part:

struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS-1] = {
That's not standard C, but a gcc extension to initialise a range of
elements to the same value.

Check the gcc manual, under 'C Extensions' - 'Designated Inits'.

Martien
--
|
Martien Verbruggen |
| The gene pool could use a little chlorine.
|
Oct 13 '08 #5
On 13 Ekim, 13:52, Martien Verbruggen <m...@tradingpost.com.auwrote:
On Mon, 13 Oct 2008 03:23:31 -0700 (PDT),
* * * * berte <behzate...@gmail.comwrote:
Hello folks,
I investigating kernel sources I coincided with this part:
struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
* *[0 ... NR_IRQS-1] = {

That's not standard C, but a gcc extension to initialise a range of
elements to the same value.

Check the gcc manual, under 'C Extensions' - 'Designated Inits'.

Martien
--
* * * * * * * * * * * * |
Martien Verbruggen * * *|
* * * * * * * * * * * * | The gene pool could usea little chlorine.
* * * * * * * * * * * * |
Thank you all. I got it :-)

Regards,
berte
Oct 13 '08 #6
jacob navia <ja***@nospam.comwrites:
berte wrote:
>>
I investigating kernel sources I coincided with this part:

struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
[0 ... NR_IRQS-1] = {
.status = IRQ_DISABLED,
.chip = &no_irq_chip,
.handle_irq = handle_bad_irq,
.depth = 1,
.lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
#ifdef CONFIG_SMP
.affinity = CPU_MASK_ALL
#endif
}
};

Q1- What is this part "[0 ... NR_IRQS-1]" ?
Q2- Elipsis using with arrays ?

This is a gnu extension. In
http://gcc.gnu.org/onlinedocs/gcc-2....c_4.html#SEC88
you can read:
4.20 Labeled Elements in Initializers
<snip quote from old manual>

By quoting such an old manual you obscure what is C99 and what is an
extension. The newer version makes it much clearer.

http://gcc.gnu.org/onlinedocs/gcc-4....signated-Inits

--
Ben.
Oct 13 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Brian | last post by:
I'm diddlying with a script, and found some behavior I don't understand. Take this snippet: for ($i = 0; $i <= count($m); $i++) { array_shift($m); reset($m); }
2
by: Stormkid | last post by:
Hi Group I'm trying to figure out a way that I can take two (two dimensional) arrays and avShed and shed, and subtract the matching elements in shed from avShed I've pasted the arrays blow from a...
15
by: lawrence | last post by:
I wanted to test xml_parse_into_struct() so I took the example off of www.php.net and put this code up on a site: <?php $simple = <<<END <item>
8
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array(...
12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
8
by: Mike S. Nowostawsky | last post by:
I tried using the "toUpperCase()" property to change the value of an array entity to uppercase BUT it tells me that the property is invalid. It seems that an array is not considered an object when...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
0
by: Antoninus Twink | last post by:
On 13 Oct 2008 at 10:23, berte wrote: This is a GNU extension. See <http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html>
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.