caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: John Carr <jfc@mit.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Conditionally boxed 32 bit integers?
Date: Mon, 05 Sep 2011 18:11:36 -0400	[thread overview]
Message-ID: <201109052211.p85MBafp022102@outgoing.mit.edu> (raw)
In-Reply-To: <201109051516.p85FGX80005823@outgoing.mit.edu>


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;;
  

  reply	other threads:[~2011-09-05 22:11 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 [this message]
2011-09-06  7:50       ` Fabrice Le Fessant
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=201109052211.p85MBafp022102@outgoing.mit.edu \
    --to=jfc@mit.edu \
    --cc=caml-list@inria.fr \
    /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).