caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] NULL as a caml value
@ 2002-05-12 20:45 Lauri Alanko
  2002-05-13  7:20 ` Jacques Garrigue
  0 siblings, 1 reply; 6+ messages in thread
From: Lauri Alanko @ 2002-05-12 20:45 UTC (permalink / raw)
  To: caml-list

Hello.

The docs weren't very clear on this, so I just wanted to check: is
(value)NULL a legal caml value? Checking from the sources, it seems that the
GC does leave alone all pointers that don't point to within the caml-managed
heap. However, the docs state that only "memory allocated by malloc" can be
turned directly into an abstract caml value. So may I rely on NULL working?
It would ease dealing with many C interfaces.


Lauri Alanko
la@iki.fi
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [Caml-list] NULL as a caml value
@ 2002-05-13 14:56 Damien Doligez
  0 siblings, 0 replies; 6+ messages in thread
From: Damien Doligez @ 2002-05-13 14:56 UTC (permalink / raw)
  To: cq, garrigue; +Cc: caml-list

>From: Christopher Quinn <cq@htec.demon.co.uk>
>> Does it even need to be word aligned?
>> If Is_long() tests positive the 'pointer' is also ignored.
>> I hope I have not erred!?

There are three cases to consider:

A. word-aligned
B. odd
C. equal to 2 modulo 4

>From: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
>Otherwise, looking at the runtime's source, I see nothing that would
>prevent from using any (even non-aligned) pointer outside of the caml
>heaps to be cast to a value, but the manual does not allow it
>explicitly, so this may mean that such non-aligned even values could
>be used for something else. (Actually they are already used for
>compaction.)

Yes, compaction is the reason why non-aligned pointers are not allowed
by the documentation.  The compaction code will crash on case C.

So you can have it word-aligned, or odd, but not all arbitrary
pointers are allowed.  Be careful.  And compaction is now activated by
default (not in 3.04, but in the working version).

Don't ask me what happens on 64-bit machines, I'd have to look at the
source :-)

-- Damien
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-05-14  7:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-12 20:45 [Caml-list] NULL as a caml value Lauri Alanko
2002-05-13  7:20 ` Jacques Garrigue
2002-05-13 10:05   ` Christopher Quinn
2002-05-13 10:56     ` Jacques Garrigue
2002-05-13 19:47   ` Lauri Alanko
2002-05-13 14:56 Damien Doligez

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).