caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] ocamlopt with external function taking more than 5 params
  2003-08-05 16:50 [Caml-list] ocamlopt with external function taking more than 5 params Lars Nilsson
@ 2003-08-05 16:47 ` David Brown
  2003-08-05 17:18   ` Pixel
  2003-08-07 12:47 ` Damien Doligez
  1 sibling, 1 reply; 4+ messages in thread
From: David Brown @ 2003-08-05 16:47 UTC (permalink / raw)
  To: Lars Nilsson; +Cc: Caml List

On Tue, Aug 05, 2003 at 12:50:11PM -0400, Lars Nilsson wrote:
> Hi all,
> 
> I am wondering if I am doing something wrong, or if I am experiencing a bug.
> I am trying to implement a function in C that takes more than 5 parameters
> (8 in my real code). For some reason it does not appear that the native code
> version is being called properly. If anyone can shed any light on this I
> would be very grateful...

> [c-tester.c]
> CAMLprim void tester_bytecode(value a, value b, value c, value d,
>                               value e, value f, value g, value h)
> CAMLprim void tester_native(value *argv, int argc)
> {

These two are reversed.  The native code version calls with all of the
arguments, whereas the bytecode version passes in an array.

Dave

-------------------
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] 4+ messages in thread

* [Caml-list] ocamlopt with external function taking more than 5 params
@ 2003-08-05 16:50 Lars Nilsson
  2003-08-05 16:47 ` David Brown
  2003-08-07 12:47 ` Damien Doligez
  0 siblings, 2 replies; 4+ messages in thread
From: Lars Nilsson @ 2003-08-05 16:50 UTC (permalink / raw)
  To: Caml List

Hi all,

I am wondering if I am doing something wrong, or if I am experiencing a bug.
I am trying to implement a function in C that takes more than 5 parameters
(8 in my real code). For some reason it does not appear that the native code
version is being called properly. If anyone can shed any light on this I
would be very grateful...

The resulting output for the ocamlopt compiled program is

  Pointer = 0x3, N = 5

This is of course not exactly what I would expect, since I would really like
to see a valid array of values containing integers.

I am attempting this under RH7.2 Linux, gcc 2.95.3, using both Ocaml 3.06
and the current CVS version, with the same result.

Thanks in advance for any insights,

Lars Nilsson
Quantum Chamaeleon
http://www.quantumchamaeleon.com

[tester.ml]
external tester : int -> int -> int -> int -> int -> int -> int -> int ->
unit = "tester_bytecode" "tester_native"

let _ =
  tester 1 2 3 4 5 6 7 8

[c-tester.c]
CAMLprim void tester_bytecode(value a, value b, value c, value d,
                              value e, value f, value g, value h)
{
     CAMLparam5(a, b, c, d, e);
     CAMLxparam3(f, g, h);

     printf("Doing nothing\n");

     CAMLreturn0;
}

CAMLprim void tester_native(value *argv, int argc)
{
     CAMLparamN(argv, argc);

     printf("Pointer = %p, N = %d\n", argv, argc);

     CAMLreturn0;
}

-------------------
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] 4+ messages in thread

* Re: [Caml-list] ocamlopt with external function taking more than 5 params
  2003-08-05 16:47 ` David Brown
@ 2003-08-05 17:18   ` Pixel
  0 siblings, 0 replies; 4+ messages in thread
From: Pixel @ 2003-08-05 17:18 UTC (permalink / raw)
  To: Caml List

I responded to David Brown's message in private by mistake. So others know,
he pointed out the error made by me (for reasons unknown. I may plead
insanity at a later point). Got the native and bytecode calling convention
mixed up.

Thanks, David.

Lars Nilsson
Quantum Chamaeleon
http://www.quantumchamaeleon.com

-------------------
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] 4+ messages in thread

* Re: [Caml-list] ocamlopt with external function taking more than 5 params
  2003-08-05 16:50 [Caml-list] ocamlopt with external function taking more than 5 params Lars Nilsson
  2003-08-05 16:47 ` David Brown
@ 2003-08-07 12:47 ` Damien Doligez
  1 sibling, 0 replies; 4+ messages in thread
From: Damien Doligez @ 2003-08-07 12:47 UTC (permalink / raw)
  To: Lars Nilsson; +Cc: Caml List

On Tuesday, Aug 5, 2003, at 18:50 Europe/Paris, Lars Nilsson wrote:

> I am wondering if I am doing something wrong, or if I am experiencing 
> a bug.
> I am trying to implement a function in C that takes more than 5 
> parameters
> (8 in my real code).
[...]
> The resulting output for the ocamlopt compiled program is
>
>   Pointer = 0x3, N = 5

Note that 0x3 is the representation of 1 as an O'Caml value, and
5 is the representation of 2.


> CAMLprim void tester_bytecode(value a, value b, value c, value d,
>                               value e, value f, value g, value h)

> CAMLprim void tester_native(value *argv, int argc)

You have them reversed.  The native-code version should take 8
arguments, and the byte-code version should take argv and argc.

-- 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] 4+ messages in thread

end of thread, other threads:[~2003-08-07 12:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-05 16:50 [Caml-list] ocamlopt with external function taking more than 5 params Lars Nilsson
2003-08-05 16:47 ` David Brown
2003-08-05 17:18   ` Pixel
2003-08-07 12:47 ` 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).