This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Make the pointer parameter to __gthread_setspecific non-const
- From: "Danny Smith" <dansmister at gmail dot com>
- To: "Aaron W. LaFramboise" <aaronavay62 at aaronwl dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 Sep 2008 18:09:42 +1200
- Subject: Re: [PATCH] Make the pointer parameter to __gthread_setspecific non-const
- References: <48768624.4090608@aaronwl.com> <48B05B22.8010001@aaronwl.com> <84fc9c000808231212v771e8950taa5fddf1472e5fc7@mail.gmail.com> <48B0700D.8060000@aaronwl.com> <84fc9c000808231326y49bce6f2hc65fdb40a8cf874c@mail.gmail.com> <48B079F4.60401@aaronwl.com> <84fc9c000808231410t73284a7aw27fe4ae072609af@mail.gmail.com> <48B0B525.2060002@aaronwl.com> <84fc9c000808240133pa3f4489jbbeb87d3d6b577ba@mail.gmail.com> <9c03c2dd0808242243x4d3bcd0dtd6ce84b41ff06ec0@mail.gmail.com>
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