1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me to understand anonymous array

Discussion in 'C' started by techme, Apr 16, 2010.

  1. techme

    techme New Member

    Joined:
    Feb 15, 2010
    Messages:
    86
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I saw the following code in linux kernel 2.6.20'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.
     
  2. techme

    techme New Member

    Joined:
    Feb 15, 2010
    Messages:
    86
    Likes Received:
    0
    Trophy Points:
    0
    Till now i can't solve this so please help me to solve it.
    I will be thankful to you.
     

Share This Page