On 7/22/11 10:47 AM, Jonathan M Davis wrote:
On Wednesday 13 July 2011 23:37:02 Andrew Wiley wrote:
Hey, does anyone else thing a function like this belongs in Phobos, and if
so, where do you think it should go?
T ntoh(T)(T val) if (__traits(isArithmetic, T)) {
version(BigEndian) {
return val
On Wednesday 13 July 2011 23:37:02 Andrew Wiley wrote:
> Hey, does anyone else thing a function like this belongs in Phobos, and if
> so, where do you think it should go?
>
> T ntoh(T)(T val) if (__traits(isArithmetic, T)) {
> version(BigEndian) {
> return val;
> }
> else version (LittleEndian) {
On Sat, 16 Jul 2011 17:51:50 -0400, Jonathan M Davis
wrote:
I think that the problem is a combination of NaN and real. If I change
the
first three tests (which all test using init) to use is, then all of the
tests
pass until real is tested with T.max, and it's doesn't survive being
swap
On 7/17/11 4:27 AM, Timon Gehr wrote:
Imposing meaning to bytes is the only point for data types to exist whatsoever.
How do you distinguish between an integer and a network byte order integer at
function boundaries?
Good point. Then probably the functions swapping bytes away from native
shoul
Christian Manning wrote:
> How about this?:
>
> private template Eqsize(T) {
> static if (T.sizeof == 4) {
> alias uint S;
> }
> else static if (T.sizeof == 8) {
> alias ulong S;
> }
> }
>
> private union IntFloat {
> uint _int;
> float _float;
> }
>
> pr
How about this?:
private template Eqsize(T) {
static if (T.sizeof == 4) {
alias uint S;
}
else static if (T.sizeof == 8) {
alias ulong S;
}
}
private union IntFloat {
uint _int;
float _float;
}
private union IntDouble {
ulong _long;
double _double;
Jonathan M Davis wrote:
private T swapEndianImpl(T)(T val)
if(is(Unqual!T == ulong))
{
return ((val& 0xff00UL)>> 56) |
((val& 0x00ffUL)>> 40) |
((val& 0xff00UL)>> 24) |
((val& 0x00ffUL)>> 8) |
Jonathan M Davis wrote:
> On Sunday 17 July 2011 09:40:06 Alix Pexton wrote:
>> On 17/07/2011 07:42, Jonathan M Davis wrote:
>> > On Saturday 16 July 2011 23:31:09 Andrew Wiley wrote:
>> [snip]
>>
>> >> Take a look at http://www.dmh2000.com/cpp/dswap.shtml . It made the
>> >> odd
>> >> behavior mak
On Sunday 17 July 2011 01:48:37 Jonathan M Davis wrote:
> On Sunday 17 July 2011 09:40:06 Alix Pexton wrote:
> > On 17/07/2011 07:42, Jonathan M Davis wrote:
> > > On Saturday 16 July 2011 23:31:09 Andrew Wiley wrote:
> > [snip]
> >
> > >> Take a look at http://www.dmh2000.com/cpp/dswap.shtml . It
On Sunday 17 July 2011 09:40:06 Alix Pexton wrote:
> On 17/07/2011 07:42, Jonathan M Davis wrote:
> > On Saturday 16 July 2011 23:31:09 Andrew Wiley wrote:
> [snip]
>
> >> Take a look at http://www.dmh2000.com/cpp/dswap.shtml . It made the
> >> odd
> >> behavior make a lot more sense to me.
> >
>
On 17/07/2011 07:42, Jonathan M Davis wrote:
On Saturday 16 July 2011 23:31:09 Andrew Wiley wrote:
[snip]
Take a look at http://www.dmh2000.com/cpp/dswap.shtml . It made the odd
behavior make a lot more sense to me.
Okay. Good to know. In other words, we can't have swapEndian work with floati
On Sunday 17 July 2011 16:09:13 KennyTM~ wrote:
> On Jul 17, 11 15:44, Jonathan M Davis wrote:
> > On Sunday 17 July 2011 15:31:36 KennyTM~ wrote:
> >> On Jul 17, 11 05:51, Jonathan M Davis wrote:
> >>> On Saturday 16 July 2011 15:38:29 Andrei Alexandrescu wrote:
> Just paste the code here.
>
On Jul 17, 11 15:44, Jonathan M Davis wrote:
On Sunday 17 July 2011 15:31:36 KennyTM~ wrote:
On Jul 17, 11 05:51, Jonathan M Davis wrote:
On Saturday 16 July 2011 15:38:29 Andrei Alexandrescu wrote:
Just paste the code here.
This is what I have at the moment:
import core.bitop;
[snip]
p
On Sunday 17 July 2011 15:31:36 KennyTM~ wrote:
> On Jul 17, 11 05:51, Jonathan M Davis wrote:
> > On Saturday 16 July 2011 15:38:29 Andrei Alexandrescu wrote:
> >> Just paste the code here.
> >
> > This is what I have at the moment:
> >
> > import core.bitop;
>
> [snip]
>
> > private T swapEnd
On Jul 17, 11 05:51, Jonathan M Davis wrote:
On Saturday 16 July 2011 15:38:29 Andrei Alexandrescu wrote:
Just paste the code here.
This is what I have at the moment:
import core.bitop;
[snip]
private T swapEndianImpl(T)(T val)
if(is(Unqual!T == ulong))
{
return ((val& 0xff
On Saturday 16 July 2011 23:31:09 Andrew Wiley wrote:
> On Sat, Jul 16, 2011 at 2:51 PM, Jonathan M Davis
wrote:
> > On Saturday 16 July 2011 15:38:29 Andrei Alexandrescu wrote:
> > > Just paste the code here.
> >
> > This is what I have at the moment:
> >
> > import core.bitop;
> >
> > /++
> >
On Sat, Jul 16, 2011 at 2:51 PM, Jonathan M Davis wrote:
> On Saturday 16 July 2011 15:38:29 Andrei Alexandrescu wrote:
> > Just paste the code here.
>
> This is what I have at the moment:
>
> import core.bitop;
>
> /++
>Swaps the endianness of the given value. Any integral value,
>charact
On Saturday 16 July 2011 15:38:29 Andrei Alexandrescu wrote:
> Just paste the code here.
This is what I have at the moment:
import core.bitop;
/++
Swaps the endianness of the given value. Any integral value,
character, or floating point value is accepted.
+/
T swapEndian(T)(T val)
On 7/16/11 3:39 AM, Jonathan M Davis wrote:
On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
On 7/14/11 5:51 AM, Regan Heath wrote:
That's my point. I need 8/16/32/64/128 bit versions and it really would
be better if there were general variants. My version are less than
optimal, but
Andrew Wiley wrote:
> On Sat, Jul 16, 2011 at 6:21 AM, Christian Manning
> wrote:
>
>> Jonathan M Davis wrote:
>>
>> > On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
>> >> On 7/14/11 5:51 AM, Regan Heath wrote:
>> >> > That's my point. I need 8/16/32/64/128 bit versions and it reall
Andrew Wiley wrote:
> On Sat, Jul 16, 2011 at 6:21 AM, Christian Manning
> wrote:
>
>> Jonathan M Davis wrote:
>>
>> > On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
>> >> On 7/14/11 5:51 AM, Regan Heath wrote:
>> >> > That's my point. I need 8/16/32/64/128 bit versions and it reall
On Sat, Jul 16, 2011 at 6:21 AM, Christian Manning wrote:
> Jonathan M Davis wrote:
>
> > On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
> >> On 7/14/11 5:51 AM, Regan Heath wrote:
> >> > That's my point. I need 8/16/32/64/128 bit versions and it really
> would
> >> > be better if th
Jonathan M Davis wrote:
> On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
>> On 7/14/11 5:51 AM, Regan Heath wrote:
>> > That's my point. I need 8/16/32/64/128 bit versions and it really would
>> > be better if there were general variants. My version are less than
>> > optimal, but do
On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
> On 7/14/11 5:51 AM, Regan Heath wrote:
> > That's my point. I need 8/16/32/64/128 bit versions and it really would
> > be better if there were general variants. My version are less than
> > optimal, but do use intrinsics where possible.
Christian Manning wrote:
> Jonathan M Davis wrote:
>
>> On 2011-07-15 14:23, Christian Manning wrote:
>>> Andrei Alexandrescu wrote:
>>> > On 7/14/11 5:51 AM, Regan Heath wrote:
>>> >> That's my point. I need 8/16/32/64/128 bit versions and it really
>>> >> would be better if there were general v
Jonathan M Davis wrote:
> On 2011-07-15 14:23, Christian Manning wrote:
>> Andrei Alexandrescu wrote:
>> > On 7/14/11 5:51 AM, Regan Heath wrote:
>> >> That's my point. I need 8/16/32/64/128 bit versions and it really
>> >> would be better if there were general variants. My version are less
>> >>
On 7/15/11 4:23 PM, Christian Manning wrote:
Andrei Alexandrescu wrote:
On 7/14/11 5:51 AM, Regan Heath wrote:
That's my point. I need 8/16/32/64/128 bit versions and it really would
be better if there were general variants. My version are less than
optimal, but do use intrinsics where possibl
On 2011-07-15 14:23, Christian Manning wrote:
> Andrei Alexandrescu wrote:
> > On 7/14/11 5:51 AM, Regan Heath wrote:
> >> That's my point. I need 8/16/32/64/128 bit versions and it really would
> >> be better if there were general variants. My version are less than
> >> optimal, but do use intrins
Andrei Alexandrescu wrote:
> On 7/14/11 5:51 AM, Regan Heath wrote:
>> That's my point. I need 8/16/32/64/128 bit versions and it really would
>> be better if there were general variants. My version are less than
>> optimal, but do use intrinsics where possible. Someone else can do a far
>> better
On Thu, Jul 14, 2011 at 10:45 AM, Jonathan M Davis wrote:
> On 2011-07-14 10:26, Andrew Wiley wrote:
> > On Thu, Jul 14, 2011 at 9:02 AM, Jonathan M Davis
> wrote:
> > > On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
> > > > On 7/14/11 5:51 AM, Regan Heath wrote:
> > > > > That's my
On 2011-07-14 10:26, Andrew Wiley wrote:
> On Thu, Jul 14, 2011 at 9:02 AM, Jonathan M Davis
wrote:
> > On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
> > > On 7/14/11 5:51 AM, Regan Heath wrote:
> > > > That's my point. I need 8/16/32/64/128 bit versions and it really
> > > > would
On Thu, Jul 14, 2011 at 9:02 AM, Jonathan M Davis wrote:
> On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
> > On 7/14/11 5:51 AM, Regan Heath wrote:
> > > That's my point. I need 8/16/32/64/128 bit versions and it really would
> > > be better if there were general variants. My versio
On Thursday 14 July 2011 09:02:12 Jonathan M Davis wrote:
> On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
> > On 7/14/11 5:51 AM, Regan Heath wrote:
> > > That's my point. I need 8/16/32/64/128 bit versions and it really
> > > would
> > > be better if there were general variants. My
On Thursday 14 July 2011 06:27:47 Andrei Alexandrescu wrote:
> On 7/14/11 5:51 AM, Regan Heath wrote:
> > That's my point. I need 8/16/32/64/128 bit versions and it really would
> > be better if there were general variants. My version are less than
> > optimal, but do use intrinsics where possible.
On Thu, 14 Jul 2011 12:27:47 +0100, Andrei Alexandrescu
wrote:
On 7/14/11 5:51 AM, Regan Heath wrote:
That's my point. I need 8/16/32/64/128 bit versions and it really would
be better if there were general variants. My version are less than
optimal, but do use intrinsics where possible. Some
On Thu, 14 Jul 2011 14:20:24 +0100, Piotr Szturmaj
wrote:
I implemented all of those except for Whirlpool. I still have the
originals, which I started to tidy for inclusion into phobos .. at least
that was the plan, I don't have a lot of spare time for this soft of
thing unfortunately.
I w
Regan Heath wrote:
On Thu, 14 Jul 2011 11:44:23 +0100, Piotr Szturmaj
wrote:
Regan Heath wrote:
On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
wrote:
I did have to create a 64-bit version for std.datetime, so it has a
private
function called endianSwap64 to do the job. So, it's not li
Steven Schveighoffer wrote:
On Thu, 14 Jul 2011 06:12:00 -0400, Piotr Szturmaj
wrote:
Btw. How compiler intrinsics work? I see there's only bswap
declaration (without body) in core.bitop. Where can I find compiler
code which actually substitutes bswap() into real instructions?
A complier in
On 7/14/11 5:51 AM, Regan Heath wrote:
That's my point. I need 8/16/32/64/128 bit versions and it really would
be better if there were general variants. My version are less than
optimal, but do use intrinsics where possible. Someone else can do a far
better job than I, and it really should be don
On Thu, 14 Jul 2011 06:12:00 -0400, Piotr Szturmaj
wrote:
Btw. How compiler intrinsics work? I see there's only bswap declaration
(without body) in core.bitop. Where can I find compiler code which
actually substitutes bswap() into real instructions?
A complier intrinsic is a special fun
On Thu, 14 Jul 2011 06:16:37 -0400, David Nadlinger
wrote:
On 7/14/11 12:05 PM, Jonathan M Davis wrote:
On Thursday 14 July 2011 10:55:49 Regan Heath wrote:
On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M
Davis
wrote:
I did have to create a 64-bit version for std.datetime, so it has a
pr
On Thu, 14 Jul 2011 11:44:23 +0100, Piotr Szturmaj
wrote:
Regan Heath wrote:
On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
wrote:
I did have to create a 64-bit version for std.datetime, so it has a
private
function called endianSwap64 to do the job. So, it's not like I'm
saying that
On Thursday 14 July 2011 11:51:14 Regan Heath wrote:
> On Thu, 14 Jul 2011 11:05:07 +0100, Jonathan M Davis
>
> wrote:
> > On Thursday 14 July 2011 10:55:49 Regan Heath wrote:
> >> On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
> >>
> >>
> >> wrote:
> >> > On Thursday 14 July 2011 00:03:2
On Thu, 14 Jul 2011 11:05:07 +0100, Jonathan M Davis
wrote:
On Thursday 14 July 2011 10:55:49 Regan Heath wrote:
On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
wrote:
> On Thursday 14 July 2011 00:03:23 Andrew Wiley wrote:
>> On Wed, Jul 13, 2011 at 11:59 PM, Jonathan M Davis
>
> w
Regan Heath wrote:
On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
wrote:
I did have to create a 64-bit version for std.datetime, so it has a
private
function called endianSwap64 to do the job. So, it's not like I'm
saying that
the situation couldn't be improved, but druntime and Phobos do
On 7/14/11 12:05 PM, Jonathan M Davis wrote:
On Thursday 14 July 2011 10:55:49 Regan Heath wrote:
On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
wrote:
I did have to create a 64-bit version for std.datetime, so it has a
private
function called endianSwap64 to do the job. So, it's not lik
On 7/14/11 12:12 PM, Piotr Szturmaj wrote:
Yesterday, I had to write my own bswap for ulong because intrinsic
version supports only uints. Is there any implementation obstacle
preventing ulong and ushort bswap in core.bitop?
Btw. How compiler intrinsics work? I see there's only bswap declaration
Jonathan M Davis wrote:
I did have to create a 64-bit version for std.datetime, so it has a private
function called endianSwap64 to do the job. So, it's not like I'm saying that
the situation couldn't be improved, but druntime and Phobos do currently give
you the exact same thing that C and C++ d
On Thursday 14 July 2011 10:55:49 Regan Heath wrote:
> On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
>
> wrote:
> > On Thursday 14 July 2011 00:03:23 Andrew Wiley wrote:
> >> On Wed, Jul 13, 2011 at 11:59 PM, Jonathan M Davis
> >
> > wrote:
> >> > On Wednesday 13 July 2011 23:37:02 Andrew
On Thu, 14 Jul 2011 08:14:10 +0100, Jonathan M Davis
wrote:
On Thursday 14 July 2011 00:03:23 Andrew Wiley wrote:
On Wed, Jul 13, 2011 at 11:59 PM, Jonathan M Davis
wrote:
> On Wednesday 13 July 2011 23:37:02 Andrew Wiley wrote:
> > Hey, does anyone else thing a function like this belongs
Andrew Wiley wrote:
>Hey, does anyone else thing a function like this belongs in Phobos,
>and if so, where do you think it should go?
>
>T ntoh(T)(T val) if (__traits(isArithmetic, T)) {
>version(BigEndian) {
> return val;
>}
>else version (LittleEndian) {
> ubyte[] arr = (cast(ubyte*)&val)[0 .. T.
On Thursday 14 July 2011 00:03:23 Andrew Wiley wrote:
> On Wed, Jul 13, 2011 at 11:59 PM, Jonathan M Davis
wrote:
> > On Wednesday 13 July 2011 23:37:02 Andrew Wiley wrote:
> > > Hey, does anyone else thing a function like this belongs in Phobos,
> > > and
> >
> > if
> >
> > > so, where do you t
On Thu, Jul 14, 2011 at 12:03 AM, Andrew Wiley wrote:
> On Wed, Jul 13, 2011 at 11:59 PM, Jonathan M Davis wrote:
>
>> On Wednesday 13 July 2011 23:37:02 Andrew Wiley wrote:
>> > Hey, does anyone else thing a function like this belongs in Phobos, and
>> if
>> > so, where do you think it should go?
On Wed, Jul 13, 2011 at 11:59 PM, Jonathan M Davis wrote:
> On Wednesday 13 July 2011 23:37:02 Andrew Wiley wrote:
> > Hey, does anyone else thing a function like this belongs in Phobos, and
> if
> > so, where do you think it should go?
> >
> > T ntoh(T)(T val) if (__traits(isArithmetic, T)) {
> >
On Wednesday 13 July 2011 23:37:02 Andrew Wiley wrote:
> Hey, does anyone else thing a function like this belongs in Phobos, and if
> so, where do you think it should go?
>
> T ntoh(T)(T val) if (__traits(isArithmetic, T)) {
> version(BigEndian) {
> return val;
> }
> else version (LittleEndian) {
Hey, does anyone else thing a function like this belongs in Phobos, and if
so, where do you think it should go?
T ntoh(T)(T val) if (__traits(isArithmetic, T)) {
version(BigEndian) {
return val;
}
else version (LittleEndian) {
ubyte[] arr = (cast(ubyte*)&val)[0 .. T.sizeof];
ubyte temp;
for(int
56 matches
Mail list logo