perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: Apache::Util::size_string issues
Date Tue, 29 Jan 2002 05:20:07 GMT
Doug MacEachern wrote:

> On Mon, 28 Jan 2002, Stas Bekman wrote:
>  
> 
>>static MP_INLINE
>>SV *mpxs_Apache__Util_size_string(pTHX_ apr_off_t  size)
>>{
>>     char buff[5];
>>
>>     apr_strfsize(size, buff);
>>
>>     return newSVpvn(buff, 4);
>>}
>>
> 
> that'd be fine.  i'd probably use mpxs_set_targ instead, but that can be
> later.


like this?

static MP_INLINE void mpxs_apr_strfsize(pTHX_ SV *sv, SV *arg)
{
    apr_off_t size = mp_xs_sv2_apr_off_t(arg);
    char *ptr;
    
    mpxs_sv_grow(sv, 5);
    apr_strfsize(size, ptr);
    mpxs_sv_cur_set(sv, strlen(ptr)); /*XXX*/
}

static XS(MPXS_apr_strfsize)
{
    dXSARGS;

    mpxs_usage_items_1("size");

    mpxs_set_targ(mpxs_apr_strfsize, ST(0));
}


>>we want it to be perlish, right?
>>
>>there is a problem with apr_off_t since we typedef it as IV, therefore 
>>if you try:
>>
>>  Apache::Util::size_string(42_000_000_000);
>>
>>it looses data when converting from NV or PV to IV. Which means that we 
>>can use this function only up to 1G numbers or so. Doesn't sound good.
>>
>
> normally off_t is the same size as IV, you'd have to compile apache with
> largefile flags to make it bigger.  might be better to change apr_strftime
> to use a type that can always hold a bigger number.


you mean, apr_strfsize, not apr_strftime

OK, will ask.

what about this:

>>Also apr_strfsize is in the APR::Strings module in the map file. Should 
>>we have APR::Strings::strfsize instead of Apache__Util_size_string.
>>





-- 


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message