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, libgfortran] PR53445/53444 - Fix compilation on VxWorks


On Tue, May 22, 2012 at 10:33 PM, Janne Blomqvist
<blomqvist.janne@gmail.com> wrote:
> On Tue, May 22, 2012 at 5:57 PM, Tobias Burnus <burnus@net-b.de> wrote:
>> On 05/22/2012 03:06 PM, Tobias Burnus wrote:
>>>
>>> The attached patches fix compilation issues on VxWorks.
>>>
>>> a) VxWorks has strerror_r but contrary to POSIX, the function in VxWorks
>>> (at least in older versions) takes only two arguments: errnum and buf and
>>> not also the buffer length. I added a configure check for that variant.
>>
>>
>> I forgot to attach that patch. Now with patch and automake 1.11.1 for the
>> generated files.
>>
>> Tobias
>
> For the a) patch (strerror_r): The configure.ac diff occurs twice in
> the patch, and the patch file has DOS line endings. Also, based on
> some googling the vxworks 2-arg strerror_r returns OK or ERROR (an
> enum, I presume). So the trick with builtin_choose_expr is both wrong
> and unnecessary. Thus I'd replace
>
> +#elif defined(HAVE_STRERROR_R_2ARGS)
> + Âreturn
> + Â Â__builtin_choose_expr (__builtin_classify_type (strerror_r (0, buf))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â== 5,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â/* char*-returning strerror_r() Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Âstrerror_r (errnum, buf),
> + Â Â Â Â Â Â Â Â Â Â Â Â Â/* int-returning strerror_r () Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â(strerror_r (errnum, buf), buf));
>
> with
>
> #elif defined(HAVE_STRERROR_R_2ARGS)
> if (strerror_r (errnum, buf) == OK)
> Âreturn buf;
> return NULL;

Googling some more, it seems the vxworks STATUS is just a typedef for
int, so I guess the original patch works. Also the error checking is
not useful here, so we could do just

#elif defined(HAVE_STRERROR_R_2ARGS)
strerror_r (errnum, buf);
return buf;

-- 
Janne Blomqvist


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