develooper Front page | perl.perl5.porters | Postings from February 2018

Re: Windows doesn't recognize ssize_t XS typemap

Thread Previous
From:
Karl Williamson
Date:
February 9, 2018 17:21
Subject:
Re: Windows doesn't recognize ssize_t XS typemap
Message ID:
2dc2709f-56de-43eb-46d8-542494c564c4@khwilliamson.com
On 02/09/2018 09:27 AM, Dagfinn Ilmari Mannsåker wrote:
> Karl Williamson <public@khwilliamson.com> writes:
> 
>> On 02/09/2018 07:22 AM, Dagfinn Ilmari Mannsåker wrote:
>>> ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes:
>>>
>>> On the other hand, I don't understand the reasoning behind making the
>>> parameter in XS::APITest::test_utf8_to_bytes() signed.  utf8_to_bytes()
>>> takes a STRLEN*, so the ssize_t (or SSize_t) parameter causes a compiler
>>> warning.  The commit message that made the change just says «For testing
>>> purposes, this parameter should be signed when it comes from perl
>>> space».
>>
>> Sorry about that. I will add comments to the file.
>>
>> This showed up as a problem on testing a 64-bit machine with a 32-bit
>> ptr size.
> 
> The "bitness" of a machine is usually taken to mean the pointer size. I
> presume you mean a 32bit machine with perl configured to use 64bit
> integers?
> 
>> utf8_to_bytes is passed a STRLEN*.  When it finds an error in the
>> operation it returns -1 cast to STRLEN.  In the test file, because of
>> the disparity between the sizes that got returned to perl space as
>> 0xFFFFFFFF instead of -1.
>>
>> If there's a better way to handle this, I'm all ears
> 
> If the function uses -1 to signal errors, the parameter should be of a
> signed type.
> 
> BTW, as mentioned on IRC, the pointee signedness mismatch is fatal under
> C++.
> 
> - ilmari
> 


Here's a better explanation and patch, concluded from irc discussion

commit e0280e4921cf0b53edc3e4790ff6f201046adcbc
  Author: Karl Williamson <khw@cpan.org>
  Date:   Fri Feb 9 10:10:47 2018 -0700

      APItest: Fix C++ compiles

      0a9f8f95112ff40e13406b3e5aab49c01487f045 introduced failures on C++
      compilations.  This is a better patch, suggested by ilmari.

      The issue was in cases where the pointer size is 32 bits and the word
      size was 64, a (STRLEN) -1 returned as an error was getting turned 
into
      0xFFFFFFFF instead of -1.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About