From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p85MBisX022088 for ; Tue, 6 Sep 2011 00:11:44 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvcAAJVIZU4SB0QimWdsb2JhbABCmRiPAhQBAQEBAQgLCwcUJoFGAQEEASdXCwtGV4gMrm+If4ZqBKRX X-IronPort-AV: E=Sophos;i="4.68,335,1312149600"; d="scan'208";a="118461712" Received: from dmz-mailsec-scanner-5.mit.edu ([18.7.68.34]) by mail1-smtp-roc.national.inria.fr with ESMTP; 06 Sep 2011 00:11:39 +0200 X-AuditID: 12074422-b7ba7ae000000a14-22-4e6549148769 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id 32.34.02580.419456E4; Mon, 5 Sep 2011 18:11:32 -0400 (EDT) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id p85MBbHi007233 for ; Mon, 5 Sep 2011 18:11:37 -0400 Received: from localhost (CONTENTS-VNDER-PRESSVRE.MIT.EDU [18.9.64.11]) (authenticated bits=0) (User authenticated as jfc@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id p85MBafp022102 for ; Mon, 5 Sep 2011 18:11:37 -0400 (EDT) Message-Id: <201109052211.p85MBafp022102@outgoing.mit.edu> To: caml-list@inria.fr In-reply-to: <201109051516.p85FGX80005823@outgoing.mit.edu> References: <201109041522.p84FM5DA001371@outgoing.mit.edu> <20110905072553.GA32471@ccellier.rd.securactive.lan> <201109051516.p85FGX80005823@outgoing.mit.edu> Comments: In-reply-to John Carr message dated "Mon, 05 Sep 2011 11:16:33 -0400." X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 23.1.1 Date: Mon, 05 Sep 2011 18:11:36 -0400 From: John Carr X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsUixCmqrCvimepn8PKvlMWnHRtYHBg9Jr04 xBLAGMVlk5Kak1mWWqRvl8CVMbt7OlvBOYGKXTNbmRoYd/F2MXJySAiYSMxtb2eDsMUkLtxb D2RzcQgJ7GOUWHijkRHCOcEoMXH6YyYIZwaTxOKzX8BaeAWsJGbd2cUEYosAtc+af4UFxBYW sJU49GUeWA2ngLXEuZav7BDN8xglutoWsoIkmAWSJBa/P8wMsVtX4uOimewgNouAqkTb9Rlg Q9kEZCUetXcxTmDkW8DIsIpRNiW3Sjc3MTOnODVZtzg5MS8vtUjXVC83s0QvNaV0EyMoQNhd lHYw/jyodIhRgINRiYf34cpkPyHWxLLiytxDjJIcTEqivHPcU/2E+JLyUyozEosz4otKc1KL DzFKcDArifDO+5ziJ8SbklhZlVqUD5OS5mBREufl2ungJySQnliSmp2aWpBaBJOV4eBQkuAN 8gAaKliUmp5akZaZU4KQZuLgBBnOAzT8D8hi3uKCxNzizHSI/ClGRSlx3kiQZgGQREZpHlwv LIJfMYoDvSLMawdSxQOMfrjuV0CDmYAGu1olgQwuSURISTUwSibznzmwaGXk3LfxpXMOJTzr 2hUe9pwnzrg4XFTHs1jNq/Ydy/mDdZ+n8hYtFrwhsbjSsq/xaW+qbbT4tFXZPEfXV8XMt4lQ ung4ilnypVfdxSqW3UflMs54LlzYJWpnaiA4s3XHNnYrcR2JmJy7CzPcPc33urrvMXfaK3R4 poxJwO8PScFKLMUZiYZazEXFiQBLFISWuwIAAA== Subject: Re: [Caml-list] Conditionally boxed 32 bit integers? 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;;