Browse thread
[Caml-list] ocaml_startup et Solaris/x86
-
Mathieu Avila
-
Jacques Garrigue
-
Mathieu Avila
-
Jacques Garrigue
- Mathieu Avila
-
Jacques Garrigue
-
Mathieu Avila
-
Jacques Garrigue
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Mathieu Avila <mavila@i...> |
| Subject: | Re: [Caml-list] ocaml_startup et Solaris/x86 |
Jacques Garrigue a écrit :
>From: Mathieu Avila <mavila@irisa.fr>
>
>
>
>>>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