How to avoid volatiles
Hi everyone, I had question in want eradicate volatile from here: for example: #define 0x01c40800 if ((volatile void *)pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE) /**HERE**/ return 8; else return pll_div(pllbase, PLLC_PREDIV); Thanks. Regards --Prabhakar
On Fri, Oct 14, 2011 at 2:51 PM, Prabhakar Lad <prabhakar.csengg@gmail.com>wrote:
Hi everyone,
I had question in want eradicate volatile from here: for example:
#define 0x01c40800
if ((volatile void *)pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE) /**HERE**/ return 8; else return pll_div(pllbase, PLLC_PREDIV);
Thanks.
Regards --Prabhakar
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi,
volatile keyword is make use of to enforce compiler that not to optimize the code that contains this qualifier. In this case maybe any of the two compared values could be changed in an unknowing way to the compiler which are to be considered and no optimization is required, hence volatile keyword is made use of. Regards, Rohan Puri
Thanks Rohan. Regards --Prabhakar On Fri, Oct 14, 2011 at 3:14 PM, rohan puri <rohan.puri15@gmail.com> wrote:
On Fri, Oct 14, 2011 at 2:51 PM, Prabhakar Lad <prabhakar.csengg@gmail.com
wrote:
Hi everyone,
I had question in want eradicate volatile from here: for example:
#define 0x01c40800
if ((volatile void *)pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE) /**HERE**/ return 8; else return pll_div(pllbase, PLLC_PREDIV);
Thanks.
Regards --Prabhakar
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi,
volatile keyword is make use of to enforce compiler that not to optimize the code that contains this qualifier.
In this case maybe any of the two compared values could be changed in an unknowing way to the compiler which are to be considered and no optimization is required, hence volatile keyword is made use of.
Regards, Rohan Puri
On Fri, Oct 14, 2011 at 3:14 PM, rohan puri <rohan.puri15@gmail.com> wrote:
On Fri, Oct 14, 2011 at 2:51 PM, Prabhakar Lad <prabhakar.csengg@gmail.com
wrote:
Hi everyone,
I had question in want eradicate volatile from here: for example:
#define 0x01c40800
if ((volatile void *)pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE) /**HERE**/ return 8; else return pll_div(pllbase, PLLC_PREDIV);
Thanks.
Regards --Prabhakar
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Hi,
volatile keyword is make use of to enforce compiler that not to optimize the code that contains this qualifier.
In this case maybe any of the two compared values could be changed in an unknowing way to the compiler which are to be considered and no optimization is required, hence volatile keyword is made use of.
Regards, Rohan Puri
Hi, I think Prabhakar is referring to Documentation/volatile-considered-harmful.txt in the Linux kernel source code and is hence trying to avoid volatile.. Am I right Prabhakar? Regards, Srivatsa S. Bhat
On Fri, Oct 14, 2011 at 2:51 PM, Prabhakar Lad <prabhakar.csengg@gmail.com>wrote:
Hi everyone,
I had question in want eradicate volatile from here: for example:
#define 0x01c40800
if ((volatile void *)pllbase == (volatile void *)DAVINCI_PLL_CNTRL0_BASE) /**HERE**/ return 8; else return pll_div(pllbase, PLLC_PREDIV);
Hi, Take a look at this: http://www.netrino.com/Embedded-Systems/How-To/C-Volatile-Keyword Regards, Srivatsa S. Bhat
participants (3)
-
Prabhakar Lad -
rohan puri -
Srivatsa Bhat