[MLton-devel] FW: cygwin segfault

Mike Thomas miketh@brisbane.paradigmgeo.com
Tue, 13 May 2003 16:45:38 +1000


This is a multi-part message in MIME format.

------=_NextPart_000_0025_01C3196F.153A6A80
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hi Stephen.

|  Let us know of any more problems,
| and thanks for all the help.  Now, back to the FFI and OpenGL.

You wish!

=========================================================================$
mlton main.sml ffi.o
/c/DOCUME~1/miketh/LOCALS~1/Temp/fileRKtyru.o(.text+0x1b7e):/c/DOCUME~1/mike
th/LOCALS~1/Temp/filezsFsVi.0.S: undefined reference to `_Thread_returnToC'
collect2: ld returned 1 exit status
call to system failed: gcc -o main
/c/DOCUME~1/miketh/LOCALS~1/Temp/filezIvsvw.o
/c/DOCUME~1/miketh/LOCALS~1/Temp/fileRKtyru.o
ffi.o -L/usr/lib/mlton/self -lmlton -lm -lgmp

$ nm --defined-only --print-file-name /usr/lib/mlton/self/*.a | grep -i
return
=========================================================================

Attached are some files modified from the ffi example attempting to make the
callback function work.  At link time as shown above there is a missing
symbol.  How do I get that missing symbol "_Thread_returnToC"?

Also:

$ mlton -stop o ffi.c

gives me "ffi.1.o" rather than "ffi.o"!

The unmodified ffi example worked alright the other day (or so I think), so
I may have broken something while messing around with the runtime?
Compiling the hello world example works fine.

Cheers

Mike Thomas.

------=_NextPart_000_0025_01C3196F.153A6A80
Content-Type: application/octet-stream;
	name="ffi.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="ffi.c"

/* ffi.c */=0A=
#include "ffi.h"=0A=
=0A=
Int FFI_INT =3D 13;=0A=
double summer_1 =3D 1.0;=0A=
double summer_2 =3D 2.0;=0A=
=0A=
Char ffi(Pointer a1, Pointer a2, Int n) {=0A=
	double *ds =3D (double*)a1;=0A=
	int *p =3D (int*)a2;=0A=
	int i;=0A=
	double sum;=0A=
=0A=
        MLton_callFromC ();=0A=
	sum =3D 0.0;=0A=
	for (i =3D 0; i < GC_arrayNumElements(a1); ++i) {=0A=
		sum +=3D ds[i];=0A=
		ds[i] +=3D n;=0A=
	}=0A=
	*p =3D (int)sum;=0A=
	return 'c';=0A=
}=0A=

------=_NextPart_000_0025_01C3196F.153A6A80
Content-Type: application/octet-stream;
	name="ffi.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="ffi.h"

/* ffi.h */

#include "mlton.h"

#define BOOL0 0
#define BOOL1 1
#define INT0 -1
#define INT1 0
#define INT2 1
#define REAL0 -1.234
#define REAL1 1.234
#define STRING0 "hello there\nhow are you\n"
#define WORD0 0x0
#define WORD1 0xFFFFFFFF

#define FFI_SIZE 10

extern Int FFI_INT;

/* ffi is a silly function.  It sums the elements ds, stores the
 * result in p, adds i to each element of ds, and returns 'c'.
 */
Char ffi (Pointer ds, Pointer p, Int n);


------=_NextPart_000_0025_01C3196F.153A6A80
Content-Type: application/smil;
	name="main.sml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="main.sml"

(* Callback *)
val summer_1 = _ffi "summer_1" : real;
val summer_2 = _ffi "summer_2" : real;
val summer_3 = ref 0.0         : real ref;
fun summer () :unit = (summer_3 := summer_1 + summer_2; ());
MLton.FFI.handleCallFromC summer;

(* Declare ffi to be implemented by calling the C function ffi. *)
val ffi = _ffi "ffi": real array * int ref * int -> char;
open Array

(* val size = _const "FFI_SIZE": int; *)
val size = 10
val a = tabulate (size, fn i => real i)
val r = ref 0
val n = 17

(* Call the C function *)
val c = ffi (a, r, n)

val n = _ffi "FFI_INT": int;

val _ = print (concat [Int.toString n, "\n"])

val _ =
   print (if c = #"c" andalso !r = 45
	     then "success\n"
	  else "fail\n")

------=_NextPart_000_0025_01C3196F.153A6A80--




-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com

_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel