chekmate@athena.mit.edu (Adam Kao) (01/06/90)
Hi, I'm trying to use some C/Starbase code from HP Common Lisp II by way of the foreign function interface. Here's what happens: ------- ;;; HP COMMON LISP II Development Environment Rev A.02.01 02/08/88 ;;; ;;; Copyright (c) Hewlett-Packard Co. 1988. All Rights Reserved. ;;; Copyright (c) Lucid, Inc. 1987. All Rights Reserved. ;;; ;;; RESTRICTED RIGHTS LEGEND ;;; Use, duplication, or disclosure by the Government ;;; is subject to restrictions set forth in ;;; subdivision (b)(3)(ii) of the ;;; Rights in Technical Data and Computer Software ;;; Clause at 52.227-7013. ;;; Hewlett-Packard Company ;;; 3000 Hanover Street, Palo Alto, Ca 94303 > (define-c-function (shadecube "_main") () ) SHADECUBE > (load-foreign-files '("/skipjack/adamk/test/shadecube.o") '("-ldd98721" "-lsb1" "-lsb2" "-lm" "-lc")) ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _ftod. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _dtof. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _itofl. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _fltoi. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _rndfl. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _fmulf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _fdivf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _faddf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _fsubf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _ffadd. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _ffsub. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _ffmul. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _ffdiv. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _afaddf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _afsubf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _afmulf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _afdivf. ;;; Warning: In /lib/libc.a:fpshorts.o/ - redefining foreign-symbol _fcmpf. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _float. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _fix. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _fadd. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _fsub. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _fmul. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _fdiv. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _afadd. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _afsub. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _afmul. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _afdiv. ;;; Warning: In /lib/libc.a:fpsupport.o/ - redefining foreign-symbol _fcmp. ;;; Warning: In /lib/libc.a:ldiv.o/ - redefining foreign-symbol _ldiv. ;;; Warning: In /lib/libc.a:lrem.o/ - redefining foreign-symbol _lrem. ;;; Warning: In /lib/libc.a:uldiv.o/ - redefining foreign-symbol _uldiv. ;;; Warning: The following foreign-symbols are undefined: (asm_strlenfieldwidth) NIL > (shadecube) Starbase error 19: Cannot map frame buffer into user space. Procedure name: gopen File descriptor: 3 Device file name: /dev/crtren Library location: HP98721 driver (115) Process lisp exited abnormally with code 255 -------- As you can see, my lisp process died completely. The file shadecube.c is essentially the example from chapter 13 of the Starbase Tutorial manuals. It runs fine when I compile and run it from the command line. Does anyone know what happened here? Why do I get "error 19"? It seems to be dying on the first call to Starbase. Has anyone successfully run Starbase code from Lisp? Thanks in advance, Adam
adamk@mit-amt.MEDIA.MIT.EDU (Adam Kao) (01/06/90)
Just to clarify my earlier posting; Whenever I call gopen(), it fails, returning -1. My Lisp process died because the C procedure called exit() when gopen() failed. I have replaced the exit() call with return and now the C procedure returns to the Lisp process. The call to gopen() fails every way I've tried it, which includes calling it from within a couple different programs, calling it from Lisp directly, calling it with mode INIT | THREE_D | MODEL_XFORM, and calling it with mode INIT only. The call to gopen() generates a different error on a different machine, namely: Starbase error 2049: Could not allocate memory. Procedure name: gopen File descriptor: 3 Device file name: /dev/crtren Library location: HP98721 driver (14) System errno: No such file or directory Is gopen() trying to allocate memory in a way that can't be done inside a Lisp process? In the Lisp manual it mentions that foreign code should "use malloc to manage memory . . . avoid using sbrk". Could this have something to do with gopen() failing? Thank you for your time, Adam