[cfe-dev] [libcxx] random_device for Windows needs more storage

Yaron Keren yaron.keren at gmail.com
Mon Oct 7 13:20:12 PDT 2013


The actual data type is typedef ULONG_PTR HCRYPTPROV;
I found two conflicting descriptions in microsoft.com for ULONG_PTR:

The first
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
says
it's always 64 bits:


#if defined(_WIN64)
 typedef unsigned __int64 ULONG_PTR;
#else
 typedef unsigned long ULONG_PTR;
#endif

The second http://msdn.microsoft.com/en-us/library/cc230394.aspx says it's
essentially int, 32 bit or 64 bit.

Looking in the MingW header file basestd.h, ULONG_PTR is defined to either
__int64 in WIN64 or long in WIN32, so it is always 64 bit.

uintptr_t will be 32 bits in WIN32.

The ideal would be to use the correct typdef HCRYPTPROV but this would
require exposing it in random header which is probably wrong. So my
question is if private member __f_ must be an int or is it an
implementation detail and a uint64_t will be OK.

Yaron


2013/10/7 Richard <legalize at xmission.com>

>
> In article <
> CANa4zJo+YND+HH3vz1Y-JymaLCjR2-QJkdLgFCWW27AYbP0YyA at mail.gmail.com>,
>     Yaron Keren <yaron.keren at gmail.com> writes:
>
> > Is it OK to modify the private member __f_ type from int to uint64_t?
>
> Wouldn't intptr_t or uintptr_t be more appropriate?
>
> "Handles" in Windows are more likely to be pointers masquerading as an
> integer for opacity purposes.
> --
> "The Direct3D Graphics Pipeline" free book <
> http://tinyurl.com/d3d-pipeline>
>      The Computer Graphics Museum <http://computergraphicsmuseum.org>
>          The Terminals Wiki <http://terminals.classiccmp.org>
>   Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131007/0b0b67af/attachment.html>


More information about the cfe-dev mailing list