lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] failure with GNU lightning on Mac OS X 10.6.2


From: Todd Rovito
Subject: [Lightning] failure with GNU lightning on Mac OS X 10.6.2
Date: Mon, 22 Feb 2010 23:32:21 -1000

Greetings,
   Perhaps I am doing something really stupid, but I am trying to get
GNU lightning to work on my Mac OS X 10.6.2 with the sample programs.
Here is the code:

     #include <stdio.h>
     #include "lightning.h"

     static jit_insn codeBuffer[1024];

     typedef int (*pifi)(int);    /* Pointer to Int Function of Int */

     int main()
     {
       pifi  incr = (pifi) (jit_set_ip(codeBuffer).iptr);
       int   in;

       jit_leaf(1);                     /*      leaf  1             */
       in = jit_arg_i();                /* in = arg_i               */
       jit_getarg_i(JIT_R0, in);        /*      getarg_i R0         */
       jit_addi_i(JIT_RET, JIT_R0, 1);  /*      addi_i   RET, R0, 1 */
       jit_ret();                       /*      ret                 */

       jit_flush_code(codeBuffer, jit_get_ip().ptr);

       /* call the generated code, passing 5 as an argument */
       printf("%d + 1 = %d\n", 5, incr(5));
       return 0;
     }

I compile the code with the command "gcc incr.c -o incr -I
/opt/lightning/include/". All compiles fine.  When I execute the
program on the mac I get Bus Error.  It works fine with Linux Fedora
12, so I am pretty sure it has something to do with the Mac.  Here is
output from gdb:

Todd-Rovitos-MacBook:test rovitotv$ gcc -ggdb incr.c -o incr -I
/opt/lightning/include/
Todd-Rovitos-MacBook:test rovitotv$ gdb incr
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for
shared libraries .. done

(gdb) run
Starting program: /Users/rovitotv/prog/lightning/test/incr
Reading symbols for shared libraries +. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x0000000100001100
0x0000000100001100 in codeBuffer ()
(gdb) bt
#0  0x0000000100001100 in codeBuffer ()
#1  0x0000000100000e5f in main () at incr.c:22
(gdb)


Thanks for the help.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]