public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix const pointer warning in gthr-win32.h
@ 2008-07-11  2:01 Aaron W. LaFramboise
  2008-07-11  4:29 ` Kaveh R. GHAZI
  2008-08-23 18:32 ` [PATCH] Make the pointer parameter to __gthread_setspecific non-const Aaron W. LaFramboise
  0 siblings, 2 replies; 18+ messages in thread
From: Aaron W. LaFramboise @ 2008-07-11  2:01 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 246 bytes --]

This patch fixes a warning about casting away pointer constness.

It was necessary to copy the CONST_CAST definition to tsystem.h since 
this file cannot include system.h.

This patch was tested by a bootstrap on i386-pc-mingw32.

OK to commit?


[-- Attachment #2: gcc-4.4.0-20080710-cast.patch --]
[-- Type: text/plain, Size: 1491 bytes --]

2008-07-10  Aaron W. LaFramboise  <aaronavay62@aaronwl.com>

	* gcc/tsystem.h (CONST_CAST, CONST_CAST2): Duplicate from system.h.
	* gcc/gthr-win32.h (__gthread_setspecific): Use CONST_CAST.

Index: gcc/gthr-win32.h
===================================================================
--- gcc/gthr-win32.h	(revision 137703)
+++ gcc/gthr-win32.h	(working copy)
@@ -612,7 +612,10 @@ __gthread_getspecific (__gthread_key_t k
 static inline int
 __gthread_setspecific (__gthread_key_t key, const void *ptr)
 {
-  return (TlsSetValue (key, (void*) ptr) != 0) ? 0 : (int) GetLastError ();
+  if (TlsSetValue (key, CONST_CAST(void *, ptr)) != 0)
+    return 0;
+  else
+    return GetLastError ();
 }
 
 static inline void
Index: gcc/tsystem.h
===================================================================
--- gcc/tsystem.h	(revision 137703)
+++ gcc/tsystem.h	(working copy)
@@ -131,6 +131,16 @@ extern int errno;
    unreachable default case of a switch.  Do not use gcc_assert(0).  */
 #define gcc_unreachable() (abort ())
 
+/* This is a copy of CONST_CAST from system.h */
+
+#if defined(__GNUC__) && GCC_VERSION != 4000
+/* GCC 4.0.x has a bug where it may ICE on this expression.  */
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
+#else
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)(FROMTYPE)(X))
+#endif
+#define CONST_CAST(TYPE,X) CONST_CAST2(TYPE, const TYPE, (X))
+
 /* Filename handling macros.  */
 #include "filenames.h"
 

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-09-03  6:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-11  2:01 [PATCH] Fix const pointer warning in gthr-win32.h Aaron W. LaFramboise
2008-07-11  4:29 ` Kaveh R. GHAZI
2008-07-28 23:33   ` Aaron W. LaFramboise
2008-07-29 17:21     ` Ian Lance Taylor
2008-07-30 22:01       ` Kaveh R. Ghazi
2008-07-31  4:08         ` Aaron W. LaFramboise
2008-08-23 18:32 ` [PATCH] Make the pointer parameter to __gthread_setspecific non-const Aaron W. LaFramboise
2008-08-23 18:48   ` Richard Guenther
2008-08-23 19:42     ` Aaron W. LaFramboise
2008-08-23 19:53       ` Richard Guenther
2008-08-23 21:22         ` Aaron W. LaFramboise
2008-08-23 21:31           ` Richard Guenther
2008-08-23 22:12             ` Aaron W. LaFramboise
2008-08-24  0:24               ` Richard Guenther
2008-08-24  4:23                 ` Aaron W. LaFramboise
2008-08-24 10:33                   ` Richard Guenther
2008-08-25  7:55                     ` Danny Smith
2008-09-03  8:31                       ` Danny Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).