On Wed, Mar 31, 2010 at 10:08 AM, Dave Shield <[email protected]>wrote:

> On 31 March 2010 08:25, Bart Van Assche <[email protected]> wrote:
> >> MF> #ifndef INT32_MAX
> >> MF> #define INT32_MAX 0x7fffffff
> >> MF> #endif
>
> > It seems like some context information got lost in this discussion. The
> > constant in 0x7fffffff in the source file agent/mibgroup/ucd-snmp/disk.c
> > ... [refers] to the largest value
> > representable by the SNMPv2-SMI type Integer32
>
> > This also means that the above #ifndef / #endif construct is not correct:
> it
> > will cause the code in agent/mibgroup/ucd-snmp/disk.c not to limit
> long_ret
> > to the range 0 .. 0x7fffffff on systems where sizeof(int) == 8.
>
> Are you sure?
>
> Checking the one 64-bit system I have access to, the system defines
> in <stdint.h> include the following
>
> # define INT32_MAX              (2147483647)
> # define INT64_MAX              (__INT64_C(9223372036854775807))
> # define UINT32_MAX             (4294967295U)
> # define UINT64_MAX             (__UINT64_C(18446744073709551615))
>
> These are in decimal, rather than hex, but the two 32-bit constants
> equate to 0x7FFFFFFF and 0xFFFFFFFF  respectively.
> So the masking would be the same, regardless of whether the
> constant comes from the system header file, or a local definition.
>
> Are you aware of a system where {U,}INT32_MAX have different
> values to this?
>

On most 64-bit systems sizeof(int) == 4 and on some others sizeof(int) == 8.
All (seldom) systems using the ILP64 programming model have sizeof(int) ==
8. See also table one in John R. Mashey, *The Long Road to 64 Bits*, ACM
Queue, October 10, 2006 (http://queue.acm.org/detail.cfm?id=1165766).

And please note that gcc flags may affect the size of ints -- at least gcc
3.x has a flag -mint64 on MIPS that make ints 64 bits wide instead of 32
bits.

Bart.
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to