From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA23473; Wed, 5 Nov 2003 09:30:00 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA23673 for ; Wed, 5 Nov 2003 09:29:59 +0100 (MET) Received: from smtp.irisa.fr (smtp.irisa.fr [131.254.130.26]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hA58Tw108866 for ; Wed, 5 Nov 2003 09:29:58 +0100 (MET) Received: from localhost (localhost.localdomain [127.0.0.1]) by localhost.irisa.fr (Postfix) with ESMTP id AB4CDFAD2 for ; Wed, 5 Nov 2003 09:29:58 +0100 (CET) Received: from smtp.irisa.fr ([131.254.130.26]) by localhost (meli.irisa.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 08054-06 for ; Wed, 5 Nov 2003 09:29:58 +0100 (CET) Received: from IRISA.fr (buffle.irisa.fr [131.254.13.24]) by smtp.irisa.fr (Postfix) with ESMTP id 58102FACB for ; Wed, 5 Nov 2003 09:29:58 +0100 (CET) Message-ID: <3FA8B506.6030805@IRISA.fr> Date: Wed, 05 Nov 2003 09:29:58 +0100 From: Mathieu Avila Reply-To: mavila@irisa.fr User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.5) Gecko/20031007 X-Accept-Language: fr, en MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] ocaml_startup et Solaris/x86 References: <3FA60A42.3040707@IRISA.fr> <20031104100910W.garrigue@kurims.kyoto-u.ac.jp> <3FA7AF07.1080207@IRISA.fr> <20031105111831A.garrigue@kurims.kyoto-u.ac.jp> In-Reply-To: <20031105111831A.garrigue@kurims.kyoto-u.ac.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at irisa.fr X-Loop: caml-list@inria.fr X-Spam: no; 0.00; mathieu:01 caml-list:01 jacques:01 mathieu:01 libs:01 callback:01 callbacks:01 langages:01 callback:01 val:01 val:01 dynamically:01 ocaml's:01 runtime:01 argv:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Jacques Garrigue a écrit : >From: Mathieu Avila > > > >>>I'm using ocaml on Solaris8/x86, and many C libraries, with no >>>problem. >>> >>> >>> >>Are you able to call the ocaml code from the C ? I think this is rather >>different from calling C libs from a standalone OCaml code. >> >> > >If you mean calling callback, I can. My libraries are full of >callbacks from C to caml. > > > >>In my case, i mix the 2 langages in this way : >> >>cmain.ml: >>-------------------------------------------------------- >>let cmain_ocaml n = try >>... >>;; >> >>let _ = Callback.register "cmain_ocaml" cmain_ocaml >>-------------------------------------------------------- >> >>in a cmain_cpp.cpp , where there is the "real" main() function: >>-------------------------------------------------------- >> static value * cmain_closure = NULL; >> if (cmain_closure==NULL) >> cmain_closure = caml_named_value("cmain_ocaml"); >> result = Int_val(callback(*cmain_closure,Val_int(n))); >>-------------------------------------------------------- >> >>It crashses when calling : callback(*cmain_closure...) >> >>All is compiled into native solaris object code. >>The same thing works perfectly on solaris/sparc. >> >> > >Do I understand correctly than the C code above is inside the main >function? > > >Then I cannot see how it would work. Callback.register dynamically >adds "cmain_ocaml" to a table of known functions. If you don't call >ocaml's main function (i.e. the main() function of the ocaml C >runtime, or at least caml_main()), your caml function will not be >registered and this should not work. > > > 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