caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr>
To: John Carr <jfc@mit.edu>, caml-list@inria.fr
Subject: Re: [Caml-list] Conditionally boxed 32 bit integers?
Date: Tue, 06 Sep 2011 09:50:48 +0200	[thread overview]
Message-ID: <4E65D0D8.10304@inria.fr> (raw)
In-Reply-To: <201109052211.p85MBafp022102@outgoing.mit.edu>

[-- Attachment #1: Type: text/plain, Size: 2583 bytes --]

I think the (old) reason of the way Sys.word_size is implemented is that
the same code can run both on 32 bits and 64 bits, when compiled to
bytecode. But of course, I see no reason why such a primitive could not
be added, with different compilation schemes for asm (it would be hard
coded) and bytecode (it would continue to call the runtime function).

Fabrice


On 09/06/2011 12:11 AM, John Carr wrote:
> I found a simpler way to make Sys.word_size be a compile time constant.
> See patch at end.  Technically this is preprocessing, which I wanted to
> avoid, but it's not preprocessing in my code.
> 
>> INRIA developers, is it easy to add an intrinsic so we can write
>>
>> 	extern word_size : int = "%caml_word_size"
>>
>> in sys.ml?  If sys.cmx has a constant definition, ocamlopt should do
>> constant folding on conditional expressions testing Sys.word_size.
> 
> 
> diff -rc /tmp/ocaml-3.12.1/stdlib/Makefile.shared ./stdlib/Makefile.shared
> *** /tmp/ocaml-3.12.1/stdlib/Makefile.shared	Fri May 21 07:28:21 2010
> --- ./stdlib/Makefile.shared	Mon Sep  5 17:39:14 2011
> ***************
> *** 49,56 ****
>   stdlib.cmxa: $(OBJS:.cmo=.cmx)
>   	$(CAMLOPT) -a -o stdlib.cmxa $(OBJS:.cmo=.cmx)
>   
> ! sys.ml: sys.mlp ../VERSION
> ! 	sed -e "s|%%VERSION%%|`sed -e 1q ../VERSION`|" sys.mlp >sys.ml
>   
>   clean::
>   	rm -f sys.ml
> --- 49,57 ----
>   stdlib.cmxa: $(OBJS:.cmo=.cmx)
>   	$(CAMLOPT) -a -o stdlib.cmxa $(OBJS:.cmo=.cmx)
>   
> ! sys.ml: sys.mlp ../VERSION ../config/m.h
> ! 	ws=`sed -n -e 's/^#define ARCH_SIXTYFOUR/64/p' -e 's/^#undef ARCH_SIXTYFOUR/32/p' ../config/m.h`; \
> ! 	sed -e "s|%%VERSION%%|`sed -e 1q ../VERSION`|" -e "s|%%WORD_SIZE%%|$$ws|" sys.mlp >sys.ml
>   
>   clean::
>   	rm -f sys.ml
> diff -rc /tmp/ocaml-3.12.1/stdlib/sys.mlp ./stdlib/sys.mlp
> *** /tmp/ocaml-3.12.1/stdlib/sys.mlp	Mon Feb 26 09:21:57 2007
> --- ./stdlib/sys.mlp	Mon Sep  5 17:35:33 2011
> ***************
> *** 23,29 ****
>   external get_argv: unit -> string * string array = "caml_sys_get_argv"
>   
>   let (executable_name, argv) = get_argv()
> ! let (os_type, word_size) = get_config()
>   let max_array_length = (1 lsl (word_size - 10)) - 1;;
>   let max_string_length = word_size / 8 * max_array_length - 1;;
>   
> --- 23,30 ----
>   external get_argv: unit -> string * string array = "caml_sys_get_argv"
>   
>   let (executable_name, argv) = get_argv()
> ! let (os_type, _) = get_config()
> ! let word_size = %%WORD_SIZE%%;;
>   let max_array_length = (1 lsl (word_size - 10)) - 1;;
>   let max_string_length = word_size / 8 * max_array_length - 1;;
>   
> 

[-- Attachment #2: fabrice_le_fessant.vcf --]
[-- Type: text/x-vcard, Size: 380 bytes --]

begin:vcard
fn:Fabrice LE FESSANT
n:LE FESSANT;Fabrice
org:INRIA Saclay -- Ile-de-France;P2P & OCaml
adr;quoted-printable:;;Parc Orsay Universit=C3=A9 ;Orsay CEDEX;;91893;France
email;internet:fabrice.le_fessant@inria.fr
title;quoted-printable:Charg=C3=A9 de Recherche
tel;work:+33 1 74 85 42 14
tel;fax:+33 1 74 85 42 49 
url:http://fabrice.lefessant.net/
version:2.1
end:vcard


  reply	other threads:[~2011-09-06  7:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-04 15:22 John Carr
2011-09-04 17:28 ` Hezekiah M. Carty
2011-09-04 20:58 ` Richard W.M. Jones
2011-09-05  7:25 ` rixed
2011-09-05 15:16   ` John Carr
2011-09-05 22:11     ` John Carr
2011-09-06  7:50       ` Fabrice Le Fessant [this message]
2011-09-05  9:50 ` Gerd Stolpmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E65D0D8.10304@inria.fr \
    --to=fabrice.le_fessant@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=jfc@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).