[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201508041501.t74F1MH3026171@ignucius.se.axis.com>
Date: Tue, 4 Aug 2015 17:01:22 +0200
From: Hans-Peter Nilsson <hans-peter.nilsson@...s.com>
To: xili_gchen_5257@...mail.com
CC: starvik@...s.com, jespern@...s.com, linux-cris-kernel@...s.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] cris: arch-v10: kgdb: Add volatile for static variable
is_dyn_brkp
> From: Chen Gang <xili_gchen_5257@...mail.com>
> Date: Fri, 10 Jul 2015 23:50:07 +0200
> Within one C file, current gcc can optimize the global static variables
> according to the C code, but it will skip assembly code -- it will pass
> them to gas directly.
>
> if the static variable is used between C code and assembly code in one C
> file (e.g. is_dyn_brkp in kgdb.c), it needs volatile to let gcc know it
> should not be optimized, or it may cause issue.
In this case it's *mostly* a matter of taste but please avoid
using volatile as a hammer when there are other tools available.
> -static unsigned char is_dyn_brkp = 0;
> +static volatile unsigned char is_dyn_brkp;
Please instead use "__used", i.e.
+static unsigned char __used is_dyn_brkp = 0;
brgds, H-P
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists