difference between DECLARE_* and DEFINE_* macro namespaces ?

Rik van Riel riel at surriel.com
Mon Sep 26 10:29:57 EDT 2022


On Wed, 2022-09-21 at 13:33 -0600, jim.cromie at gmail.com wrote:
> difference between DECLARE_* and DEFINE_* macro namespaces ?

I am not sure there is a clear difference any more nowadays.

Both DECLARE_* and DEFINE_* seem to be used for both defining
a type and declaring an (often initialized) instance of that type.

For example, DEFINE_SPINLOCK creates an unlocked spinlock:

#define DEFINE_SPINLOCK(x)      spinlock_t x = __SPIN_LOCK_UNLOCKED(x)

Meanwhile, DECLARE_RWSEM does the exact same thing, but for
the rw_semaphore:

#define DECLARE_RWSEM(name) \
        struct rw_semaphore name = __RWSEM_INITIALIZER(name)

-- 
All Rights Reversed.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20220926/123a3279/attachment.sig>


More information about the Kernelnewbies mailing list