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: Thomas Petazzoni
Subject: Re: [Demexp-dev] XDR _int32 attribute
Date: Mon, 26 Sep 2005 10:43:26 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050322)

Hi,

David MENTRE wrote:

> Yes, it is specific to ocamlrpcgen. It is used to tell the compiler to
> map the specified RPC int into an OCaml Int32. By default, I map all
> int to native 31-bits OCaml integers.

According to RFC 1014, section 3.1:

==
3.1 Integer

   An XDR signed integer is a 32-bit datum that encodes an integer in
   the range [-2147483648,2147483647].  The integer is represented in
   two's complement notation.  The most and least significant bytes are
   0 and 3, respectively.  Integers are declared as follows:

         int identifier;

           (MSB)                   (LSB)
         +-------+-------+-------+-------+
         |byte 0 |byte 1 |byte 2 |byte 3 |                      INTEGER
         +-------+-------+-------+-------+
         <------------32 bits------------>
==

So, a simple «int» should be 32-bits signed integer. If ocamlrpcgen
doesn't do that by default, then I suppose it's broken.

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.

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

> I suppose you implementation maps int to int32 so you can safely
> ignore it with something like:
> #define _int32 /* nothing */

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.

Thanks,

Thomas
-- 
Thomas Petazzoni
address@hidden





reply via email to

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