caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Porting to EPOC
@ 2001-05-29  9:07 Tore Lund
  2001-05-29 12:00 ` Xavier Leroy
  0 siblings, 1 reply; 5+ messages in thread
From: Tore Lund @ 2001-05-29  9:07 UTC (permalink / raw)
  To: caml-list

I am trying to port the OCaml runtime to EPOC.  If you don't know EPOC,
this is the operating system in recent Psion PDAs and a growing number
of mobile phones.  

Development for EPOC is normally done in a PC emulator using VC++.  Once
everything works you use a setup where GCC is called upon to produce
code for the target machine (which has an ARM processor).  Thus, porting
to EPOC actually means porting to two different platforms: emulator and
target.

So far I have compiled ocamlrun with an extra module of my own that
allows the program to be started from EPOC.  Once the program is
running, I want to call caml_main() with the name of a bytecode
executable.  What will hopefully happen then is that the bytecode file
will be loaded, initializations will be performed, and after that I will
be able to call some ML function each time the user presses a key.  This
ought to work somehow.

However, the ML code must necessarily call EPOC functions in order to
perform output and the like.  Suppose I have a function epocfunc() in my
startup EPOC module, how can I tell ocamlc that epocfunc() is a legal
function?  The systematic way to go about it is of course to port ocamlc
to EPOC as well and then do things by the book, but I had really hoped
to avoid this (especially since two ports are required).  And none of
the -custom, -make-runtime or -output-obj switches seem to address this
situation.

So, is there a way to make the Win32 version of ocamlc produce bytecode
that is machine-independent and that calls epocfunc()?  One thing that
might work is to make a C file with a dummy epocfunc(), put it in the
byterun directory and then recompile everything (for Win32).  That would
presumably make ocamlc accept epocfunc() as a primitive.  But this is
really a dirty trick, and I had hoped for a less messy way to do it.

I notice there is an undocumented compiler switch -use-prims <file>. 
Maybe this would solve my problem if I knew the format of <file>?

Grateful for any hint.
-- 
    Tore

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Porting to EPOC
  2001-05-29  9:07 [Caml-list] Porting to EPOC Tore Lund
@ 2001-05-29 12:00 ` Xavier Leroy
  2001-05-29 14:10   ` Tore Lund
  0 siblings, 1 reply; 5+ messages in thread
From: Xavier Leroy @ 2001-05-29 12:00 UTC (permalink / raw)
  To: Tore Lund; +Cc: caml-list

[ Cross-compiling OCaml bytecode for a runtime system containing
  platform-specific external functions. ]

> I notice there is an undocumented compiler switch -use-prims <file>. 
> Maybe this would solve my problem if I knew the format of <file>?

Yes, -use-prims is exactly what you need.  The format is one C
function name per line, in the exact order in which they appear in the
table cprim[] in byterun/prims.c.  

Even easier: building the runtime system in byterun produces the file
byterun/primitives, which happens to have exactly the right format.  Whopee!

Have fun with Epoc,

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Porting to EPOC
  2001-05-29 12:00 ` Xavier Leroy
@ 2001-05-29 14:10   ` Tore Lund
  2001-05-29 14:22     ` Alain Frisch
  0 siblings, 1 reply; 5+ messages in thread
From: Tore Lund @ 2001-05-29 14:10 UTC (permalink / raw)
  To: caml-list

Xavier Leroy wrote:
> 
> [ Cross-compiling OCaml bytecode for a runtime system containing
>   platform-specific external functions. ]
> 
> > I notice there is an undocumented compiler switch -use-prims <file>.
> > Maybe this would solve my problem if I knew the format of <file>?
> 
> Yes, -use-prims is exactly what you need.  The format is one C
> function name per line, in the exact order in which they appear in the
> table cprim[] in byterun/prims.c.
> 
> Even easier: building the runtime system in byterun produces the file
> byterun/primitives, which happens to have exactly the right format.  Whopee!

Sorry, doesn't work.  I try to compile the following file:

 let _ = c_test ();;

and all I get is this:

  C:\Data\ocaml>ocamlc -use-prims prims ctest.ml
  File "ctest.ml", line 1, characters 8-14:
  Unbound value c_test

even though I have put c_test at the bottom of the list in prims.

Any ideas?
-- 
    Tore

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Porting to EPOC
  2001-05-29 14:10   ` Tore Lund
@ 2001-05-29 14:22     ` Alain Frisch
  2001-05-29 14:59       ` Tore Lund
  0 siblings, 1 reply; 5+ messages in thread
From: Alain Frisch @ 2001-05-29 14:22 UTC (permalink / raw)
  To: Tore Lund; +Cc: caml-list

On Tue, 29 May 2001, Tore Lund wrote:

> Sorry, doesn't work.  I try to compile the following file:
> 
>  let _ = c_test ();;
> 
> and all I get is this:
> 
>   C:\Data\ocaml>ocamlc -use-prims prims ctest.ml
>   File "ctest.ml", line 1, characters 8-14:
>   Unbound value c_test
> 
> even though I have put c_test at the bottom of the list in prims.
> 
> Any ideas?

You have to declare the primitive to Caml:

external c_test: unit -> unit = "c_test"


-- 
  Alain Frisch

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

* Re: [Caml-list] Porting to EPOC
  2001-05-29 14:22     ` Alain Frisch
@ 2001-05-29 14:59       ` Tore Lund
  0 siblings, 0 replies; 5+ messages in thread
From: Tore Lund @ 2001-05-29 14:59 UTC (permalink / raw)
  To: caml-list

Alain Frisch wrote:
> 
> On Tue, 29 May 2001, Tore Lund wrote:
> 
> > Sorry, doesn't work.  I try to compile the following file:
> >
> >  let _ = c_test ();;
> >
> > and all I get is this:
> >
> >   C:\Data\ocaml>ocamlc -use-prims prims ctest.ml
> >   File "ctest.ml", line 1, characters 8-14:
> >   Unbound value c_test
> >
> > even though I have put c_test at the bottom of the list in prims.
> >
> > Any ideas?
> 
> You have to declare the primitive to Caml:
> 
> external c_test: unit -> unit = "c_test"

Thanks, I just found out myself.
-- 
    Tore

-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


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

end of thread, other threads:[~2001-05-29 15:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-29  9:07 [Caml-list] Porting to EPOC Tore Lund
2001-05-29 12:00 ` Xavier Leroy
2001-05-29 14:10   ` Tore Lund
2001-05-29 14:22     ` Alain Frisch
2001-05-29 14:59       ` Tore Lund

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