From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id E68FBBC2A for ; Fri, 5 Aug 2005 16:06:25 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j75E6Pbb022938 for ; Fri, 5 Aug 2005 16:06:25 +0200 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 QAA04643 for ; Fri, 5 Aug 2005 16:06:25 +0200 (MET DST) From: brjackson@blueyonder.co.uk Received: from smtp-out5.blueyonder.co.uk (smtp-out5.blueyonder.co.uk [195.188.213.8]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j75E6OwT005617 for ; Fri, 5 Aug 2005 16:06:24 +0200 Received: from webmail.blueyonder.co.uk ([195.188.53.233]) by smtp-out5.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.6713); Fri, 5 Aug 2005 15:07:10 +0100 Received: from 195.188.213.34 (SquirrelMail authenticated user); by webmail.blueyonder.co.uk with HTTP; Fri, 5 Aug 2005 15:06:24 +0100 (BST) Message-ID: <6768.195.188.213.34.1123250784.squirrel@195.188.213.34> Date: Fri, 5 Aug 2005 15:06:24 +0100 (BST) To: caml-list@inria.fr User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-OriginalArrivalTime: 05 Aug 2005 14:07:10.0116 (UTC) FILETIME=[F878AE40:01C599C6] X-Miltered: at concorde with ID 42F37261.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 42F37260.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-j-chkmail-Score: MSGID : 42F37261.000 on concorde : j-chkmail score : X : 0/20 1 X-Spam: no; 0.00; bindings:01 ocaml:01 lablgl:01 api:01 bigarray:01 gdb:01 ocaml:01 elt:01 elt:01 stub:01 bytecode:01 stub:01 camlparam:01 alloc:01 wosize:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.7 required=5.0 tests=MISSING_SUBJECT,NO_REAL_NAME autolearn=disabled version=3.0.3 Hi. I've recently been experimenting with some Glu bindings for Ocaml. I am aware of the excellent Lablgl but wanted something closer to the C API. Unfortunately there seems to be a problem with a particular function that returns a tuple of three floats. I think that I'm constructing the tuple wrong since if it is changed so that it returns a bigarray it works. With the following code gdb reports a crash in caml_format_float when gluUnProject is called: (* OCAML CODE *) external gluUnProject : float -> float -> float -> (float, float64_elt, c_layout) Array1.t -> (float, float64_elt, c_layout) Array1.t -> (int, int_elt, c_layout) Array1.t -> (float * float * float) = "stub_gluUnProject_bytecode" "stub_gluUnProject_native" /* C CODE */ value stub_gluUnProject_native(value v1, value v2, value v3, value v4, value v5, value v6) { CAMLparam5(v1, v2, v3, v4, v5); CAMLxparam1(v6); CAMLlocal1(result); result = alloc(Double_wosize * 3, Double_array_tag); double obj[3]; fp_gluUnProject(Double_val(v1), Double_val(v2), Double_val(v3), (double *) Data_bigarray_val(v4), (double *) Data_bigarray_val(v5), (int *) Data_bigarray_val(v6), obj, obj+1, obj+2); Store_double_field(result, 0, obj[0]); Store_double_field(result, 1, obj[1]); Store_double_field(result, 2, obj[2]); CAMLreturn(result); } The values altered by fp_gluUnProject (obj[...]) are correct. If the code is changed to the following (so that is returns a bigarray) it works: (* OCAML CODE *) external gluUnProject : float -> float -> float -> (float, float64_elt, c_layout) Array1.t -> (float, float64_elt, c_layout) Array1.t -> (int, int_elt, c_layout) Array1.t -> float, float64_elt, c_layout) Array1.t = "stub_gluUnProject_bytecode" "stub_gluUnProject_native" /* C CODE */ value stub_gluUnProject_native(value v1, value v2, value v3, value v4, value v5, value v6) { CAMLparam5(v1, v2, v3, v4, v5); CAMLxparam1(v6); CAMLlocal1(result); double obj[3]; fp_gluUnProject(Double_val(v1), Double_val(v2), Double_val(v3), (double *) Data_bigarray_val(v4), (double *) Data_bigarray_val(v5), (int *) Data_bigarray_val(v6), obj, obj+1, obj+2); result = alloc_bigarray_dims(BIGARRAY_FLOAT64 | BIGARRAY_C_LAYOUT, 1, obj, 3); CAMLreturn(result); } I've have the feeling that the problem is either blindingly obvious or I have misunderstood sections 18.3-18.5 of the manual. Thanks for any insight/help. Bob Jackson.