This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Make the pointer parameter to __gthread_setspecific non-const


On Mon, Aug 25, 2008 at 5:43 PM, Danny Smith <dansmister@gmail.com> wrote:
> On Sun, Aug 24, 2008 at 8:33 PM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Sun, Aug 24, 2008 at 3:11 AM, Aaron W. LaFramboise
>> <aaronavay62@aaronwl.com> wrote:
>>> Richard Guenther wrote:
>>>>
>>>> On Sat, Aug 23, 2008 at 10:58 PM, Aaron W. LaFramboise
>>>> <aaronavay62@aaronwl.com> wrote:
>>>
>>>>> If you do a clean bootstrap of i386-pc-mingw32 from svn or a snapshot, it
>>>>> will fail in stage2 in a file that includes gthr-win32.h.
>>>>
>>>> Ok.  I'd rather use the union trick then in gthr-win32.h.
>>>
>>> Alright.  In that case, is the attached patch OK?
>>>
>>> As I mentioned, neither <system.h> nor <tsystem.h> are available here
>>> because other top-level libraries that don't have those use this, so we have
>>> to redefine this macro.
>>>
>>> I tested this on i386-pc-mingw32 with a bootstrap.
>>
>> This is ok.
>>
>> Thanks,
>> Richard.
>>
>>> 2008-08-23  Aaron W. LaFramboise  <aaronavay62@aaronwl.com>
>>>
>>>        * gcc/gthr-win32.h (__gthread_setspecific): Use CONST_CAST2.
>>>

I have committed the following patch as obvious to restore bootstrap on mingw32.

2008-09-03 Danny Smith  <dannysmith@usrs.sourceforge.net>

	* gthr-win32.h (CONST_CAST2): Really make sure CONST_CAST2 is
	defined.
	(__gthread_setspecific): Revert 2008-08-31 change to
	__GTHREAD_HIDE_W32API case.  Apply it to !__GTHREAD_HIDE_W32API
	case.

	
Index: gthr-win32.h
===================================================================
--- gthr-win32.h	(revision 139848)
+++ gthr-win32.h	(working copy)
@@ -32,6 +32,11 @@
 #ifndef GCC_GTHR_WIN32_H
 #define GCC_GTHR_WIN32_H

+/* Make sure CONST_CAST2 (origin in system.h) is declared.  */
+#ifndef CONST_CAST2
+#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union
{FROMTYPE _q; TOTYPE _nq;})(X))._nq)
+#endif
+
 /* Windows32 threads specific definitions. The windows32 threading model
    does not map well into pthread-inspired gcc's threading model, and so
    there are caveats one needs to be aware of.
@@ -455,10 +460,7 @@
 static inline int
 __gthread_setspecific (__gthread_key_t key, const void *ptr)
 {
-  if (TlsSetValue (key, CONST_CAST2(void *, const void *, ptr)) != 0)
-    return 0;
-  else
-    return GetLastError ();
+  return __gthr_win32_setspecific (key, ptr);
 }

 static inline void
@@ -615,7 +617,10 @@
 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_CAST2(void *, const void *, ptr)) != 0)
+    return 0;
+  else
+    return GetLastError ();
 }

 static inline void


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]