View mode: basic / threaded / horizontal-split · Log in · Help
March 14, 2011
Re: Read file/stream
On Fri, 11 Mar 2011 22:39:43 -0000, Stewart Gordon <smjg_1998@yahoo.com>  
wrote:

> On 11/03/2011 21:51, Steven Schveighoffer wrote:
> <snip>
>>> Presumably there's a reason that it's been provided for uint but not  
>>> ushort or ulong....
>>
>> I think things in std.intrinsic are functions that tie directly to CPU  
>> features,
>
> True, but...
>
>> so presumably, the CPU only provides the possibility for 4-byte width.
>
> D is designed to run on a variety of CPUs.  Do you really think that  
> they all have a built-in instruction to reverse the order of 4 bytes but  
> no other number?

I have some in the cryptographic hash modules which I am trying to tidy up  
for inclusion into phobos.  They make use of bswap where possible but  
otherwise have to do things the long way.  It would be nice to have some  
in std.intrinsic for 16, and 64 bit entities.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/
March 14, 2011
Re: Read file/stream
On Fri, 11 Mar 2011 17:39:43 -0500, Stewart Gordon <smjg_1998@yahoo.com>  
wrote:

> On 11/03/2011 21:51, Steven Schveighoffer wrote:
> <snip>
>>> Presumably there's a reason that it's been provided for uint but not  
>>> ushort or ulong....
>>
>> I think things in std.intrinsic are functions that tie directly to CPU  
>> features,
>
> True, but...
>
>> so presumably, the CPU only provides the possibility for 4-byte width.
>
> D is designed to run on a variety of CPUs.  Do you really think that  
> they all have a built-in instruction to reverse the order of 4 bytes but  
> no other number?

No, but if the CPU does not support it, the compiler must simulate it for  
that platform.  I don't know the reasoning behind only supporting 4 bytes,  
but I'm sure it has something to do with IP addresses being 4 bytes that  
probably makes CPUs support that specific length more prevalently.

I suspect the decision to create an intrinsic or just a regular function  
is highly subjective (i.e. how many CPUs must support an optimized version  
in order to make it an intrinsic), so you'd have to ask Walter why it's  
not in there.

-Steve
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home