diff options
author | Kai Tietz <kai.tietz@onevision.com> | 2010-06-11 08:14:33 +0000 |
---|---|---|
committer | Kai Tietz <ktietz@gcc.gnu.org> | 2010-06-11 10:14:33 +0200 |
commit | 10d291f61fd76bd4bea77e2a3be0142ea574b656 (patch) | |
tree | b68ad72d0eb1a6b3c3d16ea618983f80d8aa41c7 /gcc/system.h | |
parent | 2aa9a961d4252247641c5d91d4329785728342a2 (diff) | |
download | gcc-10d291f61fd76bd4bea77e2a3be0142ea574b656.zip gcc-10d291f61fd76bd4bea77e2a3be0142ea574b656.tar.gz gcc-10d291f61fd76bd4bea77e2a3be0142ea574b656.tar.bz2 |
system.h (helper_const_non_const_cast): New inline for gcc version <= 4.0.
2010-06-11 Kai Tietz <kai.tietz@onevision.com>
* system.h (helper_const_non_const_cast): New inline for
gcc version <= 4.0.
(CONST_CAST2): For gcc version <= 4.0 use
new helper to do const/non-const casting.
From-SVN: r160598
Diffstat (limited to 'gcc/system.h')
-rw-r--r-- | gcc/system.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/system.h b/gcc/system.h index 085df7d..29b7cd2 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -834,6 +834,20 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; /* GCC 4.0.x has a bug where it may ICE on this expression, so does GCC 3.4.x (PR17436). */ #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq) +#elif defined(__GNUC__) +static inline char * +helper_const_non_const_cast (const char *p) +{ + union { + const char *const_c; + char *c; + } val; + val.const_c = p; + return val.c; +} + +#define CONST_CAST2(TOTYPE,FROMTYPE,X) \ + ((TOTYPE) helper_const_non_const_cast ((const char *) (FROMTYPE) (X))) #else #define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X)) #endif |