From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p867olU4013627 for ; Tue, 6 Sep 2011 09:50:52 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnsDAAXQZU5KfVI0imdsb2JhbABCDoRBmDKLGAgUAQEBCgkNBxIGIoFGAQEBAQMSAg8EGQE5AwwBBQUOCgkhAgIPAiMBBQEcBgEMCAEBHodTmykKi32DFoRtiSgCAwaFU4ERBI4khQqFD4Eohi88gUeBbDo X-IronPort-AV: E=Sophos;i="4.68,337,1312149600"; d="vcf'?scan'208";a="107840816" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-MD5; 06 Sep 2011 09:50:52 +0200 Received: by mail-ww0-f52.google.com with SMTP id 6so6969525wwe.9 for ; Tue, 06 Sep 2011 00:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:x-enigmail-version:content-type; bh=a6470Cr3FZmXzN9IIZmbeVPXuTZlS1Kxz6eNt4a30Cg=; b=JIRBRWeYYHvKnKtba89oLn2PUgidf7xnkm6Eof9344Khk+4dAQSu/v7EvBXCp+ervA oTQXaKszUjlr7SBuLFGE5B6KE/wF9qEhgFbeVMmDYsSmJYHX+YdiO4YgZfdzaAszKn9R vI58GXL1NCejxySLWmC8bciac9Omn+nO8NV+A= Received: by 10.227.72.200 with SMTP id n8mr809370wbj.19.1315295452438; Tue, 06 Sep 2011 00:50:52 -0700 (PDT) Received: from [193.55.250.205] (chercheurs2-205.saclay.inria.fr [193.55.250.205]) by mx.google.com with ESMTPS id z18sm10748418wbm.22.2011.09.06.00.50.49 (version=SSLv3 cipher=OTHER); Tue, 06 Sep 2011 00:50:49 -0700 (PDT) Sender: Fabrice Le Fessant Message-ID: <4E65D0D8.10304@inria.fr> Date: Tue, 06 Sep 2011 09:50:48 +0200 From: Fabrice Le Fessant User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: John Carr , caml-list@inria.fr References: <201109041522.p84FM5DA001371@outgoing.mit.edu> <20110905072553.GA32471@ccellier.rd.securactive.lan> <201109051516.p85FGX80005823@outgoing.mit.edu> <201109052211.p85MBafp022102@outgoing.mit.edu> In-Reply-To: <201109052211.p85MBafp022102@outgoing.mit.edu> X-Enigmail-Version: 1.1.2 Content-Type: multipart/mixed; boundary="------------060805070106090705040905" X-Validation-by: fabrice.le_fessant@inria.fr Subject: Re: [Caml-list] Conditionally boxed 32 bit integers? This is a multi-part message in MIME format. --------------060805070106090705040905 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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;; > > --------------060805070106090705040905 Content-Type: text/x-vcard; charset=utf-8; name="fabrice_le_fessant.vcf" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fabrice_le_fessant.vcf" 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 --------------060805070106090705040905--