Re: Initializing non-static locks

Matthias Urlichs (smurf@noris.de)
30 Oct 1998 15:06:01 +0100


"William R. Dirks" <dirks@netcom.com> writes:
> I hit this problem in my driver. The way I solved it was to make a
> static variable
> rwlock_t rw_lock_unlocked = RW_LOCK_UNLOCKED;
>
> Then use rw_lock_unlocked instead of RW_LOCK_UNLOCKED. Maybe that is an
> idea for the kernel?
>
No, the problem is that if you assign a struct to a variable (EXCEPT where
declaring the variable), you have to typecode the struct. The very idea of
assigning a constant struct to a variable is a GCC extension. Basically you
write it like this:

structure = ((struct foo) {x + y, 'a', 0});

The whole right side of this should have been in the definition of the
RW_LOCK_UNLOCKED macro, not just the part between-and-including the braces.

See also the "Constructors" node of gcc.info.

-- 
Matthias Urlichs  |  noris network GmbH   |   smurf@noris.de  |  ICQ: 20193661
The quote was selected randomly. Really.    |      http://www.noris.de/~smurf/
-- 
Honest criticism is hard to take, particularly from a relative, a
friend, an acquaintance, or a stranger.
                -- Franklin P. Jones

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/