On Friday, March 11, 2011 14:39:43 Stewart Gordon 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?
You end up using ntohl and htonl, I believe. They're in core somewhere. I don't think that you necessarily get 64-bit versions versions, since unfortunately, they're not standard. But perhaps we should add them with implementations (rather than just declarations for C functions) for cases when they don't exist... IIRC, I had to create 64-bit versions for std.datetime and put them in there directly to do what I was doing, but we really should get the 64-bit versions in druntime at some point. - Jonathan M Davis