LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-25-2013, 03:14 PM   #1
vilhelmgray
LQ Newbie
 
Registered: Apr 2013
Posts: 4

Rep: Reputation: Disabled
ATOMIC_INIT macro defined as a compound literal


While hacking the Linux kernel v3.2, I noticed some architectures defined the ATOMIC_INIT macro slightly different than most others.

arch/x86/include/asm/atomic.h:
Code:
#define ATOMIC_INIT(i)  { (i) }
arch/alpha/include/asm/atomic.h:
Code:
#define ATOMIC_INIT(i)          ( (atomic_t) { (i) } )
In later versions of the Linux kernel, the compound literal definition is replaced with the definition used in the x86 architecture code. This was probably done to allow the initialization of static atomic_t variables, which aren't possible if using compound literals.

Does anyone know why a compound literal was even used in the first place?

Last edited by vilhelmgray; 04-25-2013 at 03:16 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to test whether a macro is defined rainman1985_2010 Programming 2 03-20-2011 06:37 AM
C++: Macro not defined in quotes!? CoderMan Programming 2 12-12-2009 11:39 PM
Way to convert Macro Defined functions from linux Kernel in Visual C++ Kunsheng Programming 5 06-29-2009 09:25 AM
too literal! treebug Linux - General 2 03-16-2006 12:30 PM
#defining a macro inside a macro? saravkrish Programming 1 05-24-2005 09:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration