<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/92b94daa2fb95ae6a57491d9c74ea2ef"
  from="Mathieu Avila &lt;mavila@i...&gt;"
  author="Mathieu Avila"
  date="2003-11-05T08:30:00"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86"
  prev="2003/11/7c2a1cb12f95300a9f19c0db7c2ad6e0"
  next="2003/11/e00f3df02875aef67715de70b65c6100"
  prev-in-thread="2003/11/1cd61c5f67a7aa90f725b489dbc1143b"
  prev-thread="2003/11/5ebcd6d0eea2cdbc8d8713f184910c24"
  next-thread="2003/11/96c5a045d70b126cf9ebbe6b346fc3dd"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/927fa5865c499289949ce45512930e10"
  from="Mathieu Avila &lt;mavila@i...&gt;"
  author="Mathieu Avila"
  date="2003-11-03T07:56:52"
  subject="[Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/9caf042d7c5391a959764eb56c3450e0"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-04T01:09:10"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/fc711ff363ee98e5a52de94c646ee486"
  from="Mathieu Avila &lt;mavila@i...&gt;"
  author="Mathieu Avila"
  date="2003-11-04T13:52:10"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/1cd61c5f67a7aa90f725b489dbc1143b"
  from="Jacques Garrigue &lt;garrigue@k...&gt;"
  author="Jacques Garrigue"
  date="2003-11-05T02:18:41"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
<msg 
  url="2003/11/92b94daa2fb95ae6a57491d9c74ea2ef"
  from="Mathieu Avila &lt;mavila@i...&gt;"
  author="Mathieu Avila"
  date="2003-11-05T08:30:00"
  subject="Re: [Caml-list] ocaml_startup et Solaris/x86">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Jacques Garrigue a écrit :

&gt;From: Mathieu Avila &lt;mavila@irisa.fr&gt;
&gt;
&gt;  
&gt;
&gt;&gt;&gt;I'm using ocaml on Solaris8/x86, and many C libraries, with no
&gt;&gt;&gt;problem.
&gt;&gt;&gt;
&gt;&gt;&gt;      
&gt;&gt;&gt;
&gt;&gt;Are you able to call the ocaml code from the C ? I think this is rather 
&gt;&gt;different from calling C libs from a standalone OCaml code.
&gt;&gt;    
&gt;&gt;
&gt;
&gt;If you mean calling callback, I can. My libraries are full of
&gt;callbacks from C to caml.
&gt;
&gt;  
&gt;
&gt;&gt;In my case, i mix the 2 langages in this way :
&gt;&gt;
&gt;&gt;cmain.ml:
&gt;&gt;--------------------------------------------------------
&gt;&gt;let cmain_ocaml n = try
&gt;&gt;...
&gt;&gt;;;
&gt;&gt;
&gt;&gt;let _ = Callback.register "cmain_ocaml" cmain_ocaml
&gt;&gt;--------------------------------------------------------
&gt;&gt;
&gt;&gt;in a cmain_cpp.cpp , where there is the "real" main() function:
&gt;&gt;--------------------------------------------------------
&gt;&gt; static value * cmain_closure = NULL;
&gt;&gt; if (cmain_closure==NULL)
&gt;&gt;   cmain_closure = caml_named_value("cmain_ocaml");
&gt;&gt; result = Int_val(callback(*cmain_closure,Val_int(n)));
&gt;&gt;--------------------------------------------------------
&gt;&gt;
&gt;&gt;It crashses when calling :  callback(*cmain_closure...)
&gt;&gt;
&gt;&gt;All is compiled into native solaris object code.
&gt;&gt;The same thing works perfectly on solaris/sparc.
&gt;&gt;    
&gt;&gt;
&gt;
&gt;Do I understand correctly than the C code above is inside the main
&gt;function?
&gt;  
&gt;
&gt;Then I cannot see how it would work. Callback.register dynamically
&gt;adds "cmain_ocaml" to a table of known functions. If you don't call
&gt;ocaml's main function (i.e. the main() function of the ocaml C
&gt;runtime, or at least caml_main()), your caml function will not be
&gt;registered and this should not work.
&gt;
&gt;  
&gt;
Sorry, i didn't show you all the useful code. There is a call to 
"ocaml_startup" with the appropriate
argv argument (i.e nothing). I believe this is where all initialisations 
are done. However, it works perfectly on Solaris/SPARC...

--
Mathieu



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

</contents>

</message>

