demexp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Demexp-dev] XDR _int32 attribute


From: David MENTRE
Subject: Re: [Demexp-dev] XDR _int32 attribute
Date: Mon, 26 Sep 2005 11:14:17 +0200

Hello,

2005/9/26, Thomas Petazzoni <address@hidden>:
> So, a simple «int» should be 32-bits signed integer. If ocamlrpcgen
> doesn't do that by default, then I suppose it's broken.

AFAIR, ocamlrpcgen maps by default XDR "int" to opaque 4-bytes type,
that should be manually converted to OCaml native int, int32, etc.

*I* decided to consider XDR "int" as 31-bits OCaml native ints, for
easier programming.

> I don't have the source at hand, but if there are simple «int» in your
> XDR file, then it means that they are limited to 31-bits, which is not
> correct according to the RFC.

In fact, all XDR "int" (except those marked _int32) used in the
current protocol are used as identifiers starting at 0 (or for ranges
of small size). Those identifiers are created on the server, so this
invariant is enforced by the server. So we have some delay before
reaching 1 billion tags or questions (ok, like 640 KB is sufficient
for now ;-).

So we can say that the specification of demexp protocol is a subset of
XDR types, with "int" limited to 31 bits (once again, except for those
marked as _int32). However, I don't know how to specifiy this cleanly,
except as a comment in the XDR file (which I should add). If you have
any suggestion...

If you follow strictly XDR standard and always interpret int as 32
bits, you are always safe.

> Just for the culture, what's the purpose of the remaining bit in native
> OCaml integers ?

The lowest bit is always set to one for an integer, so that integers
(odd numbers) can be easily distinguished from pointers (word aligned,
even numbers) by the garbage collector. A similar trick is used in
other GCs, like the one used in GNU SmallTalk.

> Yep, that's what I did for the moment, but I just wanted to make sure
> that this wasn't going to create an incompatibility while communicating
> with the server.

This should not. However, if you see a way that such a restriction on
integers could trigger an issue, please tell it to us.

Interoperability is only tested when two *different* implementations
can communicate, so your work and detailed review is quite useful and
appreciated.

Yours,
d.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]