64 bit types and C libraries

Daniel Keep daniel.keep.lists at gmail.com
Tue May 22 08:10:44 PDT 2007


torhu wrote:
> How's the BIGNUM struct defined?

As far as I can tell, the OpenSSL docs don't specify; they state that
BIGNUM should be treated as an opaque type, and that you must never
attempt to directly access its members.

That practically screams of "BIGNUM's implementation is
platform-dependant" :P

Mandel wrote:
> I think you can go with long/ulong. Since the size is fixed for D, the
> compiler does the job emulating a 64 integer on systems where int is
> smaller 32bits.

It doesn't matter what D is capable of; if OpenSSL has been compiled in
32-bit mode, then it's using BIGNUM internally.  If you try passing it a
long, then you can very well end up with serious errors (see below).

Sean Kelly wrote:
> It sounds like PQ_64BIT is intended to always be 64 bits in length, so
> it's probably safe to just use a long.
>
> Sean

Actually, PQ_64BIT can be aliased to BIGNUM which can be an *arbitrary*
number of bits; it's a dynamically allocated structure.

However, if his version is compiled with 64-bit integer support, and he
doesn't mind not supporting BIGNUM versions, he could just stick to
ulong.  Maybe just stub out the other side of the version path with some
static assert(false)'s. :)

Ok; bed time.

	-- Daniel

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/


More information about the Digitalmars-d-learn mailing list