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, libfortran] PR46267 strerror() might not be thread-safe, take 2


On Fri, Jan 21, 2011 at 21:29, Jerry DeLisle <jvdelisle@frontier.com> wrote:
> On 01/21/2011 09:42 AM, Janne Blomqvist wrote:
>>
>> On Fri, Jan 21, 2011 at 19:36, Jakub Jelinek<jakub@redhat.com> Âwrote:
>>>
>>> On Fri, Jan 21, 2011 at 07:24:56PM +0200, Janne Blomqvist wrote:
>>>>
>>>> @@ -141,6 +141,38 @@ gfc_xtoa (GFC_UINTEGER_LARGEST n, char *buffer,
>>>> size_t len)
>>>> Â Âreturn p;
>>>> Â}
>>>>
>>>> +
>>>> +/* Hopefully thread-safe wrapper for a strerror() style function. Â*/
>>>> +
>>>> +char *
>>>> +gf_strerror (int errnum,
>>>> +#ifdef HAVE_STRERROR_R
>>>> + Â Â Â Â Âchar * buf, size_t buflen)
>>>> +{
>>>> + Â/* TODO: How to prevent the compiler warning due to strerror_r of
>>>> + Â Â the untaken branch having the wrong return type? Â*/
>>>> + Âif (__builtin_classify_type (strerror_r (0, buf, 0)) == 5)
>>>> + Â Â{
>>>> + Â Â Â/* GNU strerror_r() Â*/
>>>> + Â Â Âreturn strerror_r (errnum, buf, buflen);
>>>> + Â Â}
>>>> + Âelse
>>>> + Â Â{
>>>> + Â Â Â/* POSIX strerror_r () Â*/
>>>> + Â Â Âstrerror_r (errnum, buf, buflen);
>>>> + Â Â Âreturn buf;
>>>> + Â Â}
>>>> +#else
>>>> + Â Â Â Â Â Â char * buf __attribute__((unused)),
>>>> + Â Â Â Â Âsize_t buflen __attribute__((unused)))
>>>> +{
>>>> + Â/* strerror () is not necessarily thread-safe, but should at least
>>>> + Â Â be available everywhere. Â*/
>>>> + Âreturn strerror (errnum);
>>>> +#endif
>>>> +}
>>>
>>> The #ifdef inside of the parameters ending inside function
>>> looks very ugly, you can use unused attribute unconditionally
>>> and start #ifdef only within function body.
>>
>> Fair enough; updated patch attached. Otherwise no changes. Ok for trunk?
>>
> OK, thanks.
>
> Jerry

Thanks,

Sending        libgfortran/ChangeLog
Sending        libgfortran/config.h.in
Sending        libgfortran/configure
Sending        libgfortran/configure.ac
Sending        libgfortran/intrinsics/gerror.c
Sending        libgfortran/io/unix.c
Sending        libgfortran/libgfortran.h
Sending        libgfortran/runtime/error.c
Transmitting file data ........
Committed revision 169110.


-- 
Janne Blomqvist


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