List Info

Thread: "ocaml_beginners"::[] ia64




"ocaml_beginners"::[] ia64
country flaguser name
France
2008-03-26 16:53:51
Hi,
Is there a macro from <caml/config.h> (or from
stdlib.h) that can be used to 
check if the architecture is a 64 bits or a 32 bits ?
thanks

------------------------------------

Archives up to December 31, 2007 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/

The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    ht
tp://groups.yahoo.com/group/ocaml_beginners/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:ocaml_beginners-digest@yahoogroups.com 
    mailto:ocaml_beginners-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/


"ocaml_beginners"::[] Re: ia64
country flaguser name
United States
2008-03-26 21:32:16

IA64 implies itanium which is irrelevant to your question.
You might test for _LP64 or perhaps _LLP64 but this approach to 64 bit
programming is misguided.
You don't need a macro.
Instead you can write something like this

int myfunc()
{
if(sizeof(void *) == 8)
take_64bit_path();
else if (sizeof(void *) == 4)
take_32_bit_path();
.....
}

An optimizing C compiler will generate code for only the
right branch and eliminated dead code for the other branches.
Similarly, some developers rely on header files (macros) to determine
CPU endianness. This is misguided too.
One could write this static inline function which compilers
like gcc turn into a constant (unfortunately there are certain
older compilers which can't do that (e.g. sun forte)!).

static int endian()
{
int x = 0x12345678;
unsigned char *y = &x;

if(y[0] == 0x12 && y[1] == 0x34 && y[2] == 0x56 && y[3] == 0x78)
return 1; /* big endian */
else if (......)
return 2; /* little endian */
else if (.....)
.... etc.... /* whatever else */
}

--- In ocaml_beginners%40yahoogroups.com">ocaml_beginnersyahoogroups.com, Florent Monnier <fmonnier...>
wrote:
&gt;
> Hi,
> Is there a macro from <caml/config.h>; (or from stdlib.h) that can be
used to
> check if the architecture is a 64 bits or a 32 bits ?
> thanks
&gt;

__._,_.___
.

__,_._,___
Re: "ocaml_beginners"::[] ia64
country flaguser name
United Kingdom
2008-03-27 18:33:02

On Wed, Mar 26, 2008 at 10:53:51PM +0100, Florent Monnier wrote:
&gt; Is there a macro from <caml/config.h>; (or from stdlib.h) that can be used to
> check if the architecture is a 64 bits or a 32 bits ?

What's the actual problem you are having?

Rich.

--
Richard Jones
Red Hat

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )