C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

what is this code exactly meaning?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language (Moderated)
View previous topic :: View next topic  
Author Message
Cocy
Guest





PostPosted: Thu Mar 29, 2007 6:20 am    Post subject: what is this code exactly meaning? Reply with quote



Hi,

I saw the following code in linux kernel 2.6's code (arch/sparc/lib/
atomic32.c #L17).

spinlock_t __atomic_hash[ATOMIC_HASH_SIZE] = {
[0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED
};

, where
"SPIN_LOCK_UNLOCKED" returns spinlock_t type of struct,
ATOMIC_HASH_SIZE is defined as "4" just above that function in the
same file,
and "spinlock_t" is defined as struct in include/linux/
spinlock_types.h file.

What does the description

[0 ... (ATOMIC_HASH_SIZE-1)] = SPIN_LOCK_UNLOCKED

means exactly?

Is this means initializing anonymous array or something??? like
[0] = SPIN_LOCK_UNLOCKED
[1] = SPIN_LOCK_UNLOCKED
[2] = SPIN_LOCK_UNLOCKED
[3] = SPIN_LOCK_UNLOCKED
???

What I don't understand most is the part "..." in
"[0 ... (ATOMIC_HASH_SIZE-1)]". I've never seen this description in
C before, except for indicating possibility of additional arguments of
a
function (but it's still different from the declaration like
"func(arg1, arg2, ...)" ).

Does anyone know what it is?

Thanks in advance.

Cocy
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Back to top
WillerZ
Guest





PostPosted: Mon Apr 16, 2007 8:17 pm    Post subject: Re: what is this code exactly meaning? Reply with quote



It's a GCC extension, which (I believe) operates as you surmised.
--
comp.lang.c.moderated - moderation address: clcm (AT) plethora (DOT) net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.